Fix dead assertion in Slack private-channel audience test - #2748
Fix dead assertion in Slack private-channel audience test#2748kapunahelewong wants to merge 1 commit into
Conversation
The test "ignores Slack bot and app members when deriving a private-channel audience" asserted against mocks.rows.audienceMembers, but ensureCaptureAudience is fully mocked in this file and never writes to that array (it always hardcodes kind: "org" and ignores memberEmails). The assertion could never pass and never actually exercised the bot/app-member filtering it claimed to cover. Switch to the same convention already used by sibling tests in this describe block: assert on what the mocked ensureCaptureAudience was called with (kind, memberEmails, upstreamRefHash), matching what createSlackThreadCapture actually passes through createCapture. Verified the fix catches a real regression: temporarily disabled the bot/app-user filter in connectors.ts, confirmed this test fails, then restored the filter. Full brain suite: 282/282 passing, 34 files. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Here's a visual recap of what changed: Open the full interactive recap |
There was a problem hiding this comment.
Builder reviewed your changes — looks good ✅
Review Details
Code Review Summary
PR #2748 replaces a dead assertion in the Slack private-channel audience test with an assertion against the mocked ensureCaptureAudience call. This aligns the test with the actual mock boundary and verifies the filtered member email, private-channel audience kind, and upstream reference hash that createSlackThreadCapture should pass through.
The approach is sound for this low-risk, test-only change. Two independent reviews found no confirmed correctness, security, or performance issues. The new assertion is materially stronger than reading mocks.rows.audienceMembers, which the fully mocked audience implementation does not populate, and the reported targeted and full-suite verification supports the change. No comments are required.
Risk assessment: Low risk (test-only change).
🧪 Browser testing: Skipped — PR only modifies backend/config/docs, no UI impact

Problem
The test `"ignores Slack bot and app members when deriving a private-channel audience"` in
templates/brain/server/lib/brain.test.tsasserted:But
./audiences.jsis fully mocked at the top of the same test file, and the mockedensureCaptureAudiencenever writes tomocks.rows.audienceMembers— it always hardcodeskind: "org"and ignores whatevermemberEmails/kindare actually passed in. So the real audience-membership logic inaudiences.tsnever runs during this test, andmocks.rows.audienceMembersis always[]. The assertion could never pass — deterministic, not a flake.This was blocking PR #2711 (an unrelated docs-only PR) from going green in CI.
Fix
Switched the assertion to the same convention already used by sibling tests in this describe block (e.g. around L2979/L3025/L3031): assert on what the mocked
ensureCaptureAudiencewas actually called with, rather than reading back a mock table the stub never populates.This matches what
createSlackThreadCaptureinconnectors.tsactually passes throughcreateCapture→ensureCaptureAudience.Verification
is_bot/is_app_user/is_workflow_bot/deleted) inconnectors.ts, reran, saw it fail, then restored the filter (git diffonconnectors.tsshows no residual changes).brainsuite: 282/282 tests passing across 34 files.Only one file changed —
templates/brain/server/lib/brain.test.ts.🤖 Generated with Claude Code