evOo-local/apps/web/e2e/helpers.ts
cynarAI a55ed44394
One product: evOo updates and name, phone actions, German on mobile, working account deletion, consistent settings (#168)
* Pull updates from evOo instead of the upstream Rakazo repository

The in-app server updater, the image-based compose files and the desktop
auto-updater still pointed at elie222/rakazo, so updating an evOo install
would have pulled Rakazo. They now follow cynarAI/evOo-local, where the
publish workflow already pushes the images. The disabled Rakazo production
deploy job is gone from CI; evo deploys itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Call the product evOo everywhere people see its name

The desktop setup window and menu, account emails, the iOS app name and
permission prompts, sign-in headings, messages bots post into connected chat
apps, the web fetch user agent, issue templates and the marketing site still
said Rakazo, or EvOo. They now say evOo. The marketing site no longer calls
evOo an alternative to itself.

Internal identifiers (package scopes, env vars, bundle ids, the desktop
productName that keys its data folder and keychain entry) stay as they are.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Open conversation actions by holding a row on a phone

Pin, move to folder, mark unread, duplicate, archive and delete only opened
on right-click, which iOS Safari never fires. Holding a conversation or a
folder header now dispatches the same contextmenu event, so the existing menu
opens under the finger; Android's own long-press event is not doubled and the
lift does not also open the conversation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Give small chrome icons a 44px touch area on phones

The browser and computer toggles, the activity bell, the create button and the
section plus buttons were 18 to 36 px targets. On touch screens each now gets
an invisible 44px hit area without changing how it looks; the create button
uses the same plus icon as the rest of the sidebar instead of a text glyph,
and the computer toggle gets an accessible name.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Add German to the mobile app

German speakers saw the phone app in English because the mobile UI only
knew English, Simplified Chinese, and Russian. The app now ships a German
catalog covering every mobile chrome string, follows a German device
language (de, de-DE, de-AT, de-CH, ...), and offers Deutsch in the Account
language picker.

Strings that also exist in the web German catalog reuse its wording so
web and phone say the same thing; the rest follow the same terms and the
informal "du".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Use the evOo sign-in strings in the German phone catalog

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Make account deletion work and give settings one section style

Deleting an account posted to the auth endpoint without a JSON content
type, so the server refused it and the button did nothing. The privacy
page now deletes through the auth client and returns to sign-in. It also
drops the claims it could not verify, the export button that only showed
an alert, and its own padding, and shows where the data and the computer
live. Notifications and media settings use the same SettingsSection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Use status tokens, the shared switch and one German glossary

Voice stage dots, the onboarding progress bar and the Voice First button
used raw emerald, violet, cyan and rose; they now use foreground, success
and destructive like the rest of the app. The routine editor's hand-built
switch is the shared Switch. German says Unterhaltung for threads and
Space consistently on web and phone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Expect the evOo setup copy in the desktop e2e specs

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Translate the voice preview label in the German phone catalog

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

* Wait for the main thread URL without waiting for every resource

openMainBotThread already navigated with domcontentloaded; its URL check
then waited for the full load event, which can exceed 20 s on a busy
runner. The composer check that follows covers readiness.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgvrj34NMnaqvtgvruYQZZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-06 00:38:31 +02:00

298 lines
11 KiB
TypeScript

import { expect, type Locator, type Page, type Route, type TestInfo } from "@playwright/test";
type RpcEnvelope = { json?: Record<string, unknown> };
function isBenignRouteError(error: unknown) {
return /disposed|already handled|Target closed|Request context disposed/i.test(String(error));
}
/** Unterhaltungen rows only — `.sidebar-projekte` is nested inside the same shell block on main. */
export function unterhaltungenOnly(page: Page) {
return page.locator(".sidebar-unterhaltungen").locator(":scope > *:not(.sidebar-projekte)");
}
export function isRealSandboxProvider(provider = process.env.SANDBOX_PROVIDER) {
return provider === "e2b" || provider === "daytona" || provider === "box";
}
export function realSandboxTimeout(real: number, emulated: number) {
if (process.env.SANDBOX_PROVIDER === "box") return Math.max(real, 300_000);
return isRealSandboxProvider() ? real : emulated;
}
export function activeBotId(page: Page) {
const id = new URL(page.url()).pathname.split("/").filter(Boolean).at(-1);
if (!id || id === "app") throw new Error(`missing bot id in ${page.url()}`);
return id;
}
export async function rpc<T>(page: Page, procedure: string, body: unknown): Promise<T> {
const spaceId = await page.evaluate(() => window.localStorage.getItem("rakazo:space-id"));
const response = await page.request.post(`/rpc/${procedure}`, {
data: { json: body },
headers: spaceId ? { "x-rakazo-space-id": spaceId } : undefined,
});
const parsed = (await response.json()) as { json?: T; error?: { message?: string } };
if (!response.ok() || parsed.error) {
throw new Error(`${procedure} ${response.status()}: ${parsed.error?.message ?? "failed"}`);
}
return parsed.json as T;
}
/** Read status and headers before the body so Playwright does not dispose the response early. */
export async function fetchRpcEnvelope(route: Route) {
const response = await route.fetch();
const status = response.status();
const headers = response.headers();
const body = (await response.json()) as RpcEnvelope;
return { status, headers, body };
}
/** Fulfill a fetched RPC response without passing a consumed `response` into `route.fulfill`. */
export async function fulfillFetchedRpc(
route: Route,
fetched: { status: number; headers: { [key: string]: string }; body: RpcEnvelope },
) {
await route.fulfill({
status: fetched.status,
headers: fetched.headers,
contentType: "application/json",
body: JSON.stringify(fetched.body),
});
}
/** 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) => {
try {
const fetched = await fetchRpcEnvelope(route);
const json = fetched.body.json;
if (!json) {
await fulfillFetchedRpc(route, fetched);
return;
}
await fulfillFetchedRpc(route, { ...fetched, body: { json: patch(json) } });
} catch (error) {
if (isBenignRouteError(error)) return;
throw error;
}
});
}
async function visible(locator: Locator, timeout: number) {
return locator.isVisible({ timeout }).catch(() => false);
}
/**
* Walks the first-run wizard, which lands in the main conversation with the main bot's first
* onboarding question pending (the composer works regardless). Unless `mainConversation` is
* set, it then opens the main bot's own thread, where most specs start.
*/
export async function completeOnboarding(
page: Page,
testInfo?: TestInfo,
options: { mainConversation?: boolean } = {},
) {
await page.waitForURL(/\/(onboarding|app)/, { timeout: 20_000 });
if (page.url().includes("/onboarding")) {
await expect(page.locator('[data-rakazo-surface="onboarding"]')).toHaveAttribute(
"data-onboarding-step",
/^(emoji|language|voice|integrations|scan|bot)$/,
{ timeout: 30_000 },
);
}
const design = page.getByRole("heading", { name: /Design your Oo/i });
const language = page.getByRole("heading", { name: /Choose your language/i });
const voice = page.getByRole("heading", { name: /Pick a voice/i });
const integrations = page.getByRole("heading", { name: "Server integrations", exact: true });
const chief = page.getByText("Chief").first();
// Scripted CI has needsModel false, so a fresh owner starts on integrations.
// A model-gated run still opens the look picker first.
const entry = design.or(integrations).or(chief);
await expect(entry.first()).toBeVisible({ timeout: 20_000 });
if (await design.isVisible()) {
await page.getByRole("button", { name: "Continue", exact: true }).click();
await expect(language).toBeVisible();
await page.getByRole("button", { name: /Skip/i }).click();
await expect(voice).toBeVisible();
await page.getByRole("button", { name: "Skip", exact: true }).click();
}
if (await visible(integrations, 8_000)) {
if (testInfo) await captureScreenshot(page, testInfo, "02-connect-apps");
await page.getByRole("button", { name: "Skip", exact: true }).click();
}
// The scan step, when shown, either asks first (skip it) or advances by itself. Onboarding
// then lands in the main conversation.
const skipScan = page
.locator('[data-onboarding-step="scan"]')
.getByRole("button", { name: "Skip", exact: true });
await expect(async () => {
if (await skipScan.isVisible()) await skipScan.click();
expect(page.url()).toMatch(/\/app\/g\/[^/]+$/);
}).toPass({ timeout: 30_000 });
await expect(chief).toBeVisible({ timeout: 15_000 });
await waitForChatComposer(page);
if (testInfo) {
await captureScreenshot(page, testInfo, "03-create-first-bot");
await captureScreenshot(page, testInfo, "06-onboarding-complete");
}
if (!options.mainConversation) await openMainBotThread(page);
}
/** The main bot's own thread stays reachable by URL; the sidebar lists the main conversation. */
export async function openMainBotThread(page: Page) {
const main = await rpc<{ id: string }>(page, "bots/ensureMain", {});
await page.goto(`/app/${main.id}`, { waitUntil: "domcontentloaded" });
await page.waitForURL(new RegExp(`/app/${main.id}$`), {
timeout: 20_000,
waitUntil: "domcontentloaded",
});
await waitForChatComposer(page);
return main.id;
}
export async function signup(
page: Page,
email: string,
password: string,
name: string,
testInfo?: TestInfo,
) {
await expect(async () => {
await page.goto("/sign-up", { waitUntil: "domcontentloaded" });
await expect(page.getByRole("heading", { name: "Create your evOo" })).toBeVisible({
timeout: 5_000,
});
}).toPass({ timeout: 45_000 });
if (testInfo) await captureScreenshot(page, testInfo, "01-sign-up");
await page.getByPlaceholder("Your name").fill(name);
await page.getByPlaceholder("Your email address").fill(email);
await page.getByPlaceholder("Password").fill(password);
await page.getByRole("button", { name: "Create account" }).click();
}
export async function captureScreenshot(page: Page, testInfo: TestInfo, name: string) {
const screenshotPath = testInfo.outputPath(`${name}.png`);
await page.screenshot({
animations: "disabled",
caret: "hide",
fullPage: true,
path: screenshotPath,
});
await testInfo.attach(name, { contentType: "image/png", path: screenshotPath });
}
export async function openNewBot(page: Page) {
await page.getByTestId("create-menu-trigger").click();
await page.getByTestId("create-new-bot").click();
await expect(page.getByTestId("side-panel")).toHaveAttribute("data-panel", "create");
await expect(page.getByTestId("create-bot-form")).toBeVisible();
}
export async function openNewGroup(page: Page) {
await page.getByTestId("create-menu-trigger").click();
await page.getByTestId("create-new-group").click();
}
export async function openNewSpace(page: Page) {
await page.getByTestId("create-menu-trigger").click();
await page.getByTestId("create-new-space").click();
}
/** Open the create form from the + picker, submit, and wait for the new chat. */
export async function createBotFromPicker(
page: Page,
options: {
name?: string;
title?: string;
description?: string;
computerMode?: "team" | "dedicated";
} = {},
) {
const name = options.name ?? "New Bot";
await openNewBot(page);
const form = page.getByTestId("create-bot-form");
await form.locator("label:has-text('Name') input").fill(name);
if (options.title != null) {
await form.locator("label:has-text('Title') input").fill(options.title);
}
if (options.description != null) {
await form.locator("label:has-text('Description') textarea").fill(options.description);
}
if (options.computerMode === "dedicated") {
await form.getByTestId("create-bot-private").click();
} else if (options.computerMode === "team") {
await form.getByTestId("create-bot-team").click();
}
await form.getByRole("button", { name: "Create", exact: true }).click();
await page.waitForURL(/\/app\/[^/]+$/);
await expect(page.getByTestId("side-panel")).toHaveAttribute("data-panel", "closed");
}
/** Open the user Settings overlay, optionally switching to a sidebar section. */
export async function openUserSettings(
page: Page,
section?:
| "general"
| "integrations"
| "models"
| "memory"
| "voice"
| "notifications"
| "usage"
| "computer"
| "updates"
| "privacy",
) {
await expect(page.getByTestId("shell-root")).toHaveAttribute("data-ready", "true", {
timeout: 60_000,
});
await expect(page.getByTestId("user-menu-trigger")).toBeVisible({ timeout: 30_000 });
await page.getByTestId("user-menu-trigger").click();
await page.getByRole("button", { name: "Settings", exact: true }).click();
const settings = page.getByTestId("user-settings");
await expect(settings).toBeVisible();
if (section && section !== "general") {
await settings.getByTestId(`settings-nav-${section}`).click();
}
return settings;
}
/** Wait until the shell thread is loaded and the message composer is interactive. */
export async function waitForChatComposer(page: Page) {
await expect(page.getByTestId("shell-root")).toHaveAttribute("data-ready", "true", {
timeout: 30_000,
});
await expect(page.getByRole("combobox", { name: "Message" })).toBeVisible();
}
/** Create a named bot via RPC for test setup (skips the + picker). */
export async function createNamedBot(
page: Page,
name: string,
options: { computerMode?: "team" | "dedicated" } = {},
) {
const bot = await rpc<{ id: string; name: string }>(page, "bots/create", {
name,
title: "",
description: "",
notifyOnFinish: true,
computerMode: options.computerMode ?? "team",
});
await page.goto(`/app/${bot.id}`, { waitUntil: "domcontentloaded" });
await page.waitForURL(/\/app\/[^/]+$/, { timeout: 20_000 });
await waitForChatComposer(page);
return bot.id;
}