From f0593bad07a523312ff64ad8167879158c32b7cc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 24 Sep 2026 05:00:15 +0000 Subject: [PATCH] fix(e2e): harden onboarding-model-labels rpc/me intercept Avoid passing a consumed fetch Response into route.fulfill alongside json, which intermittently throws Response has been disposed in CI. Add routePatchRpc helper that reads the body once and fulfills with status, headers, and patched json only. Co-authored-by: cynarAI --- apps/web/e2e/helpers.ts | 17 +++++++++++++++ apps/web/e2e/onboarding-model-labels.spec.ts | 23 ++++++-------------- 2 files changed, 24 insertions(+), 16 deletions(-) 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}`);