import { afterAll } from '@rstest/playwright'; import { beforeAll } from '@rstest/playwright'; import type { Browser } from 'playwright'; import type { BrowserContext } from 'playwright'; import { describe } from '@rstest/playwright'; import { expect } from '@rstest/playwright'; import type { FrameLocator } from 'playwright'; import type { Page } from 'playwright'; import type { PlaywrightFixtures } from '@rstest/playwright'; import type { PlaywrightTest } from '@rstest/playwright'; import type { TestContext } from '@rstest/core'; import type { TestOptions } from '@rstest/core'; export { afterAll } export declare const afterEach: TapAfterEachHook; export { beforeAll } export declare const beforeEach: TapBeforeEachHook; /** * Define one bounded host transport failure for an exact HTTP fixture script. * * The code and message use the same contract as `MiniAppHostActionError`, so a * malformed fixture fails before the Surface receives a request. */ export declare function createTapMiniappTestTransportError(value: TapMiniappTestFixtureHttpTransportError_2): TapMiniappTestFixtureHttpTransportError_2; declare type DeepReadonly = T extends (...arguments_: never[]) => unknown ? T : T extends readonly (infer Entry)[] ? readonly DeepReadonly[] : T extends object ? { readonly [Key in keyof T]: DeepReadonly; } : T; export { describe } export { expect } declare type GeneratedFixtureChannelSeed = GeneratedFixtureSeed['channels'][number]; declare type GeneratedFixtureHttpHeaderInput = MiniappTestFixtureHttpHeaderInput; declare type GeneratedFixtureHttpRequest = GeneratedFixtureHttpScript['request']; declare type GeneratedFixtureHttpResponse = Extract['response']; declare type GeneratedFixtureHttpScript = MiniappTestFixtureHttpScript; declare type GeneratedFixtureHttpScriptState = MiniappTestFixtureHttpScriptState; declare type GeneratedFixtureHttpTransportError = MiniappTestFixtureHttpTransportError; declare type GeneratedFixtureLedger = MiniappTestFixtureLedger; declare type GeneratedFixtureProjectSeed = GeneratedFixtureSeed['projects'][number]; declare type GeneratedFixtureSeed = MiniappTestFixtureSeed; declare type GeneratedFixtureSnapshot = MiniappTestFixtureSnapshot; declare type GeneratedLifecycleReceipt = MiniappTestResetFixtureControlReceipt | MiniappTestRemountSurfaceControlReceipt; /** Private SDK snapshot: keeps the public adapter independent of workspace packages. */ declare type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue; }; declare type MergeContext = { [Key in keyof FixturesContext | keyof ExtraContext]: Key extends keyof FixturesContext ? FixturesContext[Key] : Key extends keyof ExtraContext ? ExtraContext[Key] : never; }; declare type MiniappTestEmitHostEventControlReceipt = { schemaVersion: 1; requestId: string; runId: string; operation: 'emit-host-event'; delivered: number; }; declare type MiniappTestFixtureChannelAccess = { isParticipant: boolean; capabilities: string[]; visibleUntilSequence?: number | undefined; }; declare type MiniappTestFixtureChannelSeed = { roomId: string; title: string; archived?: boolean | undefined; createdAt?: number | undefined; updatedAt?: number | undefined; messages: JsonValue[]; specialistIds: string[]; access?: MiniappTestFixtureChannelAccess | undefined; projectId?: string | undefined; }; declare type MiniappTestFixtureChannelState = { roomId: string; title: string; archived: boolean; createdAt: number; updatedAt: number; messages: JsonValue[]; specialistIds: string[]; access: MiniappTestFixtureChannelAccess; projectId?: string | undefined; }; declare type MiniappTestFixtureCheckpoint = { installationId: string; releaseId: string; runtimeSlot: string; checkpointReference: string; value: JsonValue; }; declare type MiniappTestFixtureHttpCapture = { sequence: number; matched: boolean; request: MiniappTestFixtureHttpRequest; credentialRef?: string | undefined; auth?: 'github' | undefined; }; declare type MiniappTestFixtureHttpCaptures = { requests: MiniappTestFixtureHttpCapture[]; dropped: number; }; declare type MiniappTestFixtureHttpHeader = { name: string; value: string; }; declare type MiniappTestFixtureHttpHeaderInput = { name: string; value: string; enabled?: boolean | undefined; }; declare type MiniappTestFixtureHttpRequest = { method: string; url: string; query: MiniappTestFixtureHttpHeaderInput[]; headers: MiniappTestFixtureHttpHeaderInput[]; body?: string | undefined; timeoutMs?: number | undefined; responseBodyLimitBytes?: number | undefined; followRedirects?: boolean | undefined; }; declare type MiniappTestFixtureHttpResponse = { finalUrl: string; status: number; statusText: string; headers: MiniappTestFixtureHttpHeader[]; bodyText?: string | undefined; bodyBase64?: string | undefined; bodyKind: 'text' | 'binary'; bodyTruncated: boolean; sizeBytes: number; elapsedMs: number; contentType?: string | undefined; }; declare type MiniappTestFixtureHttpScript = { request: MiniappTestFixtureHttpRequest; credentialRef?: string | undefined; auth?: 'github' | undefined; repeat?: number | undefined; } & ({ response: MiniappTestFixtureHttpResponse; transportError?: never; } | { response?: never; transportError: MiniappTestFixtureHttpTransportError; }); declare type MiniappTestFixtureHttpScriptState = { request: MiniappTestFixtureHttpRequest; credentialRef?: string | undefined; auth?: 'github' | undefined; repeat: number; } & ({ response: MiniappTestFixtureHttpResponse; transportError?: never; } | { response?: never; transportError: MiniappTestFixtureHttpTransportError; }); declare type MiniappTestFixtureHttpTransportError = { code: string; message: string; }; declare type MiniappTestFixtureLedger = { entries: MiniappTestFixtureLedgerEntry[]; dropped: number; }; declare type MiniappTestFixtureLedgerEntry = { sequence: number; fixtureGeneration: number; timestampMs: number; kind: 'event' | 'host-action' | 'native' | 'platform'; operation: string; detail: JsonValue; }; declare type MiniappTestFixturePresence = { packageId: string; namespace: string; room: string; selfParticipantId: string; participants: MiniappTestFixturePresenceParticipant[]; }; declare type MiniappTestFixturePresenceParticipant = { participantId: string; displayName: string; state: JsonValue; updatedAtMs: number; }; declare type MiniappTestFixtureProjectSeed = { id: string; name: string; discoverable?: boolean | undefined; }; declare type MiniappTestFixtureProjectState = { id: string; name: string; discoverable: boolean; }; declare type MiniappTestFixtureSeed = { projects: MiniappTestFixtureProjectSeed[]; channels: MiniappTestFixtureChannelSeed[]; workflows: MiniappTestFixtureWorkflow[]; vfsFiles: MiniappTestFixtureVfsFile[]; vfsDirectories: MiniappTestFixtureVfsDirectory[]; storage: MiniappTestFixtureStorageEntry[]; presence: MiniappTestFixturePresence[]; checkpoints: MiniappTestFixtureCheckpoint[]; specialists: MiniappTestFixtureSpecialist[]; httpScripts: MiniappTestFixtureHttpScript[]; userFiles: MiniappTestFixtureUserFile[]; userFilePickerOutcomes: MiniappTestFixtureUserFilePickerOutcome[]; userFileLaunchContext?: MiniappTestFixtureUserFileLaunchContext | undefined; }; declare type MiniappTestFixtureSnapshot = { schemaVersion: 1; fixtureVersion: string; workspaceId: string; channelId: string; fixtureGeneration: number; fixtureDigest: string; clockTick: number; state: MiniappTestFixtureState; }; declare type MiniappTestFixtureSpecialist = { id: string; value: JsonValue; }; declare type MiniappTestFixtureState = { projects: MiniappTestFixtureProjectState[]; channels: MiniappTestFixtureChannelState[]; workflows: MiniappTestFixtureWorkflow[]; vfsFiles: MiniappTestFixtureVfsFile[]; vfsDirectories: MiniappTestFixtureVfsDirectory[]; storage: MiniappTestFixtureStorageEntry[]; presence: MiniappTestFixturePresence[]; checkpoints: MiniappTestFixtureCheckpoint[]; specialists: MiniappTestFixtureSpecialist[]; httpScripts: MiniappTestFixtureHttpScriptState[]; userFiles: MiniappTestFixtureUserFile[]; userFilePickerOutcomes: MiniappTestFixtureUserFilePickerOutcome[]; userFileLaunchContext?: MiniappTestFixtureUserFileLaunchContext | undefined; }; declare type MiniappTestFixtureStorageEntry = { workspaceId: string; packageId: string; namespace: string; key: string; revision: number; value: JsonValue; }; declare type MiniappTestFixtureUserFile = { id: string; name: string; data: number[]; kind: 'existing' | 'destination'; state: 'ready' | 'malformed' | 'encrypted' | 'offline' | 'provider-unavailable' | 'quota-exceeded'; }; declare type MiniappTestFixtureUserFileExternalMutation = { fileId: string; change: 'replace' | 'delete' | 'create'; data: number[]; }; declare type MiniappTestFixtureUserFileLaunchContext = { apiVersion: 1; intent: 'open' | 'import' | 'export'; fileId: string; }; declare type MiniappTestFixtureUserFilePickerCancellation = {}; declare type MiniappTestFixtureUserFilePickerOutcome = { intent: 'open' | 'save'; } & ({ result: MiniappTestFixtureUserFilePickerResult; cancel?: never; } | { result?: never; cancel: MiniappTestFixtureUserFilePickerCancellation; }); declare type MiniappTestFixtureUserFilePickerResult = { fileIds: string[]; externalMutation?: MiniappTestFixtureUserFileExternalMutation | undefined; }; declare type MiniappTestFixtureVfsDirectory = { conversationId: string; path: string; }; declare type MiniappTestFixtureVfsFile = { conversationId: string; path: string; data: number[]; }; declare type MiniappTestFixtureWorkflow = { workflowId: string; name: string; result: JsonValue; type?: string | undefined; createdAt?: number | undefined; updatedAt?: number | undefined; }; declare type MiniappTestRemountSurfaceControlReceipt = { schemaVersion: 1; requestId: string; runId: string; operation: 'remount-surface'; mode: 'MINIAPP_TEST_MODE_SURFACE' | 'MINIAPP_TEST_MODE_LIVE_TAP'; surfaceGeneration: number; fixtureGeneration?: number | undefined; fixtureDigest?: string | undefined; instanceId: string; documentId: string; }; declare type MiniappTestResetFixtureControlReceipt = { schemaVersion: 1; requestId: string; runId: string; operation: 'reset-fixture'; mode: 'MINIAPP_TEST_MODE_SURFACE' | 'MINIAPP_TEST_MODE_LIVE_TAP'; surfaceGeneration: number; fixtureGeneration?: number | undefined; fixtureDigest?: string | undefined; instanceId: string; documentId: string; }; declare type MiniappTestScriptHttpControlReceipt = { schemaVersion: 1; requestId: string; runId: string; operation: 'script-http'; fixtureGeneration: number; scriptedRequests: number; }; declare type MiniappTestSeedFixtureControlReceipt = { schemaVersion: 1; requestId: string; runId: string; operation: 'seed-fixture'; fixtureGeneration: number; fixtureDigest: string; surfaceGeneration: number; instanceId: string; documentId: string; }; /** Validate a driver session before any endpoint or provenance field is used. */ export declare function parseTapMiniappTestSession(value: unknown): TapMiniappTestSession; declare type TapAfterEachCallback = (context: TapHookContext) => void | Promise; declare type TapAfterEachHook = (callback: TapAfterEachCallback, timeout?: number) => void; declare type TapBeforeEachCallback = (context: TapHookContext) => void | TapAfterEachCallback | Promise>; declare type TapBeforeEachHook = (callback: TapBeforeEachCallback, timeout?: number) => void; declare type TapHookContext = TestContext & { [Key in keyof TapRstestFixtures]: Key extends keyof ExtraContext ? ExtraContext[Key] : TapRstestFixtures[Key]; } & Partial>; export declare type TapMiniappTestControl = { /** Restore the declared fixture and permission scenario in Surface mode. */ reset: () => Promise; /** Remount the surface and await its exact ready handshake. */ remountSurface: () => Promise; /** * Ask the TAP host to emit one versioned platform event through the normal * frame bridge. Payloads must be canonical JSON no larger than 60 KiB. */ emitHostEvent: (event: string, payload?: unknown) => Promise; }; export declare type TapMiniappTestEventReceipt = TapMiniappTestEventReceipt_2; declare type TapMiniappTestEventReceipt_2 = DeepReadonly; export declare type TapMiniappTestFixture = Readonly & { /** Origins authorized for host-mediated SDK HTTP, not browser-wide egress. */ readonly allowedNetworkOrigins: readonly string[]; readonly credentialAliases: readonly string[]; fixture: TapMiniappTestFixtureApi; control: TapMiniappTestControl; }>; export declare type TapMiniappTestFixtureApi = Readonly<{ /** Public fixture-control contract version. */ schemaVersion: 1; /** Restore the declared fixture and remount an exact ready Surface. */ reset: () => Promise; /** Replace all deterministic fixture realms with this strict JSON seed. */ seed: (seed: TapMiniappTestFixtureSeed) => Promise; /** Read a deterministic snapshot of every fixture realm. */ snapshot: () => Promise; /** Exact host-mediated SDK HTTP scripting and request capture. */ http: Readonly<{ script: (script: TapMiniappTestFixtureHttpScript) => Promise; requests: () => Promise; }>; /** Ordered host-action, native, platform, and event evidence. */ ledger: Readonly<{ read: () => Promise; }>; }>; declare type TapMiniappTestFixtureChannelSeed = DeepReadonly & { messages?: readonly GeneratedFixtureChannelSeed['messages'][number][]; specialistIds?: readonly string[]; }>; export declare type TapMiniappTestFixtureHttpBodyKind = TapMiniappTestFixtureHttpBodyKind_2; declare type TapMiniappTestFixtureHttpBodyKind_2 = GeneratedFixtureHttpResponse['bodyKind']; export declare type TapMiniappTestFixtureHttpCaptures = TapMiniappTestFixtureHttpCaptures_2; declare type TapMiniappTestFixtureHttpCaptures_2 = DeepReadonly; export declare type TapMiniappTestFixtureHttpHeaderInput = TapMiniappTestFixtureHttpHeaderInput_2; declare type TapMiniappTestFixtureHttpHeaderInput_2 = Omit & { enabled?: boolean | null; }; export declare type TapMiniappTestFixtureHttpRequest = TapMiniappTestFixtureHttpRequest_2; declare type TapMiniappTestFixtureHttpRequest_2 = Omit & { query?: readonly TapMiniappTestFixtureHttpHeaderInput_2[]; headers?: readonly TapMiniappTestFixtureHttpHeaderInput_2[]; body?: string | null; timeoutMs?: number | null; responseBodyLimitBytes?: number | null; followRedirects?: boolean | null; }; export declare type TapMiniappTestFixtureHttpResponse = TapMiniappTestFixtureHttpResponse_2; declare type TapMiniappTestFixtureHttpResponse_2 = Omit & { bodyText: string | null; bodyBase64: string | null; bodyKind: TapMiniappTestFixtureHttpBodyKind_2; contentType: string | null; }; export declare type TapMiniappTestFixtureHttpScript = TapMiniappTestFixtureHttpScript_2; declare type TapMiniappTestFixtureHttpScript_2 = DeepReadonly; declare type TapMiniappTestFixtureHttpScriptCommon = { request: TapMiniappTestFixtureHttpRequest_2; credentialRef?: string; auth?: 'github'; repeat?: number; }; export declare type TapMiniappTestFixtureHttpScriptState = TapMiniappTestFixtureHttpScriptState_2; declare type TapMiniappTestFixtureHttpScriptState_2 = DeepReadonly & { repeat: GeneratedFixtureHttpScriptState['repeat']; } & ({ response: TapMiniappTestFixtureHttpResponse_2; transportError?: never; } | { response?: never; transportError: TapMiniappTestFixtureHttpTransportError_2; })>; export declare type TapMiniappTestFixtureHttpTransportError = TapMiniappTestFixtureHttpTransportError_2; declare type TapMiniappTestFixtureHttpTransportError_2 = DeepReadonly; export declare type TapMiniappTestFixtureLedger = TapMiniappTestFixtureLedger_2; declare type TapMiniappTestFixtureLedger_2 = DeepReadonly & { entries: readonly (Omit & { kind: TapMiniappTestFixtureLedgerKind_2; })[]; }>; export declare type TapMiniappTestFixtureLedgerKind = TapMiniappTestFixtureLedgerKind_2; declare type TapMiniappTestFixtureLedgerKind_2 = GeneratedFixtureLedger['entries'][number]['kind']; declare type TapMiniappTestFixtureProjectSeed = DeepReadonly; export declare type TapMiniappTestFixtureScriptReceipt = TapMiniappTestFixtureScriptReceipt_2; declare type TapMiniappTestFixtureScriptReceipt_2 = DeepReadonly; export declare type TapMiniappTestFixtureSeed = TapMiniappTestFixtureSeed_2; declare type TapMiniappTestFixtureSeed_2 = DeepReadonly> & { projects?: readonly TapMiniappTestFixtureProjectSeed[]; channels?: readonly TapMiniappTestFixtureChannelSeed[]; httpScripts?: readonly TapMiniappTestFixtureHttpScript_2[]; }>; export declare type TapMiniappTestFixtureSeedReceipt = TapMiniappTestFixtureSeedReceipt_2; declare type TapMiniappTestFixtureSeedReceipt_2 = DeepReadonly; export declare type TapMiniappTestFixtureSnapshot = TapMiniappTestFixtureSnapshot_2; declare type TapMiniappTestFixtureSnapshot_2 = DeepReadonly & { state: Omit & { httpScripts: readonly TapMiniappTestFixtureHttpScriptState_2[]; }; }>; export declare type TapMiniappTestLifecycleReceipt = TapMiniappTestLifecycleReceipt_2; declare type TapMiniappTestLifecycleReceipt_2 = DeepReadonly & { mode: 'live-tap' | 'surface'; /** Runtime fixture realm generation after the lifecycle operation. */ fixtureGeneration: number | null; /** Runtime fixture realm digest; compare with fixture snapshots, not the session input digest. */ fixtureDigest: string | null; }>; export declare type TapMiniappTestSession = ValidatedTapMiniappTestSession; export declare type TapRstestFixtures = { browser: Browser; context: BrowserContext; page: Page; /** Locator for the authorized miniapp iframe mounted by TAP's real frame host. */ surface: FrameLocator; /** Provenance and scoped host controls for this exact test run. */ tap: TapMiniappTestFixture; }; declare type TapRstestTest = Omit, 'afterEach' | 'beforeEach' | 'extend'> & { (description: string, callback?: (context: TapTestCallbackContext) => void | Promise, timeout?: number): void; (description: string, options: TestOptions, callback?: (context: TapTestCallbackContext) => void | Promise): void; afterEach: TapAfterEachHook; beforeEach: TapBeforeEachHook; extend: = Record>(fixtures: PlaywrightFixtures) => TapRstestTest>; }; declare type TapTestCallbackContext = TestContext & ExtraContext; /** Rstest's per-test context plus TAP's authorized browser and run fixtures. */ export declare type TapTestContext = TestContext & TapRstestFixtures; /** * Rstest's Playwright test API with TAP-owned browser, page, iframe, and run * fixtures. The upstream runner still owns scheduling, assertions, hooks, and * reporting; TAP owns the privileged browser/session boundary. */ export declare const test: TapRstestTest; declare type ValidatedTapMiniappTestSession = Readonly<{ protocolMajor: number; protocolMinor: number; features: readonly string[]; runId: string; runNonce: string; expiresAt: string; workspaceId: string; channelId: string; packageId: string; installationId: string; bindingId: string; releaseDigest?: string; localGeneration?: number; matrixEntryId: string; profileId: string; target: string; /** @deprecated Use `target`. */ matrixTarget: string; mode: 'surface' | 'live-tap'; presentation: 'headless' | 'visible'; dataScope: 'fixture' | 'selected-channel'; selectedChannelId?: string; permissionScenario: string; fixtureVersion?: string; seed: number; environment: Readonly<{ viewport: Readonly<{ width: number; height: number; }>; locale: string; timezone: string; theme: 'dark' | 'light'; reducedMotion: boolean; seed: number; fixedNow?: string; }>; artifacts: Readonly<{ trace: 'always' | 'failure-only' | 'off'; screenshots: 'always' | 'failure-only' | 'off'; maxBytes?: number; }>; sourceDigest: string; testBundleDigest: string; descriptorDigest: string; /** SHA-256 attestation of the immutable descriptor fixture inputs selected for this run. */ fixtureDigest?: string; policyDigest: string; adapterVersion: string; hostVersion: string; hostContractVersion: string; runnerName: 'rstest'; runnerVersion: string; nodeVersion: string; playwrightVersion: string; browserEngine: string; browserVersion: string; targetId: string; browserContextId?: string; targetType: 'page'; pageUrl: string; surfaceId: string; surfaceSelector: string; surfaceAssetOrigin: string; cdpEndpoint: string; cdpAuthorization: string; artifactDirectory: string; allowedNetworkOrigins: readonly string[]; effectGrants: readonly string[]; credentialAliases: readonly string[]; }>; export { }