import { test, expect, loginAs } from "./fixtures"; // Dashboard "Today" and "Waiting for you", and the Ctrl+K command palette (1.49.0). test.describe("dashboard and command palette", () => { test("the admin dashboard shows what's on today and what's waiting", async ({ page }) => { await loginAs(page, "admin"); await page.goto("/dashboard/admin"); const today = page.getByTestId("today-panel"); await expect(today).toBeVisible(); // Seeded on today: the hidden kids church and serving Sunday. await expect(today.getByTestId("today-events")).toContainText("E2E Serving Sunday"); await expect(today.getByText("Waiting for you")).toBeVisible(); }); test("Ctrl+K finds an event and opens it", async ({ page }) => { await loginAs(page, "supervisor"); await page.goto("/dashboard/supervisor"); await expect(page.getByTestId("today-panel")).toBeVisible(); await page.keyboard.press("Control+k"); const dialog = page.getByRole("dialog", { name: "Go to or search" }); await expect(dialog).toBeVisible(); await dialog.getByRole("combobox", { name: "Search" }).fill("Paid Conference"); await expect(dialog.getByRole("option", { name: /E2E Paid Conference/ })).toBeVisible(); await page.keyboard.press("Enter"); await expect(page).toHaveURL(/\/dashboard\/supervisor\/events/); await expect(page.getByRole("heading", { name: "Edit Event" })).toBeVisible(); await expect(page.getByPlaceholder("Event title")).toHaveValue("E2E Paid Conference"); }); test("the palette's actions and pages follow the role", async ({ page }) => { await loginAs(page, "supervisor"); await page.goto("/dashboard/supervisor"); await page.getByRole("button", { name: /Search or jump to/ }).click(); const dialog = page.getByRole("dialog", { name: "Go to or search" }); await dialog.getByRole("combobox", { name: "Search" }).fill("new event"); await dialog.getByRole("option", { name: "New event" }).click(); await expect(page.getByRole("heading", { name: "New Event" })).toBeVisible(); // Staff don't get admin pages. await loginAs(page, "staff"); await page.goto("/dashboard/staff"); await page.keyboard.press("Control+k"); const staffDialog = page.getByRole("dialog", { name: "Go to or search" }); await staffDialog.getByRole("combobox", { name: "Search" }).fill("users"); await expect(staffDialog.getByRole("option", { name: "Users" })).toHaveCount(0); await staffDialog.getByRole("combobox", { name: "Search" }).fill("scan"); await expect(staffDialog.getByRole("option", { name: "Scan tickets" })).toBeVisible(); }); });