Ships the /app/calculators page with the 10-pill sub-nav and flips
the sidebar Calculators link to available. All formula math stays
in the vanilla viewer for this commit.
client/src/pages/Calculators.tsx
PILLS array mirrors public/components/calculators.html exactly:
BP Percentile, BMI, Growth, Bilirubin, Vital Signs, BSA,
Weight-Based Dosing, Resus Meds, GCS, Equipment. Each pill carries
its canonical source (AAP 2017 Flynn / Fenton 2013 / AAP 2022
Kemper / Bhutani 1999 / Mosteller / PALS / …) so when a reader
opens the page they know which authoritative reference the numbers
trace back to.
Why no math in this commit — explicitly gated
The migration checkpoint has a specific rule for this tab:
"generate test vectors (JSON file with {inputs, expectedOutput}
tuples) by running the vanilla version with 20+ known cases. The
React port must match every vector byte-for-byte. An LLM will
sometimes 'simplify' a long array of numbers and silently break it
— don't let that happen." This applies in particular to:
• Rosner quantile splines in the BP percentile calc
• Fenton 2013 LMS preterm (210 validated cases)
• AAP 2022 bilirubin phototherapy + exchange (1190 validated cases)
• Bhutani nomogram risk zones
• APLS + Best Guess weight-for-age
Each formula gets its own commit once the vector file lands in
e2e/fixtures/ — this shell just makes the nav complete so users
can navigate to the tab in the React tree.
e2e/tests/calculators-react.spec.js — three smoke tests:
all 10 pills render by data-testid in the expected order, pill
click switches the active panel, and the legacy-viewer link is
present.
Client tsc -b + vite build clean. Bundle 460.19 kB / 131.43 kB gz.
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
// ============================================================
|
|
// 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();
|
|
});
|
|
});
|