evOo-local/apps/web/e2e/first-conversation.spec.ts
cynarAI b3f20967db
Preselect the recommended model while none is connected (#150)
Without a model key the settings opened on the keyless deployment default
(OpenRouter). The connect flow now opens on Claude Opus 5, so a new user
only adds a key or signs in. A connected credential, an owner-chosen
default, or a deployment key still decides as before.


Claude-Session: https://claude.ai/code/session_01KWEAjTw26eRf3ZXTXfRjmD

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-05 10:17:33 +02:00

52 lines
2.6 KiB
TypeScript

/**
* E2E: a new account reaches onboarding and, without a model, sees how to connect one.
*/
import { expect, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, routePatchRpc, signup } from "./helpers";
test("a signed-out visit to onboarding returns there after sign-in", async ({ page }) => {
const email = `return-onboarding-${Date.now()}@rakazo.test`;
await signup(page, email, "password12", "Return");
await page.waitForURL(/\/onboarding$/, { timeout: 20_000 });
await page.context().clearCookies();
await page.goto("/onboarding", { waitUntil: "domcontentloaded" });
await page.waitForURL((url) => url.pathname === "/sign-in");
expect(new URL(page.url()).searchParams.get("next")).toBe("/onboarding");
await page.getByPlaceholder("Your email address").fill(email);
await page.getByPlaceholder("Password").fill("password12");
await page.getByRole("button", { name: "Continue with email" }).click();
await page.waitForURL(/\/onboarding$/, { timeout: 20_000 });
await expect(page.locator('[data-rakazo-surface="onboarding"]')).toBeVisible();
});
test("without a model the composer offers to connect one", async ({ page }) => {
const testInfo = test.info();
await signup(page, `model-needed-${Date.now()}@rakazo.test`, "password12", "Model needed");
await completeOnboarding(page, undefined, { mainConversation: true });
// Scripted CI has a model; this is what the API returns without one.
const keyless = { needsModel: true, defaultProvider: "anthropic", defaultModel: "claude-opus-5" };
await routePatchRpc(page, "bootstrap", (json) => ({
...json,
me: { ...(json.me as Record<string, unknown>), ...keyless },
}));
await routePatchRpc(page, "me", (json) => ({ ...json, ...keyless }));
await page.reload({ waitUntil: "domcontentloaded" });
const notice = page.getByTestId("composer-model-needed");
await expect(notice).toContainText("Connect a model so your Oo can reply.");
await captureScreenshot(page, testInfo, "first-conversation-model-needed");
await notice.getByRole("button", { name: "Connect model" }).click();
const settings = page.getByTestId("model-settings");
await expect(settings).toBeVisible();
// The recommendation is preselected, so only the key or sign-in is left.
await expect(settings.getByRole("combobox", { name: "Model" })).toHaveText("Claude Opus 5");
await captureScreenshot(page, testInfo, "model-settings-recommended");
await page.emulateMedia({ colorScheme: "dark" });
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
await captureScreenshot(page, testInfo, "model-settings-recommended-dark");
});