@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 92 lines 3.17 KB
Raw
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4
5 const testConfigProvider = ConfigProvider.fromEnv({
6 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
7 });
8
9 describe('CLI: composio dev', () => {
10 layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
11 it.effect('renders generated help when developer mode is on', () =>
12 Effect.gen(function* () {
13 yield* cli(['dev', '--help']);
14 const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
15
16 expect(output).toContain('projects');
17 expect(output).toContain('triggers');
18 expect(output).toContain('--mode');
19 })
20 );
21 });
22
23 layer(
24 TestLive({
25 baseConfigProvider: testConfigProvider,
26 cliUserConfig: { developerModeEnabled: false },
27 })
28 )(it => {
29 it.effect('renders reduced help when developer mode is off', () =>
30 Effect.gen(function* () {
31 yield* cli(['dev', '--help']);
32 const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
33
34 expect(output).toContain('When off');
35 expect(output).toContain('composio dev --mode on');
36 expect(output).not.toContain('projects');
37 })
38 );
39
40 it.effect('blocks dev subcommands when developer mode is off', () =>
41 Effect.gen(function* () {
42 expect((yield* Effect.result(cli(['dev', 'init'])))._tag).toBe('Failure');
43 const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
44
45 expect(output).toContain('When off');
46 expect(output).toContain('composio dev --mode on');
47 })
48 );
49 });
50
51 layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
52 it.effect('persists mode changes through the config service', () =>
53 Effect.gen(function* () {
54 yield* cli(['dev', '--mode', 'off']);
55 expect((yield* Effect.result(cli(['dev', 'init'])))._tag).toBe('Failure');
56 const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
57
58 expect(output).toContain('Developer mode disabled');
59 expect(output).toContain('When off');
60 })
61 );
62 });
63
64 layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
65 it.effect('blocks destructive dev commands until config enables them', () =>
66 Effect.gen(function* () {
67 const error = yield* Effect.flip(cli(['dev', 'triggers', 'disable', 'trg_123']));
68 const output = String(error);
69
70 expect(output).toContain('disabled by config');
71 expect(output).toContain('developer.destructive_actions');
72 })
73 );
74 });
75
76 layer(
77 TestLive({
78 baseConfigProvider: testConfigProvider,
79 cliUserConfig: { developerDangerousCommandsEnabled: true },
80 })
81 )(it => {
82 it.effect('requires --dangerously-allow for destructive dev commands', () =>
83 Effect.gen(function* () {
84 const error = yield* Effect.flip(cli(['dev', 'triggers', 'disable', 'trg_123']));
85 const output = String(error);
86
87 expect(output).toContain('requires explicit acknowledgement');
88 expect(output).toContain('--dangerously-allow');
89 })
90 );
91 });
92 });