Skip to content

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): add regression test for spinner double-error on callback failure

jkomynoa85835430d90
diff --git a/ts/packages/cli/test/src/services/terminal-ui.test.ts b/ts/packages/cli/test/src/services/terminal-ui.test.ts
index aab88f320..1b623c327 100644
--- a/ts/packages/cli/test/src/services/terminal-ui.test.ts
+++ b/ts/packages/cli/test/src/services/terminal-ui.test.ts
@@ -195,5 +195,31 @@ describe('TerminalUI', () => {
expect(result).toBe(99);
})
);
+
+ it.scoped(
+ 'useMakeSpinner does NOT double-error when callback calls spinner.error then fails',
+ () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+
+ const exit = yield* Effect.exit(
+ ui.useMakeSpinner('fetching', spinner =>
+ Effect.gen(function* () {
+ // Simulate tapError pattern: callback calls spinner.error(), then the effect fails
+ yield* spinner.error('Login timed out. Please try again.');
+ return yield* Effect.fail(new Error('timed out'));
+ })
+ )
+ );
+
+ expect(exit._tag).toBe('Failure');
+
+ const lines = yield* MockConsole.getLines();
+ // Should see the user's error message
+ expect(lines).toContain('Login timed out. Please try again.');
+ // Should NOT see the default spinner message as a second error
+ expect(lines.filter(l => l === 'fetching')).toHaveLength(0);
+ })
+ );
});
});