Remember the thread list's dragged width across runs
Kept in layout.json next to the config, as the web keeps its sidebar width in browser storage. Tests now write to a scratch config folder.
This commit is contained in:
1 parent
320dbf492d
commit
81a1ee942c
5 files changed
+81
-8
No files matched your search
@@ -1,14 +1,21 @@
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { testRender } from "@opentui/react/test-utils";
|
||||
import { createMockKeys, type KeyInput } from "@opentui/core/testing";
|
||||
import type { OrchestrationV2ShellSnapshot, OrchestrationV2ThreadProjection, ThreadId } from "@t3tools/contracts";
|
||||
|
||||
import type { ConnectionStatus, T3Session } from "../../src/client/session.ts";
|
||||
import { DEFAULT_CONFIG, type Tui3Config } from "../../src/config.ts";
|
||||
import type { Layout } from "../../src/layout.ts";
|
||||
import { App } from "../../src/ui/App.tsx";
|
||||
import { v2Projection, v2ShellSnapshot, v2ThreadId } from "../../vendor/t3code/packages/client-runtime/src/state/orchestrationV2TestFixtures.ts";
|
||||
|
||||
export { v2Projection, v2ShellSnapshot, v2ThreadId };
|
||||
|
||||
// Settings and layout saves go to a scratch folder, never the real config.
|
||||
process.env.XDG_CONFIG_HOME = mkdtempSync(join(tmpdir(), "tui3-test-"));
|
||||
|
||||
// Updates from the app's own timers land outside act(); the warnings say nothing useful here.
|
||||
const consoleError = console.error;
|
||||
console.error = (...args: unknown[]) => {
|
||||
@@ -69,10 +76,10 @@ export function fakeSession(
|
||||
}
|
||||
|
||||
/** Renders the whole app against a fake session, with helpers to drive it by key and mouse. */
|
||||
export async function renderApp(options: { readonly session?: ReturnType<typeof fakeSession>; readonly config?: Partial<Tui3Config>; readonly width?: number; readonly height?: number } = {}) {
|
||||
export async function renderApp(options: { readonly session?: ReturnType<typeof fakeSession>; readonly config?: Partial<Tui3Config>; readonly layout?: Layout; readonly width?: number; readonly height?: number } = {}) {
|
||||
const fake = options.session ?? fakeSession();
|
||||
const config = { ...DEFAULT_CONFIG, ...options.config };
|
||||
const rig = await testRender(<App session={fake.session} config={config} />, { width: options.width ?? 140, height: options.height ?? 40 });
|
||||
const rig = await testRender(<App session={fake.session} config={config} {...(options.layout ? { layout: options.layout } : {})} />, { width: options.width ?? 140, height: options.height ?? 40 });
|
||||
// The app runs on timers and subscriptions, as it does live: tests wait for frames rather than wrap each update in act().
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = false;
|
||||
const keys = createMockKeys(rig.renderer);
|
||||
|
||||
Reference in new issue
Block a user