import { type Page } from '@playwright/test'; /** * Walk the guided creation wizard and land on the new character's sheet. * Picks the Barbarian class (a non-caster, so there's no Spells step) and the * default standard array; selects the minimum required trained skills. */ export async function createCharacter(page: Page, name: string): Promise { await page.getByRole('button', { name: '+ New character' }).first().click(); await page.getByLabel('Name').fill(name); // Class step: pick a class card (waits for the data-driven list to load). await page.getByTestId('class-card').filter({ hasText: 'Barbarian' }).click(); await page.getByRole('button', { name: 'Next' }).click(); // → Origin await page.getByRole('button', { name: 'Next' }).click(); // → Abilities (standard array valid) await page.getByRole('button', { name: 'Next' }).click(); // → Skills const next = page.getByRole('button', { name: 'Next' }); const boxes = page.locator('input[type="checkbox"]'); const count = await boxes.count(); for (let i = 0; i < count; i++) { if (!(await next.isDisabled())) break; await boxes.nth(i).check(); } await next.click(); // → Review await page.getByRole('button', { name: 'Create character' }).click(); }