Files
ttrpg_manager/e2e/fixes.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

91 lines
4.0 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();
});
async function makeCampaign(page: import('@playwright/test').Page, name: string) {
await page.getByRole('button', { name: '+ New campaign' }).first().click();
await page.locator('input[data-autofocus]').fill(name);
await page.getByRole('button', { name: 'Create' }).click();
}
test('combat HP damage button reduces hit points', async ({ page }) => {
await makeCampaign(page, 'Combat Test');
await page.getByRole('link', { name: 'Combat' }).click();
await page.getByRole('button', { name: '+ New encounter' }).first().click();
await page.locator('input[data-autofocus]').fill('Fight');
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('10/10')).toBeVisible();
// Enter 4 damage and apply
await page.getByLabel('Goblin HP amount').fill('4');
await page.getByRole('button', { name: 'Dmg' }).click();
await expect(page.getByText('6/10')).toBeVisible();
// Heal 2 back
await page.getByLabel('Goblin HP amount').fill('2');
await page.getByRole('button', { name: 'Heal' }).click();
await expect(page.getByText('8/10')).toBeVisible();
});
test('combat condition picker adds preset and valued conditions as tags', async ({ page }) => {
await makeCampaign(page, 'Conditions');
await page.getByRole('link', { name: 'Combat' }).click();
await page.getByRole('button', { name: '+ New encounter' }).first().click();
await page.locator('input[data-autofocus]').fill('Fight');
await page.getByRole('button', { name: 'Create' }).click();
await page.getByLabel('Name').fill('Goblin');
await page.getByRole('button', { name: 'Add', exact: true }).click();
const row = page.locator('li', { hasText: 'Goblin' });
// Non-valued condition adds immediately on selection
await row.getByLabel('Add condition').selectOption('Prone');
await expect(row.getByRole('button', { name: /Prone/ })).toBeVisible();
// Valued condition (5e Exhaustion) shows a value field, then adds a tag
await row.getByLabel('Add condition').selectOption('Exhaustion');
await row.getByLabel('Condition value').fill('3');
await row.getByRole('button', { name: 'Add', exact: true }).click();
await expect(row.getByRole('button', { name: /Exhaustion 3/ })).toBeVisible();
// Clicking a tag removes it
await row.getByRole('button', { name: /Prone/ }).click();
await expect(row.getByRole('button', { name: /Prone/ })).toHaveCount(0);
});
test('character can be deleted', async ({ page }) => {
await makeCampaign(page, 'Delete Test');
await page.getByRole('link', { name: 'Characters' }).click();
await page.getByRole('button', { name: '+ New character' }).first().click();
await page.locator('input[data-autofocus]').fill('Doomed');
await page.getByRole('button', { name: 'Create' }).click();
await expect(page.getByRole('heading', { name: 'Doomed' })).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByRole('button', { name: 'Delete', exact: true }).last().click();
await expect(page.getByRole('heading', { name: 'Doomed' })).toHaveCount(0);
});
test('compendium CR filter narrows the bestiary', async ({ page }) => {
await makeCampaign(page, 'Filter Test');
await page.getByRole('link', { name: 'Compendium' }).click();
await expect(page.getByText(/results/)).toBeVisible();
const countText = async () => (await page.getByText(/results/).textContent()) ?? '';
const before = parseInt((await countText()).replace(/\D/g, ''), 10);
await page.getByLabel('Min CR').selectOption({ label: 'CR ≥ 10' });
// wait for the count to update
await expect.poll(async () => parseInt((await countText()).replace(/\D/g, ''), 10)).toBeLessThan(before);
});