Skip to content

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

Open
NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
NewCoder3294:test/handler-unit-tests
Open

test: add unit tests for server handler business logic#820
NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
NewCoder3294:test/handler-unit-tests

Conversation

@NewCoder3294
Copy link
Contributor

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 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 2, 2026

@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
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