From ea862bdd6d1d3e7922c255a9d29e59bd3ff71cf4 Mon Sep 17 00:00:00 2001 From: Raylan LIN Date: Mon, 6 Apr 2026 10:47:54 +0800 Subject: [PATCH] test: add missing tests for file/upload, search/query, vision/describe - Add test/commands/file/upload.test.ts - Add test/commands/search/query.test.ts - Add test/commands/vision/describe.test.ts - Update other test files to use resetStatusBar() for clean state --- test/commands/auth/login.test.ts | 4 +- test/commands/auth/logout.test.ts | 4 +- test/commands/auth/refresh.test.ts | 4 +- test/commands/auth/status.test.ts | 4 +- test/commands/config/set.test.ts | 8 +-- test/commands/config/show.test.ts | 4 +- test/commands/file/upload.test.ts | 38 ++++++++++++++ test/commands/image/generate.test.ts | 4 +- test/commands/quota/show.test.ts | 4 +- test/commands/search/query.test.ts | 38 ++++++++++++++ test/commands/speech/synthesize.test.ts | 8 +-- test/commands/text/chat.test.ts | 8 +-- test/commands/video/download.test.ts | 8 +-- test/commands/video/generate.test.ts | 4 +- test/commands/video/task-get.test.ts | 8 +-- test/commands/vision/describe.test.ts | 70 +++++++++++++++++++++++++ 16 files changed, 182 insertions(+), 36 deletions(-) create mode 100644 test/commands/file/upload.test.ts create mode 100644 test/commands/search/query.test.ts create mode 100644 test/commands/vision/describe.test.ts diff --git a/test/commands/auth/login.test.ts b/test/commands/auth/login.test.ts index 0a2d757..0a9767f 100644 --- a/test/commands/auth/login.test.ts +++ b/test/commands/auth/login.test.ts @@ -18,7 +18,7 @@ describe('auth login command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -31,7 +31,7 @@ describe('auth login command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('--api-key is required'); diff --git a/test/commands/auth/logout.test.ts b/test/commands/auth/logout.test.ts index 1bd79c8..3d36211 100644 --- a/test/commands/auth/logout.test.ts +++ b/test/commands/auth/logout.test.ts @@ -17,7 +17,7 @@ describe('auth logout command', () => { noColor: true, yes: false, dryRun: true, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -33,7 +33,7 @@ describe('auth logout command', () => { yes: false, dryRun: true, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/auth/refresh.test.ts b/test/commands/auth/refresh.test.ts index 5f49476..9a3234e 100644 --- a/test/commands/auth/refresh.test.ts +++ b/test/commands/auth/refresh.test.ts @@ -17,7 +17,7 @@ describe('auth refresh command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -29,7 +29,7 @@ describe('auth refresh command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('not authenticated via OAuth'); diff --git a/test/commands/auth/status.test.ts b/test/commands/auth/status.test.ts index 8aa0d2f..7b59cc8 100644 --- a/test/commands/auth/status.test.ts +++ b/test/commands/auth/status.test.ts @@ -17,7 +17,7 @@ describe('auth status command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -33,7 +33,7 @@ describe('auth status command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/config/set.test.ts b/test/commands/config/set.test.ts index 6130096..24c4c30 100644 --- a/test/commands/config/set.test.ts +++ b/test/commands/config/set.test.ts @@ -17,7 +17,7 @@ describe('config set command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -29,7 +29,7 @@ describe('config set command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('--key and --value are required'); @@ -46,7 +46,7 @@ describe('config set command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -60,7 +60,7 @@ describe('config set command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('Invalid config key'); diff --git a/test/commands/config/show.test.ts b/test/commands/config/show.test.ts index 14ae5d5..72a96b3 100644 --- a/test/commands/config/show.test.ts +++ b/test/commands/config/show.test.ts @@ -18,7 +18,7 @@ describe('config show command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -34,7 +34,7 @@ describe('config show command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/file/upload.test.ts b/test/commands/file/upload.test.ts new file mode 100644 index 0000000..a77cbbd --- /dev/null +++ b/test/commands/file/upload.test.ts @@ -0,0 +1,38 @@ +import { describe, it, expect } from 'bun:test'; +import { default as uploadCommand } from '../../../src/commands/file/upload'; + +describe('file upload command', () => { + it('has correct name', () => { + expect(uploadCommand.name).toBe('file upload'); + }); + + it('requires file argument', async () => { + const config = { + apiKey: 'test-key', + region: 'global' as const, + baseUrl: 'https://api.minimax.io', + output: 'text' as const, + timeout: 10, + verbose: false, + quiet: false, + noColor: true, + yes: false, + dryRun: true, + nonInteractive: true, + async: false, + }; + + await expect( + uploadCommand.execute(config, { + quiet: false, + verbose: false, + noColor: true, + yes: false, + dryRun: true, + help: false, + nonInteractive: true, + async: false, + }), + ).rejects.toThrow('Missing required argument: --file'); + }); +}); \ No newline at end of file diff --git a/test/commands/image/generate.test.ts b/test/commands/image/generate.test.ts index 8b7e4f4..f4ee1e8 100644 --- a/test/commands/image/generate.test.ts +++ b/test/commands/image/generate.test.ts @@ -18,7 +18,7 @@ describe('image generate command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -30,7 +30,7 @@ describe('image generate command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('Missing required argument: --prompt'); diff --git a/test/commands/quota/show.test.ts b/test/commands/quota/show.test.ts index e56cc33..a07a8d6 100644 --- a/test/commands/quota/show.test.ts +++ b/test/commands/quota/show.test.ts @@ -18,7 +18,7 @@ describe('quota show command', () => { noColor: true, yes: false, dryRun: true, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -34,7 +34,7 @@ describe('quota show command', () => { yes: false, dryRun: true, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/search/query.test.ts b/test/commands/search/query.test.ts new file mode 100644 index 0000000..9d7cc3b --- /dev/null +++ b/test/commands/search/query.test.ts @@ -0,0 +1,38 @@ +import { describe, it, expect } from 'bun:test'; +import { default as queryCommand } from '../../../src/commands/search/query'; + +describe('search query command', () => { + it('has correct name', () => { + expect(queryCommand.name).toBe('search query'); + }); + + it('requires q argument', async () => { + const config = { + apiKey: 'test-key', + region: 'global' as const, + baseUrl: 'https://api.minimax.io', + output: 'text' as const, + timeout: 10, + verbose: false, + quiet: false, + noColor: true, + yes: false, + dryRun: true, + nonInteractive: true, + async: false, + }; + + await expect( + queryCommand.execute(config, { + quiet: false, + verbose: false, + noColor: true, + yes: false, + dryRun: true, + help: false, + nonInteractive: true, + async: false, + }), + ).rejects.toThrow('--q is required'); + }); +}); \ No newline at end of file diff --git a/test/commands/speech/synthesize.test.ts b/test/commands/speech/synthesize.test.ts index 33f29c3..c06cf35 100644 --- a/test/commands/speech/synthesize.test.ts +++ b/test/commands/speech/synthesize.test.ts @@ -18,7 +18,7 @@ describe('speech synthesize command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -30,7 +30,7 @@ describe('speech synthesize command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('--text or --text-file is required'); @@ -48,7 +48,7 @@ describe('speech synthesize command', () => { noColor: true, yes: false, dryRun: true, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -65,7 +65,7 @@ describe('speech synthesize command', () => { yes: false, dryRun: true, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/text/chat.test.ts b/test/commands/text/chat.test.ts index d087dd2..58b16f5 100644 --- a/test/commands/text/chat.test.ts +++ b/test/commands/text/chat.test.ts @@ -31,7 +31,7 @@ describe('text chat command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -50,7 +50,7 @@ describe('text chat command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); @@ -74,7 +74,7 @@ describe('text chat command', () => { noColor: true, yes: false, dryRun: true, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -91,7 +91,7 @@ describe('text chat command', () => { yes: false, dryRun: true, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/video/download.test.ts b/test/commands/video/download.test.ts index 1b33d84..d919bfb 100644 --- a/test/commands/video/download.test.ts +++ b/test/commands/video/download.test.ts @@ -18,7 +18,7 @@ describe('video download command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -30,7 +30,7 @@ describe('video download command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('--file-id is required'); @@ -48,7 +48,7 @@ describe('video download command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -61,7 +61,7 @@ describe('video download command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('--out is required'); diff --git a/test/commands/video/generate.test.ts b/test/commands/video/generate.test.ts index 2ce5680..9745890 100644 --- a/test/commands/video/generate.test.ts +++ b/test/commands/video/generate.test.ts @@ -18,7 +18,7 @@ describe('video generate command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -30,7 +30,7 @@ describe('video generate command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('Missing required argument: --prompt'); diff --git a/test/commands/video/task-get.test.ts b/test/commands/video/task-get.test.ts index b48f733..8a55c64 100644 --- a/test/commands/video/task-get.test.ts +++ b/test/commands/video/task-get.test.ts @@ -26,7 +26,7 @@ describe('video task get command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -38,7 +38,7 @@ describe('video task get command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }), ).rejects.toThrow('--task-id is required'); @@ -62,7 +62,7 @@ describe('video task get command', () => { noColor: true, yes: false, dryRun: false, - nonInteractive: false, + nonInteractive: true, async: false, }; @@ -79,7 +79,7 @@ describe('video task get command', () => { yes: false, dryRun: false, help: false, - nonInteractive: false, + nonInteractive: true, async: false, }); diff --git a/test/commands/vision/describe.test.ts b/test/commands/vision/describe.test.ts new file mode 100644 index 0000000..7cdc5ab --- /dev/null +++ b/test/commands/vision/describe.test.ts @@ -0,0 +1,70 @@ +import { describe, it, expect } from 'bun:test'; +import { default as describeCommand } from '../../../src/commands/vision/describe'; + +describe('vision describe command', () => { + it('has correct name', () => { + expect(describeCommand.name).toBe('vision describe'); + }); + + it('requires either image or fileId', async () => { + const config = { + apiKey: 'test-key', + region: 'global' as const, + baseUrl: 'https://api.minimax.io', + output: 'text' as const, + timeout: 10, + verbose: false, + quiet: false, + noColor: true, + yes: false, + dryRun: true, + nonInteractive: true, + async: false, + }; + + await expect( + describeCommand.execute(config, { + quiet: false, + verbose: false, + noColor: true, + yes: false, + dryRun: true, + help: false, + nonInteractive: true, + async: false, + }), + ).rejects.toThrow('Missing required argument'); + }); + + it('rejects both image and fileId', async () => { + const config = { + apiKey: 'test-key', + region: 'global' as const, + baseUrl: 'https://api.minimax.io', + output: 'text' as const, + timeout: 10, + verbose: false, + quiet: false, + noColor: true, + yes: false, + dryRun: true, + nonInteractive: true, + async: false, + }; + + await expect( + describeCommand.execute(config, { + image: 'test.jpg', + fileId: 'file-123', + quiet: false, + verbose: false, + noColor: true, + yes: false, + dryRun: true, + help: false, + nonInteractive: true, + async: false, + }), + ).rejects.toThrow('Conflicting arguments'); + }); +}); \ No newline at end of file