Shuffle/e2e/tests/web/krit49-anmeldung-einstieg.spec.ts
cschlaefke 7eaed46dc2
All checks were successful
CI / flutter (pull_request) Successful in 1m38s
CI / web-build (pull_request) Successful in 1m38s
CI / supabase (pull_request) Successful in 13s
CI / supabase-tests (pull_request) Successful in 35s
CI / e2e (pull_request) Successful in 2m58s
test(auth): address review findings on sign-in prompt (PR A)
Correct the focus comment (refs #61), test Space key and focus state,
prove scrollability at 200 percent text, drop needless minWidth, English
doc comment, allow OutlinedButton as secondary action in standalone cards,
English prompt text says plays instead of games.

Refs #49

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 01:25:22 +01:00

89 lines
4.2 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { GoTrueClient, randomEmail, randomPassword } from '../../support/gotrue';
import { expectSignedIn, login, open, textOf } from '../../support/web';
const gotrue = new GoTrueClient();
/** Texte (app_en.arb). */
const prompt = {
title: 'Your account',
body: 'Sign in to manage your collection and plays.',
};
test.describe('#49 Kriterium 1 / QUE-09 Kriterium 13 (web): Anmelde-Hinweis auf der Startseite', () => {
test('#49 Kriterium 1: abgemeldet zeigt die Startseite den Hinweis mit „Sign in“ und „Create account“', async ({ page }) => {
await open(page, '/');
await expect(textOf(page, prompt.title)).toBeVisible();
await expect(textOf(page, prompt.body)).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign in', exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'Create account', exact: true })).toBeVisible();
});
test('#49 Kriterium 1: „Sign in“ fuehrt zu /login', async ({ page }) => {
await open(page, '/');
await page.getByRole('button', { name: 'Sign in', exact: true }).click();
await expect(page).toHaveURL(/\/login$/);
await expect(page.getByRole('textbox', { name: 'Email address' })).toBeVisible();
});
test('#49 Kriterium 1: „Create account“ fuehrt zu /register', async ({ page }) => {
await open(page, '/');
await page.getByRole('button', { name: 'Create account', exact: true }).click();
await expect(page).toHaveURL(/\/register$/);
await expect(page.getByRole('textbox', { name: 'Display name' })).toBeVisible();
});
test('QUE-06 Kriterium 4: Lesereihenfolge; erster Tab erreicht „Sign in“, Enter loest aus', async ({ page }) => {
await open(page, '/');
await expect(page.getByRole('button', { name: 'Sign in', exact: true })).toBeVisible();
// Lesereihenfolge (Semantics-Baum): Ueberschrift, Text, „Sign in“, „Create account“.
const snapshot = await page.locator('body').ariaSnapshot();
const pos = [
`heading "${prompt.title}"`,
prompt.body,
'button "Sign in"',
'button "Create account"',
].map((needle) => snapshot.indexOf(needle));
expect(pos.every((p) => p >= 0)).toBe(true);
expect([...pos].sort((x, y) => x - y)).toEqual(pos);
// Reihenfolge ueber das Verhalten: erster Tab = „Sign in“, zweiter Tab = „Create account“,
// Enter loest den fokussierten Knopf aus. DOM-Fokus (toBeFocused) liegt nur auf „Create account“;
// „Sign in“ bekommt nie DOM-Fokus (kein tabindex, AppPrimaryButton verwirft focusable/focused
// des FilledButton), siehe Issue #61. Der Fokusring selbst wird im Canvas gezeichnet.
await page.keyboard.press('Tab');
await page.keyboard.press('Enter');
await expect(page).toHaveURL(/\/login$/);
});
test('QUE-06 Kriterium 4: zweiter Tab erreicht „Create account“, Enter loest aus', async ({ page }) => {
await open(page, '/');
await expect(page.getByRole('button', { name: 'Create account', exact: true })).toBeVisible();
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await expect(page.getByRole('button', { name: 'Create account', exact: true })).toBeFocused();
await page.keyboard.press('Enter');
await expect(page).toHaveURL(/\/register$/);
});
test('QUE-06 Kriterium 4: Leertaste loest „Create account“ aus', async ({ page }) => {
await open(page, '/');
await expect(page.getByRole('button', { name: 'Create account', exact: true })).toBeVisible();
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await expect(page.getByRole('button', { name: 'Create account', exact: true })).toBeFocused();
await page.keyboard.press('Space');
await expect(page).toHaveURL(/\/register$/);
});
test('#49 Kriterium 1: angemeldet erscheint der Hinweis nicht', async ({ page }) => {
const email = randomEmail();
const password = randomPassword();
await gotrue.createConfirmedUser(email, password);
await login(page, email, password);
await expectSignedIn(page);
await expect(page.getByRole('button', { name: 'Create account', exact: true })).toHaveCount(0);
await expect(textOf(page, prompt.body)).toHaveCount(0);
});
});