Skip to content

test(lcms): failing unit tests demonstrating review findings B1–B7 (for #232)#312

Open
PiTrem wants to merge 1 commit into
231-display-lcms-datafrom
test/pr232-blocking-findings
Open

test(lcms): failing unit tests demonstrating review findings B1–B7 (for #232)#312
PiTrem wants to merge 1 commit into
231-display-lcms-datafrom
test/pr232-blocking-findings

Conversation

@PiTrem

@PiTrem PiTrem commented Jun 23, 2026

Copy link
Copy Markdown
Member

These are failing unit tests that reproduce the seven blocking issues from the review of #232. They are meant to land on the 231-display-lcms-data branch as a red baseline to fix against — each test asserts the correct (post-fix) behaviour, so it fails today and turns green once the bug is fixed. No production code is changed.

How to run

yarn test --watchAll=false src/__tests__/units/pr232_review_blocking.test.tsx

(Run against Node 22.17.x, the CI version.)

What each test shows (current result on branch head)

# Location Expected (correct) Actual now
B1 sagas/saga_ui.js peak-add on a non-LCMS layout dispatches EDITPEAK.ADD_POSITIVE dispatches UPDATE_HPLCMS_PEAKS → peak-add silently no-ops on NMR/IR/MS
B2 helpers/integration.js getArea cumulative difference k(xU)−k(xL) = 3 4.5 (integrates the cumulative k curve again); also not invariant to a baseline shift of k (→ 304.5)
B3 helpers/integration.js getAbsoluteArea area from raw y = 1.0 0.5 (uses cumulative k)
B4 helpers/chem.js Convert2Peak honour stored LC/MS peaks + offset → [{x:3,y:100}] [{x:11,y:5}] (recomputed from raw data, offset ignored)
B5 components/d3_multi/multi_focus.js 100 mm² ≡ 1 cm² (same density factor) 100× off (0.01 vs 1) — double /100 for mm²
B6 components/d3_line_rect/index.js UV-Vis update path must not throw on a featureless feature TypeError: Cannot read properties of undefined (reading '0')
B7 components/d3_line_rect/rect_focus.js drawBar must not crash when tTrEndPts is empty (threshold cleared) TypeError: … reading 'y'

The one passing test is the B7 precondition (convertThresEndPts(feature, '') returns []), confirming a cleared threshold produces the empty endpoint list that then crashes drawBar.

Notes

  • B1 is a saga test using the repo's existing drainSelects generator-stepping pattern (__tests__/units/sagas/saga_ui_lcms.test.tsx).
  • B5 calls the pure method via MultiFocus.prototype.computeYTransformFactor; B7 invokes the real drawBar on a stubbed RectFocus instance.
  • B6 reproduces the guarded componentDidMount vs unguarded componentDidUpdate access forms verbatim because ViewerLineRect is not exported; exporting it would let the test drive the real lifecycle.

Suggested fixes are summarised in the review of #232.

Adds src/__tests__/units/pr232_review_blocking.test.tsx, one self-contained
suite that reproduces each of the seven blocking issues raised in the review of
this PR. Every test asserts the correct (post-fix) behaviour, so it fails on the
current branch and turns green once the bug is fixed.

- B1 saga_ui.js: peak-add no longer dispatches EDITPEAK.ADD_POSITIVE on
  non-LCMS layouts (NMR/IR/MS), so peak-add silently no-ops.
- B2 integration.js getArea: trapezoidally integrates the cumulative `k`
  curve instead of returning k(xU)-k(xL); wrong NMR/CV integral.
- B3 integration.js getAbsoluteArea: uses cumulative `k` instead of raw `y`.
- B4 chem.js Convert2Peak: LC/MS branch discards stored peaks and ignores offset.
- B5 multi_focus.js: CV current-density factor double-divides by 100 for mm².
- B6 d3_line_rect/index.js: componentDidUpdate dereferences data[0] unguarded.
- B7 rect_focus.js drawBar: dereferences tTrEndPts[0] with no length guard.

Run: yarn test --watchAll=false src/__tests__/units/pr232_review_blocking.test.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant