push to maple-street
This commit is contained in:
@@ -49,48 +49,61 @@ test.describe("assign mutations", () => {
|
||||
await page.goto(`${BASE}/schedule`);
|
||||
await expect(page).toHaveURL(`${BASE}/schedule`);
|
||||
|
||||
// The interactive editor mounts for coordinators: each open cell has an
|
||||
// assign <select>. Take the first instance row (Audio pre-assigned;
|
||||
// The interactive editor mounts for coordinators: each open cell opens the
|
||||
// ranked picker. Take the first instance row (Audio pre-assigned;
|
||||
// Livestream + Slides open).
|
||||
const row = page.locator("tbody tr").first();
|
||||
await expect(row.locator("select").first()).toBeVisible();
|
||||
await expect(row.getByRole("button", { name: /Choose volunteer/ }).first()).toBeVisible();
|
||||
|
||||
const audio = await cellForRole(page, row, "Audio");
|
||||
const livestream = await cellForRole(page, row, "Livestream");
|
||||
const slides = await cellForRole(page, row, "Slides");
|
||||
|
||||
// Clear the pre-assigned Audio seat so every seat in the row is open and a
|
||||
// free volunteer (Avery) can be assigned twice — the second trips rule 1.
|
||||
// free volunteer can be assigned twice — the second trips rule 1.
|
||||
await audio.locator("button", { hasText: "Clear" }).click();
|
||||
// Optimistic revert: the cell is open again and shows the assign picker.
|
||||
await expect(audio.locator("select")).toBeVisible();
|
||||
// Optimistic revert: the cell is open again and shows the ranked picker.
|
||||
await expect(
|
||||
audio.getByRole("button", { name: /Choose volunteer/ }),
|
||||
).toBeVisible();
|
||||
|
||||
// Assign Avery Kim to Livestream — the cell updates at once (optimistic):
|
||||
// the picker is replaced by the name + a Clear control, no full reload.
|
||||
await livestream.locator("select").selectOption({ label: "Avery Kim" });
|
||||
// Assign Sam Okafor to Livestream. Sam is verified qualified on both the
|
||||
// Livestream and Slides skills.
|
||||
await livestream
|
||||
.getByRole("button", { name: /Choose volunteer/ })
|
||||
.click();
|
||||
const livestreamDialog = page.getByRole("dialog");
|
||||
await expect(livestreamDialog).toBeVisible();
|
||||
await livestreamDialog
|
||||
.locator("li")
|
||||
.filter({ hasText: "Sam Okafor" })
|
||||
.getByRole("button", { name: "Assign" })
|
||||
.click();
|
||||
await expect(
|
||||
livestream.locator("button", { hasText: "Clear" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
livestream.locator("span", { hasText: "Avery Kim" }),
|
||||
livestream.locator("span", { hasText: "Sam Okafor" }),
|
||||
).toBeVisible();
|
||||
|
||||
// Force a rule-1 duplicate: Avery already has Livestream, so assigning
|
||||
// Avery to Slides must roll back — the cell keeps its picker (stays open)
|
||||
// and an error toast shows the server's message.
|
||||
await slides.locator("select").selectOption({ label: "Avery Kim" });
|
||||
await expect(slides.locator("select")).toBeVisible();
|
||||
const toast = page
|
||||
.getByRole("status")
|
||||
.filter({ hasText: "Already assigned in this instance" });
|
||||
await expect(toast).toBeVisible();
|
||||
// The picker refuses the rule-1 duplicate in the UI: Sam is already serving
|
||||
// in this instance, so the excluded list explains why there is no Assign.
|
||||
await slides.getByRole("button", { name: /Choose volunteer/ }).click();
|
||||
const slidesDialog = page.getByRole("dialog");
|
||||
await slidesDialog
|
||||
.getByRole("button", { name: /unavailable \/ not eligible/i })
|
||||
.click();
|
||||
const samRow = slidesDialog.locator("li").filter({ hasText: "Sam Okafor" });
|
||||
await expect(samRow).toContainText("Already serving in this service");
|
||||
await expect(samRow.getByRole("button", { name: "Assign" })).toHaveCount(0);
|
||||
await page.getByRole("button", { name: "Close ranked picker" }).click();
|
||||
|
||||
// The successful optimistic assign is still live.
|
||||
await expect(
|
||||
livestream.locator("button", { hasText: "Clear" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
livestream.locator("span", { hasText: "Avery Kim" }),
|
||||
livestream.locator("span", { hasText: "Sam Okafor" }),
|
||||
).toBeVisible();
|
||||
|
||||
// No console or page errors while the mutations run.
|
||||
@@ -116,8 +129,11 @@ test.describe("assign mutations", () => {
|
||||
await page.goto(`${BASE}/schedule`);
|
||||
await expect(page).toHaveURL(`${BASE}/schedule`);
|
||||
|
||||
// Read-only grid: no per-cell assign <select> mounts for a volunteer.
|
||||
const assignControls = await page.locator("tbody tr").locator("select").count();
|
||||
// Read-only grid: no per-cell picker trigger mounts for a volunteer.
|
||||
const assignControls = await page
|
||||
.locator("tbody tr")
|
||||
.getByRole("button", { name: /Choose volunteer/ })
|
||||
.count();
|
||||
expect(assignControls, "volunteer grid should expose no assign control").toBe(0);
|
||||
|
||||
// The route still enforces the chokepoint directly.
|
||||
|
||||
Reference in New Issue
Block a user