// ============================================================ // PE GUIDE (React port) — smoke tests for the full checklist. // Covers age-group + system pills, overview, scales, sound // libraries, component checklist with status toggles, and the // Generate Exam Report path (mocked via page.route). // ============================================================ const { test, expect, E2E_BASE } = require('../fixtures'); async function openPeGuide(page) { await page.goto(E2E_BASE + '/app/peguide'); await page.waitForSelector('[data-testid="pe-age-group-pills"]', { timeout: 15000 }); } test.describe('React PE Guide — age-group × system navigation', () => { test('all 6 age-group pills render', async ({ authedPage: _, page }) => { await openPeGuide(page); for (const age of ['newborn', 'infant', 'toddler', 'preschool', 'school', 'adolescent']) { await expect(page.locator('[data-testid="pe-age-' + age + '"]')).toBeVisible(); } }); test('all 4 system pills render', async ({ authedPage: _, page }) => { await openPeGuide(page); for (const sys of ['msk', 'neuro', 'resp', 'cv']) { await expect(page.locator('[data-testid="pe-system-' + sys + '"]')).toBeVisible(); } }); test('switching age group rewrites the overview banner', async ({ authedPage: _, page }) => { await openPeGuide(page); await page.click('[data-testid="pe-age-newborn"]'); await expect(page.locator('[data-testid="pe-overview"]')).toContainText('Newborn'); await page.click('[data-testid="pe-age-adolescent"]'); await expect(page.locator('[data-testid="pe-overview"]')).toContainText('Adolescent'); }); test('CV system shows APTM + cardiac sounds + innocent murmurs', async ({ authedPage: _, page }) => { await openPeGuide(page); await page.click('[data-testid="pe-system-cv"]'); await expect(page.locator('[data-testid="pe-cv-aptm"]')).toBeVisible(); await expect(page.locator('[data-testid="sound-normal"]').first()).toBeVisible(); }); test('Resp system shows respiratory sound library', async ({ authedPage: _, page }) => { await openPeGuide(page); await page.click('[data-testid="pe-system-resp"]'); await expect(page.locator('[data-testid="pe-resp-sounds"]')).toBeVisible(); }); }); test.describe('React PE Guide — checklist + generation', () => { test('mark-all-normal sets summary counts and enables Generate', async ({ authedPage: _, page }) => { await openPeGuide(page); await page.click('[data-testid="pe-age-toddler"]'); await page.click('[data-testid="pe-system-msk"]'); await page.click('[data-testid="btn-pe-all-normal"]'); await expect(page.locator('[data-testid="pe-checklist"]')).toContainText('0 not assessed'); await expect(page.locator('[data-testid="btn-pe-generate"]')).toBeEnabled(); }); test('Generate Exam Report calls /api/generate-pe-narrative', async ({ authedPage: _, page }) => { await page.route('**/api/generate-pe-narrative', (route) => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ success: true, model: 'mock-model', narrative: 'MOCK PE narrative from the React port.', summary: { normal: 5, abnormal: 0, notAssessed: 0 }, }), }), ); await openPeGuide(page); await page.click('[data-testid="pe-age-toddler"]'); await page.click('[data-testid="pe-system-msk"]'); await page.click('[data-testid="btn-pe-all-normal"]'); await page.click('[data-testid="btn-pe-generate"]'); await expect(page.locator('[data-testid="pe-narrative"]')).toContainText('MOCK PE narrative'); }); });