Files
ttrpg_manager/e2e/worldbuilding.spec.ts
NilsBriggen ed3d967526 Phase 5: campaign management & worldbuilding
- New entities (note/npc/quest/calendar): schemas, Dexie v4 tables, repos, hooks;
  campaign cascade-delete now covers them all
- Dashboard hub: campaign stats, navigation cards, party overview, recent rolls;
  opening a campaign lands here
- Notes/Wiki: tags, [[wiki-links]] with click-to-open/create, backlinks panel,
  full-text search, autosave
- NPC manager (role/location/faction/status) and Quest tracker (status +
  objectives checklist + reward)
- In-world Calendar: integer day counter + events (no real Date -> no timezone bug)
- Fix: calendarRepo.get is read-only (creating-on-read crashed inside liveQuery)

8 new unit tests (wikilinks + extended cascade), worldbuilding e2e.

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

51 lines
2.3 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('worldbuilding: dashboard, note with wiki link, npc, quest, calendar', async ({ page }) => {
// Create campaign, then open its dashboard
await page.getByRole('button', { name: '+ New campaign' }).first().click();
await page.locator('input[data-autofocus]').fill('Barovia');
await page.getByRole('button', { name: 'Create' }).click();
await page.getByRole('link', { name: 'Dashboard' }).click();
await expect(page.getByRole('heading', { name: 'Barovia' })).toBeVisible();
// Notes: create two and link them
await page.getByRole('link', { name: 'Notes & Wiki' }).click();
await page.getByRole('button', { name: '+ New note' }).first().click();
await page.getByLabel('Note title').fill('Strahd');
await page.getByPlaceholder(/Write here/).fill('Lord of [[Castle Ravenloft]].');
// The link is "missing" until created; click it to create the target note
await page.getByRole('button', { name: 'Castle Ravenloft' }).click();
await expect(page.getByLabel('Note title')).toHaveValue('Castle Ravenloft');
// Backlink from Strahd should appear
await expect(page.getByText('Linked from')).toBeVisible();
// NPC
await page.getByRole('link', { name: 'Dashboard' }).click();
await page.getByRole('link', { name: 'NPCs' }).click();
await page.getByRole('button', { name: '+ New NPC' }).first().click();
await expect(page.getByLabel('NPC name')).toBeVisible();
// Quest with an objective
await page.getByRole('link', { name: 'Dashboard' }).click();
await page.getByRole('link', { name: 'Quests' }).click();
await page.getByRole('button', { name: '+ New quest' }).first().click();
await page.getByPlaceholder('Add objective…').fill('Find the Tome');
await page.getByRole('button', { name: 'Add', exact: true }).click();
await expect(page.locator('input[value="Find the Tome"]')).toBeVisible();
// Calendar advances days
await page.getByRole('link', { name: 'Dashboard' }).click();
await page.getByRole('link', { name: 'Calendar' }).click();
await page.getByRole('button', { name: '+1 week' }).click();
await expect(page.getByText('7', { exact: true })).toBeVisible();
});