import AxeBuilder from "@axe-core/playwright"; import { test, expect, loginAs, api, v2 } from "./fixtures"; // 1.50.2: event dropdowns are a searchable picker — upcoming events first, past ones a click // away, and typing searches them all. test.describe("event picker", () => { test("opens on upcoming events; past ones are behind a button or found by searching", async ({ page }) => { const start = new Date(Date.now() - 40 * 864e5); await v2(page, "supervisor", "POST", "/api/v2/events", { title: "E2E Picker Old Gathering", description: "A past event for the picker test.", price: 0, location: "1 Test Street, Pretoria", startDate: start.toISOString(), endDate: new Date(start.getTime() + 2 * 3600e3).toISOString(), }); await loginAs(page, "supervisor"); await page.goto("/dashboard/supervisor/email-attendees"); await page.getByRole("button", { name: /^Event: Select an event/ }).click(); const list = page.getByRole("listbox", { name: "Events" }); await expect(list.getByRole("option", { name: /E2E Free Evening/ })).toBeVisible(); await expect(list.getByRole("option", { name: /E2E Picker Old Gathering/ })).toHaveCount(0); // The open picker passes the WCAG 2.2 AA checks. const axe = await new AxeBuilder({ page }).include("[data-testid=event-picker]").withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]).analyze(); expect(axe.violations.map((v) => `${v.id}: ${v.nodes.map((n) => n.target.join(" ")).join(", ")}`)).toEqual([]); await page.getByRole("button", { name: /^Show past events/ }).click(); await expect(list.getByRole("option", { name: /E2E Picker Old Gathering/ })).toBeVisible(); await page.getByRole("button", { name: "Hide past events" }).click(); // Searching finds past events too; the keyboard chooses. const search = page.getByRole("combobox", { name: "Search events" }); await search.fill("old gathering"); await expect(list.getByRole("option")).toHaveCount(1); await search.press("Enter"); await expect(page.getByRole("button", { name: /^Event: E2E Picker Old Gathering/ })).toBeFocused(); // Escape closes without changing anything. await page.keyboard.press("ArrowDown"); await expect(list).toBeVisible(); await page.keyboard.press("Escape"); await expect(list).toBeHidden(); await expect(page.getByRole("button", { name: /^Event: E2E Picker Old Gathering/ })).toBeVisible(); }); test("the reports event list can be searched", async ({ page }) => { await loginAs(page, "admin"); await page.goto("/dashboard/supervisor/reports"); await page.getByRole("button", { name: /^Events:/ }).click(); await page.getByRole("button", { name: "Clear", exact: true }).click(); await page.getByLabel("Search events").fill("alpha"); await page.getByRole("button", { name: /^Select these 1$/ }).click(); await expect(page.getByRole("button", { name: "Events: E2E Alpha Course" })).toBeVisible(); }); });