Seed Bible extension API (v1.18.0) / seed-bible/extensions/testing / TestHost
Interface: TestHost
Properties
calls
calls: TestCall[];Every call that got past the permission check, in order.
chat
chat: (
providerId: string,
request: Omit<SandboxChatRequest, "providerId">,
) => Promise<string | null>;Asks a chat provider for its reply.
Parameters
| Parameter | Type |
|---|---|
providerId | string |
request | Omit<SandboxChatRequest, "providerId"> |
Returns
Promise<string | null>
chatProviders
chatProviders: Set<string>;clipboard
clipboard: string[];What sb.clipboard.writeText copied.
discover
discover: (
providerId: string,
request: Omit<SandboxDiscoverRequest, "providerId">,
) => Promise<SandboxDiscoverResult[]>;Asks a Discover provider for results, as the Discover panel does.
Parameters
| Parameter | Type |
|---|---|
providerId | string |
request | Omit<SandboxDiscoverRequest, "providerId"> |
Returns
Promise<SandboxDiscoverResult[]>
discoverProviders
discoverProviders: Set<string>;Registered Discover and chat providers, by id.
dispose
dispose: () => void;Closes every channel. Call it at the end of each test.
Returns
void
flush
flush: () => Promise<void>;Waits until every message already sent between the two sides has arrived.
Returns
Promise<void>
granted
granted: () => (
| "reading:position"
| "reading:selection"
| "reading:navigate"
| "reading:history"
| "highlights:read"
| "highlights:write"
| "notes:read"
| "notes:write"
| "saves:read"
| "saves:write"
| "profile:read"
| "chat:respond"
| "chat:shared"
| "friends:read"
| "session:read"
| "audio:playback"
| "clipboard:write"
| "embed:casualos"
| "device:microphone"
| "device:camera"
)[];What's granted now, implied permissions included.
Returns
( | "reading:position" | "reading:selection" | "reading:navigate" | "reading:history" | "highlights:read" | "highlights:write" | "notes:read" | "notes:write" | "saves:read" | "saves:write" | "profile:read" | "chat:respond" | "chat:shared" | "friends:read" | "session:read" | "audio:playback" | "clipboard:write" | "embed:casualos" | "device:microphone" | "device:camera")[]
opened
opened: SandboxVerseRef[];Every sb.reading.open.
panes
panes: Map<string, TestPane>;Open panes and portals, by pane id.
ready
ready: Promise<void>;Settles once main has finished, or rejects with its error.
renderView
renderView: (
view: string,
options?: {
container?: HTMLElement;
paneId?: string;
props?: SandboxJsonValue;
surface?: "pane" | "modal" | "settings";
},
) => Promise<HTMLElement>;Renders a view into container (or a new element in document.body) with its own sb, as a pane would. Returns the element it rendered in.
Parameters
| Parameter | Type |
|---|---|
view | string |
options? | { container?: HTMLElement; paneId?: string; props?: SandboxJsonValue; surface?: "pane" | "modal" | "settings"; } |
options.container? | HTMLElement |
options.paneId? | string |
options.props? | SandboxJsonValue |
options.surface? | "pane" | "modal" | "settings" |
Returns
Promise<HTMLElement>
requests
requests: {
granted: boolean;
permissions: (
| "reading:position"
| "reading:selection"
| "reading:navigate"
| "reading:history"
| "highlights:read"
| "highlights:write"
| "notes:read"
| "notes:write"
| "saves:read"
| "saves:write"
| "profile:read"
| "chat:respond"
| "chat:shared"
| "friends:read"
| "session:read"
| "audio:playback"
| "clipboard:write"
| "embed:casualos"
| "device:microphone"
| "device:camera"
)[];
}[];The permission prompts the user would have seen, and their answers. A request for what's already granted is answered without one, as in the app.
granted
granted: boolean;permissions
permissions: (
| "reading:position"
| "reading:selection"
| "reading:navigate"
| "reading:history"
| "highlights:read"
| "highlights:write"
| "notes:read"
| "notes:write"
| "saves:read"
| "saves:write"
| "profile:read"
| "chat:respond"
| "chat:shared"
| "friends:read"
| "session:read"
| "audio:playback"
| "clipboard:write"
| "embed:casualos"
| "device:microphone"
| "device:camera"
)[];selectTool
selectTool: (
id: string,
options?: {
itemId?: string;
selection?: SandboxSelectedVerse[];
},
) => Promise<void>;The user selects a tool (or one of its items). Waits for its handler.
Parameters
| Parameter | Type |
|---|---|
id | string |
options? | { itemId?: string; selection?: SandboxSelectedVerse[]; } |
options.itemId? | string |
options.selection? | SandboxSelectedVerse[] |
Returns
Promise<void>
setState
setState: (state: Partial<SandboxState>) => Promise<void>;The app's state changes, e.g. the reader moves to another chapter.
Parameters
| Parameter | Type |
|---|---|
state | Partial<SandboxState> |
Returns
Promise<void>
storage
storage: Map<string, SandboxJsonValue>;The extension's sb.storage. Set entries on it to seed storage.
toasts
toasts: string[];Every sb.app.toast message, in order.
tools
tools: Map<string, SandboxToolDefinition>;Registered tools, by the id the extension gave them.