Files
lunch/e2e/runde.spec.ts
kai 6f43b81f9b
release / which version (push) Successful in 2s
release / olares chart · sanity (push) Successful in 3s
release / app (push) Successful in 1m5s
release / tag and release (push) Successful in 2s
26.11.45: Runde beenden, Tage, Kalender-Abo (#46)
2026-11-08 05:23:22 +00:00

82 lines
4.2 KiB
TypeScript

import { expect, test } from "@playwright/test";
// 26.11.45 (Kai, 8.11.2026): Tag je Gericht von Hand, Runde ändern, Kalender-Abo,
// Runde beenden und löschen. Läuft nach „mail“ — die Runde aus plan/kochen hat
// schon Gekochtes, also nur „Beenden“.
test.describe.configure({ mode: "serial" });
const cards = (page: import("@playwright/test").Page) => page.locator("main ol > li");
test("a dish gets a day by hand and shows it on the plan and today", async ({ page }) => {
await page.goto("/plan");
const card = cards(page).filter({ has: page.getByRole("combobox", { name: /^Tag für/ }) }).first();
const title = (await card.locator("h2").textContent())!;
const day = card.getByRole("combobox", { name: `Tag für ${title}` });
await expect(day).toHaveValue("");
const label = (await day.locator("option").nth(2).textContent())!;
await day.selectOption({ label });
await expect(day).not.toHaveValue("");
await expect(card.locator("p", { hasText: label })).toBeVisible();
await page.goto("/");
await expect(page.locator("main li").filter({ hasText: title })).toContainText(label);
});
test("the round's settings can change", async ({ page }) => {
await page.goto("/plan");
const before = await page.locator("header p.text-muted-foreground").textContent();
await page.getByRole("button", { name: "Einstellungen ändern" }).click();
await page.getByRole("button", { name: "Warme Mahlzeiten: mehr" }).click();
await page.getByRole("button", { name: "Speichern" }).click();
await expect(page.getByRole("button", { name: "Einstellungen ändern" })).toBeVisible();
await expect(page.locator("header p.text-muted-foreground")).not.toHaveText(before!);
});
test("the household calendar link serves the plan, and a new link kills the old", async ({ page, playwright }) => {
await page.goto("/mehr#kalender");
await page.getByLabel("Essenszeit").fill("19:00");
await page.getByRole("button", { name: "Essenszeit speichern" }).click();
await expect(page.getByRole("button", { name: "Gespeichert" })).toBeVisible();
await page.getByRole("button", { name: "Kalender-Abo starten" }).click();
const first = (await page.getByTestId("calendar-url").textContent())!;
expect(first).toMatch(/\/kalender\/[A-Za-z0-9_-]{43}\.ics$/);
await expect(page.getByRole("link", { name: "Im Kalender öffnen" })).toHaveAttribute("href", /^webcal:\/\//);
// Ohne Sitzung: Der Link allein reicht.
const anon = await playwright.request.newContext();
const res = await anon.get(first);
expect(res.status()).toBe(200);
expect(res.headers()["content-type"]).toContain("text/calendar");
const ics = await res.text();
expect(ics).toContain("BEGIN:VEVENT");
expect(ics).toMatch(/DTSTART;TZID=Europe\/Berlin:\d{8}T190000/);
await page.getByRole("button", { name: "Neuen Link erzeugen" }).click();
await expect(page.getByTestId("calendar-url")).not.toHaveText(first);
const second = (await page.getByTestId("calendar-url").textContent())!;
expect((await anon.get(first)).status()).toBe(404);
expect((await anon.get(second)).status()).toBe(200);
await anon.dispose();
});
test("a round with cooked dishes can only end; then the next one opens and an empty one can go", async ({ page }) => {
await page.goto("/plan");
await expect(page.getByRole("button", { name: "Runde löschen" })).toHaveCount(0);
const end = page.getByRole("button", { name: "Runde beenden" });
await end.click();
await page.getByRole("button", { name: /Wirklich beenden/ }).click();
await expect(page.getByRole("link", { name: "Runde eröffnen" })).toBeVisible();
await page.getByRole("link", { name: "Runde eröffnen" }).click();
await page.getByRole("button", { name: "Runde eröffnen" }).click();
await expect(page).toHaveURL(/\/$/);
await page.goto("/plan");
await page.getByRole("button", { name: "Runde löschen" }).click();
await page.getByRole("button", { name: /Wirklich löschen/ }).click();
await expect(page.getByRole("link", { name: "Runde eröffnen" })).toBeVisible();
// Für den Rundgang danach wieder eine Runde.
await page.getByRole("link", { name: "Runde eröffnen" }).click();
await page.getByRole("button", { name: "Runde eröffnen" }).click();
await expect(page).toHaveURL(/\/$/);
});