import { test, expect } from '@playwright/test'; import { createCharacter } from './helpers'; test.beforeEach(async ({ page }) => { await page.goto('/'); await page.evaluate(async () => { indexedDB.deleteDatabase('ttrpg-manager'); localStorage.clear(); }); await page.reload(); }); test('player view shows the party and hides enemy HP numbers', async ({ page }) => { await page.getByRole('button', { name: '+ New campaign' }).first().click(); await page.locator('input[data-autofocus]').fill('Show'); await page.getByRole('button', { name: 'Create' }).click(); // A player character await page.getByRole('link', { name: 'Characters' }).click(); await createCharacter(page, 'Hero'); // An active encounter with the hero + a monster await page.getByRole('link', { name: 'Combat' }).click(); await page.getByRole('button', { name: '+ New encounter' }).first().click(); await page.locator('input[data-autofocus]').fill('Skirmish'); await page.getByRole('button', { name: 'Create' }).click(); await page.getByLabel('Name').fill('Bandit'); await page.getByRole('button', { name: 'Add', exact: true }).click(); const addChar = page.locator('select').filter({ has: page.locator('option', { hasText: 'Choose…' }) }); await addChar.selectOption({ label: 'Hero (Lv 1)' }); await page.getByRole('button', { name: 'Start combat' }).click(); // Player view await page.getByRole('link', { name: 'Dashboard' }).click(); await page.getByRole('link', { name: 'Player View' }).click(); await expect(page.getByRole('heading', { name: 'Show' })).toBeVisible(); await expect(page.getByText('Hero').first()).toBeVisible(); // Enemy shows a status word, not exact HP await expect(page.getByText('Bandit')).toBeVisible(); await expect(page.getByText(/Healthy|Bloodied|Down/)).toBeVisible(); });