Files
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

107 lines
5.9 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 (Ben als sein Gericht), 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("Gericht von Ben (sicher)"); // Bens Gericht (kinder.spec)
await expect(items(page).first().getByRole("combobox", { name: /^Wer kocht/ })).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(/^\d+ Portion(en)?$/).innerText();
await spaghetti.getByRole("button", { name: "Spaghetti Bolognese: mehr Portionen" }).click();
await expect(spaghetti.getByText(/^\d+ Portion(en)?$/)).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", { name: /^Wer kocht/ })).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("costs: per portion in the plan, a budget light, and an own price on the dish", async ({ page }) => {
await page.goto("/plan");
const cost = page.locator("section", { hasText: "Kosten der Runde" });
await expect(cost).toContainText(/etwa \d+,\d{2}\s€/);
await expect(items(page).first()).toContainText(/pro Portion/);
await expect(items(page).first().getByText("Kosten unsicher")).toBeAttached(); // nur Richtpreise: keine Punkte
// Richtwert in „Mehr“: 1 € ist sicher zu wenig → rot, mit Wort.
await page.goto("/mehr");
await page.getByLabel("Richtwert je Runde in EUR").fill("1");
await page.getByRole("button", { name: "Speichern" }).first().click();
await expect(page.getByText("Gespeichert.")).toBeVisible();
await page.goto("/plan");
await expect(cost).toContainText("deutlich über 1,00");
// Eigener Preis an einer Zutat des Gerichts.
await page.goto("/gerichte");
await page.getByRole("link", { name: /Spaghetti Bolognese/ }).click();
const section = page.locator("section", { hasText: "Kosten" }).last();
await section.getByRole("button", { name: "Preis für Spaghetti eintragen" }).click();
const dialog = page.getByRole("dialog");
await dialog.getByLabel("Preis in EUR").fill("1,99");
await dialog.getByLabel("für").fill("500");
await dialog.getByRole("button", { name: "Speichern" }).click();
await expect(section.locator("li", { hasText: "Spaghetti" })).toContainText("3,98 € je kg · eigener Preis");
});
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.locator("main article h2").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();
});