import { expect, test } from "@playwright/test"; test("root redirects to agents with nav counters", async ({ page }) => { await page.goto("/"); await expect(page).toHaveURL(/\/agents$/); await expect(page.getByRole("heading", { name: "Agents" })).toBeVisible(); await expect(page.getByRole("link", { name: /Agents.*1.*1/ })).toBeVisible(); await expect(page.getByRole("link", { name: /Checks.*2.*1.*1/ })).toBeVisible(); await expect(page.getByRole("link", { name: /Incidents.*2/ })).toBeVisible(); }); test("agents list links to detail", async ({ page }) => { await page.goto("/agents?sort=status&dir=desc"); await expect(page).toHaveURL(/\/agents$/); await page.goto("/agents"); await expect(page.getByRole("heading", { name: "Agents" })).toBeVisible(); await expect(page.locator("thead")).not.toContainText("hostname"); await expect(page.locator("thead")).toContainText("features"); await expect(page.locator("thead")).not.toContainText("asc"); await expect(page.locator("thead")).not.toContainText("desc"); await expect(page.locator("thead")).toContainText("↓"); await expect(page.locator("body")).toContainText("checks 3"); await expect(page.locator("body")).toContainText("warn 1"); await expect(page.getByRole("button", { name: /Timezone: default/ })).toBeVisible(); await page.getByRole("button", { name: /Timezone: default/ }).click(); await expect(page.getByRole("button", { name: /Timezone: browser/ })).toBeVisible(); await page.getByRole("button", { name: /Timezone: browser/ }).click(); await expect(page.getByRole("button", { name: /Timezone: utc \(UTC\)/ })).toBeVisible(); await expect(page.locator("tbody")).toContainText("UTC"); await page.getByPlaceholder("search agent").fill("host-1"); await expect(page).toHaveURL(/\/agents$/); await expect(page.locator("tbody")).toContainText("host-1"); await expect(page.locator("tbody")).not.toContainText("host-2"); await page.getByRole("button", { name: "host" }).click(); await expect(page).toHaveURL(/\/agents$/); await page.getByRole("button", { name: "clear" }).click(); await page.getByRole("link", { name: "agent-1" }).first().click(); await expect(page).toHaveURL(/\/agents\/agent-1$/); await expect(page.locator("body")).toContainText("hostname"); await expect(page.getByRole("link", { name: "Checks" }).last()).toBeVisible(); await expect(page.locator("tbody").first().locator("tr").first()).toContainText("warning"); await expect(page.locator("thead").first()).not.toContainText("incident_key"); await expect(page.locator("thead").first()).not.toContainText("exit"); await expect(page.locator("tbody").first()).toContainText("load high"); await page.getByRole("link", { name: "check_id" }).click(); await expect(page).toHaveURL(/sort=check_id/); await page.getByRole("link", { name: "Events" }).last().click(); await expect(page).toHaveURL(/tab=events.*sort=check_id|sort=check_id.*tab=events/); await expect(page.locator("thead").first()).not.toContainText("exit"); await page.getByRole("link", { name: "Checks" }).last().click(); await expect(page).toHaveURL(/tab=checks.*sort=check_id|sort=check_id.*tab=checks/); }); test("checks page lists rows", async ({ page }) => { await page.goto("/checks"); await expect(page.getByRole("heading", { name: "Checks" })).toBeVisible(); await expect(page).toHaveURL(/\/checks$/); await expect(page.locator("thead").first()).not.toContainText("agent_id"); await expect(page.locator("thead").first()).not.toContainText("incident_key"); await expect(page.locator("thead").first()).not.toContainText("exit"); await expect(page.locator("thead").first()).toContainText("↓"); await expect(page.locator("body")).toContainText("disk"); await expect(page.locator("body")).toContainText("load"); await expect(page.locator("body")).toContainText("agent_liveness"); await page.getByPlaceholder("search check").fill("lo"); await expect(page).toHaveURL(/\/checks$/); await expect(page.locator("tbody")).toContainText("load"); await expect(page.locator("tbody")).not.toContainText("disk"); await page.getByRole("button", { name: "clear" }).click(); await page.getByRole("button", { name: /^CHECK/ }).click(); await expect(page).toHaveURL(/\/checks$/); await page.getByRole("link", { name: "disk" }).click(); await expect(page).toHaveURL(/\/checks\/disk$/); await expect(page.getByRole("link", { name: "Agents" }).last()).toBeVisible(); await expect(page.locator("body")).toContainText("host-1"); await expect(page.locator("body")).toContainText("disk ok"); await page.getByRole("link", { name: "Events" }).last().click(); await expect(page).toHaveURL(/\/checks\/disk\?tab=events(?:&events_limit=\d+)?$/); await expect(page.locator("body")).toContainText("12"); await expect(page.locator("thead").last()).not.toContainText("exit"); }); test("incidents filter renders", async ({ page }) => { await page.goto("/incidents"); await expect(page.locator("body")).toContainText("load high"); await expect(page.locator("thead")).toContainText("HOST"); await expect(page.locator("thead")).not.toContainText("agent_id"); await expect(page.locator("tbody")).toContainText("host-1"); await expect(page.locator("tbody")).toContainText("agent_liveness"); await expect(page.locator("tbody")).toContainText("agent is dead"); await page.getByRole("link", { name: "agent_liveness" }).click(); await expect(page).toHaveURL(/\/checks\/agent_liveness$/); await expect(page.locator("body")).toContainText("host-2"); await page.goto("/incidents"); await page.getByRole("link", { name: "host-1" }).first().click(); await expect(page).toHaveURL(/\/agents\/agent-1$/); }); test("events page", async ({ page }) => { await page.goto("/events"); await expect(page.locator("body")).toContainText("agent_liveness"); await expect(page.locator("body")).toContainText("agent is dead"); await page.goto("/events?agent_id=agent-1&check_id=disk"); await expect(page.getByRole("heading", { name: "Events" })).toBeVisible(); await expect(page.getByRole("button", { name: "query" })).toHaveCount(0); await expect(page.getByRole("link", { name: /agent_id=.*agent-1/ })).toBeVisible(); await expect(page.getByRole("link", { name: /check_id=.*disk/ })).toBeVisible(); }); test("events page loads the next cursor page on scroll", async ({ page }) => { await page.goto("/events"); await expect(page.locator("tbody")).toContainText("disk extra 7"); await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); await expect(page.locator("tbody")).toContainText("disk extra 11"); await expect(page).toHaveURL(/\/events$/); }); test("outbox page", async ({ page }) => { await page.goto("/outbox"); await expect(page.locator("body")).toContainText("debug"); });