From 7fe2775f61eebf677bed32724597fa8ea21fcff5 Mon Sep 17 00:00:00 2001 From: bewest <2492599-bewest@users.noreply.replit.com> Date: Mon, 19 Jan 2026 17:14:30 +0000 Subject: [PATCH] Update documentation with recent test stability improvements Add details about a floating-point precision fix for boluswizardpreview.test.js and note an infrastructure issue with test process hangs during server teardown in replit.md. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cf276ff5-4001-4b44-93fe-7c9786ee4327 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 0e1264f9-9ae7-4b11-a0e7-658fe3d1f1ac Replit-Helium-Checkpoint-Created: true --- docs/test-specs/flaky-tests.md | 18 ++++++++++++++++++ replit.md | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/test-specs/flaky-tests.md b/docs/test-specs/flaky-tests.md index 2c77fee1..7e9cacd5 100644 --- a/docs/test-specs/flaky-tests.md +++ b/docs/test-specs/flaky-tests.md @@ -45,6 +45,24 @@ Some tests are slow due to server boot overhead (2-3s per test): ## Recently Fixed Tests +### boluswizardpreview.test.js - Floating-Point Precision Fix (Fixed January 19, 2026) + +**Problem:** Test `set a pill to the BWP with infos` would intermittently fail, expecting `'0.50U'` but receiving `'0.51U'`. + +**Root Cause:** +- The `roundInsulinForDisplayFormat()` function in `lib/sandbox.js` used `Math.floor(insulin / 0.01) * 0.01` +- Floating-point precision errors caused values like `0.50499999...` to sometimes be represented as `0.5050000001...` +- The floor operation at this boundary could produce either `0.50` or `0.51` non-deterministically + +**Fix Applied:** +1. Added epsilon (`1e-9`) before floor operation: `Math.floor(insulin * 100 + 1e-9) / 100` +2. Applied same fix to medtronic rounding style for consistency +3. The epsilon is small enough not to affect normal values but stabilizes boundary cases + +**Verification:** Test passes 100% across 5 consecutive runs. + +--- + ### api.shape-handling.test.js (Fixed January 19, 2026) **Problem:** Test file was slow and occasionally timed out during stress testing due to excessive server boot overhead. diff --git a/replit.md b/replit.md index 40fc6547..4ceca756 100644 --- a/replit.md +++ b/replit.md @@ -143,11 +143,14 @@ npm run test:slow # Tests with slow threshold logging **Summary:** ✅ **TESTS STABLE** - Stress testing (3-5 iterations per test file) shows 100% pass rate across all test files including api.shape-handling (now optimized). **Recent Fixes:** +- `boluswizardpreview.test.js` - Fixed floating-point precision issue in `roundInsulinForDisplayFormat()` by adding epsilon (1e-9) before floor operation; test "set a pill to the BWP with infos" now stable - `api.shape-handling.test.js` - Fixed by optimizing server boot (beforeEach→before); now runs in ~6s with 172ms/test avg - `api.deduplication.test.js` - Fixed timeout issues by increasing timeout to 30s and optimizing cleanup -- `boluswizardpreview.test.js` - All 10 tests now pass - `api3.renderer.test.js` - XML/CSV content type tests now pass +**Known Infrastructure Issue:** +- Full test suite runs may hang during server teardown (tick cycles continue after tests complete). Individual test files pass when run in isolation. This is a test cleanup issue, not test flakiness. + **Flaky Test Status:** See `docs/test-specs/flaky-tests.md` for current status summary and improvement roadmap. #### Slow Tests