Files
ttrpg_manager/e2e/compendium.spec.ts
T
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

47 lines
2.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { createCharacter } from './helpers';
test.beforeEach(async ({ page }) => {
await page.goto('/');
await page.evaluate(async () => {
indexedDB.deleteDatabase('ttrpg-manager');
localStorage.clear();
});
await page.reload();
});
test('compendium: browse 5e categories, switch to PF2e, cross-link a spell', async ({ page }) => {
// Set up a 5e campaign + character to receive a spell
await page.getByRole('button', { name: '+ New campaign' }).first().click();
await page.locator('input[data-autofocus]').fill('Saltmarsh');
await page.getByRole('button', { name: 'Create' }).click();
await page.getByRole('link', { name: 'Characters' }).click();
await createCharacter(page, 'Wizard Wendy');
// Compendium → 5e categories exist (Feats is a new one)
await page.getByRole('link', { name: 'Compendium' }).click();
await expect(page.getByRole('button', { name: 'Feats' })).toBeVisible();
await page.getByRole('button', { name: 'Conditions' }).click();
await expect(page.getByText(/results/)).toBeVisible();
// Spells → add one to the character
await page.getByRole('button', { name: 'Spells', exact: true }).click();
await page.getByPlaceholder(/Search spells/i).fill('fireball');
await page.getByRole('button', { name: /Fireball/ }).first().click();
await page.getByLabel('Add spell to character').selectOption({ label: 'Wizard Wendy' });
await expect(page.getByText(/Added to Wizard Wendy/)).toBeVisible();
// Switch to PF2e — bestiary loads from the static dataset
await page.getByRole('button', { name: 'Pathfinder 2e' }).click();
await page.getByRole('button', { name: 'Bestiary' }).click();
await expect.poll(async () => {
const t = (await page.getByText(/results/).textContent()) ?? '';
return parseInt(t.replace(/\D/g, ''), 10) || 0;
}, { timeout: 15000 }).toBeGreaterThan(0);
// Verify the spell landed on the character sheet
await page.getByRole('link', { name: 'Characters' }).click();
await page.getByRole('link', { name: /Wizard Wendy/ }).click();
await expect(page.getByText('Fireball')).toBeVisible();
});