import { test, expect } from "@playwright/test"; test("home renders, search autocompletes and navigates", async ({ page }) => { await page.goto("/"); await expect(page.getByRole("heading", { level: 1 })).toContainText("encyclopedia"); const box = page.getByRole("combobox", { name: "Search tools" }).first(); await box.fill("duck"); await expect(page.getByRole("listbox").first()).toBeVisible(); await box.press("ArrowDown"); await box.press("Enter"); await expect(page).toHaveURL(/\/tools\/duckdb/); await expect(page.getByRole("heading", { level: 1 })).toHaveText(/DuckDB/); }); test("directory: query, filter toggle, sort and shareable URL", async ({ page }) => { await page.goto("/tools?q=database"); await expect(page.getByText(/tools ยท lexical search/)).toBeVisible(); const disclosure = page.locator("summary", { hasText: "Filters" }); if (await disclosure.isVisible()) await disclosure.click(); const first = page.getByRole("link", { name: "Open source", exact: false }).first(); await first.click(); await expect(page).toHaveURL(/source=open-source/); await expect(page.getByText("Share this view")).toBeVisible(); await page.getByRole("link", { name: "Name" }).click(); await expect(page).toHaveURL(/sort=name/); await page.getByRole("link", { name: "Clear all" }).click(); await expect(page).toHaveURL(/\/tools\?q=database$/); }); test("empty state", async ({ page }) => { await page.goto("/tools?q=zzqqxxnotatool"); await expect(page.getByText(/No tools match/)).toBeVisible(); }); test("tool page shows sources, facts, alternatives and compare link; JSON-LD present", async ({ page }) => { await page.goto("/tools/duckdb"); await expect(page.getByRole("heading", { name: "Sources & verification" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Capabilities" })).toBeVisible(); await expect(page.getByRole("link", { name: /Visit official site/ })).toHaveAttribute("href", /duckdb\.org/); expect(await page.locator('script[type="application/ld+json"]').count()).toBeGreaterThanOrEqual(2); await page.getByRole("link", { name: "Compare DuckDB with other tools" }).click(); await expect(page).toHaveURL(/compare\?tools=duckdb/); }); test("compare renders facts and editorial tables", async ({ page }) => { await page.goto("/compare?tools=duckdb,sqlite,postgresql"); await expect(page.getByRole("heading", { name: "Documented facts" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Editorial assessment" })).toBeVisible(); await expect(page.getByRole("columnheader", { name: "DuckDB" }).first()).toBeVisible(); }); test("categories and collections navigate", async ({ page }) => { await page.goto("/categories"); await page.getByRole("link", { name: /Analytical engines/ }).first().click(); await expect(page).toHaveURL(/categories\/analytics-engines/); await page.goto("/collections"); await page.getByRole("link", { name: /Apple Silicon AI/ }).click(); await expect(page.getByRole("heading", { level: 1 })).toHaveText(/Apple Silicon AI/); }); test("keyboard: slash focuses search, skip link works", async ({ page }) => { await page.goto("/about"); await page.keyboard.press("/"); await expect(page.getByRole("combobox", { name: "Search tools" }).first()).toBeFocused(); await page.goto("/"); await page.keyboard.press("Tab"); await expect(page.getByRole("link", { name: "Skip to content" })).toBeFocused(); }); test("robots, sitemap and health", async ({ request }) => { const r = await request.get("/robots.txt"); expect(await r.text()).toContain("Disallow: /admin"); const s = await request.get("/sitemap.xml"); const x = await s.text(); expect(x).toContain("/tools/duckdb"); expect(x).not.toContain("/admin"); const h = await request.get("/api/health"); expect((await h.json()).ok).toBe(true); }); test("no-JS fallback: directory and tool page are server-rendered", async ({ browser }) => { const ctx = await browser.newContext({ javaScriptEnabled: false }); const page = await ctx.newPage(); await page.goto("/tools?q=python"); await expect(page.getByRole("heading", { level: 1 })).toContainText("python"); expect(await page.getByRole("article").count()).toBeGreaterThan(0); await page.goto("/tools/python"); await expect(page.getByRole("heading", { name: "Overview" })).toBeVisible(); await ctx.close(); }); test("error report form submits", async ({ page }) => { await page.goto("/tools/duckdb"); await page.getByLabel("What is wrong?").fill("E2E test report: nothing is wrong, this is a smoke test."); await page.getByRole("button", { name: "Send report" }).click(); await expect(page.getByText(/Report received\.|Too many reports/)).toBeVisible(); });