Skip to content

zidane-ui/palette/testing

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

Functions#

createFixturePaletteHostFunction#

Creates a PaletteHost held in memory.

TypeScript
function createFixturePaletteHost(options?: FixturePaletteOptions): FixturePaletteHost
Parameters
NameTypeDefaultDescription
options?FixturePaletteOptions{}

Its commands, files, extension items, settings and recents.

ui/src/palette/testing/index.ts:96

Constants#

DEMO_PALETTE_COMMANDSConstant#

Demo / commands.

TypeScript
const DEMO_PALETTE_COMMANDS: readonly PaletteCommand[]

ui/src/palette/testing/index.ts:13

DEMO_PALETTE_CONVERSATIONSConstant#

Demo conversation text, by session id, for the content search.

TypeScript
const DEMO_PALETTE_CONVERSATIONS: Readonly<Record<string, string>>

ui/src/palette/testing/index.ts:41

DEMO_PALETTE_EXTENSION_ITEMSConstant#

A demo extension item (its source is its provider's id).

TypeScript
const DEMO_PALETTE_EXTENSION_ITEMS: readonly PaletteItem[]

ui/src/palette/testing/index.ts:29

DEMO_PALETTE_FILESConstant#

Demo project files, relative to the project root.

TypeScript
const DEMO_PALETTE_FILES: readonly string[]

ui/src/palette/testing/index.ts:20

Interfaces#

FixturePaletteHostInterface#

The PaletteHost createFixturePaletteHost returns, plus a way to change its extension items.

TypeScript
interface FixturePaletteHost extends PaletteHost
FixturePaletteHost properties
NameTypeDescription
extensions?from PaletteHostPaletteExtensions

Extension-contributed items. Absent: no extensions source.

recents?from PaletteHostPaletteRecents

Persistent recents. Absent: recents last as long as the page.

settings?from PaletteHostReadable<Partial<Settings>>

The settings in effect, read when the palette lists its rows. Absent: no settings rows.

listCommands?from PaletteHost(query: PaletteCommandQuery) => Promise<readonly PaletteCommand[]>

The / commands for a folder. Absent: no commands source.

listFiles?from PaletteHost(query: PaletteFileQuery) => Promise<readonly PaletteFileEntry[]>

The project's files (without gitignored ones). Absent: no files source.

searchConversations?from PaletteHost(query: PaletteConversationQuery) => Promise<readonly PaletteConversationHit[]>

Content matches inside conversations, best first; a newer call may cancel an older scan (it then resolves with whatever it has, or rejects). Absent: no "In conversations" group.

setExtensionItems(items: readonly PaletteItem[]) => void

Replaces the extension items and tells extensions.subscribe listeners.

setSettings?from PaletteHost(patch: Partial<Settings>) => Promise<void>

Applies a settings patch. Absent: settings rows are not offered.

ui/src/palette/testing/index.ts:86

FixturePaletteOptionsInterface#

Options of createFixturePaletteHost. Each list defaults to the demo data.

TypeScript
interface FixturePaletteOptions
FixturePaletteOptions properties
NameTypeDescription
commands?false | readonly PaletteCommand[]

The / commands, for any folder. false: no listCommands.

conversations?false | Readonly<Record<string, string>>

Conversation text by session id, for the content search. false: no searchConversations.

extensionItems?false | readonly PaletteItem[]

Extension items. false: no extensions.

files?false | readonly string[]

File paths relative to any root. false: no listFiles.

onSetSettings?(patch: Partial<Settings>) => void

Called with each settings patch, after the host applied it.

recents?readonly string[]

The stored recents. Default: none.

runExtension?(sourceId: string, itemId: string) => PaletteExtensionRun

What running an extension item answers. Default: a notice naming it.

settings?false | Partial<Settings>

The settings in effect. false: no settings / setSettings. Default: {}.

ui/src/palette/testing/index.ts:66