test(integrations): mock RelayfileSetup.joinWorkspace so remote-read tests pass#188
Conversation
…andle 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) <noreply@anthropic.com>
|
Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI. |
|
Warning Review limit reached
More reviews will be available in 34 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the integration tests in src/main/integrations.test.ts by adding a refreshToken mock to workspaceHandle, exposing workspaceHandle on the hoisted mock object, and mocking the @relayfile/sdk's RelayfileSetup class to return the mocked workspace handle. The feedback suggests improving test assertability and control by exposing joinWorkspace as a mock function on the hoisted mock object and using vi.fn().mockImplementation() to mock RelayfileSetup.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| readFileCalls, | ||
| relayClient, | ||
| relayWorkspaceManager, | ||
| workspaceHandle, |
There was a problem hiding this comment.
| vi.mock('@relayfile/sdk', () => ({ | ||
| RelayfileSetup: class { | ||
| async joinWorkspace() { | ||
| return mock.workspaceHandle | ||
| } | ||
| } | ||
| })) |
There was a problem hiding this comment.
|
pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #188 in AgentWorkforce/pear. |
Problem
The vitest
integrations.test.tssuite has 2 failing tests onmain:reads a targeted remote Slack event record without reconciling local mountsreads Slack DM/user message records when DM listening is enabled(added in fix(integrations): allow listing Slack DM/user remote dirs within event scope #186)Both fail identically at
getIntegrationRemoteReaderHandle→RelayfileSetup.joinWorkspacewith a ~3.5sfetchWithTimeoutnetwork timeout.Root cause
readRemoteFile/listRemoteDirectorywere refactored (#183/#184) to resolve a reader handle viaRelayfileSetup.joinWorkspace(getIntegrationRemoteReaderHandle), replacing the oldrelayWorkspaceManager.withHandlepath. The vitest suite never mocked@relayfile/sdk, so those tests fell through to a real network join and timed out.This went unnoticed because the gated CI command
npm testonly runs the nodesrc/main/__tests__/*.test.tssuite — the vitest*.test.tsfiles (includingintegrations.test.ts) are not run in CI. So #183/#184 (which broke the pre-existing test) and #186 (which added a second test on the same un-mocked path) both merged green.Fix (test-only)
Mock
@relayfile/sdksoRelayfileSetup.joinWorkspacereturns the existing in-memory workspace handle:workspaceHandleon the hoisted mock and add arefreshTokenstub (for the 401/403 retry path inwithIntegrationRemoteHandle).No production code changes. Repairs both the pre-existing failure and the #186-added test.
Verification
npx vitest run src/main/integrations.test.ts→ 30/30 green, ~310ms (was 2 failing with ~3.5s network timeouts).Follow-up (not in this PR)
Worth gating the vitest suite in CI so this class of breakage is caught at PR time rather than after merge.
🤖 Generated with Claude Code