evOo-local/apps/web/e2e/host-computer-prompt.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

65 lines
2.5 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, fulfillFetchedRpc, signup } from "./helpers";
for (const platform of ["darwin", "win32"]) {
test(`host computer choice explains file access on ${platform}`, async ({ page }, testInfo) => {
await signup(
page,
`host-choice-${platform}-${Date.now()}@rakazo.test`,
"password12",
"Host Tester",
);
await completeOnboarding(page);
await page.addInitScript((platform) => {
Object.defineProperty(window, "rakazoDesktop", {
value: {
platform,
window: {
close: async () => {},
minimize: async () => {},
toggleMaximize: async () => {},
state: async () => ({ minimized: false, maximized: false, fullScreen: false }),
},
oauth: { onCallback: () => () => {} },
update: {
state: async () => ({ phase: "idle", currentVersion: "0.1.0" }),
},
},
});
}, platform);
await page.route(/\/rpc\/(me|bootstrap)$/, async (route) => {
const response = await route.fetch();
const body = (await response.json()) as {
json: Record<string, unknown> & { me?: Record<string, unknown> };
};
const me = route.request().url().endsWith("/me") ? body.json : body.json.me;
if (me) {
me.canChooseHostComputer = true;
me.computerHost = null;
}
await fulfillFetchedRpc(route, response, body);
});
await page.reload();
const dialog = page.getByRole("dialog", { name: "Where should bots run?" });
await expect(dialog).toBeVisible();
await expect(dialog).toHaveAccessibleDescription(
/Local access lets bots run commands without asking\. Avoid it on shared or public servers\./,
);
const host = platform === "darwin" ? "this Mac" : "this computer";
await expect(
dialog.getByText(
`Docker limits access to your computer for added security. Using ${host} lets bots work with your local files and tools.`,
),
).toBeVisible();
await expect(
dialog.getByText(
"Local access lets bots run commands without asking. Avoid it on shared or public servers.",
),
).toBeVisible();
await expect(dialog.getByRole("button", { name: "Docker", exact: true })).toBeVisible();
await expect(dialog.getByText(/recommended/i)).toHaveCount(0);
await expect(dialog.getByRole("button", { name: `Use ${host}` })).toBeVisible();
await captureScreenshot(page, testInfo, `host-computer-choice-${platform}`);
});
}