diff --git a/extensions/googlechat/src/channel.test.ts b/extensions/googlechat/src/channel.test.ts index 7b623956bc0..46d1cd75f13 100644 --- a/extensions/googlechat/src/channel.test.ts +++ b/extensions/googlechat/src/channel.test.ts @@ -290,6 +290,51 @@ describe("googlechatPlugin outbound resolveTarget", () => { }); describe("googlechatPlugin outbound cfg threading", () => { + it("preserves accountId when sending pairing approvals", async () => { + const cfg = { + channels: { + googlechat: { + enabled: true, + accounts: { + work: { + serviceAccount: { + type: "service_account", + }, + }, + }, + }, + }, + }; + const account = { + accountId: "work", + config: {}, + credentialSource: "inline", + }; + resolveGoogleChatAccountMock.mockReturnValue(account); + resolveGoogleChatOutboundSpaceMock.mockResolvedValue("spaces/WORK"); + sendGoogleChatMessageMock.mockResolvedValue({ + messageName: "spaces/WORK/messages/msg-1", + }); + + await googlechatPlugin.pairing?.notifyApproval?.({ + cfg: cfg as never, + id: "user@example.com", + accountId: "work", + }); + + expect(resolveGoogleChatAccountMock).toHaveBeenCalledWith({ + cfg, + accountId: "work", + }); + expect(sendGoogleChatMessageMock).toHaveBeenCalledWith( + expect.objectContaining({ + account, + space: "spaces/WORK", + text: expect.any(String), + }), + ); + }); + it("threads resolved cfg into sendText account resolution", async () => { const cfg = { channels: { diff --git a/extensions/googlechat/src/channel.ts b/extensions/googlechat/src/channel.ts index 04257101575..03c0c00ffd5 100644 --- a/extensions/googlechat/src/channel.ts +++ b/extensions/googlechat/src/channel.ts @@ -317,8 +317,8 @@ export const googlechatPlugin = createChatChannelPlugin({ idLabel: "googlechatUserId", message: PAIRING_APPROVED_MESSAGE, normalizeAllowEntry: (entry) => formatAllowFromEntry(entry), - notify: async ({ cfg, id, message }) => { - const account = resolveGoogleChatAccount({ cfg: cfg }); + notify: async ({ cfg, id, message, accountId }) => { + const account = resolveGoogleChatAccount({ cfg: cfg, accountId }); if (account.credentialSource === "none") { return; }