# zidane-ui/workspace/testing

Import: `import { … } from 'zidane-ui/workspace/testing'`. Source: [ui/src/workspace/testing/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts).

## Functions

### `createFixtureWorkspaceHost`

Function.

Creates a [`WorkspaceHost`](https://zidane.si/docs/reference/ui-workspace-headless.md#WorkspaceHost) held in memory: layouts per scope key and, unless `panels: false`, extension panels
per folder.

```ts
function createFixtureWorkspaceHost(
  options?: FixtureWorkspaceOptions,
): FixtureWorkspaceHost
```

**Parameters**

- `options?` (`FixtureWorkspaceOptions`, default `{}`): The stored layouts and the extension panels.

**Returns** `FixtureWorkspaceHost`

Source: [ui/src/workspace/testing/index.ts:60](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts#L60)

## Constants

### `DEMO_WORKSPACE_LAYOUT`

Constant.

A demo layout: open, Files and Todos in one group, Diffs split off to the right.

```ts
const DEMO_WORKSPACE_LAYOUT: WorkspaceLayout
```

Source: [ui/src/workspace/testing/index.ts:136](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts#L136)

### `DEMO_WORKSPACE_TABS`

Constant.

The tabs the demos offer: an app's own kinds, as the desktop app's catalog lists them.

```ts
const DEMO_WORKSPACE_TABS: readonly WorkspaceTab[]
```

Source: [ui/src/workspace/testing/index.ts:127](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts#L127)

## Interfaces

### `FixtureWorkspaceControl`

Interface.

Changes the fixture from outside, as another window or an extension would.

```ts
interface FixtureWorkspaceControl
```

**Properties**

- `actions` (`() => readonly { actionId: string; cwd: string; panelId: string; payload: unknown }[]`): The actions run so far, oldest first.
- `changePanel` (`(cwd: string, panelId: string) => void`): Announces that a panel changed.
- `setCatalog` (`(cwd: string, panels: readonly WorkspacePanelSummary[]) => void`): Replaces a folder's catalog and announces it.
- `setContent` (`(cwd: string, panelId: string, content: PanelContent) => void`): Replaces a panel's content and announces the change.
- `setLayout` (`(key: string, layout: WorkspaceLayout) => void`): Stores `layout` for the scope `key`, as another window would.
- `watching` (`() => readonly string[]`): The panels watched now, as `cwd/panelId`.

Source: [ui/src/workspace/testing/index.ts:33](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts#L33)

### `FixtureWorkspaceHost`

Interface.

The [`WorkspaceHost`](https://zidane.si/docs/reference/ui-workspace-headless.md#WorkspaceHost) [`createFixtureWorkspaceHost`](https://zidane.si/docs/reference/ui-workspace-testing.md#createFixtureWorkspaceHost) returns, with its control.

```ts
interface FixtureWorkspaceHost extends WorkspaceHost
```

**Properties**

- `control` (`FixtureWorkspaceControl`): Changes the fixture from outside.
- `layouts?` (`WorkspaceLayouts<WorkspaceScope>`, from `WorkspaceHost`): Persistent layouts. Absent: layouts last as long as the page.
- `panels?` (`WorkspacePanels`, from `WorkspaceHost`): Extension panels. Absent: only the app's own tabs.

Source: [ui/src/workspace/testing/index.ts:49](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts#L49)

### `FixtureWorkspaceOptions`

Interface.

Options of [`createFixtureWorkspaceHost`](https://zidane.si/docs/reference/ui-workspace-testing.md#createFixtureWorkspaceHost).

```ts
interface FixtureWorkspaceOptions
```

**Properties**

- `initial?` (`WorkspaceLayout`): What a scope with nothing stored reads. Default: closed, no tab.
- `layouts?` (`Readonly<Record<string, WorkspaceLayout>>`): The layouts stored per scope key.
- `panels?` (`false | { catalog: Readonly<Record<string, readonly WorkspacePanelSummary[]>>; content: Readonly<Record<string, PanelContent>>; failing?: Readonly<Record<string, string>> }`): Extension panels, per folder. `false`: no `panels` member. Default: none offered.

Source: [ui/src/workspace/testing/index.ts:14](https://github.com/Tahul/zidane/blob/main/ui/src/workspace/testing/index.ts#L14)
