Combat: condition dropdown picker with tag chips

- System-aware condition list (5e PHB / pf2e) in src/lib/rules/conditions.ts
- Dropdown replaces free-text input; non-valued conditions add instantly,
  valued ones (Exhaustion, Frightened N, etc.) show a value field, plus Custom
- Already-applied conditions disabled in the list; chips remain click-to-remove
- New e2e covering preset + valued add and tag removal

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 00:44:37 +02:00
parent 866f1e1bf1
commit 0b356adf82
5 changed files with 194 additions and 19 deletions
+26
View File
@@ -37,6 +37,32 @@ test('combat HP damage button reduces hit points', async ({ page }) => {
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();