From ce843fe53d2bfe0fe3fa308708013053b44794db Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 06:36:58 +0100 Subject: [PATCH] test: tighten googlechat pairing timestamp --- .../googlechat/src/monitor-access.test.ts | 71 ++++++++++--------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/extensions/googlechat/src/monitor-access.test.ts b/extensions/googlechat/src/monitor-access.test.ts index 7642e4a5df0..02aff9f0a3a 100644 --- a/extensions/googlechat/src/monitor-access.test.ts +++ b/extensions/googlechat/src/monitor-access.test.ts @@ -127,6 +127,7 @@ describe("googlechat inbound access policy", () => { it("issues a pairing challenge for unauthorized DMs in pairing mode", async () => { primeCommonDefaults(); + const now = new Date("2026-05-09T06:35:00.000Z").getTime(); const issueChallenge = vi.fn(async ({ onCreated, sendPairingReply }) => { onCreated?.(); await sendPairingReply("pairing text"); @@ -146,41 +147,45 @@ describe("googlechat inbound access policy", () => { const statusSink = vi.fn(); const logVerbose = vi.fn(); - await expect( - applyGoogleChatInboundAccessPolicy({ - account: { - accountId: "default", + vi.useFakeTimers(); + vi.setSystemTime(now); + try { + await expect( + applyGoogleChatInboundAccessPolicy({ + account: { + accountId: "default", + config: { + dm: { policy: "pairing" }, + }, + } as never, config: { - dm: { policy: "pairing" }, - }, - } as never, - config: { - channels: { googlechat: {} }, - } as never, - core: createCore() as never, - space: { name: "spaces/AAA", displayName: "DM" } as never, - message: { annotations: [] } as never, - isGroup: false, - senderId: "users/abc", - senderName: "Alice", - senderEmail: "alice@example.com", - rawBody: "hello", - statusSink, - logVerbose, - }), - ).resolves.toEqual({ ok: false }); + channels: { googlechat: {} }, + } as never, + core: createCore() as never, + space: { name: "spaces/AAA", displayName: "DM" } as never, + message: { annotations: [] } as never, + isGroup: false, + senderId: "users/abc", + senderName: "Alice", + senderEmail: "alice@example.com", + rawBody: "hello", + statusSink, + logVerbose, + }), + ).resolves.toEqual({ ok: false }); - expect(issueChallenge).toHaveBeenCalledTimes(1); - expect(sendGoogleChatMessage).toHaveBeenCalledWith({ - account: expect.anything(), - space: "spaces/AAA", - text: "pairing text", - }); - expect(statusSink).toHaveBeenCalledWith( - expect.objectContaining({ - lastOutboundAt: expect.any(Number), - }), - ); + expect(issueChallenge).toHaveBeenCalledTimes(1); + expect(sendGoogleChatMessage).toHaveBeenCalledWith({ + account: expect.anything(), + space: "spaces/AAA", + text: "pairing text", + }); + expect(statusSink).toHaveBeenCalledWith({ + lastOutboundAt: now, + }); + } finally { + vi.useRealTimers(); + } }); it("allows group traffic when sender and mention gates pass", async () => {