# zidane-ui/approvals/testing

Import: `import { … } from 'zidane-ui/approvals/testing'`. Source: [ui/src/approvals/testing/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/testing/index.ts).

## Functions

### `createFixtureApprovalsHost`

Function.

Creates an [`ApprovalsHost`](https://zidane.si/docs/reference/ui-approvals-headless.md#ApprovalsHost) held in memory.

```ts
function createFixtureApprovalsHost(
  options?: FixtureApprovalsOptions,
): FixtureApprovalsHost
```

**Parameters**

- `options?` (`FixtureApprovalsOptions`, default `{}`): The pending approvals, the safelist, and whether decisions are offered.

**Returns** `FixtureApprovalsHost`

Source: [ui/src/approvals/headless/fixture-host.ts:37](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixture-host.ts#L37)

## Constants

### `DEMO_APPROVALS`

Constant.

The demo approvals, oldest first.

```ts
const DEMO_APPROVALS: readonly ApprovalRequest[]
```

Source: [ui/src/approvals/headless/fixtures.ts:76](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixtures.ts#L76)

### `DEMO_EDIT_APPROVAL`

Constant.

A one-hunk `edit`, with its resolved preview.

```ts
const DEMO_EDIT_APPROVAL: ApprovalRequest
```

Source: [ui/src/approvals/headless/fixtures.ts:19](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixtures.ts#L19)

### `DEMO_MULTI_EDIT_APPROVAL`

Constant.

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

```ts
const DEMO_MULTI_EDIT_APPROVAL: ApprovalRequest
```

Source: [ui/src/approvals/headless/fixtures.ts:54](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixtures.ts#L54)

### `DEMO_SAFELIST`

Constant.

A demo safelist: two projects.

```ts
const DEMO_SAFELIST: readonly SafelistProject[]
```

Source: [ui/src/approvals/headless/fixtures.ts:83](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixtures.ts#L83)

### `DEMO_SHELL_APPROVAL`

Constant.

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

```ts
const DEMO_SHELL_APPROVAL: ApprovalRequest
```

Source: [ui/src/approvals/headless/fixtures.ts:9](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixtures.ts#L9)

## Interfaces

### `FixtureApprovalsHost`

Interface.

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

```ts
interface FixtureApprovalsHost extends ApprovalsHost
```

**Properties**

- `pending` (`Readable<readonly WireApprovalRequest[]>`, from `ApprovalsHost`): 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?` (`ApprovalsSafelist`, from `ApprovalsHost`): The "Always allow" entries. Absent: no safelist panel.
- `denyAll?` (`(sessionId?: string) => Promise<void>`, from `ApprovalsHost`): 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?` (`(requestId: string, decision: ApprovalDecision) => Promise<void>`, from `ApprovalsHost`): 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.

Source: [ui/src/approvals/headless/fixture-host.ts:25](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixture-host.ts#L25)

### `FixtureApprovalsOptions`

Interface.

Options for [`createFixtureApprovalsHost`](https://zidane.si/docs/reference/ui-approvals-testing.md#createFixtureApprovalsHost).

```ts
interface FixtureApprovalsOptions
```

**Properties**

- `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.

Source: [ui/src/approvals/headless/fixture-host.ts:11](https://github.com/Tahul/zidane/blob/main/ui/src/approvals/headless/fixture-host.ts#L11)
