/** * Waiting for what the application decided, instead of for what it drew. * * The fixtures here are the driver half of `@variance-authority/event`. The * browser half needs no build integration and no configuration: the application * already calls `vae`, this installs the sink underneath it, and a test that * never asks for `events` pays none of it — a fixture nobody destructures is * never set up. * * A head is the part that is extra, and it is extra in the ordinary way: the * service runs `collectEvents()`, and one variable says heads are in play so * this side leaves them a return address. Not said, the page still answers and * heads are simply silent, which is the same bargain journeys make. * * The listener is the worker's, not this file's: announcements and coverage * accounts are two things said about the same execution, so they arrive on one * medium ([`wire.ts`](./wire.ts)) under one id, and this end reads only which of * the two was speaking. A page reports through a function this worker exposed * and a head reports through a socket; nothing below routes on which. */ import type { Fixtures, PlaywrightTestArgs, PlaywrightWorkerArgs } from '@playwright/test'; import { type EventLog, type HeadEventReport } from '@variance-authority/event/collect'; import type { RecorderFixture } from './completed.js'; import type { VarianceVantageWorkerFixtures } from './vantage.js'; import type { VarianceWireFixtures } from './wire.js'; export interface VarianceEventsOptions { /** * Whether services announce in this run. Defaults to whether * `VARIANCE_AUTHORITY_EVENTS` is set, which is also how a service was told, so * one line in `webServer.env` configures both ends. * * False costs nothing at all: no listener, no cookie, and a page that still * answers for itself. */ readonly heads?: boolean; /** * The origin the cookies are scoped to. Defaults to the project's `baseURL`. * Same-origin is the filter, so this is also the whole of the decision about * which services are ever asked to announce. */ readonly origin?: string; } export interface VarianceEventWorkerFixtures { /** How this project listens. The defaults need no configuration. */ readonly varianceEvents: VarianceEventsOptions; /** The desk that routes what arrives to whichever test is waiting for it. */ readonly varianceEventDesk: EventDesk; } export interface VarianceEventFixtures { /** * This execution's opaque id, once something needs the heads to name it. * * Undefined when nothing does: a run with no heads has one realm, and an id * that distinguishes executions inside it distinguishes nothing. */ readonly varianceJourney: string | undefined; /** * What this execution announced, and the waits a test can put on it. * * ```ts * await events.happened('checkout', 'upsell-modal', 'decided'); * await expect(page.getByRole('dialog')).toBeHidden(); * ``` */ readonly events: EventLog; } /** Where an announcement answers, and who is listening for it right now. */ export interface EventDesk { /** Where a head serving this execution should report. */ readonly addressFor: (journey: string) => string; /** Take this execution's announcements until the returned call gives it up. */ readonly open: (journey: string, log: EventLog) => () => void; /** Route one announcement, for a realm the driver is inside rather than beside. */ readonly take: (journey: string, report: HeadEventReport) => void; } /** * Merged into `varianceFixtures` rather than used on its own: `varianceJourney` * reads the recorder, so this half is a part of that bundle and not a bundle. */ export declare const varianceEventFixtures: Fixtures; //# sourceMappingURL=events.d.ts.map