zidane-ui/ session/ testing
import { … } from 'zidane-ui/session/testing'ui/src/session/testing/index.ts
Functions#
createFixturePlansBackendFunction#
Creates a FixturePlansBackend.
function createFixturePlansBackend(seed?: FixturePlansSeed): FixturePlansBackendParameters
| Name | Type | Default | Description |
|---|---|---|---|
| seed? | FixturePlansSeed | {} | The plans and task lists it starts with. |
Returns
createFixtureScheduleBackendFunction#
Creates a FixtureScheduleBackend.
function createFixtureScheduleBackend(
options?: FixtureScheduleOptions,
): FixtureScheduleBackendParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureScheduleOptions | {} | The starting schedules, fires, setting and clock. |
Returns
createFixtureSessionHostFunction#
Creates a FixtureSessionHost over the fixture's data.
function createFixtureSessionHost(fixture?: SessionFixture): FixtureSessionHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| fixture? | SessionFixture | {} | The data per session. |
Returns
demoUsageSummaryFunction#
A usage summary over range, ending on today: a few months of steady use across three models.
function demoUsageSummary(range: UsageRange, today?: Date): UsageSummaryParameters
| Name | Type | Description |
|---|---|---|
| range | UsageRange | The range it covers. |
| today? | Date | The last day. |
Returns
planOfFunction#
A session-scope plan over a task list, for fixtures and tests.
plansSnapshotOfFunction#
The snapshot of a session's plans, as the host broadcasts it (every run live: nothing reads as interrupted).
function plansSnapshotOf(plans: readonly PlanView[]): PlansSnapshotParameters
| Name | Type | Description |
|---|---|---|
| plans | readonly PlanView[] | The plans, oldest first. |
Returns
tallyTodosFunction#
Counts todo items by status.
function tallyTodos(items: readonly { status: TodoStatus }[]): TodoTallyCountsParameters
| Name | Type | Description |
|---|---|---|
| items | readonly { status: TodoStatus }[] | The todo list. |
Returns
Constants#
DEMO_ARTIFACT_KIND_LABELSConstant#
The artifact kinds' labels in the demo, as the backend's kind registry words them.
const DEMO_ARTIFACT_KIND_LABELS: Readonly<Record<string, string>>DEMO_GITHUB_USAGEConstant#
GitHub's API limits in the demo.
const DEMO_GITHUB_USAGE: readonly ProviderUsageSnapshot[]DEMO_PROVIDER_USAGEConstant#
Subscription windows: one provider with two accounts' worth of windows, one with credits.
const DEMO_PROVIDER_USAGE: readonly ProviderUsageSnapshot[]DEMO_SESSION_FIXTUREConstant#
A session (demo) with todos mid-task, two queued messages, three artifacts, running work and turns, plus usage.
const DEMO_SESSION_FIXTURE: SessionFixtureDEMO_TURNSConstant#
The demo's stored turns: a prompt and the answer.
const DEMO_TURNS: readonly SessionTurn[]SCHEDULES_OFF_MESSAGEConstant#
The message zidane's backend answers while the setting is off.
const SCHEDULES_OFF_MESSAGE: 'Reminders are off. Turn them on in Settings > Sessions > Reminders.'Interfaces#
FixturePlansBackendInterface#
A plans backend in memory.
interface FixturePlansBackendProperties
| Name | Type | Description |
|---|---|---|
| control | (sessionId: string, planId: string, action: PlanControlAction) => PlansSnapshot | A stop or drop ( |
| edit | (sessionId: string, planId: string, op: PlanEditOp) => PlansSnapshot | A user edit ( |
| endRun | (sessionId: string, outcome?: 'error' | 'completed' | 'aborted') => void | The session's run ended: the plan it applied stops. |
| setPlans | (sessionId: string, plans: readonly PlanView[]) => void | Replaces a session's plans. |
| snapshot | (sessionId: string) => PlansSnapshot | null | A session's snapshot, |
| subscribe | (listener: (sessionId: string) => void) => () => void | Calls |
| writeTodos | (sessionId: string, items: readonly TodoItem[]) => void | The agent's |
FixturePlansSeedInterface#
What a fixture plans backend starts with, per session id.
interface FixturePlansSeedProperties
| Name | Type | Description |
|---|---|---|
| plans? | Readonly<Record<string, readonly PlanView[]>> | Each session's plans, oldest first ( |
| todos? | Readonly<Record<string, readonly TodoItem[]>> | Each session's task list as the agent wrote it ( |
FixtureQueuedEntryInterface#
A queued entry the fixture holds, with its attachments' bytes.
interface FixtureQueuedEntryProperties
| Name | Type | Description |
|---|---|---|
| attachments? | PromptAttachment[] | Its attachments, with their bytes. |
| id | string | The entry's id. |
| text | string | The message text. |
FixtureScheduleBackendInterface#
A scripted reminders backend.
interface FixtureScheduleBackendProperties
| Name | Type | Description |
|---|---|---|
| create | (input: unknown) => Schedule |
|
| fires | (id: string, limit?: number) => ScheduleFire[] |
|
| list | (filter?: { sessionId?: string }) => Schedule[] |
|
| remove | (id: string) => boolean |
|
| replace | (list: readonly Schedule[]) => void | Replaces the stored schedules from outside (the agent set one, one fired). |
| runNow | (id: string) => ScheduleFire |
|
| setEnabled | (enabled: boolean) => void | Turns the setting on or off. |
| status | () => SchedulesStatus |
|
| subscribe | (onChange: (scheduleId?: string) => void) => () => void | Hears every change ( |
| update | (id: string, patch: unknown) => Schedule |
|
FixtureScheduleOptionsInterface#
What createFixtureScheduleBackend starts with.
interface FixtureScheduleOptionsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| enabled? | boolean | true |
|
| fires? | Readonly<Record<string, readonly ScheduleFire[]>> | Each schedule's fires, newest first. | |
| now? | () => number | Date.now | The clock. |
| schedules? | readonly Schedule[] | The stored schedules, oldest first. |
FixtureSessionControlInterface#
Changes a fixture's data from outside and announces it, as the agent or another window would.
interface FixtureSessionControlProperties
| Name | Type | Description |
|---|---|---|
| endRun | (sessionId: string, outcome?: 'error' | 'completed' | 'aborted') => void | The session's run ended: the plan it applied stops. |
| recordArtifact | (sessionId: string, row: SessionArtifactRow) => void | Records an artifact (newest first). |
| setPlans | (sessionId: string, plans: readonly PlanView[]) => void | Replaces a session's plans. |
| setQueue | (sessionId: string, entries: readonly FixtureQueuedEntry[]) => void | Replaces a session's queue. |
| setSchedules | (list: readonly Schedule[]) => void | Replaces the stored reminders (the agent set one, one fired) and announces the change. |
| setSchedulesEnabled | (enabled: boolean) => void | Turns the Reminders setting on or off and announces it. |
| setSecrets | (sessionId: string, entries: readonly SecretEntry[]) => void | Replaces a session's saved secrets (the agent saved one, another window revoked one). |
| setWork | (sessionId: string, items: readonly RunningWorkItem[]) => void | Replaces a session's running work. |
| writeTodos | (sessionId: string, items: readonly TodoItem[]) => void | The agent's |
FixtureSessionHostInterface#
The fixture host: a full SessionHost plus its control.
interface FixtureSessionHost extends SessionHostProperties
| Name | Type | Description |
|---|---|---|
artifacts?from SessionHost | SessionArtifacts | The recorded artifacts. Absent: no Artifacts panel. |
| control | FixtureSessionControl | Changes the data from outside. |
details?from SessionHost | SessionDetailsActions | The details dialog's actions. Absent: the dialog shows facts only. |
plans?from SessionHost | SessionPlans | The plans. Absent: no Todos panel. |
queue?from SessionHost | SessionQueue | The type-ahead queues. Absent: no queue. |
runningWork?from SessionHost | SessionRunningWork | The cancellable work. Absent: no running work dialog. |
schedules?from SessionHost | SessionSchedules | Reminders (zidane's schedules). Absent: no Reminders panel, no badge. |
secrets?from SessionHost | SessionSecrets | The saved secrets of a session's project. Absent: no Secrets panel. |
side?from SessionHost | SessionSideChats |
|
turns?from SessionHost | SessionTurns | The stored turns. Absent: no turn details dialog. |
usage?from SessionHost | SessionUsage | Usage. Absent: no usage card, no usage panel. |
SessionFixtureInterface#
What a fixture session host starts with, per session id.
interface SessionFixtureProperties
| Name | Type | Default | Description |
|---|---|---|---|
| artifacts? | Readonly<Record<string, readonly SessionArtifactRow[]>> | The artifacts per session, newest first. | |
| githubUsage? | readonly ProviderUsageSnapshot[] | GitHub's API limits. Absent: no | |
| kindLabel? | (kind: string) => string | An artifact kind's group label. Default: the raw kind. | |
| plans? | Readonly<Record<string, readonly PlanView[]>> | The plans per session, oldest first ( | |
| providerUsage? | readonly ProviderUsageSnapshot[] | The providers' subscription snapshots. Absent: no | |
| queue? | Readonly<Record<string, readonly FixtureQueuedEntry[]>> | The queued messages per session. | |
| scheduleFires? | Readonly<Record<string, readonly ScheduleFire[]>> | Each reminder's fires, newest first, by schedule id. | |
| schedules? | readonly Schedule[] | The stored reminders (zidane's schedules), oldest first. Absent: no | |
| schedulesEnabled? | boolean | true |
|
| secrets? | Readonly<Record<string, readonly SecretEntry[]>> | The saved secrets per session (as the session's project holds them). Absent: no | |
| secretsSaveError? | string |
| |
| sides? | Readonly<Record<string, string>> | Each session's side chat id, by the parent's id. Absent: no | |
| todos? | Readonly<Record<string, readonly TodoItem[]>> | The task list per session as the agent wrote it ( | |
| turns? | Readonly<Record<string, readonly SessionTurn[]>> | The stored turns per session. | |
| usage? | Partial<Record<UsageRange, UsageSummary>> | The usage summary per range. Absent: no | |
| work? | Readonly<Record<string, readonly RunningWorkItem[]>> | The running work per session. |