Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { describe, expect, it } from '@effect/vitest'; |
| 2 | import { Effect } from 'effect'; |
| 3 | import { resolveToolRouterSessionConnections } from 'src/services/tool-router-session-connections'; |
| 4 | import { stubComposioClient } from 'test/__utils__/services/stub-composio-client'; |
| 5 | |
| 6 | const forbidden = () => |
| 7 | Response.json( |
| 8 | { error: { message: 'Not allowed', code: 1403, slug: 'Forbidden', status: 403 } }, |
| 9 | { status: 403 } |
| 10 | ); |
| 11 | |
| 12 | describe('resolveToolRouterSessionConnections', () => { |
| 13 | it.effect.each([ |
| 14 | { listing: 'the listing for the requested toolkits', toolkits: ['gmail'] }, |
| 15 | { listing: 'the shared listing of every active account', toolkits: undefined }, |
| 16 | ])('resolves no connections when the API rejects $listing', ({ toolkits }) => |
| 17 | Effect.gen(function* () { |
| 18 | const { client, requests } = stubComposioClient(forbidden); |
| 19 | |
| 20 | const context = yield* resolveToolRouterSessionConnections(client, 'user_1', { toolkits }); |
| 21 | |
| 22 | expect(context).toEqual({ |
| 23 | connectedToolkits: [], |
| 24 | authConfigs: undefined, |
| 25 | connectedAccounts: undefined, |
| 26 | availableConnectedAccounts: undefined, |
| 27 | }); |
| 28 | expect(requests).toHaveLength(1); |
| 29 | }) |
| 30 | ); |
| 31 | }); |