import type { BrowserContext } from "@playwright/test"; /** * Subset of Playwright's `StorageState` we persist between tests within the * same worker. We model it explicitly rather than re-exporting * `Awaited>` so the cache * contract is greppable from spec files and Playwright API churn cannot * silently widen what we're persisting. */ export interface CachedStorageState { cookies: Parameters[0]; origins: Array<{ origin: string; localStorage: Array<{ name: string; value: string; }>; }>; } export type StorageStateHydrator = Pick; /** * Restores cookies and localStorage from a cached `storageState` snapshot * into the supplied browser context. * * Cookies go through `context.addCookies` (synchronous from the page's POV * because they're set before any navigation). LocalStorage requires an * `addInitScript` because it can only be written by JS executing on the * matching origin — Playwright runs the init script in every new document, * and we gate it by `window.location.origin` so we don't smuggle localStorage * onto unrelated origins (e.g. about:blank, OAuth IdP domains, or iframes * pointing at iris-app subdomains). * * Wrapping each `setItem` in try/catch protects against contexts where * localStorage is unavailable (private browsing modes, sandboxed iframes, * etc.) — we never want hydration to crash the page load. */ export declare const hydrateStorageState: (context: StorageStateHydrator, state: CachedStorageState) => Promise;