Skip to content

Extract recent-uploads & search helpers + unit tests - #28

Merged
aperson30 merged 1 commit into
mainfrom
aditya/more-tests
Jun 18, 2026
Merged

aperson30 merged 1 commit into
mainfrom
aditya/more-tests

Conversation

@aperson30

Copy link
Copy Markdown
Collaborator

Summary

Extracts two pieces of bespoke logic into testable helper modules and adds unit tests for them. No behavior change — pure refactor + tests.

What moved

  • helpers/recentUploads.ts — the Upload page's localStorage "Recent Uploads" logic (load/add/update/format/color), previously inline in UploadPage.tsx.
  • helpers/search.ts — the dashboard's advanced-search query building (buildSearchParams) and case-id parsing (itemToId), previously inline in Homepage.tsx.

UploadPage.tsx and Homepage.tsx now import from these modules; output is identical.

Tests added (14 → 28 total)

  • recent-uploads (8): empty/malformed storage, newest-first ordering, de-dup by sessionId, 8-item cap, status updates, relative-time formatting, status→color.
  • search (6): itemToId parsing + fallbacks; buildSearchParams tumor 1/0/omit mapping, sex[]/age_bin[] multi-append, optional sort_by/per_page.

Verified locally: 28 tests pass, type-check, and build all green.

- Move recent-uploads localStorage helpers from UploadPage into
  helpers/recentUploads.ts (no behavior change)
- Move advanced-search query building and case-id parsing from Homepage into
  helpers/search.ts (no behavior change)
- Add 14 unit tests for the two modules: dedup, 8-item cap, status updates,
  relative-time formatting, tumor/sex/age param mapping, and id parsing
@aperson30
aperson30 merged commit 28cb4a0 into main Jun 18, 2026
5 checks passed
@aperson30
aperson30 deleted the aditya/more-tests branch June 18, 2026 05:45
Yusufa09 pushed a commit to Yusufa09/BodyMaps-website that referenced this pull request Jul 12, 2026
Extract recent-uploads & search helpers + unit tests
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