SPB Git
4.6 KB · 52 lines typescript
1import { test, expect } from "@playwright/test";2test("home renders, search autocompletes and navigates", async ({ page }) => {3  await page.goto("/"); await expect(page.getByRole("heading", { level: 1 })).toContainText("encyclopedia");4  const box = page.getByRole("combobox", { name: "Search tools" }).first(); await box.fill("duck");5  await expect(page.getByRole("listbox").first()).toBeVisible(); await box.press("ArrowDown"); await box.press("Enter");6  await expect(page).toHaveURL(/\/tools\/duckdb/); await expect(page.getByRole("heading", { level: 1 })).toHaveText(/DuckDB/);7});8test("directory: query, filter toggle, sort and shareable URL", async ({ page }) => {9  await page.goto("/tools?q=database"); await expect(page.getByText(/tools · lexical search/)).toBeVisible();10  const disclosure = page.locator("summary", { hasText: "Filters" }); if (await disclosure.isVisible()) await disclosure.click();11  const first = page.getByRole("link", { name: "Open source", exact: false }).first(); await first.click();12  await expect(page).toHaveURL(/source=open-source/); await expect(page.getByText("Share this view")).toBeVisible();13  await page.getByRole("link", { name: "Name" }).click(); await expect(page).toHaveURL(/sort=name/);14  await page.getByRole("link", { name: "Clear all" }).click(); await expect(page).toHaveURL(/\/tools\?q=database$/);15});16test("empty state", async ({ page }) => { await page.goto("/tools?q=zzqqxxnotatool"); await expect(page.getByText(/No tools match/)).toBeVisible(); });17test("tool page shows sources, facts, alternatives and compare link; JSON-LD present", async ({ page }) => {18  await page.goto("/tools/duckdb");19  await expect(page.getByRole("heading", { name: "Sources & verification" })).toBeVisible();20  await expect(page.getByRole("heading", { name: "Capabilities" })).toBeVisible();21  await expect(page.getByRole("link", { name: /Visit official site/ })).toHaveAttribute("href", /duckdb\.org/);22  expect(await page.locator('script[type="application/ld+json"]').count()).toBeGreaterThanOrEqual(2);23  await page.getByRole("link", { name: "Compare DuckDB with other tools" }).click(); await expect(page).toHaveURL(/compare\?tools=duckdb/);24});25test("compare renders facts and editorial tables", async ({ page }) => {26  await page.goto("/compare?tools=duckdb,sqlite,postgresql");27  await expect(page.getByRole("heading", { name: "Documented facts" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Editorial assessment" })).toBeVisible();28  await expect(page.getByRole("columnheader", { name: "DuckDB" }).first()).toBeVisible();29});30test("categories and collections navigate", async ({ page }) => {31  await page.goto("/categories"); await page.getByRole("link", { name: /Analytical engines/ }).first().click(); await expect(page).toHaveURL(/categories\/analytics-engines/);32  await page.goto("/collections"); await page.getByRole("link", { name: /Apple Silicon AI/ }).click(); await expect(page.getByRole("heading", { level: 1 })).toHaveText(/Apple Silicon AI/);33});34test("keyboard: slash focuses search, skip link works", async ({ page }) => {35  await page.goto("/about"); await page.keyboard.press("/"); await expect(page.getByRole("combobox", { name: "Search tools" }).first()).toBeFocused();36  await page.goto("/"); await page.keyboard.press("Tab"); await expect(page.getByRole("link", { name: "Skip to content" })).toBeFocused();37});38test("robots, sitemap and health", async ({ request }) => {39  const r = await request.get("/robots.txt"); expect(await r.text()).toContain("Disallow: /admin");40  const s = await request.get("/sitemap.xml"); const x = await s.text(); expect(x).toContain("/tools/duckdb"); expect(x).not.toContain("/admin");41  const h = await request.get("/api/health"); expect((await h.json()).ok).toBe(true);42});43test("no-JS fallback: directory and tool page are server-rendered", async ({ browser }) => {44  const ctx = await browser.newContext({ javaScriptEnabled: false }); const page = await ctx.newPage();45  await page.goto("/tools?q=python"); await expect(page.getByRole("heading", { level: 1 })).toContainText("python"); expect(await page.getByRole("article").count()).toBeGreaterThan(0);46  await page.goto("/tools/python"); await expect(page.getByRole("heading", { name: "Overview" })).toBeVisible(); await ctx.close();47});48test("error report form submits", async ({ page }) => {49  await page.goto("/tools/duckdb"); await page.getByLabel("What is wrong?").fill("E2E test report: nothing is wrong, this is a smoke test.");50  await page.getByRole("button", { name: "Send report" }).click(); await expect(page.getByText(/Report received\.|Too many reports/)).toBeVisible();51});52
Files · laptop-initial-20261102
Menu

Theme