// ============================================================ // BEDSIDE (React port) — sub-nav shell smoke test. // // First-commit scope: the 15 sub-pills render in the expected order // and selecting a pill reveals a panel with a legacy-viewer link. // Actual clinical dosing panels (neonatal through trauma) port in // dedicated follow-up commits alongside the calculators. // ============================================================ const { test, expect, E2E_BASE } = require('../fixtures'); const EXPECTED_PILLS = [ 'neonatal', 'airway', 'cardiac', 'respiratory', 'ventilation', 'seizure', 'sepsis', 'anaphylaxis', 'sedation', 'agitation', 'antiemetics', 'antimicrobials', 'burns', 'toxicology', 'trauma', ]; async function openReactBedside(page) { await page.goto(E2E_BASE + '/app/bedside'); await page.waitForSelector('[data-testid="bedside-subnav"]', { timeout: 15000 }); } test.describe('React Bedside — sub-nav shell', () => { test('all 15 sub-pills render in the expected order', async ({ authedPage: _, page }) => { await openReactBedside(page); for (const id of EXPECTED_PILLS) { await expect(page.locator('[data-testid="bedside-pill-' + id + '"]')).toBeVisible(); } }); test('clicking a pill switches the active panel', async ({ authedPage: _, page }) => { await openReactBedside(page); await expect(page.locator('[data-testid="bedside-panel-neonatal"]')).toBeVisible(); await page.click('[data-testid="bedside-pill-airway"]'); await expect(page.locator('[data-testid="bedside-panel-airway"]')).toBeVisible(); }); test('panel carries a legacy-viewer link', async ({ authedPage: _, page }) => { await openReactBedside(page); await expect(page.getByText('Open in legacy viewer').first()).toBeVisible(); }); test('age-to-weight estimator runs in React', async ({ authedPage: _, page }) => { await openReactBedside(page); await page.fill('[data-testid="bedside-age-input"]', '3y'); await expect(page.locator('[data-testid="bedside-estimate-result"]')).toContainText('14 kg'); await expect(page.locator('[data-testid="bedside-weight-input"]')).toHaveValue('14'); await page.selectOption('[data-testid="bedside-formula-select"]', 'bestguess'); await expect(page.locator('[data-testid="bedside-estimate-result"]')).toContainText('16 kg'); await expect(page.locator('[data-testid="bedside-weight-input"]')).toHaveValue('16'); }); test('anaphylaxis panel computes IM epinephrine dose by weight', async ({ authedPage: _, page }) => { await openReactBedside(page); await page.click('[data-testid="bedside-pill-anaphylaxis"]'); await page.fill('[data-testid="anaph-weight"]', '20'); // 20 kg × 0.01 mg/kg = 0.2 mg epi IM (below the 0.5 mg cap). await expect(page.locator('[data-testid="bedside-panel-anaphylaxis"]')).toContainText('0.2 mg'); // Uncapped — ensure 0.5 kicks in past the cap threshold (wt ≥ 50 kg). await page.fill('[data-testid="anaph-weight"]', '70'); await expect(page.locator('[data-testid="bedside-panel-anaphylaxis"]')).toContainText('0.5 mg'); }); test('cardiac arrest PALS general table renders weight-scaled epinephrine', async ({ authedPage: _, page }) => { await openReactBedside(page); await page.click('[data-testid="bedside-pill-cardiac"]'); await page.fill('[data-testid="cardiac-weight"]', '25'); // Default view is general. Epi IV = 0.01 mg/kg × 25 = 0.25 mg. await expect(page.locator('[data-testid="bedside-panel-cardiac"]')).toContainText('0.25 mg'); // Switching to Asystole keeps the same dose logic. await page.click('[data-testid="cardiac-view-asystole"]'); await expect(page.locator('[data-testid="bedside-panel-cardiac"]')).toContainText('0.25 mg'); }); test('seizure pathway computes D10W bolus range by weight', async ({ authedPage: _, page }) => { await openReactBedside(page); await page.click('[data-testid="bedside-pill-seizure"]'); await page.fill('[data-testid="seizure-weight"]', '10'); // 10 kg × 2-5 mL/kg = 20-50 mL D10W await expect(page.locator('[data-testid="bedside-panel-seizure"]')).toContainText('20-50 mL'); // Lorazepam 0.1 mg/kg × 10 = 1 mg await expect(page.locator('[data-testid="bedside-panel-seizure"]')).toContainText('1 mg'); }); });