diff --git a/e2e/tests/deep-check.spec.ts b/e2e/tests/deep-check.spec.ts new file mode 100644 index 0000000..d3631a0 --- /dev/null +++ b/e2e/tests/deep-check.spec.ts @@ -0,0 +1,47 @@ +import { test, expect } from "@playwright/test"; + +const USERNAME = process.env.LOCAL_USERNAME ?? "admin"; +const PASSWORD = process.env.LOCAL_PASSWORD ?? ""; + +test("deep check button runs a check and shows results for an unknown device", async ({ page }) => { + test.skip(!PASSWORD, "LOCAL_PASSWORD not set"); + + await page.goto("/"); + await page.getByPlaceholder("Username").fill(USERNAME); + await page.getByPlaceholder("Password").fill(PASSWORD); + await page.getByRole("button", { name: "Sign in" }).click(); + await expect(page.locator(".device-table tbody tr").first()).toBeVisible({ timeout: 15_000 }); + + const unknownRow = page.locator(".device-table tbody tr").filter({ hasText: "unknown" }).first(); + await expect(unknownRow).toBeVisible(); + + const button = unknownRow.getByRole("button", { name: /deep check|checking/i }); + await expect(button).toBeVisible(); + await button.click(); + + await expect(button).toHaveText("Checking…"); + // Bounded by the script's own timeouts (well under 15s) plus SSH round trip. + await expect(page.locator(".deep-check-row").first()).toBeVisible({ timeout: 20_000 }); + await expect(button).toHaveText("Deep check"); + + // Either real findings (SSDP/mDNS/ports) or the explicit "nothing found" + // message -- either way, a result panel with actual content, not empty. + const resultRow = page.locator(".deep-check-row").first(); + await expect(resultRow).not.toBeEmpty(); +}); + +test("known devices have no deep check button", async ({ page }) => { + test.skip(!PASSWORD, "LOCAL_PASSWORD not set"); + + await page.goto("/"); + await page.getByPlaceholder("Username").fill(USERNAME); + await page.getByPlaceholder("Password").fill(PASSWORD); + await page.getByRole("button", { name: "Sign in" }).click(); + await expect(page.locator(".device-table tbody tr").first()).toBeVisible({ timeout: 15_000 }); + + // .device-badge.known specifically -- "known" is a substring of "unknown", + // so a text-based filter would match both (bit me on the labeling test too). + const knownRow = page.locator(".device-table tbody tr").filter({ has: page.locator(".device-badge.known") }).first(); + await expect(knownRow).toBeVisible(); + await expect(knownRow.getByRole("button", { name: /deep check/i })).toHaveCount(0); +});