Scene
import { Option, Schema } from 'effect';
import type { CustomElementSpec, EventSchema } from '../customElement/index.js';
import type { File } from '../file/index.js';
import type { Document, Html, HtmlBuilder, KeyboardModifiers } from '../html/index.js';
import type { Entry as ManagedResourceEntry } from '../managedResource/index.js';
import type { MountDefinition } from '../mount/index.js';
import type { VNode } from '../vdom.js';
import type { AnyCommand, AnyCommandInstance, AnyMount, CommandMatcher, MountMatcher, MountResolver, PendingMount, ResolvableCommandDefinition, ResolvableCommandMatcher, Resolver } from './internal.js';
import type { Locator, LocatorAll } from './query.js';
import { allAltText, allDisplayValue, allLabel, allPlaceholder, allRole, allSelector, allTestId, allText, allTitle } from './query.js';
export type { AnyCommand, AnyMount, MountMatcher, MountResolver, PendingMount, Resolver, };
export { find, findAll, textContent, attr, getByRole, getAllByRole, getByText, getByPlaceholder, getByLabel, getByAltText, getByTitle, getByTestId, getByDisplayValue, role, placeholder, label, altText, title, testId, displayValue, selector, text, within, getAllByText, getAllByLabel, getAllByPlaceholder, getAllByAltText, getAllByTitle, getAllByTestId, getAllByDisplayValue, first, last, nth, filter, } from './query.js';
export type { Locator, LocatorAll } from './query.js';
/** Multi-match Locator factories. Each returns a `LocatorAll` that resolves
* to every matching VNode. Convert to a single `Locator` via `first`,
* `last`, or `nth(n)`, or narrow via `filter`. */
export declare const all: {
readonly role: typeof allRole;
readonly text: typeof allText;
readonly label: typeof allLabel;
readonly placeholder: typeof allPlaceholder;
readonly altText: typeof allAltText;
readonly title: typeof allTitle;
readonly testId: typeof allTestId;
readonly displayValue: typeof allDisplayValue;
readonly selector: typeof allSelector;
};
export { sceneMatchers } from './matchers.js';
/** An immutable test simulation that includes the rendered VNode tree.
* The Model and Message are intentionally opaque. Scene tests assert
* through the view, not the model. Use Story for model-level assertions. */
export type SceneSimulation<Model, Message, OutMessage = undefined> = Readonly<{
/** @internal Phantom type that preserves Model and Message for step chain inference. */
_phantom: [Model, Message];
commands: ReadonlyArray<AnyCommand>;
mounts: ReadonlyArray<PendingMount>;
/** The sole OutMessage from the latest update-producing Scene step.
* Undefined when that step emitted none or more than one. */
outMessage: OutMessage | undefined;
html: VNode;
}>;
/** A callable step that sets the initial Model. Carries phantom type for compile-time validation. */
type GivenStep<Model> = Readonly<{
_phantomModel: Model;
}> & (<M, Message, OutMessage = undefined>(simulation: SceneSimulation<M, Message, OutMessage>) => SceneSimulation<M, Message, OutMessage>);
/** A typed Subscription Message step. */
export type SubscriptionMessageStep<Message> = Readonly<{
_tag: 'SubscriptionMessageStep';
message: Message;
}>;
/** A typed OutMessage assertion step. */
export type OutMessageStep<OutMessage> = Readonly<{
_tag: 'OutMessageStep';
expected: OutMessage;
}>;
/** A typed OutMessage sequence assertion step. */
export type OutMessagesStep<OutMessage> = Readonly<{
_tag: 'OutMessagesStep';
expected: readonly [OutMessage, OutMessage, ...ReadonlyArray<OutMessage>];
}>;
/** A single step in a scene: a `given` step, typed Message or OutMessage step,
* or scene simulation transform. */
export type SceneStep<Model, Message, OutMessage> = GivenStep<NoInfer<Model>> | Readonly<{
_tag: 'SubscriptionMessageStep';
message: NoInfer<Message>;
}> | Readonly<{
_tag: 'OutMessageStep';
expected: NoInfer<OutMessage>;
}> | Readonly<{
_tag: 'OutMessagesStep';
expected: readonly [
NoInfer<OutMessage>,
NoInfer<OutMessage>,
...ReadonlyArray<NoInfer<OutMessage>>
];
}> | ((simulation: SceneSimulation<any, any, any>) => SceneSimulation<any, any, any>);
/** Sets the initial Model for a scene test. */
export declare const given: <Model>(model: Model) => GivenStep<Model>;
/** Resolves listed Commands with their result Messages, cascading through any
* Commands the result produces. Each entry is consumed by exactly one
* matching dispatch in declaration order, so
* `[Def, m1], [Def, m2], [Def, m3]` reads as a sequence of three responses.
* For N identical responses, compose with
* `Array.makeBy(n, () => [Def, message])`. Resolvers carry across
* `resolveAll` calls: unused entries can match later dispatches, and a new
* entry replaces any leftover resolvers sharing its Definition or Instance
* shape (latest wins). */
declare const resolveAllCommands: <Matchers extends ReadonlyArray<ResolvableCommandMatcher>>(...resolvers: { [K in keyof Matchers]: Resolver<Matchers[K]>; }) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Resolves listed Commands with their result Messages, cascading through any
* Commands the results produce. Every resolver must match one dispatch in
* this call, and no actual Commands may remain unresolved. Supplied resolvers
* do not carry forward. */
declare const resolveAllExactCommands: <Matchers extends ReadonlyArray<ResolvableCommandMatcher>>(...resolvers: { [K in keyof Matchers]: Resolver<Matchers[K]>; }) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that every given matcher matches a pending Command. Definition
* matchers match by name only; Instance matchers match by name + args. */
declare const expectHasCommandsStep: (...matchers: ReadonlyArray<CommandMatcher>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that the pending Commands match the given matchers exactly
* (order-independent). Definition matchers compare by name; Instance
* matchers compare by name + args. */
declare const expectExactCommandsStep: (...matchers: ReadonlyArray<CommandMatcher>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that there are no pending Commands. */
declare const expectNoCommandsStep: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Resolves all listed Mounts with their result Messages. Mounts are resolved
* in the order listed; each resolution feeds its Message through update
* before the next is resolved. */
declare const resolveAllMounts: <R extends ReadonlyArray<unknown>>(...resolvers: { [K in keyof R]: MountResolver<R[K]>; }) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that every given Mount is among the pending Mounts. Accepts Mount
* Definitions (match by name) and Mount instances (match by name + args). */
declare const expectHasMountsStep: (...matchers: ReadonlyArray<MountMatcher>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that the pending Mounts match the given matchers exactly
* (order-independent). Accepts Mount Definitions (match by name) and Mount
* instances (match by name + args). */
declare const expectExactMountsStep: (...matchers: ReadonlyArray<MountMatcher>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that there are no pending Mounts. */
declare const expectNoMountsStep: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Acknowledges that the given Mounts disappeared from the rendered tree.
* Required for every Mount that fires and then unmounts during a scene,
* whether or not it was resolved first. Without this, the scene throws at
* the end of the test for any unacknowledged unmount. Mount matchers may
* be Definitions or instances; instances acknowledge a specific args shape. */
declare const expectEndedMountsStep: (...matchers: ReadonlyArray<MountMatcher>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Feeds a Message through update as if a Subscription had emitted it,
* then re-renders. Use it for Messages whose real cause is a Subscription
* (a timer tick, a WebSocket frame, a global listener), which have no
* element in the rendered tree to interact with. Do NOT reach for it when
* the Message has a DOM affordance: click the actual button instead, so
* the test exercises the handler wiring this step skips. Like an
* interaction, it throws if unresolved Commands, unresolved Mounts, or
* unacknowledged unmounts are pending. */
declare const emitSubscriptionMessage: <Message>(message: Message) => SubscriptionMessageStep<Message>;
/** A ManagedResource entry a scene can drive: the Option-shaped requirements
* are what the runtime watches, so the steps can check the current Model
* against them before dispatching a lifecycle Message. */
type SceneManagedResourceEntry<EntryModel, EntryMessage, Value, OnAcquired extends (...args: any) => EntryMessage = (value: Value) => EntryMessage> = ManagedResourceEntry<EntryModel, EntryMessage, Option.Option<any>, Value, any, OnAcquired>;
/** Declares that a ManagedResource's acquire succeeded, feeding the entry's
* `onAcquired` Message through update the way the runtime would. The step
* takes exactly the arguments the entry's `onAcquired` declares: a handler
* that consumes the acquired value needs one here, and a handler that
* ignores it needs none. Requires the current Model to request the
* resource: the runtime only acquires while `modelToMaybeRequirements`
* returns Some, so drive the Model into that state through real steps
* first. */
declare const acquireManagedResource: <EntryModel, EntryMessage, Value, Args extends ReadonlyArray<any>>(entry: SceneManagedResourceEntry<EntryModel, EntryMessage, Value, (...args: Args) => EntryMessage>, ...args: NoInfer<Args>) => <Message, OutMessage = undefined>(simulation: SceneSimulation<EntryModel, Message, OutMessage>) => SceneSimulation<EntryModel, Message, OutMessage>;
/** Declares that a ManagedResource's acquire failed, feeding the entry's
* `onAcquireError(error)` Message through update the way the runtime
* would. Requires the current Model to request the resource, the same as
* `ManagedResource.acquire`: the runtime only attempts acquisition
* while `modelToMaybeRequirements` returns Some. */
declare const failAcquireManagedResource: <EntryModel, EntryMessage, Value>(entry: SceneManagedResourceEntry<EntryModel, EntryMessage, Value>, error: unknown) => <Message, OutMessage = undefined>(simulation: SceneSimulation<EntryModel, Message, OutMessage>) => SceneSimulation<EntryModel, Message, OutMessage>;
/** Declares that a ManagedResource was released, feeding the entry's
* `onReleased()` Message through update. Models the runtime's Some to
* None transition, which releases and then dispatches `onReleased()`, so
* it requires the current Model to no longer request the resource: drive
* the Model out of the requesting state through real steps first. The
* runtime's Some to Some re-acquire (structurally changed requirements),
* which also dispatches `onReleased()` and then `onAcquired(value)` while
* the Model still requests the resource, has no step yet. */
declare const releaseManagedResource: <EntryModel, EntryMessage, Value>(entry: SceneManagedResourceEntry<EntryModel, EntryMessage, Value>) => <Message, OutMessage = undefined>(simulation: SceneSimulation<EntryModel, Message, OutMessage>) => SceneSimulation<EntryModel, Message, OutMessage>;
/** Dispatches a CustomEvent a rendered custom element declares, feeding the
* Message its `On*` event mapping produces through update. The event name
* and detail are typed by the encoded side of the spec's event Schemas. The
* runtime decodes the detail before invoking the event mapping. The element
* must be in the rendered tree with the event's attribute attached, so the
* test exercises the same mapping the browser event would. */
declare const emitCustomElementEvent: <Events extends Record<string, EventSchema>, Name extends keyof Events & string>(spec: CustomElementSpec<string, Record<string, Schema.Top>, Events>, target: string | Locator, eventName: Name, detail: Schema.Codec.Encoded<Events[Name]>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Steps that operate on the pending Commands of a scene simulation.
* Destructure as `const { Command } = Scene` for concise call sites. */
export declare const Command: {
/** Resolves a specific pending Command with the given result Message. */
readonly resolve: {
<Name extends string, ResultMessage>(definition: ResolvableCommandDefinition<Name, ResultMessage>, resultMessage: ResultMessage): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
<ResultMessage>(instance: AnyCommandInstance<ResultMessage>, resultMessage: ResultMessage): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Resolves listed Commands with their result Messages, cascading through any
* Commands the result produces. Each entry resolves exactly one matching
* dispatch in declaration order; compose with `Array.makeBy` for N
* identical responses. Resolvers carry across calls; a new entry replaces
* any leftovers sharing its Definition or Instance shape (latest wins). */
readonly resolveAll: typeof resolveAllCommands;
/** Resolves listed Commands and throws unless every resolver matches one
* dispatch and no actual Commands remain unresolved. Entries apply only to
* this call and never carry forward. */
readonly resolveAllExact: typeof resolveAllExactCommands;
/** Asserts that every given Command is among the pending Commands. */
readonly expectHas: typeof expectHasCommandsStep;
/** Asserts that the pending Commands match the given definitions exactly (order-independent). */
readonly expectExact: typeof expectExactCommandsStep;
/** Asserts that there are no pending Commands. */
readonly expectNone: typeof expectNoCommandsStep;
};
/** Steps that operate on the pending Mounts of a scene simulation.
* Destructure as `const { Mount } = Scene` for concise call sites. */
export declare const Mount: {
/** Resolves a specific pending Mount with the given result Message. */
readonly resolve: <Name extends string, ResultMessage>(matcher: MountDefinition<Name, ResultMessage> | AnyMount, resultMessage: ResultMessage) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Resolves all listed Mounts with their result Messages. */
readonly resolveAll: typeof resolveAllMounts;
/** Asserts that every given Mount is among the pending Mounts. */
readonly expectHas: typeof expectHasMountsStep;
/** Asserts that the pending Mounts match the given definitions exactly (order-independent, by name). */
readonly expectExact: typeof expectExactMountsStep;
/** Asserts that there are no pending Mounts. */
readonly expectNone: typeof expectNoMountsStep;
/** Acknowledges Mounts that disappeared from the rendered tree. Required for
* every Mount that fires and then unmounts during a scene. */
readonly expectEnded: typeof expectEndedMountsStep;
};
/** Steps that model Messages arriving from a Subscription.
* Destructure as `const { Subscription } = Scene` for concise call sites. */
export declare const Subscription: {
/** Feeds a Message through update as if a Subscription had emitted it,
* then re-renders. Only for Messages whose real cause is a Subscription;
* if the Message has a DOM affordance, click it instead. */
readonly emit: typeof emitSubscriptionMessage;
};
/** Steps that model the lifecycle Messages of a ManagedResource. The test
* declares the lifecycle outcome the way `Scene.Command.resolve` declares a
* Command result, and each step checks the current Model against the
* entry's `modelToMaybeRequirements` gate first, mirroring the runtime's
* None to Some and Some to None transitions. The Some to Some re-acquire
* transition has no step yet. Destructure as
* `const { ManagedResource } = Scene` for concise call sites. */
export declare const ManagedResource: {
/** Declares a successful acquire, feeding the entry's `onAcquired` Message
* through update. Takes exactly the arguments `onAcquired` declares. The
* current Model must request the resource. */
readonly acquire: typeof acquireManagedResource;
/** Declares a failed acquire, feeding `onAcquireError(error)` through
* update. The current Model must request the resource. */
readonly failAcquire: typeof failAcquireManagedResource;
/** Declares a release, feeding `onReleased()` through update. The current
* Model must no longer request the resource. */
readonly release: typeof releaseManagedResource;
};
/** Steps that model CustomEvents arriving from a rendered custom element.
* Destructure as `const { CustomElement } = Scene` for concise call sites. */
export declare const CustomElement: {
/** Dispatches a declared CustomEvent through the element's event mapping.
* The event name and detail are typed by the spec's event Schemas. */
readonly emit: typeof emitCustomElementEvent;
};
/** Asserts by structural equality that the latest update-producing Scene step
* emitted exactly the expected OutMessage. */
export declare const expectOutMessage: <OutMessage>(expected: OutMessage) => OutMessageStep<OutMessage>;
/** Asserts by structural equality that the latest update-producing Scene
* step emitted two or more expected OutMessages in runtime order. */
export declare const expectOutMessages: <Expected extends readonly [unknown, unknown, ...ReadonlyArray<unknown>]>(...expected: Expected) => OutMessagesStep<Expected[number]>;
/** Asserts that the latest update-producing Scene step emitted no OutMessages. */
export declare const expectNoOutMessage: () => <Model, Message, OutMessage>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that the preceding interaction was handled: its event handler
* produced a Message.
*
* This is the assertion behind "the key is consumed here". A Foldkit
* handler that returns a Message is what makes `h.OnKeyDownPreventDefault`
* call `preventDefault()`, so a handled keydown is one whose browser
* default is suppressed: `Space` does not scroll the page and `Enter` does
* not submit a surrounding form.
*
* Reach for this rather than asserting the Message's tag. The tag is the
* mechanism a component happens to use; being consumed is the contract, and
* it survives renaming the Message.
*
* An interaction on an element with no handler at all throws from the
* interaction step itself, so this distinguishes the narrower case of a
* handler that ran and chose to produce nothing.
*
* Only interaction steps set the outcome. `Command.resolve`, `Mount.resolve`,
* and plain `expect` leave it alone, so the value is the last *interaction*
* rather than the last step. Keep the assertion next to the interaction it
* covers.
*
* Where the event should have been consumed but was not, this is the
* assertion that says so, and it fails until the handler is fixed. Where
* falling through is intended, reach for {@link expectIgnored} instead,
* which a fall-through requires. */
export declare const expectHandled: () => <Model, Message, OutMessage>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Asserts that the preceding interaction was ignored: its event handler ran
* and produced no Message, so the event falls through and the browser
* default stands.
*
* Required after any interaction that falls through, and it acknowledges
* that fall-through as intended. Saying nothing is not an available
* position: Scene fails at the next interaction, or at the end of the
* scene, on a fall-through nothing acknowledged, because a test that leaves
* it unsaid passes whether the interaction is correctly inert or its
* handler regressed.
*
* One acknowledgement covers one fall-through. Two in a row need one each,
* and each must come before the next interaction.
*
* Carries the same adjacency caveat as {@link expectHandled}: only
* interaction steps set the outcome, so keep the assertion next to the
* interaction it covers. */
export declare const expectIgnored: () => <Model, Message, OutMessage>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Runs a function for side effects (e.g. assertions) without breaking the step chain. */
export declare const tap: <Model, Message, OutMessage = undefined>(f: (simulation: SceneSimulation<Model, Message, OutMessage>) => void) => (simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Scopes a sequence of steps to a parent element. Every Locator referenced by
* child steps (assertions, interactions) resolves within the parent's subtree.
* Use this when several steps share the same scope. For a single scoped query,
* prefer `within(parent, child)` directly. Nested `inside` calls compose scopes
* via `within(outer, inner)`. */
export declare const inside: <Model, Message, OutMessage = undefined>(parent: Locator, ...steps: ReadonlyArray<NoInfer<SceneStep<Model, Message, OutMessage>>>) => (simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a click on the element matching the target.
* Runs click handlers from the target through its ancestors until one stops
* propagation, mirroring browser event propagation.
* When the target activates a submit button and no click handler prevents
* the default, the click falls through to the `submit` handler of its form
* owner. Scene honors an explicit `form` attribute before looking for the
* nearest ancestor `<form>`. */
export declare const click: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a double-click on the element matching the target.
* When the element has no dblclick handler, the event bubbles up to the
* nearest ancestor with one, mirroring browser event propagation. */
export declare const doubleClick: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a contextmenu event on the element matching the target.
* When the element has no contextmenu handler, the event bubbles up to the
* nearest ancestor with one, mirroring browser event propagation. */
export declare const contextMenu: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
type PointerDownOptions = Readonly<{
pointerType?: string;
button?: number;
screenX?: number;
screenY?: number;
clientX?: number;
clientY?: number;
pointerId?: number;
}>;
/** Simulates a pointerdown event on the element matching the target.
* When the element has no pointerdown handler, the event bubbles up to
* the nearest ancestor with one, mirroring browser event propagation.
* The `OnPointerDown` callback receives a detached element representing
* the target and its ancestors, so `closest()` checks work in Scene tests.
* Defaults to `pointerType: 'mouse'`, `button: 0`, `screenX/screenY: 0`,
* `clientX/clientY: 0`, and `pointerId: 0`. */
export declare const pointerDown: (target: string | Locator, options?: PointerDownOptions) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
type PointerUpOptions = Readonly<{
pointerType?: string;
screenX?: number;
screenY?: number;
}>;
/** Simulates a pointerup event on the element matching the target.
* When the element has no pointerup handler, the event bubbles up to
* the nearest ancestor with one, mirroring browser event propagation.
* Defaults to `pointerType: 'mouse'` and `screenX/screenY: 0`. */
export declare const pointerUp: (target: string | Locator, options?: PointerUpOptions) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a hover (mouseenter) on the element matching the target.
* Dispatches the `mouseenter` handler, falling back to `mouseover`. */
export declare const hover: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a focus event on the element matching the target. */
export declare const focus: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a blur event on the element matching the target. */
export declare const blur: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates focus entering the subtree of the element matching the target. */
export declare const focusEnter: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates focus leaving the subtree of the element matching the target. */
export declare const focusLeave: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates a change event on the element matching the target.
* Dual: `change(target, value)` or `change(value)` for data-last piping. */
export declare const change: {
(target: string | Locator, value: string): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(value: string): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Simulates a file input change event on the element matching the target.
* For use with `OnFileChange` attributes. The handler receives a synthetic
* event with `target.files` set to the provided files array.
* Dual: `changeFiles(target, files)` or `changeFiles(files)` for data-last piping. */
export declare const changeFiles: {
(target: string | Locator, files: ReadonlyArray<File>): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(files: ReadonlyArray<File>): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Simulates a drop event with files on the element matching the target.
* For use with `OnDropFiles` attributes. The handler receives a synthetic
* event with `dataTransfer.files` set to the provided files array and a
* no-op `preventDefault`.
* Dual: `dropFiles(target, files)` or `dropFiles(files)` for data-last piping. */
export declare const dropFiles: {
(target: string | Locator, files: ReadonlyArray<File>): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(files: ReadonlyArray<File>): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Simulates form submission on the element matching the target. */
export declare const submit: (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
/** Simulates typing a value into the input matching the target.
* Dual: `type(target, value)` or `type(value)` for data-last piping. */
export { type_ as type };
declare const type_: {
(target: string | Locator, value: string): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(value: string): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Simulates typing into a contenteditable host matching the target. A
* contenteditable element has no `value`, so the `input` event reports the
* host's rendered text. Use this to drive `OnInput` on a `Contenteditable`
* element. Dual: `typeContentEditable(target, text)` or
* `typeContentEditable(text)` for data-last piping. */
export declare const typeContentEditable: {
(target: string | Locator, text: string): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(text: string): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Simulates a `beforeinput` event on the element matching the target. Drives
* `OnBeforeInput` and `OnBeforeInputPreventDefault`. Pass the edit's
* `inputType` (e.g. `'insertText'`, `'deleteContentBackward'`) and its `data`
* as an `Option` (the inserted text, or `None` for edits that carry none). Dual:
* `beforeInput(target, inputType, data)` or `beforeInput(inputType, data)` for
* data-last piping. */
export declare const beforeInput: {
(target: string | Locator, inputType: string, data: Option.Option<string>): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(inputType: string, data: Option.Option<string>): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Simulates a keydown event on the element matching the target. The event is
* self-targeted (`target === currentTarget`), so `OnKeyDownSelf` and
* `OnKeyDownSelfPreventDefault` handlers fire.
* Dual: `keydown(target, key, modifiers?)` or `keydown(key, modifiers?)` for data-last piping. */
export declare const keydown: {
(target: string | Locator, key: string): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(target: string | Locator, key: string, modifiers: Partial<KeyboardModifiers>): <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(key: string): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
(key: string, modifiers: Partial<KeyboardModifiers>): (target: string | Locator) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
/** Creates an inline assertion step. Resolves the Locator against
* the current view and asserts on the result. */
export { expect_ as expect };
declare const expect_: (locator: Locator) => {
toExist: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeAbsent: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveText: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toContainText: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveAttr: (name: string, value?: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveClass: (expected: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveStyle: (name: string, value?: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveHook: (name: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveHandler: (name: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveValue: (expected: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeDisabled: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeEnabled: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeEmpty: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeVisible: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveId: (expected: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveAccessibleName: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveAccessibleDescription: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeChecked: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
not: {
toExist: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeAbsent: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveText: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toContainText: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveAttr: (name: string, value?: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveClass: (expected: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveStyle: (name: string, value?: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveHook: (name: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveHandler: (name: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveValue: (expected: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeDisabled: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeEnabled: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeEmpty: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeVisible: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveId: (expected: string) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveAccessibleName: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toHaveAccessibleDescription: (expected: string | RegExp) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeChecked: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
};
/** Creates an inline multi-match assertion step. Use for count-based
* assertions like `toHaveCount(n)` or `toBeEmpty()`. */
export declare const expectAll: (locatorAll: LocatorAll) => {
toHaveCount: (expected: number) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeEmpty: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
not: {
toHaveCount: (expected: number) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
toBeEmpty: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
};
};
/** Adapts a Submodel view that declares `ViewInputs` to the `(model, h)`
* shape `Scene.scene` takes. `defaults` supplies the full `ViewInputs`
* once; the returned factory accepts per-test overrides for everything
* except `toView`, so tests vary value inputs while the renderer stays
* pinned:
*
* ```ts
* const sceneView = Scene.withViewInputs(view, {
* value: 5,
* toView: testToView,
* })
*
* Scene.scene({ update, view: sceneView() }, ...)
* Scene.scene({ update, view: sceneView({ isDisabled: true }) }, ...)
* ```
*/
export declare const withViewInputs: <Model, Message, ViewInputs extends object>(view: (model: Model, viewInputs: ViewInputs, h: HtmlBuilder<Message>) => Html, defaults: NoInfer<ViewInputs>) => (overrides?: Omit<Partial<NoInfer<ViewInputs>>, 'toView'>) => (model: Model, h: HtmlBuilder<Message>) => Html;
/** Executes a scene test. Throws if any Commands or Mounts remain
* unresolved, any unmount is unacknowledged, or any interaction fell
* through unacknowledged. */
export declare const scene: {
<Model, Message, OutMessage = never>(config: Readonly<{
update: (model: Model, message: Message) => Readonly<{
model: Model;
commands?: ReadonlyArray<AnyCommand>;
outMessage?: OutMessage;
}>;
view: (model: Model, h: HtmlBuilder<Message>) => Html | Document;
}>, ...steps: ReadonlyArray<SceneStep<NoInfer<Model>, NoInfer<Message>, NoInfer<OutMessage>>>): void;
<Model, Message>(config: Readonly<{
update: (model: Model, message: Message) => Readonly<{
model: Model;
commands?: ReadonlyArray<AnyCommand>;
outMessage?: never;
}>;
view: (model: Model, h: HtmlBuilder<Message>) => Html | Document;
}>, ...steps: ReadonlyArray<SceneStep<NoInfer<Model>, NoInfer<Message>, undefined>>): void;
};