import { test, expect, loginAs } from "./fixtures"; // Saved filters on list pages (1.49.2): save the current filters, make them the default (applied // when the page opens), and delete them again. test("an admin saves a registrations filter as the default, and deletes it", async ({ page }) => { await loginAs(page, "admin"); await page.goto("/dashboard/admin/registrations"); const status = page.locator("select").filter({ has: page.locator("option", { hasText: "All statuses" }) }); await status.selectOption("cancelled"); const saved = page.getByTestId("saved-filters"); await saved.getByRole("button", { name: /Saved filters/ }).click(); await saved.getByLabel("Save the current filters as").fill("Cancelled ones"); await saved.getByLabel("Use when this page opens").check(); await saved.getByRole("button", { name: "Save", exact: true }).click(); await expect(saved.getByRole("button", { name: "Cancelled ones" }).first()).toBeVisible(); // The default is applied when the page opens… await page.reload(); await expect(status).toHaveValue("cancelled"); await expect(saved.getByRole("button", { name: /Cancelled ones/ }).first()).toBeVisible(); // …but not over a link that says what to show. await page.goto("/dashboard/admin/registrations?status=paid"); await expect(status).toHaveValue("paid"); await saved.getByRole("button", { name: /Saved filters/ }).click(); page.once("dialog", d => d.accept()); await saved.getByRole("button", { name: "Delete Cancelled ones" }).click(); await expect(saved.getByText("No saved filters yet")).toBeVisible(); await page.goto("/dashboard/admin/registrations"); await expect(status).toHaveValue(""); });