// ============================================================ // CALCULATORS (React port) — sub-nav shell smoke test. // // Pure shell test until test vectors + formula ports land in // dedicated follow-up commits. // ============================================================ const { test, expect, E2E_BASE } = require('../fixtures'); const EXPECTED_PILLS = [ 'bp', 'bmi', 'growth', 'bili', 'vitals', 'bsa', 'dose', 'resus', 'gcs', 'equipment', ]; async function openReactCalc(page) { await page.goto(E2E_BASE + '/app/calculators'); await page.waitForSelector('[data-testid="calc-subnav"]', { timeout: 15000 }); } test.describe('React Calculators — sub-nav shell', () => { test('all 10 pills render in expected order', async ({ authedPage: _, page }) => { await openReactCalc(page); for (const id of EXPECTED_PILLS) { await expect(page.locator('[data-testid="calc-pill-' + id + '"]')).toBeVisible(); } }); test('clicking a pill switches the active panel', async ({ authedPage: _, page }) => { await openReactCalc(page); await expect(page.locator('[data-testid="calc-panel-bp"]')).toBeVisible(); await page.click('[data-testid="calc-pill-bili"]'); await expect(page.locator('[data-testid="calc-panel-bili"]')).toBeVisible(); }); test('each panel carries a legacy-viewer link', async ({ authedPage: _, page }) => { await openReactCalc(page); await expect(page.getByText('Open in legacy viewer').first()).toBeVisible(); }); test('BSA calculator runs in React', async ({ authedPage: _, page }) => { await openReactCalc(page); await page.click('[data-testid="calc-pill-bsa"]'); await page.fill('#react-bsa-weight', '20'); await page.fill('#react-bsa-height', '110'); await page.click('[data-testid="calc-bsa-calculate"]'); await expect(page.locator('[data-testid="calc-bsa-result"]')).toContainText('0.782'); }); test('weight-based dose calculator caps max dose', async ({ authedPage: _, page }) => { await openReactCalc(page); await page.click('[data-testid="calc-pill-dose"]'); await page.fill('#react-dose-weight', '15'); await page.fill('#react-dose-per-kg', '100'); await page.fill('#react-dose-max', '500'); await page.click('[data-testid="calc-dose-calculate"]'); await expect(page.locator('[data-testid="calc-dose-result"]')).toContainText('500.0 mg'); await expect(page.locator('[data-testid="calc-dose-result"]')).toContainText('Capped'); }); test('GCS calculator updates score from selected components', async ({ authedPage: _, page }) => { await openReactCalc(page); await page.click('[data-testid="calc-pill-gcs"]'); await expect(page.locator('[data-testid="calc-gcs-result"]')).toContainText('GCS: 15/15'); await page.selectOption('#react-gcs-motor', '1'); await expect(page.locator('[data-testid="calc-gcs-result"]')).toContainText('GCS: 10/15'); }); });