Skip to content

test(react): unit-test MHD/.raw pairing; drop redundant drop-reversed e2e#249

Merged
korbinian90 merged 1 commit into
mainfrom
claude/migrate-mhd-pairing-to-unit
Jun 17, 2026
Merged

test(react): unit-test MHD/.raw pairing; drop redundant drop-reversed e2e#249
korbinian90 merged 1 commit into
mainfrom
claude/migrate-mhd-pairing-to-unit

Conversation

@korbinian90

Copy link
Copy Markdown
Collaborator

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 / isImageType are already thoroughly unit-tested in utility.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 .raw pairing.

What this does

buildImageMessageBodies (utility.ts) is the pairing brain behind the probe-mhd drop specs - it parses each .mhd header's ElementDataFile, finds the sibling .raw (order-independent), attaches it as pairedData, removes the .raw as a standalone image, and emits a loadError when the pair is missing. It was exported but had zero unit coverage - exercised only through real WebGL drop e2e.

  • Add buildImageMessageBodies unit tests (in utility.test.ts): order-independent pairing (forward + reversed), case-insensitive basename match, quoted ElementDataFile, backslash paths, ElementDataFile = LOCAL (attached, no pairing), the missing-.raw loadError message, shared-.raw dedup, and non-MHD passthrough. No WebGL - jsdom File-like doubles (buildImageMessageBodies reads only name + arrayBuffer()).
  • Remove 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.ts stays as the real decode-reaches-canvas smoke for the drop path.

Kept in e2e (genuine integration, not touched)

The other six probe-mhd specs each exercise a distinct real decode path - drop (forward), urlparam (auto-fetch paired raw), binary, streamlit-shape, url, and unpaired (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

… 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>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 PWA Preview Deployment

Your 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.

github-actions Bot added a commit that referenced this pull request Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

coverage

Overall line coverage: 41.9% (+1.1) vs main

Package Statements Branches Functions Lines
Shared core (packages/niivue-react) 45.7% (+1.6) 46.8% (+1) 44.8% (+0.1) 46.2% (+1.5)
apps/pwa 28.9% 33.3% 52.9% 30.2%
apps/jupyter 14.4% 15.9% 14.9% 14.5%
apps/streamlit 17.8% 5.3% 18.5% 17.7%
apps/vscode 38.7% 39.6% 18.9% 38.1%
apps/desktop-tauri 81.8% 59.1% 78.9% 84.3%

📊 View full report →

@korbinian90 korbinian90 merged commit d87a05b into main Jun 17, 2026
13 checks passed
github-actions Bot added a commit that referenced this pull request Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧹 PWA Preview Cleanup

The preview deployment for this PR has been removed.

github-actions Bot added a commit that referenced this pull request Jun 17, 2026
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