From 4f9ede50f640e41022e271d9e6a288975936f991 Mon Sep 17 00:00:00 2001 From: kjgbot Date: Tue, 9 Jun 2026 18:39:45 +0200 Subject: [PATCH] test(integrations): mock RelayfileSetup.joinWorkspace in the reader-handle path readRemoteFile/listRemoteDirectory were refactored to resolve a reader handle via RelayfileSetup.joinWorkspace (getIntegrationRemoteReaderHandle), but the vitest suite never mocked @relayfile/sdk, so the remote-read tests fell through to a real network join and failed with a ~3.5s fetch timeout. CI did not catch this because the gated `npm test` only runs the node __tests__/ suite, not the vitest *.test.ts files. Mock @relayfile/sdk so joinWorkspace returns the existing in-memory workspace handle (expose it on the hoisted mock; add refreshToken for the 401 retry path). Repairs both the pre-existing "reads a targeted remote Slack event record" test and the DM/user read test added in #186. vitest integrations.test.ts: 30/30 green (~310ms, no network). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/main/integrations.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/integrations.test.ts b/src/main/integrations.test.ts index 72026071..c4951d6b 100644 --- a/src/main/integrations.test.ts +++ b/src/main/integrations.test.ts @@ -60,7 +60,8 @@ const mock = vi.hoisted(() => { } const workspaceHandle = { workspaceId: 'account-workspace-id', - client: vi.fn(() => relayClient) + client: vi.fn(() => relayClient), + refreshToken: vi.fn(async () => undefined) } const relayWorkspaceManager = { withHandle: vi.fn(async (fn: (handle: typeof workspaceHandle) => Promise) => fn(workspaceHandle)), @@ -180,6 +181,7 @@ const mock = vi.hoisted(() => { readFileCalls, relayClient, relayWorkspaceManager, + workspaceHandle, brokerManager: { listAgents: vi.fn(async () => []), sendMessage: vi.fn(async () => undefined), @@ -196,6 +198,18 @@ const mock = vi.hoisted(() => { } }) +// readRemoteFile/listRemoteDirectory now resolve a reader handle via +// RelayfileSetup.joinWorkspace (integrations.ts getIntegrationRemoteReaderHandle). +// Mock the SDK so that path returns the in-memory handle instead of doing a +// real network join. +vi.mock('@relayfile/sdk', () => ({ + RelayfileSetup: class { + async joinWorkspace() { + return mock.workspaceHandle + } + } +})) + vi.mock('electron', () => ({ BrowserWindow: mock.browserWindow, shell: {