Files
lunch/e2e/plan.spec.ts
T
kai 6f0097e0e6
release / which version (push) Successful in 2s
release / olares chart · sanity (push) Successful in 3s
release / app (push) Successful in 56s
release / tag and release (push) Successful in 2s
Plan: rule-based suggestion, drag to reorder, lock, replace, approve (26.11.11) (#12)
2026-11-07 04:33:10 +00:00

80 lines
4.4 KiB
TypeScript

import { expect, test, type Page } from "@playwright/test";
// Plan am iPhone (Paket 6): Vorschlag aus den Wünschen, nachjustieren,
// freigeben; danach zeigt „Heute“ den Plan. Läuft nach „kinder“ mit Kais
// Sitzung — Spaghetti haben Kai und Ben gewünscht, Flammkuchen hat ein Veto.
test.describe.configure({ mode: "serial" });
const items = (page: Page) => page.locator("main ol > li");
const titles = (page: Page) => items(page).locator("h2");
test("the suggestion starts with the wishes and says why", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation", { name: "Navigation" }).getByRole("link", { name: "Plan" }).click();
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Plan");
await page.getByRole("button", { name: "Vorschlag erstellen" }).click();
await expect(items(page)).toHaveCount(4);
await expect(items(page).first()).toContainText("Spaghetti Bolognese");
await expect(items(page).first()).toContainText("Wunsch von Kai, Ben");
await expect(items(page).first().getByRole("combobox")).toHaveValue(/.+/); // Kai kocht („Ich koche das“)
await expect(titles(page)).not.toContainText(["Flammkuchen"]);
});
test("a locked slot survives a new suggestion; portions and cook change", async ({ page }) => {
await page.goto("/plan");
const curry = items(page).filter({ hasText: "Gemüsecurry mit Reis" });
await curry.getByRole("button", { name: "Gemüsecurry mit Reis sperren" }).click();
await expect(curry.getByRole("button", { name: "Gemüsecurry mit Reis sperren" })).toHaveAttribute("aria-pressed", "true");
await page.getByRole("button", { name: "Neu vorschlagen" }).click();
await expect(items(page)).toHaveCount(4);
await expect(items(page).filter({ hasText: "Gemüsecurry mit Reis" }).getByRole("button", { name: /sperren/ })).toHaveAttribute("aria-pressed", "true");
const spaghetti = items(page).filter({ hasText: "Spaghetti Bolognese" });
const before = await spaghetti.getByText(/Portion/).innerText();
await spaghetti.getByRole("button", { name: "Spaghetti Bolognese: mehr Portionen" }).click();
await expect(spaghetti.getByText(/Portion/)).not.toHaveText(before);
const lentils = items(page).filter({ hasText: "Linseneintopf" });
await lentils.getByRole("combobox", { name: "Wer kocht Linseneintopf?" }).selectOption({ label: "Koch: Ben" });
await expect(lentils.getByRole("combobox")).toHaveValue(/.+/);
});
test("a dish can be replaced, moved by keyboard and removed", async ({ page }) => {
await page.goto("/plan");
await page.getByRole("button", { name: "Linseneintopf ersetzen" }).click();
const sheet = page.getByRole("dialog");
await sheet.getByRole("textbox", { name: "Gericht suchen" }).fill("Flamm");
await sheet.getByRole("button", { name: "Flammkuchen" }).click();
await expect(sheet).toBeHidden();
await expect(items(page).filter({ hasText: "Flammkuchen" })).toContainText("von Hand gewählt");
// Ziehen mit der Tastatur: Griff, Leertaste, Pfeil hoch, Leertaste.
const last = (await titles(page).last().innerText()).trim();
await page.getByRole("button", { name: `${last} verschieben` }).focus();
for (const key of ["Space", "ArrowUp", "Space"]) {
await page.keyboard.press(key);
await page.waitForTimeout(300); // dnd-kit misst und animiert zwischen den Schritten
}
await expect(titles(page).nth(2)).toHaveText(last);
await page.reload();
await expect(titles(page).nth(2)).toHaveText(last);
await page.getByRole("button", { name: `${last} streichen` }).click();
await expect(items(page)).toHaveCount(3);
await expect(page.getByText("3 Mahlzeiten")).toBeVisible();
});
test("approving shows the plan on Today and closes wishing", async ({ page }) => {
await page.goto("/plan");
const first = (await titles(page).first().innerText()).trim();
await page.getByRole("button", { name: "Plan freigeben" }).click();
await expect(page.locator("header .eyebrow")).toHaveText("Freigegeben");
await expect(page.getByRole("button", { name: "Plan freigeben" })).toHaveCount(0);
await page.goto("/");
await expect(page.getByText("Als Nächstes")).toBeVisible();
await expect(page.getByRole("heading", { level: 2 }).first()).toHaveText(first);
await expect(page.locator("section", { hasText: "Der Plan" }).locator("li")).toHaveCount(3);
await page.goto("/wuenschen");
await expect(page.getByText("Die Wünsche für diese Runde sind abgeschlossen.")).toBeVisible();
});