diff --git a/apps/web/e2e/helpers.ts b/apps/web/e2e/helpers.ts index a696374..1c686da 100644 --- a/apps/web/e2e/helpers.ts +++ b/apps/web/e2e/helpers.ts @@ -29,6 +29,23 @@ export async function rpc(page: Page, procedure: string, body: unknown): Prom return parsed.json as T; } +/** Patch a fetched RPC response without passing a consumed `response` into `route.fulfill`. */ +export async function routePatchRpc( + page: Page, + procedure: string, + patch: (json: Record) => Record, +) { + await page.route(`**/rpc/${procedure}`, async (route) => { + const response = await route.fetch(); + const body = (await response.json()) as { json: Record }; + await route.fulfill({ + status: response.status(), + headers: response.headers(), + json: { json: patch(body.json) }, + }); + }); +} + async function visible(locator: Locator, timeout: number) { return locator.isVisible({ timeout }).catch(() => false); } diff --git a/apps/web/e2e/onboarding-model-labels.spec.ts b/apps/web/e2e/onboarding-model-labels.spec.ts index 4fbb4e2..d4a8ee8 100644 --- a/apps/web/e2e/onboarding-model-labels.spec.ts +++ b/apps/web/e2e/onboarding-model-labels.spec.ts @@ -1,22 +1,13 @@ import { expect, test } from "@playwright/test"; -import { signup } from "./helpers"; +import { routePatchRpc, signup } from "./helpers"; test("onboarding no longer gates first run on a model picker", async ({ page }) => { - await page.route("**/rpc/me", async (route) => { - const response = await route.fetch(); - const body = (await response.json()) as { json: Record }; - await route.fulfill({ - response, - json: { - json: { - ...body.json, - needsModel: true, - defaultProvider: "openrouter", - defaultModel: "openai/gpt-5.6-luna", - }, - }, - }); - }); + await routePatchRpc(page, "me", (json) => ({ + ...json, + needsModel: true, + defaultProvider: "openrouter", + defaultModel: "openai/gpt-5.6-luna", + })); const stamp = Date.now(); await signup(page, `model-labels-${stamp}@rakazo.test`, "password12", `Model labels ${stamp}`);