rework of the e2e test suites

This commit is contained in:
Codex Agent
2025-11-19 22:23:33 +01:00
parent 8d2075bdd2
commit 0127114e59
32 changed files with 1593 additions and 124 deletions

View File

@@ -0,0 +1,160 @@
import type { Page } from '@playwright/test';
import { test, expectFixture as expect } from '../helpers/test-fixtures';
const futureDate = (daysAhead = 10): string => {
const date = new Date();
date.setDate(date.getDate() + daysAhead);
return date.toISOString().slice(0, 10);
};
async function ensureOnDashboard(page: Page): Promise<void> {
await page.goto('/event-admin/dashboard');
await page.waitForLoadState('networkidle');
if (page.url().includes('/event-admin/welcome')) {
const directButton = page.getByRole('button', { name: /Direkt zum Dashboard/i });
if (await directButton.isVisible()) {
await directButton.click();
await page.waitForURL(/\/event-admin\/dashboard$/, { timeout: 15_000 });
}
}
}
test.describe('Tenant Admin PWA end-to-end coverage', () => {
test.beforeEach(async ({ signInTenantAdmin }) => {
await signInTenantAdmin();
});
test('dashboard highlights core stats and quick actions', async ({ page }) => {
await ensureOnDashboard(page);
await expect(page.getByRole('heading', { name: /Hallo/i })).toBeVisible();
await expect(page.getByRole('button', { name: /Neues Event/i })).toBeVisible();
await expect(page.getByText(/Schnellaktionen/i)).toBeVisible();
await expect(page.getByText(/Kommende Events/i)).toBeVisible();
});
test('event creation flow and detail subsections', async ({ page }) => {
const eventName = `Playwright Event ${Date.now()}`;
const eventDate = futureDate(14);
await page.goto('/event-admin/events/new');
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: /Eventdetails/i })).toBeVisible();
await page.getByLabel(/Eventname/i).fill(eventName);
await page.getByLabel(/Datum/i).fill(eventDate);
const eventTypeTrigger = page.getByRole('combobox', { name: /Event-Typ/i });
await eventTypeTrigger.click();
const firstOption = page.getByRole('option').first();
await expect(firstOption).toBeVisible({ timeout: 5_000 });
await firstOption.click();
await page.getByRole('button', { name: /^Speichern/i }).click();
await expect(page).toHaveURL(/\/event-admin\/events\/[a-z0-9-]+$/, { timeout: 20_000 });
const createdSlug = page.url().split('/').pop() ?? '';
await expect(page.getByRole('heading', { name: /Eventdetails/i })).toBeVisible();
await page.goto('/event-admin/events');
await page.waitForLoadState('networkidle');
await expect(page.getByText(eventName, { exact: false })).toBeVisible();
await page.goto(`/event-admin/events/${createdSlug}/photos`);
await expect(page.getByRole('heading', { name: /Fotos moderieren/i })).toBeVisible();
await expect(page.getByText(/Noch keine Fotos vorhanden/i)).toBeVisible();
await page.goto(`/event-admin/events/${createdSlug}/members`);
await expect(page.getByRole('heading', { name: /Event-Mitglieder/i })).toBeVisible();
await page.goto(`/event-admin/events/${createdSlug}/tasks`);
await expect(page.getByRole('heading', { name: /Event-Tasks/i })).toBeVisible();
await expect(page.getByText(/Noch keine Tasks zugewiesen/i)).toBeVisible();
});
test('task library allows creating custom tasks', async ({ page }) => {
await page.goto('/event-admin/tasks');
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: /Task Bibliothek/i })).toBeVisible();
const taskTitle = `Playwright Task ${Date.now()}`;
await page.getByRole('button', { name: /^Neu$/i }).click();
await page.getByLabel(/Titel/i).fill(taskTitle);
await page.getByLabel(/Beschreibung/i).fill('Automatisierter Testfall');
await page.getByRole('button', { name: /^Speichern$/i }).click();
await expect(page.getByText(taskTitle)).toBeVisible({ timeout: 10_000 });
await page.goto('/event-admin/task-collections');
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: /Aufgabenvorlagen/i })).toBeVisible();
});
test('supporting sections (emotions, billing, settings) load successfully', async ({ page }) => {
await page.goto('/event-admin/emotions');
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: /Emotionen/i })).toBeVisible();
await page.goto('/event-admin/billing');
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: /Pakete & Abrechnung/i })).toBeVisible();
await page.goto('/event-admin/settings');
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: /Einstellungen/i })).toBeVisible();
});
test('wedding event workflow assigns tasks and exposes join token', async ({ page, fetchJoinToken }) => {
const eventName = `Playwright Hochzeit ${Date.now()}`;
const eventDate = futureDate(21);
await page.goto('/event-admin/events/new');
await page.waitForLoadState('networkidle');
await page.getByLabel(/Eventname/i).fill(eventName);
await page.getByLabel(/Datum/i).fill(eventDate);
const eventTypeCombo = page.getByRole('combobox', { name: /Event-Typ/i });
await eventTypeCombo.click();
const weddingOption = page.getByRole('option', { name: /Hochzeit|Wedding/i }).first();
await expect(weddingOption).toBeVisible();
await weddingOption.click();
await page.getByRole('button', { name: /^Speichern/i }).click();
await page.waitForURL(/\/event-admin\/events\/[a-z0-9-]+$/i, { timeout: 20_000 });
const createdSlug = page.url().split('/').pop() ?? '';
await expect(page.getByText(/Hochzeit|Wedding/i)).toBeVisible();
await page.goto(`/event-admin/events/${createdSlug}/tasks`);
await expect(page.getByRole('heading', { name: /Event-Tasks/i })).toBeVisible();
const librarySection = page
.locator('section')
.filter({ hasText: /Tasks aus Bibliothek hinzufügen|Add tasks/i })
.first();
const availableTaskLabels = librarySection.locator('label');
const availableCount = await availableTaskLabels.count();
test.skip(availableCount === 0, 'No task library entries available to assign');
const firstLabel = availableTaskLabels.first();
const taskTitle = ((await firstLabel.locator('p').first().textContent()) ?? '').trim();
await firstLabel.click();
await page
.getByRole('button', { name: /Ausgewählte Tasks zuweisen|Assign selected tasks/i })
.click();
await expect(
page.locator('section').filter({ hasText: /Zugeordnete Tasks|Assigned tasks/i }).getByText(taskTitle, { exact: false }),
).toBeVisible({ timeout: 15_000 });
const joinToken = await fetchJoinToken({ slug: createdSlug });
expect(joinToken.token).toBeTruthy();
expect(joinToken.join_url).toContain(joinToken.token);
expect(joinToken.qr_svg).toContain('<svg');
});
});

View File

@@ -0,0 +1,67 @@
import { test, expectFixture as expect } from '../helpers/test-fixtures';
/**
* Skeleton E2E coverage for the tenant onboarding journey.
*
* This suite is currently skipped until we have stable seed data and
* authentication helpers for Playwright. Once those are in place we can
* remove the skip and let the flow exercise the welcome -> packages -> summary
* steps with mocked Stripe/Paddle APIs.
*/
test.describe('Tenant Onboarding Welcome Flow', () => {
test('redirects unauthenticated users to login', async ({ page }) => {
await page.goto('/event-admin/welcome');
await expect(page).toHaveURL(/\/event-admin\/login/);
await expect(page.getByText('Bitte warten', { exact: false })).toBeVisible();
});
test('tenant admin can progress through welcome, packages, summary, and setup', async ({
tenantAdminCredentials,
signInTenantAdmin,
page,
}) => {
test.skip(
!tenantAdminCredentials,
'Provide E2E_TENANT_EMAIL and E2E_TENANT_PASSWORD (see docs/testing/e2e.md) to run onboarding tests.'
);
await signInTenantAdmin();
// If guard redirects to dashboard, hop to welcome manually.
if (!page.url().includes('/event-admin/welcome')) {
await page.goto('/event-admin/welcome');
}
await expect(page.getByRole('heading', { name: /Willkommen im Event-Erlebnisstudio/i })).toBeVisible();
// Open package selection via CTA.
await page.getByRole('button', { name: /Pakete entdecken/i }).click();
await expect(page).toHaveURL(/\/event-admin\/welcome\/packages/);
await expect(page.getByRole('heading', { name: /Wähle dein Eventpaket/i })).toBeVisible();
// Choose the first available package and ensure we land on the summary step.
const choosePackageButton = page.getByRole('button', { name: /Paket wählen/i }).first();
await choosePackageButton.waitFor({ state: 'visible', timeout: 10_000 });
await choosePackageButton.click();
await expect(page).toHaveURL(/\/event-admin\/welcome\/summary/);
await expect(page.getByRole('heading', { name: /Bestellübersicht/i })).toBeVisible();
// Validate payment sections. Depending on env we either see Stripe/Paddle widgets or configuration warnings.
const stripeConfigured = Boolean(process.env.VITE_STRIPE_PUBLISHABLE_KEY);
if (stripeConfigured) {
await expect(page.getByRole('heading', { name: /Kartenzahlung \(Stripe\)/i })).toBeVisible();
} else {
await expect(
page.getByText(/Stripe nicht verfügbar|PaymentIntent konnte nicht erstellt werden|Publishable Key fehlt/i)
).toBeVisible();
}
await expect(page.getByRole('heading', { name: /^Paddle$/i })).toBeVisible();
// Continue to the setup step without completing a purchase.
await page.getByRole('button', { name: /Weiter zum Setup/i }).click();
await expect(page).toHaveURL(/\/event-admin\/welcome\/event/);
await expect(page.getByRole('heading', { name: /Bereite dein erstes Event vor/i })).toBeVisible();
});
});

View File

@@ -0,0 +1,58 @@
import { test, expectFixture as expect } from '../helpers/test-fixtures';
test.describe('Marketing auth flows', () => {
test('registers a new account and captures welcome email', async ({ page, clearTestMailbox, getTestMailbox }) => {
await clearTestMailbox();
const stamp = Date.now();
const email = `playwright-register-${stamp}@example.test`;
const username = `playwright-${stamp}`;
const password = 'Password123!';
await page.goto('/register');
await page.getByLabel(/Vorname/i).fill('Playwright');
await page.getByLabel(/Nachname/i).fill('Tester');
await page.getByLabel(/^E-Mail/i).fill(email);
await page.getByLabel(/Telefon/i).fill('+49123456789');
await page.getByLabel(/Adresse/i).fill('Teststr. 1, 12345 Berlin');
await page.getByLabel(/Username/i).fill(username);
await page.getByLabel(/^Passwort$/i).fill(password);
await page.getByLabel(/Passwort bestätigen/i).fill(password);
await page.locator('#privacy_consent').check();
await page.getByRole('button', { name: /^Registrieren$/i }).click();
await expect.poll(() => page.url()).not.toContain('/register');
const messages = await getTestMailbox();
const hasWelcome = messages.some((message) =>
message.to.some((recipient) => recipient.email === email)
);
expect(hasWelcome).toBe(true);
});
test('shows inline error on invalid login', async ({ page }) => {
await page.goto('/login');
await page.fill('input[name="login"]', `unknown-${Date.now()}@example.test`);
await page.fill('input[name="password"]', 'totally-wrong');
await page.getByRole('button', { name: /^Anmelden$/i }).click();
await expect(
page.getByText(/Diese Anmeldedaten wurden nicht gefunden/i).first()
).toBeVisible();
});
test('sends password reset email notice', async ({ page }) => {
await page.goto('/forgot-password');
await page.getByLabel(/Email address/i).fill(`ghost-${Date.now()}@example.test`);
await page.getByRole('button', { name: /Email password reset link/i }).click();
await expect(
page.getByText(/reset link will be sent if the account exists/i)
).toBeVisible();
});
});

View File

@@ -0,0 +1,209 @@
import { test, expect } from '@playwright/test';
const EVENT_TOKEN = 'limit-event';
function nowIso(): string {
return new Date().toISOString();
}
test.describe('Guest PWA limit experiences', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript(
({ token }) => {
try {
window.localStorage.setItem(`guestName_${token}`, 'Playwright Gast');
window.localStorage.setItem(`guestCameraPrimerDismissed_${token}`, '1');
} catch (error) {
console.warn('Failed to seed guest storage', error);
}
if (!navigator.mediaDevices) {
Object.defineProperty(navigator, 'mediaDevices', {
configurable: true,
value: {},
});
}
navigator.mediaDevices.getUserMedia = () => Promise.resolve(new MediaStream());
},
{ token: EVENT_TOKEN }
);
const timestamp = nowIso();
await page.route(`**/api/v1/events/${EVENT_TOKEN}`, async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
id: 1,
slug: EVENT_TOKEN,
name: 'Limit Experience Event',
default_locale: 'de',
created_at: timestamp,
updated_at: timestamp,
}),
});
});
await page.route(`**/api/v1/events/${EVENT_TOKEN}/tasks`, async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([
{
id: 1,
title: 'Playwright Mission',
description: 'Test mission for upload limits',
instructions: 'Mach ein Testfoto',
duration: 2,
},
]),
});
});
await page.route(`**/api/v1/events/${EVENT_TOKEN}/stats`, async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
online_guests: 5,
tasks_solved: 12,
latest_photo_at: timestamp,
}),
});
});
await page.route(`**/api/v1/events/${EVENT_TOKEN}/photos**`, async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
data: [
{
id: 101,
file_path: '/photos/101.jpg',
thumbnail_path: '/photos/101-thumb.jpg',
created_at: timestamp,
likes_count: 3,
},
],
latest_photo_at: timestamp,
}),
});
});
});
test('shows limit warnings and countdown before limits are reached', async ({ page }) => {
const expiresAt = new Date(Date.now() + 2 * 86_400_000).toISOString();
await page.route(`**/api/v1/events/${EVENT_TOKEN}/package`, async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
id: 42,
event_id: 1,
used_photos: 95,
expires_at: expiresAt,
package: {
id: 77,
name: 'Starter',
max_photos: 100,
max_guests: 150,
gallery_days: 30,
},
limits: {
photos: {
limit: 100,
used: 95,
remaining: 5,
percentage: 95,
state: 'warning',
threshold_reached: 95,
next_threshold: 100,
thresholds: [80, 95, 100],
},
guests: null,
gallery: {
state: 'warning',
expires_at: expiresAt,
days_remaining: 2,
warning_thresholds: [7, 1],
warning_triggered: 2,
warning_sent_at: null,
expired_notified_at: null,
},
can_upload_photos: true,
can_add_guests: true,
},
}),
});
});
await page.goto(`/e/${EVENT_TOKEN}/upload?task=1`);
await expect(page.getByText(/Nur noch 5 von 100 Fotos möglich/i)).toBeVisible();
await expect(page.getByText(/Galerie läuft in 2 Tagen ab/i)).toBeVisible();
await page.goto(`/e/${EVENT_TOKEN}/gallery`);
await expect(page.getByText(/Noch 2 Tage online/i)).toBeVisible();
await expect(page.getByText(/Nur noch 5 von 100 Fotos möglich/i)).toBeVisible();
await expect(page.getByText(/Galerie läuft in 2 Tagen ab/i)).toBeVisible();
await expect(page.getByRole('button', { name: /Letzte Fotos hochladen/i })).toBeVisible();
});
test('marks uploads as blocked and highlights expired gallery state', async ({ page }) => {
const expiredAt = new Date(Date.now() - 86_400_000).toISOString();
await page.route(`**/api/v1/events/${EVENT_TOKEN}/package`, async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
id: 43,
event_id: 1,
used_photos: 100,
expires_at: expiredAt,
package: {
id: 77,
name: 'Starter',
max_photos: 100,
max_guests: 150,
gallery_days: 30,
},
limits: {
photos: {
limit: 100,
used: 100,
remaining: 0,
percentage: 100,
state: 'limit_reached',
threshold_reached: 100,
next_threshold: null,
thresholds: [80, 95, 100],
},
guests: null,
gallery: {
state: 'expired',
expires_at: expiredAt,
days_remaining: 0,
warning_thresholds: [7, 1],
warning_triggered: 0,
warning_sent_at: null,
expired_notified_at: expiredAt,
},
can_upload_photos: false,
can_add_guests: true,
},
}),
});
});
await page.goto(`/e/${EVENT_TOKEN}/upload?task=1`);
await expect(page.getByText(/Upload-Limit erreicht/i)).toBeVisible();
await page.goto(`/e/${EVENT_TOKEN}/gallery`);
await expect(page.getByText(/Galerie abgelaufen/i)).toBeVisible();
await expect(page.getByText(/Die Galerie ist abgelaufen\. Uploads sind nicht mehr möglich\./i)).toBeVisible();
});
});

View File

@@ -0,0 +1,52 @@
import { test, expect } from '@playwright/test';
test.describe('Guest Profile Flow', () => {
test('should require name setup on first event join and persist it', async ({ page }) => {
// Assume Vite dev server is running on localhost:5173
await page.goto('http://localhost:5173/');
// Enter event slug manually
await page.fill('input[placeholder*="Event-Code"]', 'test-event');
await page.click('button:has-text("Event beitreten")');
// Should redirect to setup if no name
await expect(page).toHaveURL(/.*\/e\/test-event\/setup/);
// Fill name and submit
await page.fill('input[placeholder*="Dein Name"]', 'Test User');
await page.click('button:has-text("LET\'S GO! ✨")');
// Should navigate to home
await expect(page).toHaveURL(/.*\/e\/test-event$/);
// Check localStorage
const storedName = await page.evaluate(() => localStorage.getItem('guestName_test-event'));
expect(storedName).toBe('Test User');
// Reload to test persistence - should stay on home, not redirect to setup
await page.reload();
await expect(page).toHaveURL(/.*\/e\/test-event$/);
// Re-nav to landing and join again - should go directly to home
await page.goto('http://localhost:5173/');
await page.fill('input[placeholder*="Event-Code"]', 'test-event');
await page.click('button:has-text("Event beitreten")');
await expect(page).toHaveURL(/.*\/e\/test-event$/);
});
test('should go directly to home if name already stored', async ({ page }) => {
// Pre-set name in localStorage
await page.addInitScript(() => {
localStorage.setItem('guestName_test-event', 'Existing User');
});
await page.goto('http://localhost:5173/');
// Join
await page.fill('input[placeholder*="Event-Code"]', 'test-event');
await page.click('button:has-text("Event beitreten")');
// Should go directly to home
await expect(page).toHaveURL(/.*\/e\/test-event$/);
});
});

View File

@@ -0,0 +1,89 @@
import fs from 'node:fs';
import path from 'node:path';
import { expectFixture as expect, test } from '../helpers/test-fixtures';
const guestCount = 15;
const uploadFixturePath = ensureUploadFixture();
test.describe('Guest PWA multi-guest journey', () => {
test('15 guests can onboard, explore tasks, trigger upload review, and reach gallery', async ({
browser,
fetchJoinToken,
}) => {
const eventSlug = process.env.E2E_GUEST_EVENT_SLUG;
test.skip(!eventSlug, 'Set E2E_GUEST_EVENT_SLUG to point the guest suite at an existing event.');
const joinToken = await fetchJoinToken({ slug: eventSlug!, ensureActive: true });
const baseUrl = (process.env.E2E_GUEST_BASE_URL ?? 'http://localhost:8000').replace(/\/+$/, '');
const landingUrl = `${baseUrl}/event`;
const eventBaseUrl = `${baseUrl}/e/${joinToken.token}`;
for (let index = 0; index < guestCount; index += 1) {
const context = await browser.newContext();
const page = await context.newPage();
const guestName = `Gast ${index + 1}`;
await page.goto(landingUrl, { waitUntil: 'domcontentloaded' });
await page.getByPlaceholder(/Event-Code eingeben|Enter event code/i).fill(joinToken.token);
await page.getByRole('button', { name: /Event beitreten|Join event/i }).click();
await completeProfileSetup(page, guestName, joinToken.token);
await page.goto(`${eventBaseUrl}/tasks`, { waitUntil: 'domcontentloaded' });
await expect(page.locator('body')).toContainText(/Aufgaben|Tasks/);
await page.goto(`${eventBaseUrl}/upload`, { waitUntil: 'domcontentloaded' });
const fileInput = page.locator('input[type="file"]');
await expect(fileInput).toBeVisible({ timeout: 15_000 });
await fileInput.setInputFiles(uploadFixturePath);
await expect(
page.getByRole('button', { name: /Nochmal aufnehmen|Retake/i })
).toBeVisible({ timeout: 15_000 });
await page.getByRole('button', { name: /Nochmal aufnehmen|Retake/i }).click();
// Simulate offline queue testing for the last five guests.
if (index >= guestCount - 5) {
await context.setOffline(true);
await page.goto(`${eventBaseUrl}/tasks`, { waitUntil: 'domcontentloaded' }).catch(() => undefined);
await context.setOffline(false);
}
await page.goto(`${eventBaseUrl}/gallery`, { waitUntil: 'domcontentloaded' });
await expect(page.locator('body')).toContainText(/Galerie|Gallery/);
const likeButtons = page.getByLabel(/Foto liken|Like photo/i);
if (await likeButtons.count()) {
await likeButtons.first().click();
}
await context.close();
}
});
});
async function completeProfileSetup(page: import('@playwright/test').Page, guestName: string, token: string) {
await page.waitForLoadState('domcontentloaded');
if (page.url().includes('/setup/')) {
await page.getByLabel(/Dein Name|Your name/i).fill(guestName);
await page.getByRole('button', { name: /Los gehts|Let's go/i }).click();
}
await page.waitForURL(new RegExp(`/e/${token}`), {
timeout: 60_000,
});
}
function ensureUploadFixture(): string {
const fixtureDir = path.join(process.cwd(), 'tests/ui/guest/fixtures');
const fixturePath = path.join(fixtureDir, 'sample-upload.png');
if (!fs.existsSync(fixtureDir)) {
fs.mkdirSync(fixtureDir, { recursive: true });
}
if (!fs.existsSync(fixturePath)) {
const png1x1 = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==',
'base64'
);
fs.writeFileSync(fixturePath, png1x1);
}
return fixturePath;
}

View File

@@ -0,0 +1,236 @@
import 'dotenv/config';
import { test as base, expect, Page, APIRequestContext, APIResponse } from '@playwright/test';
export type TenantCredentials = {
email: string;
password: string;
};
export type TenantAdminFixtures = {
tenantAdminCredentials: TenantCredentials | null;
signInTenantAdmin: () => Promise<void>;
};
export type MailboxEntry = {
id: string;
subject: string | null;
to: Array<{ email: string; name: string | null }>;
from: Array<{ email: string; name: string | null }>;
html: string | null;
text: string | null;
sent_at: string;
};
export type CouponSeedDefinition = {
code: string;
type: 'percentage' | 'flat' | 'flat_per_seat';
amount: number;
currency?: string | null;
description?: string;
enabled_for_checkout?: boolean;
usage_limit?: number | null;
per_customer_limit?: number | null;
starts_at?: string | null;
ends_at?: string | null;
packages?: number[];
};
export type TestingApiFixtures = {
clearTestMailbox: () => Promise<void>;
getTestMailbox: () => Promise<MailboxEntry[]>;
seedTestCoupons: (definitions?: CouponSeedDefinition[]) => Promise<Array<{ id: number; code: string }>>;
getLatestCheckoutSession: (filters?: { email?: string; tenantId?: number; status?: string }) => Promise<CheckoutSessionSummary | null>;
simulatePaddleCompletion: (sessionId: string, overrides?: Partial<PaddleSimulationOverrides>) => Promise<void>;
fetchJoinToken: (params: { eventId?: number; slug?: string; ensureActive?: boolean }) => Promise<JoinTokenPayload>;
};
export type CheckoutSessionSummary = {
id: string;
status: string;
provider: string | null;
tenant_id: number | null;
package_id: number | null;
user_email: string | null;
coupon_id: number | null;
amount_subtotal: string | null;
amount_total: string | null;
created_at: string | null;
};
export type PaddleSimulationOverrides = {
event_type: string;
transaction_id?: string;
status?: string;
checkout_id?: string;
metadata?: Record<string, unknown>;
};
export type JoinTokenPayload = {
event_id: number;
token_id: number;
token: string;
join_url: string;
qr_svg: string;
expires_at: string | null;
usage_count: number;
usage_limit: number | null;
};
const tenantAdminEmail = process.env.E2E_TENANT_EMAIL ?? 'hello@lumen-moments.demo';
const tenantAdminPassword = process.env.E2E_TENANT_PASSWORD ?? 'Demo1234!';
export const test = base.extend<TenantAdminFixtures & TestingApiFixtures>({
tenantAdminCredentials: async ({}, use) => {
if (!tenantAdminEmail || !tenantAdminPassword) {
await use(null);
return;
}
await use({
email: tenantAdminEmail,
password: tenantAdminPassword,
});
},
signInTenantAdmin: async ({ page, tenantAdminCredentials }, use) => {
if (!tenantAdminCredentials) {
await use(async () => {
throw new Error('Tenant admin credentials missing. Provide E2E_TENANT_EMAIL and E2E_TENANT_PASSWORD.');
});
return;
}
await use(async () => {
await performTenantSignIn(page, tenantAdminCredentials);
});
},
clearTestMailbox: async ({ request }, use) => {
await use(async () => {
await expectApiSuccess(request.delete('/api/_testing/mailbox'));
});
},
getTestMailbox: async ({ request }, use) => {
await use(async () => {
const response = await expectApiSuccess(request.get('/api/_testing/mailbox'));
const json = await response.json();
return Array.isArray(json.data) ? (json.data as MailboxEntry[]) : [];
});
},
seedTestCoupons: async ({ request }, use) => {
await use(async (definitions?: CouponSeedDefinition[]) => {
const response = await expectApiSuccess(
request.post('/api/_testing/coupons/seed', {
data: definitions && definitions.length > 0 ? { coupons: definitions } : undefined,
})
);
const json = await response.json();
return Array.isArray(json.data) ? json.data : [];
});
},
getLatestCheckoutSession: async ({ request }, use) => {
await use(async (filters?: { email?: string; tenantId?: number; status?: string }) => {
const response = await request.get('/api/_testing/checkout/sessions/latest', {
params: {
email: filters?.email,
tenant_id: filters?.tenantId,
status: filters?.status,
},
});
if (response.status() === 404) {
return null;
}
await expectApiSuccess(Promise.resolve(response));
const json = await response.json();
return json.data as CheckoutSessionSummary;
});
},
simulatePaddleCompletion: async ({ request }, use) => {
await use(async (sessionId: string, overrides?: Partial<PaddleSimulationOverrides>) => {
await expectApiSuccess(
request.post(`/api/_testing/checkout/sessions/${sessionId}/simulate-paddle`, {
data: overrides,
})
);
});
},
fetchJoinToken: async ({ request }, use) => {
await use(async ({ eventId, slug, ensureActive = true }: { eventId?: number; slug?: string; ensureActive?: boolean }) => {
const response = await expectApiSuccess(
request.get('/api/_testing/events/join-token', {
params: {
event_id: eventId,
slug,
ensure_active: ensureActive,
},
})
);
const json = await response.json();
return json.data as JoinTokenPayload;
});
},
});
export const expectFixture = expect;
async function performTenantSignIn(page: Page, credentials: TenantCredentials) {
const token = await exchangeToken(page.request, credentials);
await page.addInitScript(({ stored }) => {
localStorage.setItem('tenant_admin.token.v1', JSON.stringify(stored));
sessionStorage.setItem('tenant_admin.token.session.v1', JSON.stringify(stored));
}, { stored: token });
await page.goto('/event-admin');
await page.waitForLoadState('domcontentloaded');
}
type StoredTokenPayload = {
accessToken: string;
abilities: string[];
issuedAt: number;
};
async function exchangeToken(request: APIRequestContext, credentials: TenantCredentials): Promise<StoredTokenPayload> {
const response = await request.post('/api/v1/tenant-auth/login', {
data: {
login: credentials.email,
password: credentials.password,
},
});
if (!response.ok()) {
throw new Error(`Tenant PAT login failed: ${response.status()} ${await response.text()}`);
}
const body = await response.json();
return {
accessToken: body.token,
abilities: Array.isArray(body.abilities) ? body.abilities : [],
issuedAt: Date.now(),
};
}
async function expectApiSuccess(responsePromise: Promise<APIResponse>): Promise<APIResponse> {
const response = await responsePromise;
if (!response.ok()) {
throw new Error(`Test API request failed: ${response.status()} ${await response.text()}`);
}
return response;
}

View File

@@ -0,0 +1,33 @@
import { test, expect } from '@playwright/test';
test.describe('Marketing hero CTA smoke', () => {
test('home hero CTA navigates to packages', async ({ page, baseURL }) => {
test.skip(!baseURL, 'baseURL is required to run marketing smoke tests');
await page.goto('/');
const cta = page.getByRole('link', {
name: /Pakete entdecken|Jetzt loslegen|Discover Packages|Get started now/i,
});
await expect(cta).toBeVisible();
await cta.click();
await expect(page).toHaveURL(/\/packages/);
});
test('packages hero CTA jumps to endcustomer section', async ({ page, baseURL }) => {
test.skip(!baseURL, 'baseURL is required to run marketing smoke tests');
await page.goto('/packages');
const cta = page.getByRole('link', {
name: /Pakete entdecken|Lieblingspaket sichern|Discover Packages|Explore top packages/i,
});
await expect(cta).toBeVisible();
await cta.click();
await expect(page.locator('#endcustomer')).toBeVisible();
});
});

View File

@@ -0,0 +1,155 @@
import { test, expect } from '@playwright/test';
import { execSync } from 'child_process';
const LOGIN_EMAIL = 'checkout-e2e@example.com';
const LOGIN_PASSWORD = 'Password123!';
test.describe('Checkout Payment Step Paddle flow', () => {
test.beforeAll(async () => {
execSync(
`php artisan tenant:add-dummy --email=${LOGIN_EMAIL} --password=${LOGIN_PASSWORD} --first_name=Checkout --last_name=Tester --address="Playwrightstr. 1" --phone="+4912345678"`
);
execSync(
`php artisan tinker --execute="App\\\\Models\\\\User::where('email', '${LOGIN_EMAIL}')->update(['email_verified_at' => now()]);"`
);
});
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.fill('input[name="email"]', LOGIN_EMAIL);
await page.fill('input[name="password"]', LOGIN_PASSWORD);
await page.getByRole('button', { name: /Anmelden|Login/ }).click();
await expect(page).toHaveURL(/dashboard/);
});
test('opens Paddle checkout and shows success notice', async ({ page }) => {
await page.route('**/paddle/create-checkout', async (route) => {
const request = route.request();
const postData = request.postDataJSON() as { inline?: boolean } | null;
const inline = Boolean(postData?.inline);
if (inline) {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
mode: 'inline',
items: [
{ priceId: 'pri_123', quantity: 1 },
],
custom_data: {
tenant_id: '1',
package_id: '2',
checkout_session_id: 'cs_123',
},
customer: {
email: LOGIN_EMAIL,
},
}),
});
return;
}
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
checkout_url: 'https://paddle.test/checkout/success',
}),
});
});
await page.route('https://cdn.paddle.com/paddle/v2/paddle.js', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/javascript',
body: `
window.Paddle = {
Environment: { set: function(env) { window.__paddleEnv = env; } },
Initialize: function(opts) { window.__paddleInit = opts; },
Checkout: {
open: function(config) {
window.__paddleOpenConfig = config;
}
}
};
`,
});
});
await openCheckoutPaymentStep(page);
await page.evaluate(() => {
window.__openedUrls = [];
window.open = (url: string, target?: string | null, features?: string | null) => {
window.__openedUrls.push({ url, target: target ?? null, features: features ?? null });
return null;
};
});
await page.getByRole('button', { name: /Continue with Paddle|Weiter mit Paddle/ }).click();
await expect(
page.locator(
'text=/Paddle checkout is running in a secure overlay|Der Paddle-Checkout läuft jetzt in einem Overlay/'
)
).toBeVisible();
await expect.poll(async () => {
return page.evaluate(() => window.__paddleOpenConfig?.items?.[0]?.priceId ?? null);
}).toBe('pri_123');
await expect.poll(async () => {
return page.evaluate(() => window.__openedUrls?.length ?? 0);
}).toBe(0);
});
test('shows error state when Paddle checkout creation fails', async ({ page }) => {
await page.route('**/paddle/create-checkout', async (route) => {
await route.fulfill({
status: 500,
contentType: 'application/json',
body: JSON.stringify({ message: 'test-error' }),
});
});
await openCheckoutPaymentStep(page);
await page.getByRole('button', { name: /Continue with Paddle|Weiter mit Paddle/ }).click();
await expect(
page.locator('text=/Paddle checkout could not be started|Paddle-Checkout konnte nicht gestartet werden/')
).toBeVisible();
});
});
async function openCheckoutPaymentStep(page: import('@playwright/test').Page) {
await page.goto('/packages');
const checkoutLink = page.locator('a[href^="/checkout/"]').first();
const href = await checkoutLink.getAttribute('href');
if (!href) {
throw new Error('No checkout link found on packages page.');
}
await page.goto(href);
const nextButton = page.getByRole('button', {
name: /Weiter zum Zahlungsschritt|Continue to Payment/,
});
if (await nextButton.isVisible()) {
await nextButton.click();
}
await page.waitForSelector('text=/Zahlung|Payment/');
}
declare global {
interface Window {
__openedUrls?: Array<{ url: string; target?: string | null; features?: string | null }>;
__paddleOpenConfig?: { url?: string; items?: Array<{ priceId: string; quantity: number }>; settings?: { displayMode?: string } };
__paddleEnv?: string;
__paddleInit?: Record<string, unknown>;
}
}

View File

@@ -0,0 +1,12 @@
import { test, expectFixture as expect } from '../helpers/test-fixtures';
test.describe('Coupon scaffolding', () => {
test('default coupon presets are created via testing API', async ({ seedTestCoupons }) => {
const seeded = await seedTestCoupons();
expect(seeded.length).toBeGreaterThanOrEqual(3);
expect(seeded.map((coupon) => coupon.code)).toEqual(
expect.arrayContaining(['PERCENT10', 'FLAT50', 'EXPIRED25'])
);
});
});

View File

@@ -0,0 +1,106 @@
import { test, expect } from '@playwright/test';
test.describe('Homepage Links Test', () => {
test('Click all links on homepage and check for errors', async ({ page }) => {
// Listen for failed requests (e.g., 404s)
const failedRequests: { url: string; status: number }[] = [];
page.on('response', response => {
if (response.status() >= 400) {
failedRequests.push({
url: response.url(),
status: response.status()
});
}
});
// Listen for console errors
const consoleErrors: string[] = [];
page.on('console', msg => {
if (msg.type() === 'error') {
consoleErrors.push(msg.text());
}
});
// Navigate to homepage
await page.goto('/');
// Wait for page to load
await page.waitForLoadState('networkidle');
// Get all links
const links = page.locator('a');
const linkCount = await links.count();
console.log(`Found ${linkCount} links on homepage.`);
for (let i = 0; i < linkCount; i++) {
const link = links.nth(i);
const href = await link.getAttribute('href');
const text = await link.textContent() || '';
if (!href || href.startsWith('#') || href.startsWith('mailto:') || href.startsWith('tel:')) {
console.log(`Skipping non-navigational link: ${text} (${href})`);
continue;
}
console.log(`Clicking link ${i + 1}/${linkCount}: "${text}" -> ${href}`);
// For each link, create temporary listeners
const linkFailedRequests: { url: string; status: number }[] = [];
const linkConsoleErrors: string[] = [];
const linkResponseHandler = (response: any) => {
if (response.status() >= 400) {
linkFailedRequests.push({
url: response.url(),
status: response.status()
});
}
};
const linkConsoleHandler = (msg: any) => {
if (msg.type() === 'error') {
linkConsoleErrors.push(msg.text());
}
};
page.on('response', linkResponseHandler);
page.on('console', linkConsoleHandler);
let currentUrl = page.url();
try {
// Hover and click
await link.hover();
await link.click({ force: true });
// Wait for navigation or load
await page.waitForTimeout(2000);
currentUrl = page.url();
// Remove temporary handlers
page.removeListener('response', linkResponseHandler);
page.removeListener('console', linkConsoleHandler);
// Check for errors during this click
expect(linkFailedRequests.length).toBe(0);
expect(linkConsoleErrors.length).toBe(0);
console.log(`✓ Link "${text}" successful: ${currentUrl}`);
} catch (error: unknown) {
// Remove handlers
page.removeListener('response', linkResponseHandler);
page.removeListener('console', linkConsoleHandler);
console.error(`✗ Error clicking link "${text}": ${(error as Error).message}`);
}
// Go back to homepage if navigated away
if (currentUrl !== page.url() && !currentUrl.includes('/')) {
await page.goBack({ waitUntil: 'networkidle' });
}
}
// Final checks
expect(failedRequests.length).toBe(0);
expect(consoleErrors.length).toBe(0);
console.log('All links tested successfully.');
});
});

View File

@@ -0,0 +1,95 @@
import { test, expect } from '@playwright/test';
import { execSync } from 'child_process'; // Für artisan seed
test.describe('Marketing Package Flow: Auswahl → Registrierung → Kauf (Free & Paid)', () => {
test.beforeAll(async () => {
// Seed Test-Tenant (einmalig)
execSync('php artisan tenant:add-dummy --email=test@example.com --password=password123 --first_name=Test --last_name=User --address="Teststr. 1" --phone="+49123"');
// Mock Verifizierung: Update DB (in Test-Env)
execSync('php artisan tinker --execute="App\\Models\\User::where(\'email\', \'test@example.com\')->update([\'email_verified_at\' => now()]);"');
});
test('Free-Paket-Flow mit Wizard (ID=1, Starter, eingeloggter User)', async ({ page }) => {
// Login first
await page.goto('http://localhost:8000/de/login');
await page.fill('[name="email"]', 'test@example.com');
await page.fill('[name="password"]', 'password123');
await page.getByRole('button', { name: 'Anmelden' }).click();
await expect(page).toHaveURL(/\/dashboard/);
// Go to Wizard
await page.goto('http://localhost:8000/purchase-wizard/10');
await expect(page.locator('text=Sie sind bereits eingeloggt')).toBeVisible();
await page.getByRole('button', { name: 'Weiter zum Zahlungsschritt' }).click();
await expect(page).toHaveURL(/\/purchase-wizard\/1/); // Next step
await page.screenshot({ path: 'wizard-logged-in.png', fullPage: true });
// Payment (Free: Success)
await expect(page.locator('text=Free package assigned')).toBeVisible();
await page.screenshot({ path: 'wizard-free-success.png', fullPage: true });
});
test('Wizard Login-Fehler mit Toast', async ({ page }) => {
await page.goto('http://localhost:8000/purchase-wizard/10');
// Switch to Login
await page.getByRole('button', { name: 'Anmelden' }).click();
await page.fill('[name="email"]', 'wrong@example.com');
await page.fill('[name="password"]', 'wrong');
await page.getByRole('button', { name: 'Anmelden' }).click();
await expect(page.locator('[data-testid="toast"]')).toBeVisible(); // Toast for error
await expect(page.locator('text=Ungültige Anmeldedaten')).toBeVisible(); // Inline error
await page.screenshot({ path: 'wizard-login-error.png', fullPage: true });
});
test('Wizard Registrierung-Fehler mit Toast', async ({ page }) => {
await page.goto('http://localhost:8000/purchase-wizard/10');
// Reg form with invalid data
await page.fill('[name="email"]', 'invalid');
await page.getByRole('button', { name: 'Registrieren' }).click();
await expect(page.locator('[data-testid="toast"]')).toBeVisible();
await expect(page.locator('text=Das E-Mail muss eine gültige E-Mail-Adresse sein')).toBeVisible();
await page.screenshot({ path: 'wizard-reg-error.png', fullPage: true });
});
test('Wizard Erfolgreiche Reg mit Success-Message', async ({ page }) => {
await page.goto('http://localhost:8000/purchase-wizard/10');
// Fill valid reg data (use unique email)
await page.fill('[name="first_name"]', 'TestReg');
await page.fill('[name="last_name"]', 'User');
await page.fill('[name="email"]', 'testreg@example.com');
await page.fill('[name="username"]', 'testreguser');
await page.fill('[name="address"]', 'Teststr. 1');
await page.fill('[name="phone"]', '+49123');
await page.fill('[name="password"]', 'Password123!');
await page.fill('[name="password_confirmation"]', 'Password123!');
await page.check('[name="privacy_consent"]');
await page.getByRole('button', { name: 'Registrieren' }).click();
await expect(page.locator('text=Sie sind nun eingeloggt')).toBeVisible(); // Success message
await page.waitForTimeout(2000); // Auto-next
await expect(page).toHaveURL(/\/purchase-wizard\/1/); // Payment step
await page.screenshot({ path: 'wizard-reg-success.png', fullPage: true });
});
test('Paid-Paket-Flow (ID=2, Pro mit Stripe-Test)', async ({ page }) => {
// Ähnlich wie Free, aber package_id=2
await page.goto('http://localhost:8000/de/packages');
await page.getByRole('button', { name: 'Details anzeigen' }).nth(1).click(); // Zweites Paket (Paid)
// ... (Modal, Register/Login wie oben)
await expect(page).toHaveURL(/\/buy-packages\/2/);
// Mock Stripe
await page.route('https://checkout.stripe.com/**', async route => {
await route.fulfill({ status: 200, body: '<html>Mock Stripe Success</html>' });
});
// Simuliere Checkout: Fill Test-Karte
await page.fill('[name="cardNumber"]', '4242424242424242');
await page.fill('[name="cardExpiry"]', '12/25');
await page.fill('[name="cardCvc"]', '123');
await page.click('[name="submit"]');
await page.waitForURL(/\/marketing\/success/); // Nach Webhook
await page.screenshot({ path: 'paid-step6-success.png', fullPage: true });
// Integration: Limits-Check wie in package-flow.test.ts
await expect(page.locator('text=Remaining Photos')).toContainText('Unbegrenzt'); // Pro-Limit
});
});

View File

@@ -0,0 +1,60 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
test.describe('Package Flow in Admin PWA', () => {
test('Create event with package and verify limits', async ({ page }) => {
// Assume logged in as tenant admin, navigate to events page
await page.goto('/event-admin/events');
// Click create event button
await page.click('[data-testid="create-event"]');
await expect(page).toHaveURL(/\/event-admin\/events\/create/);
// Fill form
await page.fill('[name="name"]', 'Test Package Event');
await page.fill('[name="slug"]', 'test-package-event');
await page.fill('[name="date"]', '2025-10-01');
// Select package from dropdown
await page.selectOption('[name="package_id"]', '1'); // Assume ID 1 is Starter package
await expect(page.locator('[name="package_id"]')).toHaveValue('1');
// Submit
await page.click('[type="submit"]');
await expect(page).toHaveURL(/\/event-admin\/events/);
// Verify event created and package assigned
await expect(page.locator('text=Test Package Event')).toBeVisible();
await expect(page.locator('text=Starter')).toBeVisible(); // Package name in table
// Check dashboard limits
await page.goto('/event-admin/events');
await expect(page.locator('text=Remaining Photos')).toContainText('300'); // Starter limit
// Try to create another event to test reseller limit if applicable
// (Skip for endcustomer; assume tenant has reseller package with limit 1)
await page.goto('/event-admin/events');
await page.click('[data-testid="create-event"]');
await page.fill('[name="name"]', 'Second Event');
await page.fill('[name="slug"]', 'second-event');
await page.fill('[name="date"]', '2025-10-02');
await page.selectOption('[name="package_id"]', '1');
await page.click('[type="submit"]');
// If limit reached, expect error
await expect(page.locator('text=No available package')).toBeVisible();
});
test('Upload blocked when package limit reached in Guest PWA', async ({ page }) => {
// Assume event with package limit 0 created
await page.goto('/e/test-limited-event'); // Slug of event with max_photos = 0
// Navigate to upload
await page.click('text=Upload');
await expect(page).toHaveURL(/\/upload/);
// Expect upload disabled and error message
await expect(page.locator('button:disabled')).toBeVisible(); // Upload button disabled
await expect(page.locator('text=Upload-Limit erreicht')).toBeVisible();
});
});

View File

@@ -0,0 +1,159 @@
import { test, expectFixture as expect } from '../helpers/test-fixtures';
test.describe('Standard package checkout with Paddle completion', () => {
test('registers, applies coupon, and reaches confirmation', async ({
page,
clearTestMailbox,
getLatestCheckoutSession,
simulatePaddleCompletion,
getTestMailbox,
}) => {
await clearTestMailbox();
const unique = Date.now();
const email = `checkout+${unique}@example.test`;
const password = 'Password123!';
const username = `playwright-${unique}`;
await page.addInitScript(() => {
window.__openedWindows = [];
const originalOpen = window.open;
window.open = function (...args) {
window.__openedWindows.push(args);
return originalOpen?.apply(this, args) ?? null;
};
});
await page.route('https://cdn.paddle.com/paddle/v2/paddle.js', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/javascript',
body: `
window.__paddleEventCallback = null;
window.__paddleInitOptions = null;
window.__paddleCheckoutConfig = null;
window.Paddle = {
Environment: { set() {} },
Initialize(options) {
window.__paddleInitOptions = options;
window.__paddleEventCallback = options?.eventCallback || null;
},
Checkout: {
open(config) {
window.__paddleCheckoutConfig = config;
},
},
};
`,
});
});
let paddleRequestPayload: Record<string, unknown> | null = null;
await page.route('**/paddle/create-checkout', async (route) => {
paddleRequestPayload = route.request().postDataJSON() as Record<string, unknown>;
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
checkout_url: 'https://sandbox.paddle.test/checkout/abc123',
}),
});
});
await page.goto('/de/packages');
const standardDetailsButton = page
.getByRole('heading', { name: /^Standard$/ })
.locator('..')
.getByRole('button', { name: /Details/i })
.first();
await expect(standardDetailsButton).toBeVisible();
await standardDetailsButton.click();
await expect(page.getByRole('dialog')).toBeVisible();
await page.getByRole('link', { name: /Jetzt bestellen|Order now/i }).click();
await expect(page).toHaveURL(/purchase-wizard/);
await page.getByRole('button', { name: /^Weiter$/ }).first().click();
await expect(page.getByRole('heading', { name: 'Registrieren' })).toBeVisible();
await page.getByLabel(/Vorname/i).fill('Playwright');
await page.getByLabel(/Nachname/i).fill('Tester');
await page.getByLabel(/E-Mail/i).fill(email);
await page.getByLabel(/Telefon/i).fill('+49123456789');
await page.getByLabel(/Adresse/i).fill('Teststr. 1, 12345 Berlin');
await page.getByLabel(/Username/i).fill(username);
await page.getByLabel(/^Passwort$/i).fill(password);
await page.getByLabel(/Passwort bestätigen/i).fill(password);
await page.getByLabel(/Datenschutzerklärung/i).check();
await page.getByRole('button', { name: /^Registrieren$/ }).click();
await expect(page.getByRole('heading', { name: 'Zahlung' })).toBeVisible();
await page.getByPlaceholder(/Gutscheincode/i).fill('PERCENT10');
await page.getByRole('button', { name: /Gutschein anwenden|Apply coupon/i }).click();
await expect(page.getByText(/Gutschein PERCENT10/i)).toBeVisible();
await page.getByRole('button', { name: /Weiter mit Paddle|Continue with Paddle/i }).click();
await expect.poll(async () => page.evaluate(() => window.__paddleCheckoutConfig)).not.toBeNull();
await expect.poll(async () => {
return page.evaluate(() => window.__openedWindows?.length ?? 0);
}).toBe(1);
await expect.poll(async () => {
return page.evaluate(() => window.__openedWindows?.[0]?.[0] ?? null);
}).toContain('https://sandbox.paddle.test/checkout/abc123');
await page.evaluate(() => {
window.__paddleEventCallback?.({ name: 'checkout.completed' });
});
let session = null;
for (let i = 0; i < 6; i++) {
session = await getLatestCheckoutSession({ email });
if (session) {
break;
}
await page.waitForTimeout(500);
}
expect(session).not.toBeNull();
await simulatePaddleCompletion(session!.id);
for (let i = 0; i < 6; i++) {
const refreshed = await getLatestCheckoutSession({ email });
if (refreshed?.status === 'completed') {
session = refreshed;
break;
}
await page.waitForTimeout(500);
}
expect(session?.status).toBe('completed');
await expect(page.getByRole('button', { name: /^Weiter$/ })).toBeEnabled();
await page.getByRole('button', { name: /^Weiter$/ }).last().click();
await expect(page.getByText(/Marketing-Dashboard/)).toBeVisible();
await expect(
page.getByRole('button', { name: /Zum Admin-Bereich|To Admin Area/i })
).toBeVisible();
expect(paddleRequestPayload).not.toBeNull();
expect(paddleRequestPayload?.['coupon_code']).toBe('PERCENT10');
const messages = await getTestMailbox();
expect(messages.length).toBeGreaterThan(0);
});
});
declare global {
interface Window {
__openedWindows?: unknown[];
__paddleEventCallback?: ((event: { name: string }) => void) | null;
__paddleInitOptions?: unknown;
__paddleCheckoutConfig?: unknown;
}
}

View File

@@ -0,0 +1,49 @@
import { test, expectFixture as expect } from '../helpers/test-fixtures';
test.describe('Standard package checkout with coupons', () => {
test('applies seeded coupon and shows discount summary', async ({
page,
tenantAdminCredentials,
seedTestCoupons,
}) => {
test.skip(!tenantAdminCredentials, 'Tenant admin credentials required via E2E_TENANT_EMAIL/PASSWORD');
await seedTestCoupons();
await page.goto('/de/packages');
const detailsButtons = page.getByRole('button', {
name: /Details ansehen|Details anzeigen|View details/i,
});
await expect(detailsButtons.first()).toBeVisible();
await detailsButtons.nth(1).click();
const dialog = page.getByRole('dialog');
await expect(dialog).toBeVisible();
await expect(dialog.getByRole('heading', { name: /Standard/i })).toBeVisible();
await dialog.getByRole('link', { name: /Jetzt bestellen|Order now|Jetzt buchen/i }).click();
await expect(page).toHaveURL(/\/purchase-wizard\/\d+/);
await page.getByRole('button', { name: /^Weiter$/ }).first().click();
await expect(page.getByRole('heading', { name: /Registrieren/i })).toBeVisible();
await page.getByRole('button', { name: /^Anmelden$/ }).first().click();
await page.fill('input[name="identifier"]', tenantAdminCredentials.email);
await page.fill('input[name="password"]', tenantAdminCredentials.password);
await page.getByRole('button', { name: /^Anmelden$/ }).last().click();
await expect(page.getByPlaceholder(/Gutscheincode/i)).toBeVisible();
await page.getByPlaceholder(/Gutscheincode/i).fill('PERCENT10');
await page.getByRole('button', { name: /Gutschein anwenden|Apply coupon/i }).click();
await expect(page.getByText(/Gutschein PERCENT10 aktiviert/i)).toBeVisible();
await expect(page.getByText(/Rabatt|Discount/i)).toBeVisible();
await expect(page.getByText(/Total|Gesamt/i)).toBeVisible();
});
});