test(insights): close review gaps from #864 and #851

Merged
IZ
25d ago
+125-11

Closes two Greptile findings on merged PRs.

  • #864 (context ranking on analysis replies): the reply tests injected business loaders without rankBusinessContext, so the new ranking path in resume.ts had no coverage. Adds one case to resume-clarification.integration.test.ts. It drives an analysis reply whose business context exceeds the budget through the real ranker with a fake Jev evaluator, then checks four things. The ranked sources (profile, reply, home, exception) reach the analysis and are saved in the observation's contextSnapshot. trackAgentUsage records the typesafe-ai/jev usage (103 tokens) under the reply's org, website and chatId. The reply succeeds. The native hold is confirmed (reserved 1, confirmed 1, released 0).
  • #851 (nested ternaries): the diagnostic tool name and input selection in investigation-flow.test.ts now use plain if/else. Behavior is unchanged.

Verification

  • apps/insights: check-types clean, bun run test 764 pass / 0 fail
  • INSIGHTS_INTEGRATION_TESTS=true bun test --isolate src/resume-clarification.integration.test.ts: 8 pass / 0 fail
  • With the ranking call in resume.ts disabled, the new case fails (the analysis receives decoration in place of exception)
  • biome check clean on both files

Summary by cubic

Closes two test-coverage gaps found in review of #864 and #851.

  • Adds an integration test that runs an oversized analysis reply through the real context ranker with a fake Jev evaluator, verifying the ranked sources, trackAgentUsage recording, and native hold state.
  • Replaces nested ternaries in the diagnostic read fixture in investigation-flow.test.ts with plain if/else, without changing behavior.
  • Throws when a saved reply has no observation instead of asserting it exists, across both integration tests.

Verification

  • check-types clean, 764 unit tests pass, the integration suite passes, and the new case fails when ranking is disabled; biome check clean.