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>
This commit is contained in:
cschlaefke 2026-11-03 13:07:01 +01:00
parent cda9417353
commit eb63636fd9
4 changed files with 10 additions and 21 deletions

View file

@ -23,6 +23,8 @@ export const t = {
termsNotAccepted: 'Please agree to the privacy policy and the terms of use.', termsNotAccepted: 'Please agree to the privacy policy and the terms of use.',
confirmSuccess: 'Email confirmed.', confirmSuccess: 'Email confirmed.',
passwordChanged: 'Password changed. Other devices will be signed out; this can take up to an hour.', passwordChanged: 'Password changed. Other devices will be signed out; this can take up to an hour.',
confirmSubmit: 'Confirm email address',
recoverySubmit: 'Continue to new password',
home: 'Welcome to Shuffle. The board game catalog is coming soon.', home: 'Welcome to Shuffle. The board game catalog is coming soon.',
} as const; } as const;
@ -42,19 +44,6 @@ export async function enableSemantics(page: Page): Promise<void> {
await page.locator('flt-semantics').first().waitFor({ state: 'attached' }); await page.locator('flt-semantics').first().waitFor({ state: 'attached' });
} }
/**
* Bedient die Schaltflaeche auf Seiten ohne Eingabefeld (Link-Seite, CheckEmail) per Tastatur.
*
* BEFUND (a11y, QUE-06): Auf diesen Seiten faltet der Semantics-Baum Titel, Text und Knopf zu
* EINEM `heading` (bzw. `button`) zusammen; ein eigener `button`-Knoten fehlt, ein Klick auf
* die Mitte bewirkt nichts. Per Tab + Enter geht es. Wird die App korrigiert, kann der Helfer
* auf `getByRole('button', ...)` umgestellt werden.
*/
export async function pressFirstButton(page: Page, tabs = 1): Promise<void> {
for (let i = 0; i < tabs; i++) await page.keyboard.press('Tab');
await page.keyboard.press('Enter');
}
/** Navigiert und schaltet Semantics ein. */ /** Navigiert und schaltet Semantics ein. */
export async function open(page: Page, path: string): Promise<void> { export async function open(page: Page, path: string): Promise<void> {
await page.goto(path); await page.goto(path);

View file

@ -3,7 +3,7 @@ import { subjects } from '../../support/auth-config';
import { profileByEmail } from '../../support/db'; import { profileByEmail } from '../../support/db';
import { randomEmail, randomPassword } from '../../support/gotrue'; import { randomEmail, randomPassword } from '../../support/gotrue';
import { extractTokenHash, waitForMail } from '../../support/mailpit'; import { extractTokenHash, waitForMail } from '../../support/mailpit';
import { expectSignedIn, login, open, pressFirstButton, register, t, textOf } from '../../support/web'; 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.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 }) => { test('KTO-01 Kriterium 1: Registrieren, Link in der Mail oeffnen, bestaetigen, anmelden', async ({ page }) => {
@ -21,7 +21,7 @@ test.describe('KTO-01 Kriterium 1 (web): Registrierung bis „E-Mail bestaetigt
// Der Link aus der Mail fuehrt auf die App; erst der Klick loest die Pruefung aus (Spec E3). // 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 open(page, link.pathname + link.search);
await pressFirstButton(page); await page.getByRole('button', { name: t.confirmSubmit }).click();
await expect(textOf(page, t.confirmSuccess)).toBeVisible(); await expect(textOf(page, t.confirmSuccess)).toBeVisible();
await page.context().clearCookies(); await page.context().clearCookies();

View file

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { GoTrueClient, randomEmail, randomPassword, waitMailInterval } from '../../support/gotrue'; import { GoTrueClient, randomEmail, randomPassword, waitMailInterval } from '../../support/gotrue';
import { expectMailCount, waitForMail } from '../../support/mailpit'; import { expectMailCount, waitForMail } from '../../support/mailpit';
import { freshBrowserContext, fillField, login, open, pressFirstButton, register, t, textOf } from '../../support/web'; import { freshBrowserContext, fillField, login, open, register, t, textOf } from '../../support/web';
const gotrue = new GoTrueClient(); const gotrue = new GoTrueClient();

View file

@ -3,7 +3,7 @@ import { subjects } from '../../support/auth-config';
import { expireConfirmationLink, expireRecoveryLink } from '../../support/db'; import { expireConfirmationLink, expireRecoveryLink } from '../../support/db';
import { GoTrueClient, randomEmail, randomPassword } from '../../support/gotrue'; import { GoTrueClient, randomEmail, randomPassword } from '../../support/gotrue';
import { expectMailCount, extractTokenHash, waitForMail } from '../../support/mailpit'; import { expectMailCount, extractTokenHash, waitForMail } from '../../support/mailpit';
import { freshBrowserContext, fillField, open, pressFirstButton, t, textOf } from '../../support/web'; import { freshBrowserContext, fillField, open, t, textOf } from '../../support/web';
const gotrue = new GoTrueClient(); const gotrue = new GoTrueClient();
@ -29,7 +29,7 @@ test.describe('KTO-01 Kriterium 8 (web): Passwort zuruecksetzen', () => {
// Der Link fuehrt auf die Link-Seite; erst der Klick loest die Pruefung aus. // Der Link fuehrt auf die Link-Seite; erst der Klick loest die Pruefung aus.
await open(page, link.pathname + link.search); await open(page, link.pathname + link.search);
await pressFirstButton(page); await page.getByRole('button', { name: t.recoverySubmit }).click();
await expect(page).toHaveURL(/\/reset-password$/); await expect(page).toHaveURL(/\/reset-password$/);
await fillField(page.getByRole('textbox', { name: 'New password' }), newPassword); await fillField(page.getByRole('textbox', { name: 'New password' }), newPassword);
@ -48,7 +48,7 @@ test.describe('KTO-01 Kriterium 8 (web): Passwort zuruecksetzen', () => {
expect((await gotrue.verify(tokenHash, 'recovery')).status).toBe(200); // Link verbraucht expect((await gotrue.verify(tokenHash, 'recovery')).status).toBe(200); // Link verbraucht
await open(page, link.pathname + link.search); await open(page, link.pathname + link.search);
await pressFirstButton(page); await page.getByRole('button', { name: t.recoverySubmit }).click();
await expect(textOf(page, t.linkInvalid)).toBeVisible(); await expect(textOf(page, t.linkInvalid)).toBeVisible();
}); });
@ -60,7 +60,7 @@ test.describe('KTO-01 Kriterium 8 (web): Passwort zuruecksetzen', () => {
await expireRecoveryLink(email); await expireRecoveryLink(email);
await open(page, link.pathname + link.search); await open(page, link.pathname + link.search);
await pressFirstButton(page); await page.getByRole('button', { name: t.recoverySubmit }).click();
await expect(textOf(page, t.linkInvalid)).toBeVisible(); await expect(textOf(page, t.linkInvalid)).toBeVisible();
await expect(page.getByRole('button', { name: 'Request a new link' })).toBeVisible(); await expect(page.getByRole('button', { name: 'Request a new link' })).toBeVisible();
}); });
@ -72,7 +72,7 @@ test.describe('KTO-01 Kriterium 8 (web): Passwort zuruecksetzen', () => {
await expireConfirmationLink(email); await expireConfirmationLink(email);
await open(page, link.pathname + link.search); await open(page, link.pathname + link.search);
await pressFirstButton(page); await page.getByRole('button', { name: t.confirmSubmit }).click();
await expect(textOf(page, t.linkInvalid)).toBeVisible(); await expect(textOf(page, t.linkInvalid)).toBeVisible();
}); });