const { test, expect } = require("../../node_modules/@playwright/test"); test.skip(process.env.PLAYWRIGHT_LIVE_STACK === "1", "Stub-only UI smoke test"); test.beforeEach(async ({ request }) => { await request.post("/__reset"); }); test("editor can filter archived records and archive/unarchive from the UI", async ({ page }) => { const archiveFilters = page.locator("#archive-filter-group"); const speciesList = page.locator("#species-list"); await page.goto("/"); await page.getByPlaceholder("Bearer token for editor access").fill("editor-token"); await page.getByRole("button", { name: "Use Token" }).click(); await expect(archiveFilters).toBeVisible(); await expect(archiveFilters.getByRole("button", { name: "Active", exact: true })).toHaveClass(/is-active/); await expect(speciesList.getByRole("button", { name: /Active Shad/ })).toBeVisible(); await expect(speciesList.getByRole("button", { name: /Archived Shad/ })).toHaveCount(0); await archiveFilters.getByRole("button", { name: "All", exact: true }).click(); await expect(speciesList.getByRole("button", { name: /Archived Shad/ })).toBeVisible(); await speciesList.getByRole("button", { name: /Active Shad/ }).click(); await expect(page.getByText("Archive this species")).toBeVisible(); await expect(page.locator("#editor-is-archived")).not.toBeChecked(); await page.locator("#editor-is-archived").check(); await page.getByRole("button", { name: "Save Editorial Changes" }).click(); await expect(page.locator("#detail-archive-badge")).toBeVisible(); await expect(page.locator("#detail-archive-note")).toBeVisible(); await archiveFilters.getByRole("button", { name: "Archived", exact: true }).click(); await expect(speciesList.getByRole("button", { name: /Active Shad/ })).toBeVisible(); await speciesList.getByRole("button", { name: /Active Shad/ }).click(); await expect(page.locator("#editor-is-archived")).toBeChecked(); await page.locator("#editor-is-archived").uncheck(); await page.getByRole("button", { name: "Save Editorial Changes" }).click(); await archiveFilters.getByRole("button", { name: "Active", exact: true }).click(); await expect(speciesList.getByRole("button", { name: /Active Shad/ })).toBeVisible(); await expect(page.locator("#detail-archive-badge")).toBeHidden(); });