Skip to content

zidane-ui/machines/testing

import { … } from 'zidane-ui/machines/testing'ui/src/machines/testing/index.ts

Functions#

createFixtureMachinesHostFunction#

Creates a MachinesHost held in memory.

TypeScript
function createFixtureMachinesHost(
  options?: FixtureMachinesOptions,
): FixtureMachinesHost
Parameters
NameTypeDefaultDescription
options?FixtureMachinesOptions{}

The hosts, machines, links, updates, tokens and daemon it starts with, and the callbacks it tells.

ui/src/machines/headless/fixture-host.ts:152

Constants#

DEMO_CAPABILITIESConstant#

What a demo server can do: git and docker found, gh missing, the OS sandbox, Docker and E2B environments.

TypeScript
const DEMO_CAPABILITIES: HostCapabilities

ui/src/machines/headless/fixtures.ts:85

DEMO_DAEMONConstant#

A connected daemon holding a running session and one waiting for an answer.

TypeScript
const DEMO_DAEMON: DaemonStatus

ui/src/machines/headless/fixtures.ts:104

DEMO_HOSTSConstant#

A desktop's hosts: This computer, then three saved servers.

TypeScript
const DEMO_HOSTS: readonly HostSummary[]

ui/src/machines/headless/fixtures.ts:17

DEMO_MACHINESConstant#

The machines Box holds.

TypeScript
const DEMO_MACHINES: readonly MachineInfo[]

ui/src/machines/headless/fixtures.ts:50

DEMO_NOWConstant#

A fixed "now" for the demo data, so screenshots don't drift.

TypeScript
const DEMO_NOW: number

ui/src/machines/headless/fixtures.ts:14

DEMO_SERVER_PROVIDERSConstant#

Box's providers: Anthropic set up, OpenAI signs in with OAuth there.

TypeScript
const DEMO_SERVER_PROVIDERS: readonly HostProviderAuth[]

ui/src/machines/headless/fixtures.ts:161

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.

TypeScript
const DEMO_SYNC: HostSyncState

ui/src/machines/headless/fixtures.ts:117

DEMO_TOKENSConstant#

Box's client tokens.

TypeScript
const DEMO_TOKENS: readonly ServerToken[]

ui/src/machines/headless/fixtures.ts:72

DEMO_UPDATE_WAITINGConstant#

Box's self-update, a release waiting for runs to pause.

TypeScript
const DEMO_UPDATE_WAITING: ServerUpdateStatus

ui/src/machines/headless/fixtures.ts:62

FIXTURE_LOCAL_HOSTConstant#

This computer, as every host lists it first.

TypeScript
const FIXTURE_LOCAL_HOST: HostSummary

ui/src/machines/headless/fixture-host.ts:128

Interfaces#

FixtureMachinesControlInterface#

Pushes the fixture can make, as a backend would.

TypeScript
interface FixtureMachinesControl
FixtureMachinesControl properties
NameTypeDescription
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).

ui/src/machines/headless/fixture-host.ts:109

FixtureMachinesOptionsInterface#

Options of createFixtureMachinesHost.

TypeScript
interface FixtureMachinesOptions
FixtureMachinesOptions properties
NameTypeDescription
capabilities?false | HostCapabilities

What every host can do, or false for no capabilities. Default: false.

daemon?false | DaemonStatus

The local daemon's status, or false for no daemon. Default: no daemon.

enabled?boolean

More than This computer shows. Default: true.

folders?readonly string[]

The folders pickFolder answers, in turn. Default: /home/me/project.

health?DaemonHealth

The daemon's health. Default: connected.

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 capabilities); answers how it went. Default: it worked.

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 false for no permitted store (everything). Default: false.

presence?false | readonly SessionPresence[]

Every live session's presence, or false for no presence. Default: false.

providers?Readonly<Record<string, readonly HostProviderAuth[]>>

Each server's providers (sync.providers), by host id. Default: none.

signIn?boolean

Offer signIn (a sign-in that shows its page and completes after signInMs). Default: false.

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 false for no sync. Default: false.

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; null: the server predates it. Default: an up-to-date one.

ui/src/machines/headless/fixture-host.ts:37

Types#

FixtureMachinesHostType#

An in-memory MachinesHost and its control.

TypeScript
type FixtureMachinesHost = MachinesHost & { control: FixtureMachinesControl }

ui/src/machines/headless/fixture-host.ts:125