test(app): client journeys in Chromium on the isolated stack

Create, search, edit, archive, archived filter, restore; pages of 25;
keyboard only; two accounts; a concurrent edit; a retry after a lost answer
sends the same request id; network failures; the leave guard; a change of
language; FR/EN, desktop and 375 px, axe on every state. signIn shared.
This commit is contained in:
bchanot committed 2026-10-26 01:59:26 +01:00
1 parent b38e62770e
commit d33a8f6dad
4 files changed
+638 -27

No files matched your search

+20 -9
View File
@@ -21,17 +21,20 @@ const ROUTES: [prefix: string, target: string][] = [
['/storage/v1/', `${storageUrl}/`],
]
/** The sandbox URL a request to the fake Supabase origin maps to, or null when unmapped. */
export function sandboxUrl(url: string): string | null {
const { pathname, search } = new URL(url)
const path = pathname + search
const mapped = ROUTES.find(([prefix]) => path.startsWith(prefix))
return mapped ? mapped[1] + path.slice(mapped[0].length) : null
}
/** Replays the page's Supabase calls on the sandbox; an unmapped path is refused. */
export async function routeToSandbox(context: BrowserContext): Promise<void> {
await context.route(`${FAKE_SUPABASE_ORIGIN}/**`, async (route) => {
const path =
new URL(route.request().url()).pathname +
new URL(route.request().url()).search
const mapped = ROUTES.find(([prefix]) => path.startsWith(prefix))
if (!mapped) return route.abort('blockedbyclient')
const response = await route.fetch({
url: mapped[1] + path.slice(mapped[0].length),
})
const target = sandboxUrl(route.request().url())
if (!target) return route.abort('blockedbyclient')
const response = await route.fetch({ url: target })
await route.fulfill({ response })
})
}
@@ -43,6 +46,7 @@ const AVATAR_WEBP = Buffer.from(
)
export interface SandboxAccount {
id: string
email: string
password: string
displayName: string
@@ -105,5 +109,12 @@ export async function createAccount(
})
const { id } = (await response.json()) as { id: string }
if (withAvatar) await seedAvatar(id)
return account
return { ...account, id }
}
/** The personal workspace of a sandbox account (created by the server at sign-up). */
export function workspaceOf(account: SandboxAccount): Promise<string> {
return sql(
`select id from public.workspaces where personal_user_id = '${account.id}'`,
)
}