@devries-cameron20 / composio Mirror · read-only / commits / 109ce2a22
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 03:15 UTC

refactor(test): trim redundant unit tests for custom tools

Remove 3 tests subsumed by more comprehensive ones: - "should store correct prefixedSlug" (covered by map creation test) - "should return empty maps for empty input" (trivial) - "should only send remote items in backend payload" (covered by 2+2 mixed batch test) 58 unit tests remain (was 61). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Dhawal Upadhyay committed Mar 10, 2026 at 19:01 UTC 109ce2a22546df208fd1d6d1c708a37017f4dbed
2 files changed +4 -82
ts/packages/core/test/models/customTool.test.ts
-14
@@ -183,15 +183,6 @@ describe('buildLocalToolsMap', () => {
183 expect(map.byOriginal.has('OTHER_TOOL')).toBe(true);
184 });
185
186 - it('should store correct prefixedSlug on each entry', () => {
187 - const handles = [makeHandle('FOO')];
188 - const map = buildLocalToolsMap(handles);
189 -
190 - const entry = map.byPrefixed.get('LOCAL_FOO');
191 - expect(entry?.prefixedSlug).toBe('LOCAL_FOO');
192 - expect(entry?.handle.slug).toBe('FOO');
193 - });
194 -
186 it('should handle case-insensitive slugs (uppercased internally)', () => {
187 const handle = makeHandle('my_tool');
188 const map = buildLocalToolsMap([handle]);
@@ -205,11 +196,6 @@ describe('buildLocalToolsMap', () => {
196 expect(() => buildLocalToolsMap(handles)).toThrow('duplicate slug "DUPE"');
197 });
198
208 - it('should return empty maps for empty input', () => {
209 - const map = buildLocalToolsMap([]);
210 - expect(map.byPrefixed.size).toBe(0);
211 - expect(map.byOriginal.size).toBe(0);
212 - });
199 });
200
201 // ────────────────────────────────────────────────────────────────
ts/packages/core/test/models/customToolRouting.test.ts
+4 -68
@@ -155,18 +155,13 @@ describe('ToolRouter.create() with customTools', () => {
155 expect(payload.local_tools[0].toolkit).toBe('meta_ads');
156 });
157
158 - it('should not send local_tools when customTools is omitted', async () => {
158 + it('should not send local_tools when customTools is omitted or empty', async () => {
159 await router.create('user_1', { toolkits: ['gmail'] });
160 + expect(mockClient.toolRouter.session.create.mock.calls[0][0].local_tools).toBeUndefined();
161
161 - const payload = mockClient.toolRouter.session.create.mock.calls[0][0];
162 - expect(payload.local_tools).toBeUndefined();
163 - });
164 -
165 - it('should not send local_tools when customTools is empty', async () => {
162 + vi.clearAllMocks();
163 await router.create('user_1', { customTools: [] });
167 -
168 - const payload = mockClient.toolRouter.session.create.mock.calls[0][0];
169 - expect(payload.local_tools).toBeUndefined();
164 + expect(mockClient.toolRouter.session.create.mock.calls[0][0].local_tools).toBeUndefined();
165 });
166
167 it('should return a session with the correct sessionId', async () => {
@@ -448,41 +443,6 @@ describe('ToolRouterSession execution routing', () => {
443 expect(localExecute).not.toHaveBeenCalled();
444 });
445
451 - it('should split mixed local+remote tools and merge results', async () => {
452 - const provider = new MockProvider();
453 - captureExecuteFn(provider);
454 - const session = createSessionWithProvider(mockClient, provider, [customToolHandle]);
455 -
456 - await session.tools();
457 -
458 - // Re-mock executeMetaTool after session.tools() created the Tools instance
459 - const latestToolsInstance = (Tools as any).mock.results[
460 - (Tools as any).mock.results.length - 1
461 - ].value;
462 - latestToolsInstance.executeMetaTool.mockResolvedValueOnce({
463 - data: { GMAIL_SEND_EMAIL: { messageId: 'msg_1' } },
464 - error: null,
465 - successful: true,
466 - });
467 -
468 - const executeFn = (provider as any)._capturedExecuteFn;
469 -
470 - const result = await executeFn('COMPOSIO_MULTI_EXECUTE_TOOL', {
471 - tools: [
472 - { tool_slug: 'LOCAL_GET_USER_CONTEXT', arguments: { category: 'prefs' } },
473 - { tool_slug: 'GMAIL_SEND_EMAIL', arguments: { to: 'test@test.com' } },
474 - ],
475 - sync_response_to_workbench: false,
476 - });
477 -
478 - // Both should have been called
479 - expect(localExecute).toHaveBeenCalled();
480 - // Remote goes to backend — merged results keyed by slug
481 - expect(result.data).toHaveProperty('LOCAL_GET_USER_CONTEXT');
482 - expect(result.data).toHaveProperty('GMAIL_SEND_EMAIL');
483 - expect(result.data.GMAIL_SEND_EMAIL).toEqual({ messageId: 'msg_1' });
484 - });
485 -
446 it('should route non-MULTI_EXECUTE meta tools to backend', async () => {
447 const provider = new MockProvider();
448 captureExecuteFn(provider);
@@ -532,30 +492,6 @@ describe('ToolRouterSession execution routing', () => {
492 return { executeFn, toolsInstance, provider, session };
493 };
494
535 - it('should only send remote items in the backend payload (not local ones)', async () => {
536 - const { executeFn, toolsInstance } = await setupMultiExecute(mockClient, [customToolHandle]);
537 -
538 - toolsInstance.executeMetaTool.mockResolvedValueOnce({
539 - data: { GMAIL_SEND_EMAIL: { sent: true } },
540 - error: null,
541 - successful: true,
542 - });
543 -
544 - await executeFn('COMPOSIO_MULTI_EXECUTE_TOOL', {
545 - tools: [
546 - { tool_slug: 'LOCAL_GET_USER_CONTEXT', arguments: { category: 'a' } },
547 - { tool_slug: 'GMAIL_SEND_EMAIL', arguments: { to: 'x@y.com' } },
548 - ],
549 - sync_response_to_workbench: false,
550 - });
551 -
552 - // Backend should only receive the remote tool
553 - const metaCall = toolsInstance.executeMetaTool.mock.calls[0];
554 - const backendTools = metaCall[1].arguments.tools;
555 - expect(backendTools).toHaveLength(1);
556 - expect(backendTools[0].tool_slug).toBe('GMAIL_SEND_EMAIL');
557 - });
558 -
495 it('should merge results with remote keys first, local keys last', async () => {
496 const { executeFn, toolsInstance } = await setupMultiExecute(mockClient, [customToolHandle]);
497