66 lines
3.7 KiB
TypeScript
66 lines
3.7 KiB
TypeScript
import { test, expect, seed, loginAs, API } from "./fixtures";
|
|
|
|
// Volunteer rosters (1.46.0): a supervisor adds a role and switches the free volunteer ticket on,
|
|
// a user signs up, can't make it and asks for cover, staff take the place over, then check in by
|
|
// scanning the event's QR code. "E2E Serving Sunday" is seeded hidden and on today.
|
|
test.describe.serial("volunteer rosters", () => {
|
|
test("a supervisor adds a role and switches the volunteer ticket on", async ({ page }) => {
|
|
await loginAs(page, "supervisor");
|
|
await page.goto(`/dashboard/supervisor/volunteers?event=${seed().events.serving}`);
|
|
await page.getByRole("button", { name: "Add a role" }).click();
|
|
await page.getByLabel("Role name").fill("Welcome team");
|
|
await page.getByLabel("People needed").fill("1");
|
|
await page.getByRole("button", { name: "Add role" }).click();
|
|
await expect(page.getByTestId("roster-role")).toContainText("Welcome team");
|
|
await expect(page.getByTestId("roster-totals")).toContainText("0 of 1");
|
|
|
|
await page.getByRole("tab", { name: "Volunteer ticket" }).click();
|
|
await page.getByRole("button", { name: /Add a free "Volunteer" ticket/ }).click();
|
|
await expect(page.getByLabel("Volunteer ticket")).not.toHaveValue("");
|
|
});
|
|
|
|
test("the volunteer ticket isn't offered publicly", async ({ request }) => {
|
|
const res = await request.get(`${API}/api/events/${seed().events.serving}`);
|
|
const ev = await res.json();
|
|
expect(ev.eventOptions.map((o: { name: string }) => o.name)).toEqual(["Entry"]);
|
|
});
|
|
|
|
test("a user signs up, then asks for cover", async ({ page }) => {
|
|
await loginAs(page, "user");
|
|
await page.goto(`/dashboard/user/serving?event=${seed().events.serving}`);
|
|
await page.getByTestId("open-role").filter({ hasText: "Welcome team" }).getByRole("button", { name: "Sign up" }).click();
|
|
await expect(page.getByRole("status")).toContainText("you're on the roster");
|
|
const shift = page.getByTestId("my-shift").filter({ hasText: "Welcome team" });
|
|
await expect(shift).toContainText("free volunteer ticket");
|
|
|
|
page.once("dialog", d => d.accept("Away that weekend"));
|
|
await shift.getByRole("button", { name: "Can't make it" }).click();
|
|
await expect(shift).toContainText("Cover requested");
|
|
});
|
|
|
|
test("staff take the place over, then check in with the QR code", async ({ page, request }) => {
|
|
await loginAs(page, "staff");
|
|
await page.goto("/dashboard/user/serving");
|
|
const cover = page.getByTestId("cover-request").filter({ hasText: "Welcome team" });
|
|
await expect(cover).toContainText("Away that weekend");
|
|
await cover.getByRole("button", { name: "Take over" }).click();
|
|
await expect(page.getByRole("status")).toContainText("taken over Welcome team");
|
|
await expect(page.getByTestId("my-shift").filter({ hasText: "Welcome team" })).toBeVisible();
|
|
|
|
// The QR code on the wall holds this; a phone camera opens the check-in page.
|
|
const qr = await request.get(`${API}/api/volunteers/manage/events/${seed().events.serving}/qr`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
|
|
const { qr: code } = await qr.json();
|
|
await page.goto(`/serve/check-in?code=${encodeURIComponent(code)}`);
|
|
await expect(page.getByTestId("volunteer-checked-in")).toContainText("Welcome team");
|
|
});
|
|
|
|
test("the roster shows who took over and checked in", async ({ page }) => {
|
|
await loginAs(page, "supervisor");
|
|
await page.goto(`/dashboard/supervisor/volunteers?event=${seed().events.serving}`);
|
|
const volunteer = page.getByTestId("roster-volunteer");
|
|
await expect(volunteer).toContainText(seed().users.staff.name);
|
|
await expect(volunteer).toContainText("(QR)");
|
|
await expect(page.getByTestId("roster-totals")).toContainText("1 checked in");
|
|
});
|
|
});
|