Shuffle/e2e/tests/web/krit01-registrierung.spec.ts
cschlaefke eb63636fd9 test(e2e): click buttons via getByRole instead of keyboard helper
Removes pressFirstButton; the web build now exposes real button nodes.

Refs #41

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 13:07:01 +01:00

32 lines
1.5 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { subjects } from '../../support/auth-config';
import { profileByEmail } from '../../support/db';
import { randomEmail, randomPassword } from '../../support/gotrue';
import { extractTokenHash, waitForMail } from '../../support/mailpit';
import { expectSignedIn, login, open, register, t, textOf } from '../../support/web';
test.describe('KTO-01 Kriterium 1 (web): Registrierung bis „E-Mail bestaetigt“ und Anmeldung', () => {
test('KTO-01 Kriterium 1: Registrieren, Link in der Mail oeffnen, bestaetigen, anmelden', async ({ page }) => {
const email = randomEmail();
const password = randomPassword();
await register(page, { email, password, displayName: ' Webnutzer ' });
await expect(page).toHaveURL(/\/register\/check-email$/);
await expect(textOf(page, t.checkEmailTitle)).toBeVisible();
const mail = await waitForMail(email);
expect(mail.Subject).toBe(subjects.confirmation.en);
const { link } = extractTokenHash(mail);
expect((await profileByEmail(email)).display_name).toBe('Webnutzer');
// Der Link aus der Mail fuehrt auf die App; erst der Klick loest die Pruefung aus (Spec E3).
await open(page, link.pathname + link.search);
await page.getByRole('button', { name: t.confirmSubmit }).click();
await expect(textOf(page, t.confirmSuccess)).toBeVisible();
await page.context().clearCookies();
await page.evaluate(() => localStorage.clear());
await login(page, email, password);
await expectSignedIn(page);
});
});