Skip to content

test(integrations): mock RelayfileSetup.joinWorkspace so remote-read tests pass#188

Merged
khaliqgant merged 1 commit into
mainfrom
fix/integrations-test-relayfile-sdk-mock
Jun 9, 2026
Merged

test(integrations): mock RelayfileSetup.joinWorkspace so remote-read tests pass#188
khaliqgant merged 1 commit into
mainfrom
fix/integrations-test-relayfile-sdk-mock

Conversation

@kjgbot

@kjgbot kjgbot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Problem

The vitest integrations.test.ts suite has 2 failing tests on main:

Both fail identically at getIntegrationRemoteReaderHandleRelayfileSetup.joinWorkspace with a ~3.5s fetchWithTimeout network timeout.

Root cause

readRemoteFile / listRemoteDirectory were refactored (#183/#184) to resolve a reader handle via RelayfileSetup.joinWorkspace (getIntegrationRemoteReaderHandle), replacing the old relayWorkspaceManager.withHandle path. 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 test only runs the node src/main/__tests__/*.test.ts suite — the vitest *.test.ts files (including integrations.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/sdk so RelayfileSetup.joinWorkspace returns the existing in-memory workspace handle:

  • expose workspaceHandle on the hoisted mock and add a refreshToken stub (for the 401/403 retry path in withIntegrationRemoteHandle).

No production code changes. Repairs both the pre-existing failure and the #186-added test.

Verification

npx vitest run src/main/integrations.test.ts30/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

…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>
@codeant-ai

codeant-ai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kjgbot, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 17b25ed5-a085-45d2-810c-278c261c9055

📥 Commits

Reviewing files that changed from the base of the PR and between 4e41f8a and 4f9ede5.

📒 Files selected for processing (1)
  • src/main/integrations.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/integrations-test-relayfile-sdk-mock

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Exposing joinWorkspace as a mock function on the hoisted mock object allows individual tests to assert on its calls or customize its behavior (e.g., mocking failures or custom return values).

    workspaceHandle,
    joinWorkspace: vi.fn(async () => workspaceHandle),

Comment on lines +205 to +211
vi.mock('@relayfile/sdk', () => ({
RelayfileSetup: class {
async joinWorkspace() {
return mock.workspaceHandle
}
}
}))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

By mocking RelayfileSetup as a mock function that returns an object with the joinWorkspace mock, we make the SDK integration fully assertable and controllable in tests.

vi.mock('@relayfile/sdk', () => ({
  RelayfileSetup: vi.fn().mockImplementation(() => ({
    joinWorkspace: mock.joinWorkspace
  }))
}))

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #188 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #188 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #188 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #188 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #188 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #188 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@khaliqgant khaliqgant merged commit 7092a37 into main Jun 9, 2026
4 checks passed
@khaliqgant khaliqgant deleted the fix/integrations-test-relayfile-sdk-mock branch June 9, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants