import { ComponentType } from 'react'; import { IJsonModel } from 'flexlayout-react'; import { workspace } from './core/services/Workspace'; /** * Helpers for testing code built on the shell. * * The shell's state lives in module-level registries and stores, which is what * lets any code reach it — and what makes one test leak into the next. These * put it back. They work against the real stores and a real FlexLayout model, * so a test exercises the same code an app does; there is no need to fake * `useLayoutStore` or hand-build `visitNodes` mocks. * * Also importable as `nexus-shell/testing`. * * @example * ```ts * import { resetShell, createTestWorkspace } from 'nexus-shell/testing'; * * beforeEach(() => resetShell()); * * it('opens Desk once', () => { * const ws = createTestWorkspace({ components: { desk: Desk } }); * openTool('desk'); * openTool('desk'); * expect(ws.find('desk')).toHaveLength(1); * }); * ``` */ /** Options for {@link resetShell}. */ export interface ResetShellOptions { /** * Also clear component registrations and aliases. Off by default, because * apps usually register components at module scope — once per test file — * and clearing them would leave later tests rendering "unknown component". */ components?: boolean; /** Also clear registered commands. Defaults to `true`. */ commands?: boolean; } /** * Return every shell store and registry to its initial state: an empty * workspace with storage disabled, no menus, panels, status items, chat or * open dialog, the light theme, an anonymous profile, and nothing persisted. */ export declare const resetShell: (options?: ResetShellOptions) => void; /** Options for {@link createTestWorkspace}. */ export interface TestWorkspaceOptions { /** Starting layout. Defaults to the empty default layout. */ layout?: IJsonModel; /** Components to register, by id. */ components?: Record>; } /** * A real, headless workspace to drive in a test: storage off, the given * components registered, the given layout loaded. Returns the `workspace` * facade for convenience. */ export declare const createTestWorkspace: (options?: TestWorkspaceOptions) => typeof workspace;