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:
parent
8bf343f0f8
commit
f0593bad07
@ -29,6 +29,23 @@ export async function rpc<T>(page: Page, procedure: string, body: unknown): Prom
|
|||||||
return parsed.json as T;
|
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) {
|
async function visible(locator: Locator, timeout: number) {
|
||||||
return locator.isVisible({ timeout }).catch(() => false);
|
return locator.isVisible({ timeout }).catch(() => false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,13 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
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 }) => {
|
test("onboarding no longer gates first run on a model picker", async ({ page }) => {
|
||||||
await page.route("**/rpc/me", async (route) => {
|
await routePatchRpc(page, "me", (json) => ({
|
||||||
const response = await route.fetch();
|
...json,
|
||||||
const body = (await response.json()) as { json: Record<string, unknown> };
|
needsModel: true,
|
||||||
await route.fulfill({
|
defaultProvider: "openrouter",
|
||||||
response,
|
defaultModel: "openai/gpt-5.6-luna",
|
||||||
json: {
|
}));
|
||||||
json: {
|
|
||||||
...body.json,
|
|
||||||
needsModel: true,
|
|
||||||
defaultProvider: "openrouter",
|
|
||||||
defaultModel: "openai/gpt-5.6-luna",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const stamp = Date.now();
|
const stamp = Date.now();
|
||||||
await signup(page, `model-labels-${stamp}@rakazo.test`, "password12", `Model labels ${stamp}`);
|
await signup(page, `model-labels-${stamp}@rakazo.test`, "password12", `Model labels ${stamp}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user