Skip to content

zidane-ui/approvals/testing/contract

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

Functions#

describeApprovalsHostContractFunction#

Declares the shared ApprovalsHost suite for one implementation.

TypeScript
function describeApprovalsHostContract(
  name: string,
  makeHarness: ApprovalsHostHarnessFactory,
  capabilities: readonly ApprovalsHostCapability[],
): void
Parameters
NameTypeDescription
namestring

The implementation's name, shown in the suite title.

makeHarnessApprovalsHostHarnessFactory

Builds a fresh host over a backend that holds and records what it is given, once per test.

capabilitiesreadonly ApprovalsHostCapability[]

The optional members the host offers. Every other optional member must be undefined.

ui/src/approvals/testing/contract.ts:106

Interfaces#

ApprovalsHostContractBackendInterface#

What the backend behind the host holds, and what it records.

TypeScript
interface ApprovalsHostContractBackend
ApprovalsHostContractBackend properties
NameTypeDescription
pendingWireApprovalRequest[]

The approvals the backend holds: what a listing answers. Read at each listing; the suite changes it.

safelistSafelistProject[]

The safelist's projects. Read at each listing; a revoke changes it through removeSafelistEntry.

deniedAll(sessionId: string | undefined) => void

The backend calls this when a bulk deny reaches it (undefined: every session).

removeSafelistEntry(project: string, entry: string) => void

The backend calls this when a revoke reaches it: the entry leaves safelist.

resolved(requestId: string, decision: ApprovalDecision) => void

The backend calls this when a decision reaches it.

ui/src/approvals/testing/contract.ts:28

ApprovalsHostHarnessInterface#

A host built over a contract backend, and the pushes its backend can make.

TypeScript
interface ApprovalsHostHarness
ApprovalsHostHarness properties
NameTypeDescription
hostApprovalsHost

The host under test.

dispose?() => void

Closes connections and listeners after each test.

raise(request: WireApprovalRequest) => void

Pushes a new request, as the backend does when a tool call needs approval.

reconnect?() => void

Drops the connection and connects again, as a restarted backend would. Absent: the suite skips the re-read.

resolveElsewhere(requestId: string, decision: ApprovalDecision) => void

Pushes that another surface (a window, a terminal) answered a request.

ui/src/approvals/testing/contract.ts:42

Types#

ApprovalsHostCapabilityType#

An optional ApprovalsHost member, by its path.

TypeScript
type ApprovalsHostCapability = 'resolve' | 'denyAll' | 'safelist' | 'safelist.remove'

ui/src/approvals/testing/contract.ts:23

ApprovalsHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type ApprovalsHostHarnessFactory = (backend: ApprovalsHostContractBackend) => ApprovalsHostHarness | Promise<ApprovalsHostHarness>

ui/src/approvals/testing/contract.ts:56