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 51 lines 1.92 KB
Raw
1 import { describe, expect, layer } from '@effect/vitest';
2 import { Effect } from 'effect';
3 import { afterEach, vi } from 'vitest';
4 import { installSkill } from 'src/effects/install-skill';
5 import { cli, TestLive } from 'test/__utils__';
6
7 vi.mock('src/effects/install-skill', async original => ({
8 ...(await original<typeof import('src/effects/install-skill')>()),
9 installSkill: vi.fn(() => Effect.void),
10 }));
11
12 describe('composio setup skill', () => {
13 afterEach(() => vi.clearAllMocks());
14 layer(TestLive())(it => {
15 it.effect('passes the selected target and optional name to the installer', () =>
16 Effect.gen(function* () {
17 yield* cli(['setup', 'skill', 'claude']);
18 expect(installSkill).toHaveBeenLastCalledWith({ target: 'claude', skillName: undefined });
19 yield* cli(['setup', 'skill', 'codex', '--name', 'custom-skill']);
20 expect(installSkill).toHaveBeenLastCalledWith({
21 target: 'codex',
22 skillName: 'custom-skill',
23 });
24 yield* cli(['setup', 'skill', 'openclaw']);
25 expect(installSkill).toHaveBeenLastCalledWith({ target: 'openclaw', skillName: undefined });
26 })
27 );
28 it.effect.each([
29 { args: ['setup', 'skill'], error: { _tag: 'MissingArgument', argument: 'target' } },
30 {
31 args: ['setup', 'skill', 'cursor'],
32 error: { _tag: 'InvalidValue', option: 'target', value: 'cursor' },
33 },
34 {
35 args: ['setup', 'skill', 'claude', '--name'],
36 error: { _tag: 'InvalidValue', option: 'name' },
37 },
38 ])('rejects invalid targets and missing names before installation: $args', ({ args, error }) =>
39 Effect.gen(function* () {
40 const failure = yield* Effect.flip(cli(args));
41
42 expect(failure).toMatchObject({
43 _tag: 'ShowHelp',
44 commandPath: ['composio', 'setup', 'skill'],
45 errors: [error],
46 });
47 expect(installSkill).not.toHaveBeenCalled();
48 })
49 );
50 });
51 });