import { test, expect } from "@playwright/test"; import { signInAs, resetDb, BASE } from "./dev"; /** Building the schedule out: add a service template, then generate instances. */ test.describe("services", () => { test.beforeAll(async ({ browser }) => { const context = await browser.newContext(); const page = await context.newPage(); await resetDb(page); await context.close(); }); test("admin can add a service and generate upcoming instances", async ({ page, }) => { await page.setViewportSize({ width: 1024, height: 900 }); await signInAs(page, "admin@glenloch.local"); await page.goto(`${BASE}/admin`); const name = `E2E Service ${Date.now()}`; await page.getByLabel("Name", { exact: true }).fill(name); await page.getByLabel("Start time").fill("17:00"); await page.getByLabel("Minutes").fill("60"); await page.getByLabel("Location").fill("Chapel"); await page.getByRole("button", { name: "Add service" }).click(); await expect(page.getByRole("cell", { name: new RegExp(name) })).toBeVisible(); await page.getByRole("button", { name: "Generate upcoming Sundays" }).click(); await expect( page.getByText(/Generated \d+ new service instance\(s\)/), ).toBeVisible(); }); });