zidane-ui/ terminal/ testing
import { … } from 'zidane-ui/terminal/testing'ui/src/terminal/testing/index.ts
Functions#
createDemoTerminalHostFunction#
A fixture host holding the demo session's terminals.
function createDemoTerminalHost(): FixtureTerminalHostReturns
createFixtureTerminalHostFunction#
Creates a TerminalHost held in memory.
function createFixtureTerminalHost(
options?: FixtureTerminalOptions,
): FixtureTerminalHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureTerminalOptions | {} | The terminals per scope, availability, the prompt, and whether they can be changed. |
Returns
Constants#
DEMO_TERMINAL_SCOPEConstant#
The demo session's scope.
const DEMO_TERMINAL_SCOPE: TerminalScopeInterfaces#
FixtureTerminalInterface#
A terminal the fixture starts with: its info (defaults filled in) and the output it already printed.
interface FixtureTerminal extends Partial<TerminalInfo>Properties
| Name | Type | Description |
|---|---|---|
cols?from Partial | number | Width in character cells. |
createdAt?from Partial | number | Creation time in epoch ms. |
cwd?from Partial | string | Working directory the terminal started in. |
environment?from Partial | string | Environment kind it runs in ( |
error?from Partial | string | Failure message, when |
exitCode?from Partial | number | Exit code, once the process has exited. |
hiddenFromAgent?from Partial | boolean | The agent's terminal tools skip it. |
| history? | string | What it printed so far (ANSI allowed). |
| id | string | Terminal id. |
label?from Partial | string | Stable name ("Terminal 2", or the agent's command). |
lastActivityAt?from Partial | number | Time of the last output or input in epoch ms. |
owner?from Partial | TerminalOwner | Who started the terminal. |
program?from Partial | string | The program in the foreground, for terminals on this machine. |
rows?from Partial | number | Height in character cells. |
scope?from Partial | TerminalProjectScope | Set on project / draft terminals ( |
sessionId?from Partial | string | The session it belongs to; |
sizeSeq?from Partial | number | Bumped on every size change: signals and attach replies reach a view by different routes, so it keeps the newest size, not the last to arrive. |
status?from Partial | TerminalStatus | Connection and process state. |
target?from Partial | TerminalTarget | Where the terminal runs. |
taskId?from Partial | string | The background task it runs (agent terminals). |
title?from Partial | string | Title the program set (OSC 0/2), if any. |
FixtureTerminalControlInterface#
Changes the fixture from outside.
interface FixtureTerminalControlProperties
| Name | Type | Description |
|---|---|---|
| announce | (scope: TerminalScope) => void | The scope's list goes out again (as after any change). |
| exit | (terminalId: string, code: number) => void | The terminal's process exits with |
(terminalId: string, data: string) => void | The terminal prints | |
| relink | () => void | The link to the terminals came back: every scope reloads, every view attaches again. |
| terminals | () => TerminalInfo[] | Every terminal now. |
| writes | (terminalId: string) => string[] | The input a terminal received, one entry per write. |
FixtureTerminalOptionsInterface#
Options of createFixtureTerminalHost.
interface FixtureTerminalOptionsProperties
| Name | Type | Description |
|---|---|---|
| available? | boolean |
|
| drafts? | Readonly<Record<string, readonly FixtureTerminal[]>> | The terminals per draft id. |
| projects? | Readonly<Record<string, readonly FixtureTerminal[]>> | The terminals per project root (no session, no draft). |
| prompt? | string | The prompt a new shell prints. Default: |
| readOnly? | boolean | Leave out |
| reason? | string | Why not, when |
| sessions? | Readonly<Record<string, readonly FixtureTerminal[]>> | The terminals per session id. |
Types#
FixtureTerminalHostType#
An in-memory TerminalHost and its control.
type FixtureTerminalHost = TerminalHost & { control: FixtureTerminalControl }