zidane-ui/ machines/ testing
import { … } from 'zidane-ui/machines/testing'ui/src/machines/testing/index.ts
Functions#
createFixtureMachinesHostFunction#
Creates a MachinesHost held in memory.
function createFixtureMachinesHost(
options?: FixtureMachinesOptions,
): FixtureMachinesHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureMachinesOptions | {} | The hosts, machines, links, updates, tokens and daemon it starts with, and the callbacks it tells. |
Returns
Constants#
DEMO_CAPABILITIESConstant#
What a demo server can do: git and docker found, gh missing, the OS sandbox, Docker and E2B environments.
const DEMO_CAPABILITIES: HostCapabilitiesDEMO_DAEMONConstant#
A connected daemon holding a running session and one waiting for an answer.
const DEMO_DAEMON: DaemonStatusDEMO_HOSTSConstant#
A desktop's hosts: This computer, then three saved servers.
const DEMO_HOSTS: readonly HostSummary[]DEMO_MACHINESConstant#
The machines Box holds.
const DEMO_MACHINES: readonly MachineInfo[]DEMO_NOWConstant#
A fixed "now" for the demo data, so screenshots don't drift.
const DEMO_NOW: numberDEMO_SERVER_PROVIDERSConstant#
Box's providers: Anthropic set up, OpenAI signs in with OAuth there.
const DEMO_SERVER_PROVIDERS: readonly HostProviderAuth[]DEMO_SYNCConstant#
This computer keeping Box in sync: settings, instructions and API keys (Anthropic's opted in), a field edited on Box since, a skipped MCP server.
const DEMO_SYNC: HostSyncStateDEMO_TOKENSConstant#
Box's client tokens.
const DEMO_TOKENS: readonly ServerToken[]DEMO_UPDATE_WAITINGConstant#
Box's self-update, a release waiting for runs to pause.
const DEMO_UPDATE_WAITING: ServerUpdateStatusFIXTURE_LOCAL_HOSTConstant#
This computer, as every host lists it first.
const FIXTURE_LOCAL_HOST: HostSummaryInterfaces#
FixtureMachinesControlInterface#
Pushes the fixture can make, as a backend would.
interface FixtureMachinesControlProperties
| Name | Type | Description |
|---|---|---|
| setHealth | (health: DaemonHealth) => void | Sets the daemon's health. |
| setHosts | (hosts: readonly HostSummary[]) => void | Replaces the hosts (a status push). |
| setLinks | (links: MachineLinksStatus) => void | Replaces the links (a links push). |
| setMachineStatus | (hostId: string, machineId: string, status: 'online' | 'offline') => void | A machine came online or went offline: its server's list follows. |
| setPermitted | (actions: readonly MachinesAction[] | null) => void | Sets what the token may do. |
| setPresence | (sessions: readonly SessionPresence[]) => void | Replaces every session's presence (a presence push). |
FixtureMachinesOptionsInterface#
Options of createFixtureMachinesHost.
interface FixtureMachinesOptionsProperties
| Name | Type | Description |
|---|---|---|
| capabilities? | false | HostCapabilities | What every host can do, or |
| daemon? | false | DaemonStatus | The local daemon's status, or |
| enabled? | boolean | More than This computer shows. Default: true. |
| folders? | readonly string[] | The folders |
| health? | DaemonHealth | The daemon's health. Default: |
| hosts? | readonly HostSummary[] | The hosts, This computer first. Default: This computer alone. |
| links? | MachineLinksStatus | This computer's links. Default: none. |
| machines? | Readonly<Record<string, readonly MachineInfo[]>> | Each server's machines, by host id. |
| onAdd? | (input: { name?: string; token: string; url: string }) => void | Called when an add reaches the fixture. |
| onCapabilities? | (hostId: string, refresh: boolean) => void | Called when a capability read reaches the fixture. |
| onCreateToken? | (hostId: string, name: string, scope: ServerTokenScope) => void | Called when a token is created. |
| onDaemon? | (action: 'restart' | 'reconnect' | 'stopRun' | 'relaunchApp', detail?: unknown) => void | Called when a daemon action reaches the fixture. |
| onForget? | (hostId: string, machineId: string) => void | Called when a forget reaches the fixture. |
| onInstallTool? | (hostId: string, name: string) => { ok: boolean; output: string } | Called when an install reaches the fixture (with |
| onInvite? | (hostId: string, options: { name?: string; ttlMs?: number }) => void | { code: string; expiresAt: number } | Called when a join code is asked for; what it returns is the code. Default: a made-up code, 10 minutes. |
| onLink? | (action: 'shareStart' | 'shareStop' | 'useServer', hostId: string, detail?: unknown) => void | Called when a link action reaches the fixture. |
| onRemove? | (id: string) => void | Called when a removal reaches the fixture. |
| onRename? | (id: string, name: string) => void | Called when a rename reaches the fixture. |
| onRetry? | (hostId: string) => void | Called when a retry reaches the fixture. |
| onRevokeToken? | (hostId: string, id: string) => void | Called when a token is revoked. |
| onSetUrl? | (id: string, url: string) => void | Called when a URL change reaches the fixture. |
| onSignIn? | (hostId: string, target: unknown) => void | Called when a sign-in starts. |
| onSync? | (action: 'reset' | 'push' | 'configure' | 'takeOver', hostId: string, detail?: unknown) => void | Called when a sync action reaches the fixture; what it throws, the action rejects with. |
| onTest? | (target: { id: string } | { token: string; url: string }) => void | Called when a test reaches the fixture. |
| onUpdate? | (hostId: string, action: 'check' | 'install' | 'configure', enabled?: boolean) => void | Called when an update action reaches the fixture. |
| permitted? | false | readonly MachinesAction[] | What the token may do, or |
| presence? | false | readonly SessionPresence[] | Every live session's presence, or |
| providers? | Readonly<Record<string, readonly HostProviderAuth[]>> | Each server's providers ( |
| signIn? | boolean | Offer |
| signInMs? | number | How long a fixture sign-in waits on its page before it completes, ms. Default: never (it waits). |
| signInUrl? | string | The page a fixture sign-in opens. Default: an example address. |
| sync? | false | Readonly<Record<string, HostSyncState>> | Each server's sync from this computer, by host id, or |
| tokens? | Readonly<Record<string, readonly ServerToken[]>> | Each server's tokens, by host id. Default: none. |
| updates? | Readonly<Record<string, ServerUpdateStatus | null>> | Each server's self-update, by host id; |
Types#
FixtureMachinesHostType#
An in-memory MachinesHost and its control.
type FixtureMachinesHost = MachinesHost & { control: FixtureMachinesControl }