|
| 1 | +import { test, expect, type Page } from "@playwright/test"; |
| 2 | +import { mkdirSync } from "node:fs"; |
| 3 | +import { join } from "node:path"; |
| 4 | + |
| 5 | +// Captures PNGs of the key web UI states into web/screenshots/output/ so an |
| 6 | +// agent (or human) can visually verify UI changes. Run via `task screenshots`. |
| 7 | +// |
| 8 | +// When the theme engine lands (nibs-vmaq), extend this to loop the captures |
| 9 | +// once per theme. When the board view lands (nibs-sg09), add a capture for it. |
| 10 | + |
| 11 | +const OUT = join(import.meta.dirname, "output"); |
| 12 | +mkdirSync(OUT, { recursive: true }); |
| 13 | + |
| 14 | +const VIEW_LEVELS = ["milestones", "epics", "backlog"] as const; |
| 15 | + |
| 16 | +async function openApp(page: Page, viewLevel: (typeof VIEW_LEVELS)[number] = "milestones") { |
| 17 | + await page.addInitScript(level => { |
| 18 | + localStorage.setItem( |
| 19 | + "nibs-filter-preferences", |
| 20 | + JSON.stringify({ filter: {}, viewLevel: level }), |
| 21 | + ); |
| 22 | + }, viewLevel); |
| 23 | + await page.goto("/"); |
| 24 | + await expect(page.locator("tr[data-nib-id]").first()).toBeVisible({ timeout: 10_000 }); |
| 25 | +} |
| 26 | + |
| 27 | +function shot(page: Page, name: string) { |
| 28 | + return page.screenshot({ path: join(OUT, `${name}.png`), animations: "disabled" }); |
| 29 | +} |
| 30 | + |
| 31 | +for (const level of VIEW_LEVELS) { |
| 32 | + test(`table — ${level} view level`, async ({ page }) => { |
| 33 | + await openApp(page, level); |
| 34 | + await shot(page, `table-${level}`); |
| 35 | + }); |
| 36 | +} |
| 37 | + |
| 38 | +test("detail panel", async ({ page }) => { |
| 39 | + await openApp(page); |
| 40 | + await page.locator("tr[data-nib-id]").first().locator('[data-action="title"]').click(); |
| 41 | + await expect(page.locator('[data-testid="detail-panel"]')).toBeVisible({ timeout: 5_000 }); |
| 42 | + await expect(page.locator('[data-testid="detail-loading"]')).toBeHidden({ timeout: 5_000 }); |
| 43 | + await shot(page, "detail-panel"); |
| 44 | +}); |
| 45 | + |
| 46 | +test("editor modal", async ({ page }) => { |
| 47 | + await openApp(page); |
| 48 | + await page.locator("tr[data-nib-id]").first().click({ button: "right" }); |
| 49 | + await expect(page.locator('[data-testid="context-menu"]')).toBeVisible({ timeout: 3_000 }); |
| 50 | + await page.locator('[data-testid="ctx-edit"]').click(); |
| 51 | + await expect(page.locator('[data-testid="editor-modal"]')).toBeVisible({ timeout: 5_000 }); |
| 52 | + // Wait for the CodeMirror editor to mount so the body area isn't blank. |
| 53 | + await expect(page.locator(".cm-content").first()).toBeVisible({ timeout: 5_000 }); |
| 54 | + await shot(page, "editor-modal"); |
| 55 | +}); |
| 56 | + |
| 57 | +test("context menu", async ({ page }) => { |
| 58 | + await openApp(page); |
| 59 | + await page.locator("tr[data-nib-id]").first().click({ button: "right" }); |
| 60 | + await expect(page.locator('[data-testid="context-menu"]')).toBeVisible({ timeout: 3_000 }); |
| 61 | + await shot(page, "context-menu"); |
| 62 | +}); |
0 commit comments