Repository navigation
test(server): add route-level integration tests for migrated tool_use services - #3637
Merged
bokelley merged 1 commit intoApr 30, 2026
Merged
Conversation
… services (issue #3621) Closes #3621. Adds four integration tests that pin the tool_use output → DB write contract for brand-classifier, brand-enrichment/expandHouse, property-enhancement, and prospect-triage — the services migrated to typed input_schema tool invocations in PR #3611. https://claude.ai/code/session_01RFAvM1RBMzagDAcy5hxZEW
bokelley
marked this pull request as ready for review
April 30, 2026 10:07
bokelley
deleted the
claude/issue-3621-route-level-tool-use-integration-tests
branch
April 30, 2026 10:08
This was referenced Apr 30, 2026
bokelley
added a commit
that referenced
this pull request
Apr 30, 2026
Build Check was cancelled when #3637 merged so these tests landed unverified. Subsequent main runs have all been red. Five issues, fixed forward (production behavior unchanged except for the next_event days rounding): - brand-classifier-route + brand-enrichment-route tests used '${pid}_${Date.now()}' as the SUFFIX, producing underscored test domains. enrichBrand rejects those via /^[a-z0-9.-]+\.[a-z]{2,}$/ → route returned 500. Switch separator to hyphen. - property-enhancement-function test mocked AdAgentsManager with vi.fn().mockImplementation(...). vi.fn returns a function, not a constructor; production calls `new AdAgentsManager()`. Replace with a real class. - prospect-triage-function test raced logTriageDecision, which is fire-and-forget by design. Add a small awaitTriageLog poll helper instead of changing the production call to await (that would alter caller-visible latency for a per-domain triage decision). - member-context.ts: next_event "in N days" rendered with Math.floor on (starts_at - now) / 86_400_000, which flipped "in 5 days" to "in 4 days" when a sub-millisecond gap accrued between the test setting starts_at and the formatter computing the diff. Switch to Math.round — also semantically correct (an event 4.7 days away should render as "in 5 days", not "in 4 days"). Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.
Summary
Closes #3621.
Adds four integration tests that pin the tool_use output → DB write contract for the four services migrated to typed
input_schematool invocations in PR #3611. Without these tests, a drift in the tool_use response shape (e.g.actionreturningundefined) would let unit tests pass while silently persisting malformed data to the DB.brand-classifier-route.test.ts—POST /api/admin/brand-enrichment/domain/:domain→brandsrow haskeller_type,house_domain,confidence,related_domainsfromclassify_brandtool outputbrand-enrichment-route.test.ts—POST /api/admin/brand-enrichment/expand-house/:domain→brandsrows seeded with correcthouse_domain+keller_typefromdiscover_sub_brandsoutput; also covers the tool_use-missing → 500 pathproperty-enhancement-function.test.ts—enhanceProperty()(no HTTP route; called from MCP tool) →hosted_properties.adagents_json.ext.enhancement.ai_analysiswritten fromanalyze_propertyoutputprospect-triage-function.test.ts—triageEmailDomain()(no HTTP route; called from webhooks/batch) →TriageResult+prospect_triage_logrow matchassess_prospectoutput; covers priority default and early-skip pathPattern
All four files follow the
brand-properties-parse.test.tsSDK-layer mock pattern:vi.hoisted()+vi.mock('@anthropic-ai/sdk', FakeAnthropic)with a sharedmocks.anthropicCreatespymockRejectedValue) overridden per test withmockResolvedValueOncebeforeEach/afterAllcleanupNotes
closeDatabase()inafterAllis the pre-existing shared-pool pattern used throughoutserver/tests/integration/. The integration test runner (vitest run server/tests/integration) has nofileParallelism: false— this is a systemic risk carried forward from existing files, not introduced here.property-enhancement-function.test.tsmockswhoiserwith only the namedwhoisDomainexport (the source usesconst { whoisDomain } = await import('whoiser')); thedefault.whoisDomainkey was removed after pre-PR review.prospect-triage-function.test.tspre-emptively mocksaccount-management-db.js(createActionItem) even though none of the three test cases reachhandleSkipSideEffects, guarding against future test additions that exercise that path.Test plan
npm run test:server-integration -- --reporter=verbose brand-classifier-routepasses with DB runningnpm run test:server-integration -- --reporter=verbose brand-enrichment-routepassesnpm run test:server-integration -- --reporter=verbose property-enhancement-functionpassesnpm run test:server-integration -- --reporter=verbose prospect-triage-functionpasseshttps://claude.ai/code/session_01RFAvM1RBMzagDAcy5hxZEW
Generated by Claude Code