import { test, expect, seed, loginAs, api, v2 } from "./fixtures"; // 1.50.1: long lists load a page (or just what's needed) at a time, with search and filters. test.describe("long lists", () => { test("Payments: today, recent and a person's payments for a refund", async ({ page }) => { // A donation recorded today for the seeded user (on an event no other test totals up). await v2(page, "supervisor", "POST", "/api/v2/payments", { amount: 77, method: "cash", isDonation: true, eventId: seed().events.conference, userId: seed().users.user.id, }); await loginAs(page, "supervisor"); await page.goto("/dashboard/supervisor/payments"); await expect(page.getByText("R 77.00").first()).toBeVisible(); // Refund: picking the person loads their payments. await page.locator("label", { hasText: "Refund" }).first().click(); await page.getByPlaceholder("Search by name, email or phone…").last().fill(seed().users.user.name); await page.getByRole("button", { name: new RegExp(seed().users.user.name) }).first().click(); await expect(page.locator("option", { hasText: "R 77.00" })).toHaveCount(1); }); test("Payments API: narrowing filters", async ({ page }) => { const userId = seed().users.user.id; const mine = await v2<{ data: { userId: string }[] }>(page, "supervisor", "GET", `/api/v2/payments?userId=${userId}&limit=200`); expect(mine.data.length).toBeGreaterThan(0); expect(mine.data.every((p) => p.userId === userId)).toBe(true); const unpaid = await v2<{ status: string }[]>(page, "supervisor", "GET", "/api/v2/registrations?unpaid=true"); expect(unpaid.every((r) => ["pending", "confirmed", "partial_paid"].includes(r.status))).toBe(true); }); test("Audit log: search and the full list of actions", async ({ page }) => { await loginAs(page, "admin"); await page.goto("/dashboard/admin/audit-log"); const action = page.getByLabel("Action"); await expect(action.locator("option", { hasText: "Bulk action on registrations" })).toHaveCount(1); await expect(action.locator("option", { hasText: "Webhook added, changed or deleted" })).toHaveCount(1); await page.getByLabel("Search").fill("nobody-matches-this-xyz"); await expect(page.getByText("No matching audit entries.")).toBeVisible(); await expect(page.getByText(/0 actions match the filters/)).toBeVisible(); await page.getByRole("button", { name: "Clear filters" }).click(); await expect(page.getByLabel("Search")).toHaveValue(""); }); test("Data requests: search", async ({ page }) => { const res = await v2<{ requests: unknown[]; total: number }>(page, "admin", "GET", "/api/v2/privacy/requests?status=closed&search=nobody-matches-this-xyz"); expect(res.requests).toEqual([]); expect(res.total).toBe(0); }); });