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

next
ts 64 lines 2.08 KB
Raw
1 import { e2e, type E2ETestResult, type DefineTestsContext } from '@e2e-tests/utils';
2 import { describe, it, expect, beforeAll } from 'bun:test';
3
4 declare module 'bun' {
5 interface Env {
6 COMPOSIO_API_KEY: string;
7 }
8 }
9
10 const formatFixtureResult = (result: E2ETestResult): string =>
11 [
12 `exitCode=${result.exitCode}`,
13 '',
14 '[stdout]',
15 result.stdout.trim() || '(empty)',
16 '',
17 '[stderr]',
18 result.stderr.trim() || '(empty)',
19 ].join('\n');
20
21 const expectFixtureExitCode = (result: E2ETestResult, expectedExitCode: number): void => {
22 if (result.exitCode !== expectedExitCode) {
23 throw new Error(`file-roundtrip fixture failed\n${formatFixtureResult(result)}`);
24 }
25 };
26
27 e2e(import.meta.url, {
28 versions: { node: ['22.23.5', '24.22.3', '26.13.1'] },
29 usesFixtures: true,
30 env: {
31 COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
32 },
33 defineTests: ({ runFixture }: DefineTestsContext) => {
34 let result: E2ETestResult;
35 const isStorageUnavailable = () => result.stdout.includes('UPLOAD_UNAVAILABLE');
36
37 beforeAll(async () => {
38 result = await runFixture({ filename: 'test.mjs' });
39 }, 300_000);
40
41 describe('file round-trip', () => {
42 it('exits successfully', () => {
43 expectFixtureExitCode(result, 0);
44 });
45
46 it('reports upload outcome', () => {
47 // Accept either full round-trip or upload-only success
48 // (download or external storage upload auth may be unavailable)
49 const hasRoundTripOk = result.stdout.includes('ROUND_TRIP_OK');
50 const hasUploadOk = result.stdout.includes('UPLOAD_OK');
51 const hasUploadUnavailable = result.stdout.includes('UPLOAD_UNAVAILABLE');
52 expect(hasRoundTripOk || hasUploadOk || hasUploadUnavailable, formatFixtureResult(result)).toBe(true);
53 });
54
55 it('includes sha256 checksum', () => {
56 if (isStorageUnavailable()) {
57 expect(result.stdout, formatFixtureResult(result)).toMatch(/sha256=|storage authorization failed/);
58 return;
59 }
60 expect(result.stdout, formatFixtureResult(result)).toContain('sha256=');
61 });
62 });
63 },
64 });