import * as _playwright_test from '@playwright/test'; import { BrowserContext, Page, Browser } from '@playwright/test'; export { expect } from '@playwright/test'; interface MultiplayerUser { context: BrowserContext; page: Page; email: string; name: string; /** Test account user ID, if known from the accounts registry. */ userId?: string; } /** * Fixture function signature. Pass either a count (`users(2)`) or an * array of account names (`users(['Alice', 'Bob'])`). Returns one entry * per requested user. */ type UsersFixture = (selector: number | string[], options?: { label?: string; /** Sign in again even if the cached session still validates. */ force?: boolean; }) => Promise; interface MultiplayerFixtures { users: UsersFixture; } declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & MultiplayerFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>; /** * Account-credential plumbing for the testing module. * * Reads test accounts from the auth-origin-scoped registry at * `~/.deepspace/test-accounts.json` (the same file * `deepspace test accounts create` writes). Persisted accounts are bound to a * remote account id; `name` and `label` are optional. * * Used by the multi-user Playwright fixture in `./fixtures.ts` and is * also exported standalone in case suites want to do their own * orchestration. */ interface TestAccount { email: string; password: string; name?: string; label?: string | null; id?: string; userId?: string; createdAt?: number; } declare function loadAllTestAccounts(scope?: string): TestAccount[]; /** * Pick `count` test accounts from the local registry, optionally * filtered by `label`. Order-stable: sorted by `createdAt` ascending so * the first test account you created is always the first one returned. * * Throws with a helpful message if not enough accounts exist. */ declare function pickTestAccounts(count: number, options?: { label?: string; }): TestAccount[]; /** * Find a single account by name. Used by `users(['Alice', 'Bob'])`. * Throws if not found. */ declare function findTestAccountByName(name: string): TestAccount; /** * Per-account `storageState` cache for Playwright. * * The auth worker limits password sign-ins per account. A * multiplayer suite that spins up * many users per spec can hit the limit and start failing in non-obvious * ways. This module signs each account in *once*, persists the * resulting browser cookies + storage to disk, and reuses the file on * subsequent runs. * * Cache layout: * ~/.deepspace/playwright-states/.json * * Validity: a cached file is reused if Playwright successfully loads it * AND the resulting context produces a non-anonymous session on the * target app. If validation fails, we fall back to a fresh sign-in and * overwrite the cache. */ interface StorageStateAccount { email: string; password: string; /** Remote user id, when the local registry knows it. */ userId?: string; } /** Where the cache for `email` against `baseURL`'s origin lives. */ declare function getStatePathForEmail(email: string, baseURL: string): string; interface EnsureStorageStateOptions { /** Force a fresh sign-in even if a cached state validates. */ force?: boolean; } /** * Ensure a validated Playwright `storageState` file exists for `account` * and return its path. A cached file is probed against the app before * reuse (once per worker process); a missing, expired, or wrong-account * state triggers one fresh sign-in that overwrites it. */ declare function ensureStorageState(browser: Browser, account: StorageStateAccount, baseURL: string, options?: EnsureStorageStateOptions): Promise; /** * Convenience: open a fresh `BrowserContext` for `account` using the * cached storage state (signing in if needed). The caller is responsible * for closing the context. */ declare function newSignedInContext(browser: Browser, account: StorageStateAccount, baseURL: string, options?: EnsureStorageStateOptions): Promise; export { type EnsureStorageStateOptions, type MultiplayerUser, type TestAccount, type UsersFixture, ensureStorageState, findTestAccountByName, getStatePathForEmail, loadAllTestAccounts, newSignedInContext, pickTestAccounts, test };