Files
EventLens-Public/frontend/e2e/settings.spec.ts
T

60 lines
3.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
test("Settings communicates browser-local saving and resets accessible preference controls", async ({ page }) => {
await page.goto("/#settings");
await expect(page.getByText("Saved automatically in this browser", { exact: true })).toBeVisible();
await expect(page.getByRole("group", { name: "Timestamp display" })).toBeVisible();
await expect(page.getByRole("group", { name: "Interface density" })).toBeVisible();
await expect(page.getByRole("switch", { name: "Export redaction by default" })).toBeChecked();
await page.locator("label.preference-option").filter({ hasText: "Local browser time" }).click();
await expect(page.getByRole("status").filter({ hasText: "Preferences saved" })).toBeVisible();
await page.getByRole("switch", { name: "Export redaction by default" }).press("Space");
await page.getByLabel("Default noise mode").selectOption("all");
await page.getByLabel("Default workspace").selectOption("hunting");
await page.getByRole("radio", { name: /Compact/ }).press("Space");
await page.reload();
await expect(page.getByRole("radio", { name: /Local browser time/ })).toBeChecked();
await expect(page.getByRole("switch", { name: "Export redaction by default" })).not.toBeChecked();
await expect(page.getByLabel("Default noise mode")).toHaveValue("all");
await expect(page.getByLabel("Default workspace")).toHaveValue("hunting");
await expect(page.getByRole("radio", { name: /Compact/ })).toBeChecked();
const storedKeys = await page.evaluate(() => Object.keys(localStorage));
expect(storedKeys).toEqual(["eventlens.preferences.v1"]);
await page.getByText("Technical details", { exact: true }).press("Enter");
await expect(page.getByText("eventlens.preferences.v1", { exact: true })).toBeVisible();
await page.getByRole("button", { name: "Reset all preferences" }).press("Enter");
await expect(page.getByRole("status").filter({ hasText: "Preferences reset to defaults" })).toBeVisible();
await expect(page.getByRole("radio", { name: /^UTC/ })).toBeChecked();
await expect(page.getByRole("switch", { name: "Export redaction by default" })).toBeChecked();
await expect(page.getByLabel("Default noise mode")).toHaveValue("attention");
await expect(page.getByLabel("Default workspace")).toHaveValue("analysis");
});
test("a browser-local default workspace applies only without a deep-link override", async ({ page }) => {
await page.goto("/#settings");
await page.getByLabel("Default workspace").selectOption("hunting");
await page.goto("/");
await expect(page).toHaveURL(/#hunting$/);
await expect(page.getByRole("heading", { name: "Hunting", exact: true })).toBeVisible();
await page.goto("/#timeline");
await expect(page).toHaveURL(/#timeline$/);
await expect(page.getByRole("heading", { name: "Timeline", exact: true })).toBeVisible();
});
test("the active Settings tab remains visible in the compact workspace navigation", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/#settings");
const settingsTab = page.getByRole("button", { name: "Settings", exact: true });
await expect(settingsTab).toHaveAttribute("aria-current", "page");
const box = await settingsTab.boundingBox();
expect(box).not.toBeNull();
expect(box!.x).toBeGreaterThanOrEqual(0);
expect(box!.x + box!.width).toBeLessThanOrEqual(390);
});