Skip to content

zidane-ui/workspace/testing/contract

import { … } from 'zidane-ui/workspace/testing/contract'ui/src/workspace/testing/contract.ts

Functions#

describeWorkspaceHostContractFunction#

Declares the shared WorkspaceHost suite for one implementation.

TypeScript
function describeWorkspaceHostContract<S extends WorkspaceScope>(
  name: string,
  makeHarness: WorkspaceHostHarnessFactory<S>,
  capabilities: readonly WorkspaceHostCapability[],
): void
Type parameters
NameTypeDescription
Sextends WorkspaceScope
Parameters
NameTypeDescription
namestring

The implementation's name, shown in the suite title.

makeHarnessWorkspaceHostHarnessFactory<S>

Builds a fresh host over a backend that holds what it is given, once per test.

capabilitiesreadonly WorkspaceHostCapability[]

The optional members the host offers. Every other optional member must be undefined.

ui/src/workspace/testing/contract.ts:115

Interfaces#

WorkspaceHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface WorkspaceHostContractBackend
WorkspaceHostContractBackend properties
NameTypeDescription
contentReadonly<Record<string, PanelContent>>

Each panel's content, by id; a panel missing here fails to load.

cwdstring

The folder the extension panels are offered in (no other folder offers any).

failingAction{ actionId: string; message: string; panelId: string }

The one action that fails, with the extension's words; every other action succeeds.

layoutsReadonly<Record<string, WorkspaceLayout>>

The layouts stored per scope key (a key missing here has nothing stored).

panelsreadonly WorkspacePanelSummary[]

The extension panels offered in cwd.

ui/src/workspace/testing/contract.ts:37

WorkspaceHostContractControlInterface#

Changes the backend from outside and announces it as the backend does.

TypeScript
interface WorkspaceHostContractControl
WorkspaceHostContractControl properties
NameTypeDescription
changeCatalog() => void

An extension loaded or left: the catalog may have changed.

changePanel(cwd: string, panelId: string) => void

A panel's content changed in cwd.

writeLayout(key: string, layout: WorkspaceLayout) => void

Another window stored layout for the scope key.

ui/src/workspace/testing/contract.ts:51

WorkspaceHostHarnessInterface#

A host built over a backend, the backend's control, and how to tear them down.

TypeScript
interface WorkspaceHostHarness<S extends WorkspaceScope = WorkspaceScope>
WorkspaceHostHarness type parameters
NameTypeDefaultDescription
Sextends WorkspaceScopeWorkspaceScope
WorkspaceHostHarness properties
NameTypeDescription
controlWorkspaceHostContractControl

Changes the backend from outside.

hostWorkspaceHost<S>

The host under test.

dispose?() => void

Closes connections and timers after each test.

scope(key: string) => S

The scope the host takes for a scope key.

ui/src/workspace/testing/contract.ts:61

Types#

WorkspaceHostCapabilityType#

An optional WorkspaceHost member, by its path.

TypeScript
type WorkspaceHostCapability =
  | 'layouts'
  | 'panels'
  | 'panels.watch'
  | 'panels.subscribe'
  | 'panels.subscribeCatalog'

ui/src/workspace/testing/contract.ts:25

WorkspaceHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type WorkspaceHostHarnessFactory<S extends WorkspaceScope = WorkspaceScope> = (backend: WorkspaceHostContractBackend) => WorkspaceHostHarness<S> | Promise<WorkspaceHostHarness<S>>
WorkspaceHostHarnessFactory type parameters
NameTypeDefaultDescription
Sextends WorkspaceScopeWorkspaceScope

ui/src/workspace/testing/contract.ts:73