import type { Page } from '@playwright/test'; import { expect } from '@playwright/test'; const PLAYER_INPUT_IDS: Record = { 'Spieler 1': 'player1-input', 'Spieler 2': 'player2-input', 'Spieler 3 (optional)': 'player3-input', }; /** Open name modal, fill input, confirm — advances wizard step. */ export async function enterPlayerName( page: Page, label: string, placeholder: string, name: string, ) { const inputId = PLAYER_INPUT_IDS[label]; await page.getByRole('button', { name: `Name für ${label} eingeben` }).click(); const dialog = page.getByRole('dialog'); await expect(dialog).toBeVisible(); const input = inputId ? page.locator(`#${inputId}`) : dialog.getByRole('textbox'); await expect(input).toBeFocused(); await input.fill(name); await dialog.getByRole('button', { name: 'Übernehmen' }).click(); await expect(dialog).toBeHidden(); } export async function skipPlayer3(page: Page) { await page.getByRole('button', { name: 'Überspringen' }).click(); } export async function addPoint(page: Page, playerName: string, currentScore: number) { await page .getByRole('button', { name: `Punkt für ${playerName}. Aktueller Stand: ${currentScore}` }) .click(); } export async function addPoints( page: Page, playerName: string, count: number, startScore = 0, ) { for (let i = 0; i < count; i++) { await addPoint(page, playerName, startScore + i); } }