Skip to content

test: add unit tests for server handler business logic#820

Merged
koala73 merged 2 commits into
koala73:mainfrom
NewCoder3294:test/handler-unit-tests
Mar 19, 2026
Merged

test: add unit tests for server handler business logic#820
koala73 merged 2 commits into
koala73:mainfrom
NewCoder3294:test/handler-unit-tests

Conversation

@NewCoder3294

Copy link
Copy Markdown
Collaborator

Summary

Adds tests/handlers.test.mts with 72 test cases across 14 suites covering exported pure functions from three server handler modules. This addresses the gap noted in #181 where 949 lines of tests were deleted in a migration with no replacements.

Modules covered

Module Functions tested Test cases
server/worldmonitor/cyber/v1/_shared.ts clampInt, dedupeThreats, toProtoCyberThreat, enum maps (THREAT_TYPE_MAP, SOURCE_MAP, SEVERITY_MAP, SEVERITY_RANK) 25
server/worldmonitor/news/v1/_shared.ts + dedup.mjs + server/_shared/hash.ts deduplicateHeadlines, hashString, buildArticlePrompts 17
server/worldmonitor/infrastructure/v1/get-cable-health.ts isCableRelated, parseCoordinates, matchCableByName, findNearestCable, parseIssueDate, processNgaSignals, computeHealthMap 30

Not covered (follow-up suggestions)

server/worldmonitor/military/v1/get-usni-fleet-report.ts contains many useful pure helpers (hullToVesselType, detectDeploymentStatus, extractHomePort, stripHtml, getRegionCoords, parseUSNIArticle, extractBattleForceSummary) but these are not exported. A follow-up PR should export those functions to enable unit testing.

Test plan

  • All 72 new tests pass (npx tsx --test tests/handlers.test.mts)
  • Existing test suite (test:data) unaffected (pre-existing bootstrap test failure confirmed on main)
  • Pre-push type checks pass

Closes #181

🤖 Generated with Claude Code

Adds tests/handlers.test.mts with 72 test cases across 14 suites covering
exported pure functions from three server handler modules:

- cyber/_shared.ts: clampInt, dedupeThreats, toProtoCyberThreat, enum maps
- news/_shared.ts + dedup.mjs + hash.ts: deduplicateHeadlines, hashString,
  buildArticlePrompts
- infrastructure/get-cable-health.ts: isCableRelated, parseCoordinates,
  matchCableByName, findNearestCable, parseIssueDate, processNgaSignals,
  computeHealthMap

Closes koala73#181

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@vercel

vercel Bot commented Mar 2, 2026

Copy link
Copy Markdown

@NewCoder3294 is attempting to deploy a commit to the Elie Team on Vercel.

A member of the Team first needs to authorize it.

@koala73 koala73 added Ready to Merge PR is mergeable, passes checks, and adds value High Value Meaningful contribution to the project labels Mar 3, 2026
@vercel

vercel Bot commented Mar 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment Mar 19, 2026 8:19am

Request Review

@koala73
koala73 merged commit 58a93ea into koala73:main Mar 19, 2026
5 checks passed
nichm pushed a commit to nichm/worldmonitor-private that referenced this pull request Jul 1, 2026
Adds tests/handlers.test.mts with 72 test cases across 14 suites covering
exported pure functions from three server handler modules:

- cyber/_shared.ts: clampInt, dedupeThreats, toProtoCyberThreat, enum maps
- news/_shared.ts + dedup.mjs + hash.ts: deduplicateHeadlines, hashString,
  buildArticlePrompts
- infrastructure/get-cable-health.ts: isCableRelated, parseCoordinates,
  matchCableByName, findNearestCable, parseIssueDate, processNgaSignals,
  computeHealthMap

Closes koala73#181

Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Elie Habib <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Value Meaningful contribution to the project Ready to Merge PR is mergeable, passes checks, and adds value

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for migrated sebuf handler business logic

2 participants