Files

78 lines
4.4 KiB
TypeScript

import { expect, test } from "@playwright/test";
test("all workspaces are actionable and preserve the loaded analysis", async ({ page }) => {
await page.goto("/#analysis");
await page.getByRole("button", { name: "Load demo", exact: true }).first().click();
for (const workspace of ["Analysis", "Timeline", "Hunting", "Reports", "Settings"]) {
const button = page.getByRole("button", { name: workspace, exact: false }).first();
await expect(button).toBeEnabled();
await button.click();
await expect(button).toHaveAttribute("aria-current", "page");
}
await expect(page.getByRole("region", { name: "Local preferences context" })).toBeVisible();
await expect(page.getByRole("region", { name: "Current investigation context" })).toHaveCount(0);
await page.getByRole("button", { name: "Timeline", exact: false }).click();
await expect(page.getByRole("heading", { name: "Event timeline", exact: true })).toBeVisible();
await expect(page.getByRole("heading", { name: "Inspector", exact: true })).toBeVisible();
await page.goBack();
await expect(page.getByRole("heading", { name: "Settings", exact: true })).toBeVisible();
await page.goForward();
await expect(page.getByRole("heading", { name: "Event timeline", exact: true })).toBeVisible();
});
test("context and global actions keep an ordered, workspace-appropriate layout", async ({ page }) => {
await page.goto("/#analysis");
await page.getByRole("button", { name: "Load demo", exact: true }).first().click();
const geometry = await page.evaluate(() => {
const rect = (selector: string) => document.querySelector(selector)?.getBoundingClientRect();
const topbar = rect(".event-topbar");
const context = rect(".investigation-context");
const actions = rect(".global-actions");
return { topbar, context, actions };
});
expect(geometry.topbar?.bottom).toBeLessThanOrEqual((geometry.context?.top ?? 0) + 1);
expect(geometry.context?.bottom).toBeLessThanOrEqual((geometry.actions?.top ?? 0) + 1);
await page.getByRole("button", { name: "Settings", exact: true }).click();
await expect(page.getByRole("region", { name: "Local preferences context" })).toBeVisible();
await expect(page.getByRole("region", { name: "Current investigation context" })).toHaveCount(0);
await expect(page.getByRole("region", { name: "Analysis actions" })).toBeVisible();
await expect(page.getByText("Source", { exact: true })).toHaveCount(0);
});
test("Hunting combines facets and opens a result in the inspector", async ({ page }) => {
await page.goto("/#analysis");
await page.getByRole("button", { name: "Load demo", exact: true }).first().click();
await page.getByRole("button", { name: "Hunting", exact: false }).click();
await page.getByRole("textbox", { name: "Search hunting evidence" }).fill("DNS name resolution");
await expect(page.getByRole("status")).toHaveText("1 of 6 matching events");
await expect(page.getByRole("button", { name: /DNS name resolution timed out/ })).toBeVisible();
await page.getByRole("button", { name: /DNS name resolution timed out/ }).click();
await expect(page.getByRole("heading", { name: "Inspector", exact: true })).toBeVisible();
await expect(page.getByRole("heading", { name: "DNS name resolution timed out", exact: true })).toBeVisible();
await page.getByRole("button", { name: "Open in Timeline", exact: false }).click();
await expect(page).toHaveURL(/#timeline$/);
await expect(page.getByRole("heading", { name: "Event timeline", exact: true })).toBeVisible();
});
test("Settings persist preferences without persisting event data", async ({ page }) => {
await page.goto("/#settings");
await page.getByRole("radio", { name: /Local browser time/ }).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.getByLabel("Local browser time", { exact: false })).toBeChecked();
await expect(page.getByLabel("Default noise mode")).toHaveValue("all");
await expect(page.getByLabel("Default workspace")).toHaveValue("hunting");
await expect(page.getByLabel("Compact", { exact: false })).toBeChecked();
const stored = await page.evaluate(() => JSON.stringify(localStorage));
expect(stored).toContain("eventlens.preferences.v1");
expect(stored).not.toContain("bundled-demo");
expect(stored).not.toContain("Example Sync Service");
});