Skip to content

modals/dialog-context

An instance-scoped context that opens the library’s dialogs, and lets a test answer them instead.

In production a DialogContext with no driver opens the real alert, confirm, prompt, selectItem and selectOption modals. A test hands the context a DialogDriver, usually a ScriptedDialogDriver (scripted-dialog-driver.ts), which answers each request by its kind and interaction id. Every answer a driver gives is checked against what the real modal could have returned, so a scripted test cannot pass with a value no user could produce.

The driver belongs to the context instance and nothing is kept in a module global, a class static or the shared state bag, so scripted answers never leak between tests, vaults or plugins.

Class Description
DialogContext Opens the library’s dialogs, or lets an instance-scoped DialogDriver answer them.
InvalidDialogResponseError Error thrown when a DialogDriver answers with a value the real dialog could never return.
Interface Description
DialogContextAlertParams Parameters of DialogContext.alert.
DialogContextConfirmParams Parameters of DialogContext.confirm.
DialogContextConstructorParams Parameters for constructing a DialogContext.
DialogContextInteractionParams Parameters shared by every DialogContext method.
DialogContextPromptParams Parameters of DialogContext.prompt.
DialogContextSelectItemParams Parameters of DialogContext.selectItem.
DialogContextSelectOptionParams Parameters of DialogContext.selectOption.
DialogDriver An instance-scoped driver that can observe dialog requests and answer them. ScriptedDialogDriver (scripted-dialog-driver.ts) is the one tests use.
DialogParamsMap The parameters a dialog of each kind is shown with, without the app and the interaction id.
DialogRequestOfKind A DialogRequest of one kind.
DialogResultMap The value a dialog of each kind resolves with.
HandledDialogDriverResponse A driver’s answer that supplies the dialog’s result, so no modal is opened.
PassthroughDialogDriverResponse A driver’s answer that lets the real modal open.
Function Description
describeDialogRequest Describes a dialog request for an error message: its kind, and its interaction id when it has one.
Type Description
DialogDriverResponse A driver’s answer to a DialogRequest.
DialogKind The kind of a dialog a DialogContext shows, named after its method.
DialogRequest A read-only description of one dialog a DialogContext is about to show. Narrowing on kind narrows params.