@devries-cameron20 / composio Mirror · read-only
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 21, 04:45 UTC

next
ts 86 lines 2.51 KB
Raw
1 /**
2 * Custom local tools E2E test.
3 *
4 * Verifies local tool execution, Zod validation, session context, error handling,
5 * mixed local+remote chaining, and edge cases against the live Composio API.
6 * Uses the hackernews toolkit (public, no auth needed).
7 * Requires COMPOSIO_API_KEY in environment.
8 */
9
10 import { e2e, type E2ETestResult } from '@e2e-tests/utils';
11 import { describe, it, expect, beforeAll } from 'bun:test';
12
13 declare module 'bun' {
14 interface Env {
15 COMPOSIO_API_KEY: string;
16 }
17 }
18
19 e2e(import.meta.url, {
20 versions: { node: ['22.23.5', '24.22.3', '26.13.1'] },
21 usesFixtures: true,
22 env: {
23 COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
24 },
25 defineTests: ({ runFixture }) => {
26 let result: E2ETestResult;
27
28 beforeAll(async () => {
29 result = await runFixture({ filename: 'index.mjs' });
30 }, 120_000);
31
32 describe('Custom local tools', () => {
33 it('exits successfully', () => {
34 expect(result.exitCode).toBe(0);
35 });
36
37 it('single local tool execution works', () => {
38 expect(result.stdout).toContain('LOCAL_EXECUTE_OK');
39 });
40
41 it('Zod defaults are applied', () => {
42 expect(result.stdout).toContain('ZOD_DEFAULTS_OK');
43 });
44
45 it('error thrown by tool is wrapped into { data, error }', () => {
46 expect(result.stdout).toContain('ERROR_HANDLING_OK');
47 });
48
49 it('Zod validation failure returns error, does not crash', () => {
50 expect(result.stdout).toContain('ZOD_VALIDATION_FAIL_OK');
51 });
52
53 it('multiple local tools route to correct execute fn', () => {
54 expect(result.stdout).toContain('MULTIPLE_TOOLS_OK');
55 });
56
57 it('session context injects userId', () => {
58 expect(result.stdout).toContain('SESSION_CONTEXT_OK');
59 });
60
61 it('case-insensitive slug works', () => {
62 expect(result.stdout).toContain('CASE_INSENSITIVE_OK');
63 });
64
65 it('prefixed slug (LOCAL_) works', () => {
66 expect(result.stdout).toContain('PREFIXED_SLUG_OK');
67 });
68
69 it('local tool chains into remote tool via SessionContext.execute()', () => {
70 expect(result.stdout).toContain('CHAINED_EXECUTE_OK');
71 });
72
73 it('non-existent tool returns error gracefully', () => {
74 expect(result.stdout).toContain('NONEXISTENT_TOOL_OK');
75 });
76
77 it('session.tools() wrapping works', () => {
78 expect(result.stdout).toContain('TOOLS_WRAPPING_OK');
79 });
80
81 it('all operations complete', () => {
82 expect(result.stdout).toContain('ALL_OK');
83 });
84 });
85 },
86 });