Files
orca/mobile/src/test-support/query-client-test-renderer.ts
T
Kelvin Amoaba 6708f76690 perf(mobile): show the model picker's models as soon as a chat opens (#39152)
* perf(mobile): show the model picker's models as soon as a chat opens

* fix(mobile): retry skill scans and trailing command reads through the query

* fix(mobile): keep menu-read commands across a re-probe and rescan skills on demand

* refactor(mobile): read chat query state from the client and give the model catalog query its own module

* test(mobile): give the reopen seed catalog its fetchedAt

* fix(mobile): keep the query layer out of the phone options hook's module graph
2026-11-07 04:55:30 +00:00

26 lines
1023 B
TypeScript

import type { ReactElement } from 'react'
import { notifyManager } from '@tanstack/react-query'
import { create, type ReactTestRenderer, type TestRendererOptions } from 'react-test-renderer'
import { documentQueryClient } from './rpc-recording/hook-mount'
// TanStack tells observers on a zero-delay timer; a microtask lets act() and fake-timer tests see replies.
notifyManager.setScheduler(queueMicrotask)
/** react-test-renderer's create inside a query client that lives as long as the renderer, as a page document's does. */
export function createWithQueryClient(
element: ReactElement,
options?: TestRendererOptions
): ReactTestRenderer {
const document = documentQueryClient()
const renderer = create(document.wrap(element), options)
const update = renderer.update.bind(renderer)
const unmount = renderer.unmount.bind(renderer)
return Object.assign(renderer, {
update: (next: ReactElement) => update(document.wrap(next)),
unmount: () => {
unmount()
void document.end()
}
})
}