import { test, expect } from "@playwright/test"; test.describe("Settings Page", () => { test("settings page responds with 200", async ({ request }) => { const res = await request.get("/settings"); expect(res.status()).toBe(200); }); test("shows product configuration section", async ({ page, request }) => { // Obtain real tokens from platform-service via API, then seed // localStorage so AuthGuard's session refresh + kill-switch checks // pass naturally. Requires the deployed platform-service stack to be // reachable at http://localhost:4003, which is the same assumption // as the navigation/dashboard specs. const email = process.env.NOTELETT_E2E_EMAIL ?? "user@notelett.app"; const password = process.env.NOTELETT_E2E_PASSWORD ?? "Notelett!Test#2026"; const platformUrl = process.env.NOTELETT_E2E_PLATFORM_URL ?? "http://localhost:4003/api"; const loginRes = await request.post(`${platformUrl}/auth/login`, { data: { email, password, productId: "notelett" }, headers: { "Content-Type": "application/json", "X-Product-Id": "notelett" }, }); if (!loginRes.ok()) { test.skip( true, `Skipping: platform-service login at ${platformUrl} not reachable. Status ${loginRes.status()}.` ); return; } const tokens = (await loginRes.json()) as { user: { id: string; email: string; name?: string }; accessToken: string; refreshToken: string; }; await page.addInitScript((seed) => { localStorage.setItem("notelett_auth_user", JSON.stringify(seed.user)); localStorage.setItem("notelett_access_token", seed.accessToken); localStorage.setItem("notelett_refresh_token", seed.refreshToken); }, tokens); await page.goto("/settings"); await expect( page.getByText(/product|configuration|notelett|backend/i).first() ).toBeVisible({ timeout: 10_000 }); }); test("all pages load without console errors", async ({ page }) => { const errors: string[] = []; page.on("pageerror", (err) => errors.push(err.message)); const routes = ["/dashboard", "/workspaces", "/search", "/reviews", "/settings"]; for (const route of routes) { await page.goto(route); await page.waitForLoadState("domcontentloaded"); } const realErrors = errors.filter( (e) => !e.includes("fetch") && !e.includes("Failed") ); expect(realErrors).toHaveLength(0); }); });