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 <cynarAI@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-09-24 05:00:15 +00:00
parent 8bf343f0f8
commit f0593bad07
2 changed files with 24 additions and 16 deletions

View File

@ -29,6 +29,23 @@ export async function rpc<T>(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<string, unknown>) => Record<string, unknown>,
) {
await page.route(`**/rpc/${procedure}`, async (route) => {
const response = await route.fetch();
const body = (await response.json()) as { json: Record<string, unknown> };
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);
}

View File

@ -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<string, unknown> };
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}`);