Skip to content

modals/scripted-dialog-driver

A FIFO DialogDriver that answers a DialogContext’s dialogs from a script, for tests.

It imports nothing from Obsidian or from a test framework, so any test runner can use it, and a test needs no Obsidian App when every dialog it reaches is scripted.

Class Description
ScriptedDialogDriver A FIFO driver that answers each dialog with the next step of its script. It checks the request’s kind, and its interaction id when the step names one, records every request in ScriptedDialogDriver.transcript, and ScriptedDialogDriver.assertDone fails when a step was never used.
Interface Description
DialogTestHarness A test fixture: a DialogContext answered by its own ScriptedDialogDriver.
ScriptedDialogAlertStep A step that acknowledges an alert, which has no result.
ScriptedDialogDriverConstructorOptions Options for constructing a ScriptedDialogDriver.
ScriptedDialogPassthroughStep A step that checks and records its dialog, then lets the real modal open.
ScriptedDialogStepBase The part of a ScriptedDialogStep every step has.
ScriptedDialogValueProviderStep A step that derives its answer from the observed request, for instance to assert on the dialog’s parameters.
ScriptedDialogValueStep A step that answers its dialog with a fixed value.
Function Description
createDialogTestHarness Creates a DialogContext with no App, answered by a fresh ScriptedDialogDriver. A step that passes through throws there, since there is no real modal to open.
Type Description
CreateDialogTestHarnessOptions Options for createDialogTestHarness.
ScriptedDialogStep One expected dialog, with its scripted answer or an explicit pass-through to the real modal.