An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.
JavaScript aicursorcursor-aicursorailovablelovable-devroocodetask-managertaskstasks-listwindsurfwindsurf-ai
test(cli): fix and improve LoopCommand tests (#1579)
Ralph Khreish68aac14dae4f
diff --git a/apps/cli/src/commands/loop.command.spec.ts b/apps/cli/src/commands/loop.command.spec.tsindex 6859f02c..45702506 100644--- a/apps/cli/src/commands/loop.command.spec.ts+++ b/apps/cli/src/commands/loop.command.spec.ts@@ -389,9 +389,10 @@ describe('LoopCommand', () => {);});- it('should check sandbox auth before running', async () => {+ it('should check sandbox auth when --sandbox flag is provided', async () => {const result = createMockResult();mockLoopRun.mockResolvedValue(result);+ mockTmCore.loop.checkSandboxAuth.mockReturnValue({ ready: true });const execute = (loopCommand as any).execute.bind(loopCommand);await execute({ sandbox: true });@@ -399,8 +400,19 @@ describe('LoopCommand', () => {expect(mockTmCore.loop.checkSandboxAuth).toHaveBeenCalled();});+ it('should not check sandbox auth when --sandbox flag is not provided', async () => {+ const result = createMockResult();+ mockLoopRun.mockResolvedValue(result);++ const execute = (loopCommand as any).execute.bind(loopCommand);+ await execute({});++ expect(mockTmCore.loop.checkSandboxAuth).not.toHaveBeenCalled();+ });+it('should run interactive auth when sandbox not ready', async () => {mockTmCore.loop.checkSandboxAuth.mockReturnValue({ ready: false });+ mockTmCore.loop.runInteractiveAuth.mockReturnValue({ success: true });const result = createMockResult();mockLoopRun.mockResolvedValue(result);@@ -410,6 +422,46 @@ describe('LoopCommand', () => {expect(mockTmCore.loop.runInteractiveAuth).toHaveBeenCalled();});+ it('should throw error when sandbox auth has error', async () => {+ mockTmCore.loop.checkSandboxAuth.mockReturnValue({+ error: 'Sandbox auth failed'+ });++ const execute = (loopCommand as any).execute.bind(loopCommand);++ try {+ await execute({ sandbox: true });+ } catch {+ // Expected - processExitSpy mock throws to simulate process.exit+ }++ expect(displayError).toHaveBeenCalledWith(+ expect.objectContaining({ message: 'Sandbox auth failed' }),+ { skipExit: true }+ );+ });++ it('should throw error when interactive auth fails', async () => {+ mockTmCore.loop.checkSandboxAuth.mockReturnValue({ ready: false });+ mockTmCore.loop.runInteractiveAuth.mockReturnValue({+ success: false,+ error: 'Auth failed'+ });++ const execute = (loopCommand as any).execute.bind(loopCommand);++ try {+ await execute({ sandbox: true });+ } catch {+ // Expected - processExitSpy mock throws to simulate process.exit+ }++ expect(displayError).toHaveBeenCalledWith(+ expect.objectContaining({ message: 'Auth failed' }),+ { skipExit: true }+ );+ });+it('should show next task before starting loop', async () => {const result = createMockResult();mockLoopRun.mockResolvedValue(result);diff --git a/apps/cli/tests/integration/commands/loop.command.test.ts b/apps/cli/tests/integration/commands/loop.command.test.tsindex 99d712a7..461f4bbb 100644--- a/apps/cli/tests/integration/commands/loop.command.test.ts+++ b/apps/cli/tests/integration/commands/loop.command.test.ts@@ -147,6 +147,13 @@ describe('loop command', () => {expect(output).toContain('--tag');});+ it('should show --sandbox option in help', () => {+ const { output, exitCode } = runHelp();++ expect(exitCode).toBe(0);+ expect(output).toContain('--sandbox');+ });+it('should show --progress-file option in help', () => {const { output, exitCode } = runHelp();