Skip to content

zidane-ui/approvals/testing

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

Functions#

createFixtureApprovalsHostFunction#

Creates an ApprovalsHost held in memory.

TypeScript
function createFixtureApprovalsHost(
  options?: FixtureApprovalsOptions,
): FixtureApprovalsHost
Parameters
NameTypeDefaultDescription
options?FixtureApprovalsOptions{}

The pending approvals, the safelist, and whether decisions are offered.

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

Constants#

DEMO_APPROVALSConstant#

The demo approvals, oldest first.

TypeScript
const DEMO_APPROVALS: readonly ApprovalRequest[]

ui/src/approvals/headless/fixtures.ts:76

DEMO_EDIT_APPROVALConstant#

A one-hunk edit, with its resolved preview.

TypeScript
const DEMO_EDIT_APPROVAL: ApprovalRequest

ui/src/approvals/headless/fixtures.ts:19

DEMO_MULTI_EDIT_APPROVALConstant#

A three-hunk multi_edit from a subagent: one hunk matched a close variant, one is not in the file.

TypeScript
const DEMO_MULTI_EDIT_APPROVAL: ApprovalRequest

ui/src/approvals/headless/fixtures.ts:54

DEMO_SAFELISTConstant#

A demo safelist: two projects.

TypeScript
const DEMO_SAFELIST: readonly SafelistProject[]

ui/src/approvals/headless/fixtures.ts:83

DEMO_SHELL_APPROVALConstant#

A shell command waiting for approval, with its working directory and timeout.

TypeScript
const DEMO_SHELL_APPROVAL: ApprovalRequest

ui/src/approvals/headless/fixtures.ts:9

Interfaces#

FixtureApprovalsHostInterface#

The fixture host, plus a way to raise a request as a running agent would.

TypeScript
interface FixtureApprovalsHost extends ApprovalsHost
FixtureApprovalsHost properties
NameTypeDescription
pendingfrom ApprovalsHostReadable<readonly WireApprovalRequest[]>

The approvals waiting for a decision, oldest first. The host keeps it current: new requests, requests answered elsewhere (another window, a terminal), and a re-read after a reconnect. The host starts listening when the store gets its first subscriber.

safelist?from ApprovalsHostApprovalsSafelist

The "Always allow" entries. Absent: no safelist panel.

denyAll?from ApprovalsHost(sessionId?: string) => Promise<void>

Denies every pending approval, or only those of sessionId. Absent: no bulk deny.

dismiss(requestId: string) => void

Removes a request without a decision, as when another window answered it.

raise(request: WireApprovalRequest) => void

Adds a request to the queue, as a tool call that needs approval does.

resolve?from ApprovalsHost(requestId: string, decision: ApprovalDecision) => Promise<void>

Answers a pending approval. The request leaves pending at once; an id that is not pending does nothing. Absent: the host can show approvals but not answer them.

ui/src/approvals/headless/fixture-host.ts:25

FixtureApprovalsOptionsInterface#

Options for createFixtureApprovalsHost.

TypeScript
interface FixtureApprovalsOptions
FixtureApprovalsOptions properties
NameTypeDescription
canResolve?boolean

false leaves out resolve and denyAll (a host that shows approvals but can't answer them). Default true.

pending?readonly WireApprovalRequest[]

The approvals pending at the start, oldest first. Default: none.

safelist?false | readonly SafelistProject[]

The safelist's projects. Default: empty. false: no safelist member.

onDenyAll?(sessionId: string | undefined) => void

Called with every bulk deny (undefined: every session), after the requests left the queue.

onResolve?(requestId: string, decision: ApprovalDecision) => void

Called with every decision, after the request left the queue.

ui/src/approvals/headless/fixture-host.ts:11