Phase 15: level-up strategy advisor + campaign insights
- Level-up build-route advisor (src/features/characters/sheet/LevelUpAdvisor.tsx + useLevelUpAdvisor): ~4 system-aware routes plus a custom one; choosing a route expands it into concrete next-level steps. AI when configured, deterministic fallback (src/lib/assistant/levelup.ts) otherwise. Embedded in the existing HP-only LevelUpModal, which stays primary. - Level-up prompts/schemas added to prompts.ts (buildRoutes/buildSteps), each leading with the system constraint + class + next level. - Campaign Insights section on the Assistant page renders deterministic themes, with an optional 'ask the assistant to expand' affordance when AI is on. levelup + prompt unit tests (4 routes both systems, system vocabulary, custom route); e2e for the deterministic route→steps flow and the insights section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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('level-up advisor offers routes and expands a chosen one (deterministic)', async ({ page }) => {
|
||||
await page.getByLabel('Settings').click();
|
||||
await page.getByRole('button', { name: 'Load sample campaign' }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Sample: Lost Mine' })).toBeVisible();
|
||||
|
||||
// Open Lia (level 3 Fighter) and start a level-up.
|
||||
await page.getByLabel('Primary').getByRole('link', { name: 'Characters' }).click();
|
||||
await page.getByRole('link', { name: /Lia the Brave/ }).click();
|
||||
await page.getByRole('button', { name: 'Level up' }).click();
|
||||
|
||||
const advisor = page.getByTestId('levelup-advisor');
|
||||
await page.getByRole('button', { name: 'Suggest build routes' }).click();
|
||||
await expect(advisor).toBeVisible();
|
||||
|
||||
// Four system-aware routes; choose one and see concrete steps for the next level.
|
||||
await expect(advisor.getByText('Offense')).toBeVisible();
|
||||
await expect(advisor.getByRole('button', { name: 'Choose' })).toHaveCount(4);
|
||||
await advisor.locator('li').filter({ hasText: 'Offense' }).getByRole('button', { name: 'Choose' }).click();
|
||||
await expect(advisor.getByText('Level 4 focus')).toBeVisible();
|
||||
});
|
||||
|
||||
test('assistant page renders the campaign insights section', async ({ page }) => {
|
||||
await page.getByLabel('Settings').click();
|
||||
await page.getByRole('button', { name: 'Load sample campaign' }).click();
|
||||
await page.getByRole('link', { name: 'Assistant' }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Campaign insights' })).toBeVisible();
|
||||
// Sample has a single encounter → not enough for a trend yet.
|
||||
await expect(page.getByText(/No trends detected yet/)).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user