Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
test(cli): prove plugin setup idempotence
jkomyno committed
Jul 15, 2026 at 01:54 UTC
506c402e3619f9fc503bfb7f455a59f5cd7ba347
1 file changed
+40
-17
ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+40
-17
@@ -17,7 +17,9 @@ cp fixtures/fake-agent-host.sh /tmp/bin/${host}
17
chmod +x /tmp/bin/${host}
18
${
19
host === 'claude'
20
- ? `mkdir -p /tmp/.claude/skills /tmp/.agents/skills/composio-cli
20
+ ? `# Keep this suite focused on packaged plugin orchestration. The standalone
21
+# skill asset download and extraction path has deterministic HTTP/ZIP coverage.
22
+mkdir -p /tmp/.claude/skills /tmp/.agents/skills/composio-cli
23
printf '%s\n' '# composio-cli' > /tmp/.agents/skills/composio-cli/SKILL.md
24
printf '@composio/cli@%s\n' "$(composio --version)" > /tmp/.agents/skills/composio-cli/.composio-release-tag
25
ln -s ../../.agents/skills/composio-cli /tmp/.claude/skills/composio-cli`
@@ -26,6 +28,8 @@ ln -s ../../.agents/skills/composio-cli /tmp/.claude/skills/composio-cli`
28
export HOST_STATE_DIR=/tmp/host-state
29
export PATH=/tmp/bin:$PATH
30
composio setup --target ${host} --yes
31
+cp /tmp/host-state/commands.log first-run.log
32
+: > /tmp/host-state/commands.log
33
composio setup --target ${host} --yes
34
${
35
host === 'claude'
@@ -33,7 +37,7 @@ ${
37
test -r /tmp/.claude/skills/composio-cli/SKILL.md`
38
: ''
39
}
36
-cp /tmp/host-state/commands.log commands.log
40
+cp /tmp/host-state/commands.log second-run.log
41
`;
42
43
e2e(import.meta.url, {
@@ -41,8 +45,8 @@ e2e(import.meta.url, {
45
cli: ['current'],
46
},
47
defineTests: ({ runCmd }) => {
44
- let claude: E2ETestResultWithFiles<'commands.log'>;
45
- let codex: E2ETestResultWithFiles<'commands.log'>;
48
+ let claude: E2ETestResultWithFiles<'first-run.log' | 'second-run.log'>;
49
+ let codex: E2ETestResultWithFiles<'first-run.log' | 'second-run.log'>;
50
let unavailable: E2ETestResult;
51
52
beforeAll(async () => {
@@ -50,11 +54,11 @@ e2e(import.meta.url, {
54
// these fresh-container cases sequential to avoid same-millisecond names.
55
claude = await runCmd({
56
command: setupFixture('claude'),
53
- files: ['commands.log'],
57
+ files: ['first-run.log', 'second-run.log'],
58
});
59
codex = await runCmd({
60
command: setupFixture('codex'),
57
- files: ['commands.log'],
61
+ files: ['first-run.log', 'second-run.log'],
62
});
63
unavailable = await runCmd('composio setup --target auto --yes');
64
}, TIMEOUTS.FIXTURE);
@@ -66,6 +70,7 @@ e2e(import.meta.url, {
70
marketplaceCommand:
71
'claude plugin marketplace add https://github.com/ComposioHQ/composio-plugin-cc.git --scope user',
72
installCommand: 'claude plugin install composio@composio --scope user',
73
+ additionalMutationCommands: ['claude plugin enable composio@composio --scope user'],
74
},
75
{
76
host: 'codex' as const,
@@ -73,19 +78,37 @@ e2e(import.meta.url, {
78
marketplaceCommand:
79
'codex plugin marketplace add https://github.com/ComposioHQ/composio-plugin-openai.git --json',
80
installCommand: 'codex plugin add composio@composio --json',
81
+ additionalMutationCommands: [],
82
},
77
- ])('$host setup', ({ result, marketplaceCommand, installCommand }) => {
78
- it('installs once and is idempotent', () => {
79
- const execution = result();
80
- expect(execution.exitCode).toBe(0);
81
- expect(execution.stdout).toBe('');
82
- expect(execution.stderr).toBe('');
83
+ ])(
84
+ '$host setup',
85
+ ({ result, marketplaceCommand, installCommand, additionalMutationCommands }) => {
86
+ it('configures the plugin on the first run and is idempotent', () => {
87
+ const execution = result();
88
+ expect(execution.exitCode).toBe(0);
89
+ expect(execution.stdout).toBe('');
90
+ expect(execution.stderr).toBe('');
91
84
- const commands = execution.files['commands.log'].trim().split('\n');
85
- expect(commands.filter(command => command === marketplaceCommand)).toHaveLength(1);
86
- expect(commands.filter(command => command === installCommand)).toHaveLength(1);
87
- });
88
- });
92
+ const firstRunCommands = execution.files['first-run.log'].trim().split('\n');
93
+ expect(firstRunCommands.filter(command => command === marketplaceCommand)).toHaveLength(
94
+ 1
95
+ );
96
+ expect(firstRunCommands.filter(command => command === installCommand)).toHaveLength(1);
97
+
98
+ const secondRunCommands = execution.files['second-run.log'].trim().split('\n');
99
+ const mutationCommands = [
100
+ marketplaceCommand,
101
+ installCommand,
102
+ ...additionalMutationCommands,
103
+ ];
104
+ expect(
105
+ secondRunCommands.filter(command =>
106
+ mutationCommands.some(mutation => mutation === command)
107
+ )
108
+ ).toEqual([]);
109
+ });
110
+ }
111
+ );
112
113
describe('automatic host detection', () => {
114
it('fails clearly when neither supported host is installed', () => {