Files
NilsBriggen 04fa90e580 Proper guided character builder + level-up wizard
The bare name/class/level form left new characters as shells (1 HP, all-10
abilities, no proficiencies). Now creation and level-up are guided and auto-populate.

- Hand-authored progression tables (no SRD class/slot data exists on disk):
  src/lib/rules/{dnd5e,pf2e}/progression.ts — core classes' hit die/HP, key
  abilities, save & perception proficiencies, trained-skill counts, caster type;
  5e full/half/pact spell-slot tables, pf2e slot approximation; ASI/boost/skill
  schedules.
- src/lib/rules/progression.ts: getClassDefs/getClassDef, classSkillChoices/Count,
  buildCharacter() (HP from hit die + CON over levels, trained saves/skills, spell
  slots + ability), planLevelUp() (HP gain, new slots, ASI/boost/skill choices),
  applyIncreases/bumpRank. Pure + 12 unit tests.
- Multi-step CreationWizard (Basics → Abilities → Skills → Review) replaces the
  old form; pulls PF2e ancestry HP/speed from the bestiary; review previews HP/AC/
  saves/skills/slots; lands on a ready-to-play sheet.
- LevelUpModal reworked into a guided wizard: auto HP + spell slots, presents the
  level's actual choices (5e ASI/feat, pf2e ability boosts + skill increase) and
  applies them; keeps the strategic build-route advisor.

e2e helper drives the wizard; updated 7 specs to the new flow; new character-wizard
spec asserts a complete level-3 Wizard (HP 17, slots 4xL1 2xL2).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 09:55:48 +02:00

58 lines
2.5 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { createCharacter } from './helpers';
// Each test starts from a clean IndexedDB so runs are deterministic.
test.beforeEach(async ({ page }) => {
await page.goto('/');
await page.evaluate(async () => {
indexedDB.deleteDatabase('ttrpg-manager');
localStorage.clear();
});
await page.reload();
});
test('full core flow: campaign → character → dice → combat → compendium', async ({ page }) => {
// --- Campaign ---
await expect(page.getByRole('heading', { name: 'Campaigns' })).toBeVisible();
await page.getByRole('button', { name: '+ New campaign' }).first().click();
await page.getByLabel('').first().waitFor(); // modal open
await page.locator('input[data-autofocus]').fill('Curse of Strahd');
await page.getByRole('button', { name: 'Create' }).click();
// Card appears and becomes active
await expect(page.getByRole('heading', { name: 'Curse of Strahd' })).toBeVisible();
// --- Character ---
await page.getByRole('link', { name: 'Characters' }).click();
await expect(page.getByRole('heading', { name: 'Characters' })).toBeVisible();
await createCharacter(page, 'Ireena');
// On the sheet: set STR to 16 and expect +3 modifier
await page.getByLabel('STR score').fill('16');
await expect(page.getByText('+3').first()).toBeVisible();
// --- Dice ---
await page.getByRole('link', { name: 'Dice' }).click();
await page.getByRole('button', { name: 'Roll' }).click();
// a result total renders (1..20 for default 1d20)
await expect(page.locator('text=/= \\d+/')).toBeVisible();
// --- Combat ---
await page.getByRole('link', { name: 'Combat' }).click();
await page.getByRole('button', { name: '+ New encounter' }).first().click();
await page.locator('input[data-autofocus]').fill('Ambush');
await page.getByRole('button', { name: 'Create' }).click();
await page.getByLabel('Name').fill('Goblin');
await page.getByRole('button', { name: 'Add', exact: true }).click();
await expect(page.getByText('Goblin')).toBeVisible();
await page.getByRole('button', { name: 'Start combat' }).click();
await expect(page.getByRole('button', { name: 'End' })).toBeVisible(); // combat active
// --- Compendium ---
await page.getByRole('link', { name: 'Compendium' }).click();
await expect(page.getByText(/results/)).toBeVisible();
await page.getByPlaceholder('Search bestiary…').fill('goblin');
await page.getByRole('button', { name: /^Goblin/ }).first().click();
await expect(page.getByRole('heading', { name: 'Goblin', exact: true })).toBeVisible();
});