Skip to content

Add tests for the integrations API client - #433

Open
Shahmeerdv wants to merge 1 commit into
useagenthq:mainfrom
Shahmeerdv:test/integrations-api
Open

Shahmeerdv wants to merge 1 commit into
useagenthq:mainfrom
Shahmeerdv:test/integrations-api

Conversation

@Shahmeerdv

@Shahmeerdv Shahmeerdv commented Nov 7, 2026 •

Copy link
Copy Markdown

Closes #271.

Adds frontend/app/(workspace)/settings/integrations-api.test.ts, covering every exported function in integrations-api.ts. It stubs fetch and window the same way lib/create-run.test.ts does, so backendFetch takes its browser path.

  • fetchIntegrations: reads /api/integrations with cache: "no-store" and decodes the list; throws on a non-OK response
  • startIntegrationConnect: GitHub and Slack use the /org path while other apps don't; the provider is URL-encoded; posts the returnTo body; returns expiresAt: null when the backend omits it; throws on a non-OK response; throws when redirectUrl or state is missing or blank
  • completeIntegrationConnect: posts the state and callback, and leaves callback out when there is none; returns null on 400 and 409; throws on other errors; throws when the answer has no usable connection
  • disconnectIntegration: DELETE on the /org path for GitHub and Slack and the user path otherwise, with the connection id encoded; throws on a non-OK response

No source changes.

Checks

$ cd frontend && bun test "app/(workspace)/settings/integrations-api.test.ts"
 15 pass
 0 fail
 29 expect() calls

To check the tests catch real regressions, I temporarily changed the source so Slack skipped the /org path and 409 stopped counting as pending: 3 tests failed (the org-path connect, pending callback and org-path disconnect tests), then passed again once restored.

bun run lint and bun run typecheck in frontend pass.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Shahmeerdv

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 7, 2026
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.

Add tests for the integrations API client

1 participant