feat: Wabenhain Honig-Shop Anwendung

Vollstaendige Next.js/Prisma-E-Commerce-Anwendung fuer eine Imkerei:
Shop, Warenkorb, Stripe-Checkout, Kundenkonto mit 2FA, Admin-Bereich
(Produkte, Ernten, Chargen, Bestellungen, Gutscheine, admin-editierbare
Website-Inhalte), i18n (DE/EN), Rate-Limiting/CSP/Audit-Log-Haertung,
PostgreSQL- und MySQL-Unterstuetzung ueber austauschbare Prisma-
Treiber-Adapter, Unit-/Komponenten-/E2E-Tests.
This commit is contained in:
Nick Szaunig
2026-08-17 14:30:28 +02:00
parent 5c76fcc266
commit c7927f2883
240 changed files with 26096 additions and 137 deletions
+56
View File
@@ -0,0 +1,56 @@
import { test, expect } from "@playwright/test";
test("login with wrong credentials shows an error message", async ({ page }) => {
await page.goto("/konto");
await page.getByLabel("E-Mail", { exact: true }).first().fill("[email protected]");
await page.getByLabel("Passwort", { exact: true }).first().fill("falschespasswort");
await page.getByRole("button", { name: "Anmelden" }).click();
await expect(page.getByText(/E-Mail-Adresse oder Passwort ist falsch/i)).toBeVisible();
});
test("registration rejects a password shorter than 8 characters", async ({ page }) => {
await page.goto("/konto");
await page.getByLabel("Vorname").fill("Test");
await page.getByLabel("Nachname").fill("Person");
await page.getByLabel("E-Mail", { exact: true }).nth(1).fill(`e2e-${Date.now()}@example.de`);
await page.getByLabel(/Passwort \(mind\. 8 Zeichen\)/).fill("kurz");
await page.getByRole("button", { name: "Konto erstellen" }).click();
await expect(page.getByText(/mindestens 8 Zeichen/i)).toBeVisible();
});
test("registering, logging out, and logging back in reaches the logged-in account page", async ({ page }) => {
const email = `e2e-login-${Date.now()}@example.de`;
// Zufaellig statt eines festen Werts wie "Passwort123!" — der HIBP-
// Breach-Check (isPasswordBreached) lehnt bekannte Leak-Passwoerter ab,
// ein per Zeitstempel eindeutiges Passwort landet nicht in solchen Listen.
const password = `Xk9-qLp2-Zt${Date.now()}`;
await page.goto("/konto");
await page.getByLabel("Vorname").fill("Test");
await page.getByLabel("Nachname").fill("Person");
await page.getByLabel("E-Mail", { exact: true }).nth(1).fill(email);
await page.getByLabel(/Passwort \(mind\. 8 Zeichen\)/).fill(password);
await page.getByLabel("Passwort bestätigen").fill(password);
await page.getByRole("button", { name: "Konto erstellen" }).click();
// Registrierung meldet automatisch an — erst abmelden, um den separaten
// Login-Pfad (loginAction statt der impliziten Session bei der
// Registrierung) tatsaechlich zu pruefen. Zwei Buttons heissen "Abmelden"
// (auch "alle Geraete abmelden") — .last() ist der einfache Logout-Button,
// der tatsaechlich zur ausgeloggten Ansicht zurueckfuehrt.
await expect(page.getByRole("button", { name: "Abmelden" }).first()).toBeVisible();
await page.getByRole("button", { name: "Abmelden" }).last().click();
await expect(page.getByRole("heading", { name: "Anmelden oder Konto erstellen" })).toBeVisible();
await page.getByLabel("E-Mail", { exact: true }).first().fill(email);
await page.getByLabel("Passwort", { exact: true }).first().fill(password);
await page.getByRole("button", { name: "Anmelden" }).click();
await expect(page.getByRole("button", { name: "Abmelden" }).first()).toBeVisible();
await expect(page.getByRole("heading", { name: "Anmelden oder Konto erstellen" })).not.toBeVisible();
});
+26
View File
@@ -0,0 +1,26 @@
import { test, expect } from "@playwright/test";
test("cart page: increasing quantity updates the line total", async ({ page }) => {
await page.goto("/honig/fruehtracht-2026");
await page.getByRole("button", { name: "In den Warenkorb" }).first().click();
await page.goto("/warenkorb");
const lineTotalBefore = await page.getByText(/^\d+,\d{2}\s€$/).first().textContent();
await page.getByRole("button", { name: "Menge erhöhen" }).click();
await expect(page.getByText(/^\d+,\d{2}\s€$/).first()).not.toHaveText(lineTotalBefore ?? "");
});
test("cart page: removing the only item shows the empty-cart state", async ({ page }) => {
await page.goto("/honig/fruehtracht-2026");
await page.getByRole("button", { name: "In den Warenkorb" }).first().click();
await page.goto("/warenkorb");
await expect(page.getByText("Zwischensumme")).toBeVisible();
await page.getByRole("button", { name: "Entfernen" }).click();
await expect(page.getByText("Dein Warenkorb ist noch leer.")).toBeVisible();
});
+33
View File
@@ -0,0 +1,33 @@
import { test, expect } from "@playwright/test";
test("checkout shows live shipping cost for Versand and switches to free for Abholung", async ({ page }) => {
await page.goto("/honig/fruehtracht-2026");
await page.getByRole("button", { name: "In den Warenkorb" }).first().click();
await page.goto("/checkout");
await expect(page.getByText("Zwischensumme")).toBeVisible();
await expect(page.getByText("Gesamt")).toBeVisible();
// Versand ist per Default aktiv und zeigt eine Versandstaffel-Kosten
// (nicht "kostenlos"), solange der Warenkorb unter der Freigrenze liegt.
const summary = page.locator("aside");
await expect(summary.getByText(/Versand/)).toBeVisible();
await page.getByRole("button", { name: "Abholung in Altenmünster" }).click();
await expect(summary.getByText("kostenlos")).toBeVisible();
});
test("checkout requires street address only when Versand is selected", async ({ page }) => {
await page.goto("/honig/fruehtracht-2026");
await page.getByRole("button", { name: "In den Warenkorb" }).first().click();
await page.goto("/checkout");
await expect(page.getByLabel("Straße und Hausnummer")).toBeVisible();
await page.getByRole("button", { name: "Abholung in Altenmünster" }).click();
await expect(page.getByLabel("Straße und Hausnummer")).toHaveCount(0);
});
+17
View File
@@ -0,0 +1,17 @@
import { test, expect } from "@playwright/test";
test("homepage shows the hero heading and primary navigation", async ({ page }) => {
await page.goto("/");
await expect(page.getByRole("heading", { name: /Honig aus den Westlichen Wäldern/i })).toBeVisible();
await expect(page.getByRole("navigation").getByRole("link", { name: "Shop", exact: true })).toBeVisible();
});
test("homepage newsletter form is present and accepts an email", async ({ page }) => {
await page.goto("/");
const emailField = page.getByPlaceholder("[email protected]");
await expect(emailField).toBeVisible();
await emailField.fill("[email protected]");
await expect(emailField).toHaveValue("[email protected]");
});
+22
View File
@@ -0,0 +1,22 @@
import { test, expect } from "@playwright/test";
test("shop overview lists products", async ({ page }) => {
await page.goto("/shop");
await expect(page.getByRole("heading", { name: "Unser Sortiment" })).toBeVisible();
await expect(page.getByRole("link", { name: /Zum Honig|Zum Produkt/i }).first()).toBeVisible();
});
test("adding a product to the cart updates the cart count", async ({ page }) => {
await page.goto("/honig/fruehtracht-2026");
// "In den Warenkorb" erscheint mehrfach auf der Seite (Haupt-CTA oben,
// weitere in der "Das koennte dir auch gefallen"-Produktkarten-Sektion
// weiter unten) — .first() greift gezielt den Haupt-CTA des Produkts.
const cartButton = page.getByRole("button", { name: /Warenkorb öffnen/ });
const initialLabel = await cartButton.getAttribute("aria-label");
await page.getByRole("button", { name: "In den Warenkorb" }).first().click();
await expect(cartButton).not.toHaveAttribute("aria-label", initialLabel ?? "");
});