Skip to content

fix(tests): unbreak tool_use integration tests merged in #3637#3656

Merged
bokelley merged 1 commit into
mainfrom
bokelley/fix-broken-tool-use-tests
Apr 30, 2026
Merged

fix(tests): unbreak tool_use integration tests merged in #3637#3656
bokelley merged 1 commit into
mainfrom
bokelley/fix-broken-tool-use-tests

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Build Check has been red on main since #3637 merged with cancelled CI. Five issues — four broken tests + one pre-existing flake — fixed forward. All 44 tests across the affected suites pass locally.

What was broken

File Issue Fix
brand-classifier-route.test.ts SUFFIX = '${pid}_${Date.now()}' → underscored domain → enrichBrand rejects via regex → 500 Switch separator to hyphen
brand-enrichment-route.test.ts Same underscore issue Switch separator to hyphen
property-enhancement-function.test.ts vi.fn().mockImplementation(...) is not a constructor; production calls new AdAgentsManager() Mock with a real class
prospect-triage-function.test.ts triageEmailDomain calls logTriageDecision(...) fire-and-forget; SELECT raced INSERT Add a small awaitTriageLog poll helper (don't change production behavior)
member-context.ts > next_event Math.floor((starts_at - now) / 86_400_000) flipped "in 5 days" → "in 4 days" on sub-millisecond gap Math.round — also semantically correct

Why the production code change for next_event

The pre-existing flake is pure UX: an event 4.7 days from now should render "in 5 days", not "in 4 days". The test author set starts_at = now + 5 days and expected "in 5 days"; the formatter raced Date.now() and floored. Switching to Math.round fixes both the flake and the user-visible rounding behavior.

Test plan

  • All 5 affected suites pass locally (44/44 tests, ran with WORKOS_API_KEY=sk_test_dummy WORKOS_CLIENT_ID=client_test_dummy DATABASE_URL=...)
  • Pre-commit (test:unit + test-dynamic-imports + typecheck) — green
  • Verify Build Check goes green on this PR

Related

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
@bokelley
bokelley enabled auto-merge (squash) April 30, 2026 11:24
@bokelley
bokelley merged commit cbf4106 into main Apr 30, 2026
13 checks passed
@bokelley
bokelley deleted the bokelley/fix-broken-tool-use-tests branch April 30, 2026 11:29
bokelley added a commit that referenced this pull request Apr 30, 2026
…#3661)

Follow-up to #3656. Three integration test files still used
`${process.pid}_${Date.now()}` (underscore separator) for their PID+timestamp
SUFFIX:

- property-enhancement-function.test.ts
- brand-properties-parse.test.ts
- addie-brand-property-tools.test.ts

Underscores are invalid in domain names per RFC 1035. These three pass
today because their TEST_DOMAIN never hits a regex-validating code path —
property-enhancement skips validation; brand-properties-parse and
addie-brand-property-tools mock out the routes that would. But the next test
that adds a real `enrichBrand` / `expandHouse` call would rediscover the bug
that #3656 just fixed.

Switched to a hyphen across the board to match the convention established in
#3656 (`brand-classifier-route`, `brand-enrichment-route`, `prospect-triage`).
No behavior change for the existing tests; org/user IDs are still opaque
strings, just with a hyphen instead of an underscore in the suffix.

Verified locally: 39/39 tests pass across the three affected files.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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