Files
ttrpg_manager/e2e/compendium.spec.ts
T
NilsBriggen 379b79e6c4 Phase 2: full compendium across all categories + PF2e data
- Scraped PF2e reference from Archives of Nethys ES into public/data/pf2e/
  (spells, creatures, feats, equipment, weapons, armor, ancestries, heritages,
  backgrounds, archetypes, actions, conditions, deities) via scripts/fetch_pf2e.ts
- Registry-driven compendium: system toggle + per-category nav + generic filters
- 5e expanded: weapons, armor, feats, conditions added alongside spells/monsters/items
- PF2e data served as static assets (fetched, not bundled) for fast native parse
- Cross-links: add spell->spellbook / item->inventory to a campaign character;
  add monster/creature -> open encounter
- Condition tooltips in combat sourced from the conditions glossary
- Tests: registry filter unit tests, compendium e2e (browse + cross-link)

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

48 lines
2.2 KiB
TypeScript

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('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 page.getByRole('button', { name: '+ New character' }).first().click();
await page.locator('input[data-autofocus]').fill('Wizard Wendy');
await page.getByRole('button', { name: 'Create' }).click();
// 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();
});