evOo-local/apps/web/e2e/onboarding-model-required.spec.ts
cynarAI fc173918f7 fix(e2e): harden onboarding-model-labels rpc/me intercept (#89)
* 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>

* fix(e2e): migrate rpc/me intercept anti-pattern across specs

Extend helpers with fulfillFetchedRpc for multi-procedure or in-place
patches. Move onboarding, mobile, host-computer, and group-chats specs
off route.fulfill({ response, json }) after response.json().

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* style(e2e): biome-format host-computer-prompt rpc/me cast

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-09-24 08:16:39 +02:00

51 lines
2.0 KiB
TypeScript

import { expect, type Page, test } from "@playwright/test";
import { routePatchRpc, signup } from "./helpers";
async function forceNeedsModel(page: Page) {
await routePatchRpc(page, "me", (json) => ({ ...json, needsModel: true }));
}
test("onboarding shows the look picker when a model is still required", async ({ page }) => {
await forceNeedsModel(page);
const stamp = Date.now();
await signup(
page,
`model-required-${stamp}@rakazo.test`,
"password12",
`Model required ${stamp}`,
);
await page.waitForURL(/\/onboarding/, { timeout: 20_000 });
await expect(page.locator('[data-rakazo-surface="onboarding"]')).toHaveAttribute(
"data-onboarding-step",
/^(emoji|preferences|language|voice|integrations)$/,
{ timeout: 30_000 },
);
await expect(page.getByRole("heading", { name: /Design your Oo/i })).toBeVisible({
timeout: 20_000,
});
await expect(page.getByRole("heading", { name: "Connect a model" })).toHaveCount(0);
await expect(page.getByRole("combobox", { name: "Message" })).toHaveCount(0);
});
for (const unavailable of ["empty", "failed"] as const) {
test(`onboarding still opens when the model catalog is ${unavailable}`, async ({ page }) => {
await forceNeedsModel(page);
await page.route("**/rpc/models/list", (route) =>
unavailable === "failed" ? route.abort() : route.fulfill({ json: { json: [] } }),
);
const stamp = Date.now();
await signup(page, `catalog-${unavailable}-${stamp}@rakazo.test`, "password12", "Model setup");
await page.waitForURL(/\/onboarding/, { timeout: 20_000 });
await expect(page.locator('[data-rakazo-surface="onboarding"]')).toHaveAttribute(
"data-onboarding-step",
/^(emoji|preferences|language|voice|integrations)$/,
{ timeout: 30_000 },
);
await expect(page.getByRole("heading", { name: /Design your Oo/i })).toBeVisible({
timeout: 20_000,
});
await expect(page.getByRole("heading", { name: "Connect a model" })).toHaveCount(0);
await expect(page.getByRole("combobox", { name: "Message" })).toHaveCount(0);
});
}