Skip to content

zidane-ui/channels/testing

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

Functions#

createFixtureChannelsHostFunction#

zidane-ui/channels/testing: a ChannelsHost that runs in memory (createFixtureChannelsHost) over the channels methods as zidane answers them (createFixtureChannelsMethods), for docs, demos, galleries and an app's own tests. Not for production hosts.

TypeScript
function createFixtureChannelsHost(seed?: FixtureChannelsSeed): FixtureChannelsHost
Parameters
NameTypeDefaultDescription
seed?FixtureChannelsSeed{}

What it starts with.

ui/src/channels/headless/fixture-host.ts:487

createFixtureChannelsMethodsFunction#

zidane-ui/channels/testing: a ChannelsHost that runs in memory (createFixtureChannelsHost) over the channels methods as zidane answers them (createFixtureChannelsMethods), for docs, demos, galleries and an app's own tests. Not for production hosts.

TypeScript
function createFixtureChannelsMethods(
  seed?: FixtureChannelsSeed,
): FixtureChannelsMethods
Parameters
NameTypeDefaultDescription
seed?FixtureChannelsSeed{}

What it starts with.

ui/src/channels/headless/fixture-host.ts:162

fixtureChannelAgentFunction#

zidane-ui/channels/testing: a ChannelsHost that runs in memory (createFixtureChannelsHost) over the channels methods as zidane answers them (createFixtureChannelsMethods), for docs, demos, galleries and an app's own tests. Not for production hosts.

TypeScript
function fixtureChannelAgent(): ChannelAgent
ChannelAgent

ui/src/channels/headless/fixture-host.ts:102

fixtureChannelBindingsFunction#

zidane-ui/channels/testing: a ChannelsHost that runs in memory (createFixtureChannelsHost) over the channels methods as zidane answers them (createFixtureChannelsMethods), for docs, demos, galleries and an app's own tests. Not for production hosts.

TypeScript
function fixtureChannelBindings(): ChannelBinding[]

ui/src/channels/headless/fixture-host.ts:94

fixtureChannelConnectionsFunction#

zidane-ui/channels/testing: a ChannelsHost that runs in memory (createFixtureChannelsHost) over the channels methods as zidane answers them (createFixtureChannelsMethods), for docs, demos, galleries and an app's own tests. Not for production hosts.

TypeScript
function fixtureChannelConnections(): ChannelConnection[]

ui/src/channels/headless/fixture-host.ts:86

Interfaces#

FixtureChannelsHostInterface#

The fixture's host, with its methods.

TypeScript
interface FixtureChannelsHost extends ChannelsHostState
FixtureChannelsHost properties
NameTypeDescription
agent?from ChannelsHostStateChannelsAgent

The org's Agent. Absent: no Agent card and no Agent row.

alerts?from ChannelsHostStateChannelsAlerts

The caller's open channel alerts. Absent: no alerts list.

applyfrom ChannelsHostState(signal: { kind: string }) => void

A signal of the host: reads again what it touches. Other kinds are ignored.

bindings?from ChannelsHostStateChannelsBindings

A project's bindings (Project settings › Channels). Absent: no Channels section.

connections?from ChannelsHostStateChannelsConnections

The host's connections (Settings › Channels). Absent: no Channels page.

defaultProjectsfrom ChannelsHostStateReadable<Readonly<Record<string, string | null>>>

The defaults set from this window, by connection id (null: cleared). The host has no read of them.

held?from ChannelsHostStateChannelsHeld

A project's replies the outbound filter held, and their release. Absent: no Held replies list.

methodsFixtureChannelsMethods

The methods under it: the provider's side, what it sent.

openProject?from ChannelsHostState(projectId: string) => void

Opens a project of the host (its home): the Agent card's Open project. Absent: no Open project.

openSession?from ChannelsHostState(sessionId: string) => void

Opens a session of the host (a test session). Absent: Test as opens it in the background.

openTarget?from ChannelsHostState(target: ReadinessOpenTarget, projectId?: string) => void

Opens a screen of the app a readiness fix names (Settings › Channels, Linked accounts). The project's own screens open its settings in the kit. Absent: those fixes show without a button. projectId: the project the fix is about (absent for an alert about no project).

readiness?from ChannelsHostStateChannelsReadiness

A project's readiness checklist. Absent: no checklist.

setDefaultProject?from ChannelsHostState(connectionId: string, projectId: string | null) => Promise<void>

Sets (null: clears) the caller's default project for a connection's DMs and unbound mentions. Absent: no default project rows.

testAs?from ChannelsHostState(projectId: string, bindingId: string, as: TestAsKind, identity: { iconUrl?: string; name: string }) => Promise<TestSession>

Opens a private session with a binding's exact rules for a member or a guest. Absent: no Test as. identity: how its replies post, kept for the session's Test badge.

testSessionsfrom ChannelsHostStateReadable<Readonly<Record<string, TestSession>>>

The test sessions opened in this window, by session id.

wakefrom ChannelsHostState() => void

Reads again everything read so far (a new connection).

ui/src/channels/headless/fixture-host.ts:477

FixtureChannelsMethodsInterface#

The fixture's methods, with the provider's side and what it sent.

TypeScript
interface FixtureChannelsMethods extends ChannelsBackend
FixtureChannelsMethods properties
NameTypeDescription
callfrom ChannelsBackend<M extends 'projects.readiness' | 'channels.bindings.testAs' | 'channels.connections.list' | 'channels.connections.get' | 'channels.connections.create' | 'channels.connections.update' | 'channels.connections.remove' | 'channels.connections.status' | 'channels.connections.slackManifest' | 'channels.connections.slackCredentials' | 'channels.connections.slackInstall' | 'channels.connections.githubManifest' | 'channels.bindings.list' | 'channels.runsOn' | 'channels.bindings.put' | 'channels.bindings.remove' | 'channels.bindings.enable' | 'channels.conversations' | 'channels.defaultProject' | 'channels.held.list' | 'channels.held.release' | 'channels.alerts.list' | 'channels.agent.get' | 'channels.agent.set'>(method: M, params: ChannelsParams<M>) => Promise<ChannelsResult<M>>

Calls a method. Rejects with the host's error (the adapter's own type; classify words it).

calls{ method: string; params: unknown }[]

Every call made, in order: method and params.

canfrom ChannelsBackend(method: 'projects.readiness' | 'channels.bindings.testAs' | 'channels.connections.list' | 'channels.connections.get' | 'channels.connections.create' | 'channels.connections.update' | 'channels.connections.remove' | 'channels.connections.status' | 'channels.connections.slackManifest' | 'channels.connections.slackCredentials' | 'channels.connections.slackInstall' | 'channels.connections.githubManifest' | 'channels.bindings.list' | 'channels.runsOn' | 'channels.bindings.put' | 'channels.bindings.remove' | 'channels.bindings.enable' | 'channels.conversations' | 'channels.defaultProject' | 'channels.held.list' | 'channels.held.release' | 'channels.alerts.list' | 'channels.agent.get' | 'channels.agent.set') => boolean

Whether the host offers a method. A method it does not offer hides what needs it.

classify?from ChannelsBackend(err: unknown) => ChannelsError

Words a rejection. Default: failed with its message.

clearAlert(id: string) => void

An alert clears on recovery (channels:alert with cleared).

completeGithubManifest(connectionId: string, slug?: string) => void

GitHub's manifest flow came back: the connection holds its App's key and runs.

completeSlackInstall(connectionId: string, teamName?: string, teamId?: string) => void

Slack's OAuth page came back: the connection holds a bot token and runs. One that replaces another takes its bindings: all of them in the same workspace (teamId, default T1, the default app's), else its direct messages and mentions, its channels becoming drafts; the old one goes.

defaultsMap<string, string | null>

The defaults people set, by connection id.

onSignal(listener: (signal: ChannelsSignal) => void) => () => void

Calls listener with every signal a change sends. Returns the unsubscribe.

openAlert(alert: ChannelAlert) => void

An alert opens for the caller (channels:alert), or opens again with new words (same id).

publicUrl?from ChannelsBackendboolean

The host serves https webhooks at a public URL, so a Slack app can use HTTP instead of Socket Mode. Default false.

runFix?from ChannelsBackend(method: string, params: Record<string, unknown>) => Promise<unknown>

Calls the method a readiness fix names (fix.kind === 'method'): any method of the host, checked there like any other call. Absent: method fixes are not offered.

setReadiness(projectId: string, items: readonly ReadinessItem[]) => void

Replaces a project's extra readiness items, and says so (projects:readiness).

setState(state: ConnectionLiveState) => void

A connection's live state changes (channels:status).

ui/src/channels/headless/fixture-host.ts:50

FixtureChannelsProjectInterface#

A project the fixture knows: its id and name.

TypeScript
interface FixtureChannelsProject
FixtureChannelsProject properties
NameTypeDescription
idstring

Its id.

namestring

Its name.

ui/src/channels/headless/fixture-host.ts:15

FixtureChannelsSeedInterface#

What a fixture starts with.

TypeScript
interface FixtureChannelsSeed
FixtureChannelsSeed properties
NameTypeDescription
agent?ChannelAgent | null

The org's Agent (fixtureChannelAgent); its project joins projects when they lack it. Default none (null).

alerts?readonly ChannelAlert[]

The caller's open alerts (channels.alerts.list). Default none.

bindings?readonly ChannelBinding[]

The bindings. Default: p-app on #ops through acme, and a draft of p-app's from a published project; with an agent, its direct messages and mentions through acme too.

connections?readonly ChannelConnection[]

The connections. Default: acme (Slack, ready) and acme-github (GitHub, pending).

conversations?Readonly<Record<string, readonly Omit<ChannelConversation, 'boundBy'>[]>>

The Slack channels each connection's app is in. Default: #ops, #general, #secret (private) for acme.

held?readonly HeldPost[]

The replies the outbound filter held (channels.held.list). Default none.

projects?readonly FixtureChannelsProject[]

The projects. Default p-app (App) and p-api (API).

publicUrl?boolean

The host serves a public URL (Slack's HTTP transport). Default false.

readiness?Readonly<Record<string, readonly ReadinessItem[]>>

Items each project's checklist adds to the ones the fixture computes.

without?readonly ('projects.readiness' | 'channels.bindings.testAs' | 'channels.connections.list' | 'channels.connections.get' | 'channels.connections.create' | 'channels.connections.update' | 'channels.connections.remove' | 'channels.connections.status' | 'channels.connections.slackManifest' | 'channels.connections.slackCredentials' | 'channels.connections.slackInstall' | 'channels.connections.githubManifest' | 'channels.bindings.list' | 'channels.runsOn' | 'channels.bindings.put' | 'channels.bindings.remove' | 'channels.bindings.enable' | 'channels.conversations' | 'channels.defaultProject' | 'channels.held.list' | 'channels.held.release' | 'channels.alerts.list' | 'channels.agent.get' | 'channels.agent.set')[]

Methods to leave out, so a test can check what hides without them.

ui/src/channels/headless/fixture-host.ts:23