import { test, expect } from '@playwright/test'; test.beforeEach(async ({ page }) => { await page.goto('/'); await page.evaluate(async () => { indexedDB.deleteDatabase('ttrpg-manager'); localStorage.clear(); }); await page.reload(); }); test('creation wizard builds a complete character (HP, skills, spell slots)', async ({ page }) => { await page.getByRole('button', { name: '+ New campaign' }).first().click(); await page.locator('input[data-autofocus]').fill('Wizard Camp'); await page.getByRole('button', { name: 'Create' }).click(); await page.getByRole('link', { name: 'Characters' }).click(); await page.getByRole('button', { name: '+ New character' }).first().click(); // Basics: a level-3 Wizard await page.getByLabel('Name').fill('Mira'); await page.getByLabel('Class').selectOption('Wizard'); await page.getByLabel('Level', { exact: true }).fill('3'); await page.getByRole('button', { name: 'Next' }).click(); // Abilities: standard array assignment is valid by default (CON 13 → +1) await page.getByRole('button', { name: 'Next' }).click(); // Skills: Wizard chooses 2 const boxes = page.locator('input[type="checkbox"]'); await boxes.nth(0).check(); await boxes.nth(1).check(); await page.getByRole('button', { name: 'Next' }).click(); // Review shows derived HP + spell slots before finishing await expect(page.getByText('Max HP')).toBeVisible(); await expect(page.getByText('Spell slots')).toBeVisible(); await page.getByRole('button', { name: 'Create character' }).click(); // Lands on the sheet with real HP (d6 + CON over 3 levels = 17), not the old 1/1 await expect(page.getByText('Hit Points')).toBeVisible(); await expect(page.getByText(/\/\s*17/)).toBeVisible(); });