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.
function describeApprovalsHostContract(
name: string,
makeHarness: ApprovalsHostHarnessFactory,
capabilities: readonly ApprovalsHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | ApprovalsHostHarnessFactory | Builds a fresh host over a backend that holds and records what it is given, once per test. |
| capabilities | readonly ApprovalsHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
ApprovalsHostContractBackendInterface#
What the backend behind the host holds, and what it records.
interface ApprovalsHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| pending | WireApprovalRequest[] | The approvals the backend holds: what a listing answers. Read at each listing; the suite changes it. |
| safelist | SafelistProject[] | The safelist's projects. Read at each listing; a revoke changes it through |
| deniedAll | (sessionId: string | undefined) => void | The backend calls this when a bulk deny reaches it ( |
| removeSafelistEntry | (project: string, entry: string) => void | The backend calls this when a revoke reaches it: the entry leaves |
| resolved | (requestId: string, decision: ApprovalDecision) => void | The backend calls this when a decision reaches it. |
ApprovalsHostHarnessInterface#
A host built over a contract backend, and the pushes its backend can make.
interface ApprovalsHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| host | ApprovalsHost | 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. |
Types#
ApprovalsHostCapabilityType#
An optional ApprovalsHost member, by its path.
type ApprovalsHostCapability = 'resolve' | 'denyAll' | 'safelist' | 'safelist.remove'ApprovalsHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type ApprovalsHostHarnessFactory = (backend: ApprovalsHostContractBackend) => ApprovalsHostHarness | Promise<ApprovalsHostHarness>