test(react): unit-test MHD/.raw pairing; drop redundant drop-reversed e2e#249
Merged
Merged
Conversation
… e2e buildImageMessageBodies - the .mhd/.raw pairing brain behind the probe-mhd drop specs - was exported but untested. Add unit tests covering ElementDataFile parsing (quotes, LOCAL, backslash paths), order-independent pairing, the missing-pair loadError message, shared-.raw dedup, and non-MHD passthrough, all with no WebGL load (jsdom File-like doubles). Remove probe-mhd-drop-reversed.spec.ts: its unique claim - that pairing is independent of drop order - is now a unit test, and probe-mhd-drop.spec.ts remains as the real decode-reaches-canvas smoke for the drop path. @niivue/react unit tests green; lint + type-check green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
🚀 PWA Preview DeploymentYour PWA preview has been deployed! Preview URL: https://niivue.github.io/niivue-vscode/pr-249/ This preview will be updated automatically when you push new commits to this PR. |
Contributor
Coverage ReportOverall line coverage: 41.9% (+1.1) vs
|
Contributor
🧹 PWA Preview CleanupThe preview deployment for this PR has been removed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Next step in the unit-first migration (after #247, merged).
Heads-up on the originally-proposed candidate
I offered "DICOM magic-byte sniffing" next, but it turns out
isDicomData/isImageTypeare already thoroughly unit-tested inutility.test.ts(DICM-at-offset-128, all input shapes, wrong-offset, too-short, non-binary). The prior author already did that one. So I pivoted to the adjacent pure logic that was untested: MHD.rawpairing.What this does
buildImageMessageBodies(utility.ts) is the pairing brain behind theprobe-mhddrop specs - it parses each.mhdheader'sElementDataFile, finds the sibling.raw(order-independent), attaches it aspairedData, removes the.rawas a standalone image, and emits aloadErrorwhen the pair is missing. It was exported but had zero unit coverage - exercised only through real WebGL drop e2e.buildImageMessageBodiesunit tests (inutility.test.ts): order-independent pairing (forward + reversed), case-insensitive basename match, quotedElementDataFile, backslash paths,ElementDataFile = LOCAL(attached, no pairing), the missing-.rawloadErrormessage, shared-.rawdedup, and non-MHD passthrough. No WebGL - jsdom File-like doubles (buildImageMessageBodiesreads onlyname+arrayBuffer()).probe-mhd-drop-reversed.spec.ts: its only unique claim - pairing is independent of drop order - is now a unit test.probe-mhd-drop.spec.tsstays as the real decode-reaches-canvas smoke for the drop path.Kept in e2e (genuine integration, not touched)
The other six
probe-mhdspecs each exercise a distinct real decode path -drop(forward),urlparam(auto-fetch paired raw),binary,streamlit-shape,url, andunpaired(the missing-pair warning surfacing on-canvas). The pairing logic is now unit-tested; these keep proving the integration.Verification
@niivue/react: 132 unit tests pass (10 files; +9 here).turbo lint type-check: green.🤖 Generated with Claude Code