From aedb14f01b29df0147fc01058cad1a2f1ae47cde Mon Sep 17 00:00:00 2001 From: Kapunahele Wong Date: Fri, 7 Aug 2026 15:38:47 -0700 Subject: [PATCH] Fix dead assertion in Slack private-channel audience test 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 --- templates/brain/server/lib/brain.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/brain/server/lib/brain.test.ts b/templates/brain/server/lib/brain.test.ts index d3294fb08f..d2e6fbaf90 100644 --- a/templates/brain/server/lib/brain.test.ts +++ b/templates/brain/server/lib/brain.test.ts @@ -3639,9 +3639,13 @@ describe("Brain connector smoke coverage", () => { String(call[0]).includes("users.info"), ), ).toHaveLength(4); - expect( - mocks.rows.audienceMembers.map((member) => member.principalId), - ).toEqual(["ada@example.test"]); + expect(vi.mocked(ensureCaptureAudience)).toHaveBeenCalledWith( + expect.objectContaining({ + kind: "slack-private-channel", + memberEmails: ["ada@example.test"], + upstreamRefHash: "G123", + }), + ); }); it("caches private Slack member emails and bounds concurrent user lookups within a sync", async () => {