diff --git a/package.json b/package.json index 79c5132..b163797 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qas-cli", - "version": "0.10.0", + "version": "0.10.1", "description": "QAS CLI is a command line tool for submitting your automation test results to QA Sphere at https://qasphere.com/", "type": "module", "packageManager": "pnpm@11.1.2", diff --git a/src/commands/api/manifests/test-cases.ts b/src/commands/api/manifests/test-cases.ts index 3031332..3ddf9f4 100644 --- a/src/commands/api/manifests/test-cases.ts +++ b/src/commands/api/manifests/test-cases.ts @@ -33,7 +33,7 @@ const help = { 'precondition-text': 'Precondition text (supports HTML). Mutually exclusive with --precondition-id.', 'precondition-id': 'Shared precondition ID. Mutually exclusive with --precondition-text.', - tags: 'Comma-separated tag names (e.g., "smoke,regression").', + tags: 'Comma-separated tag names (e.g., "smoke,regression"). On update, --tags "" clears all tags.', 'is-draft': 'Whether the test case is a draft.', draft: 'Filter by draft status (true or false).', steps: @@ -223,7 +223,10 @@ function transformTCaseFields(fields: Record): Record tag.trim()) + .filter((tag) => !!tag) } return result diff --git a/src/tests/api/test-cases/create.spec.ts b/src/tests/api/test-cases/create.spec.ts index 3cb2787..30867f6 100644 --- a/src/tests/api/test-cases/create.spec.ts +++ b/src/tests/api/test-cases/create.spec.ts @@ -378,6 +378,54 @@ describe('mocked', () => { steps: [{ description: 'Step 1', expected: 'Result 1' }], }) }) + + test('--tags "" sends an empty tags array', async ({ project }) => { + await runCommand( + '--project-code', + project.code, + '--title', + 'No tags', + '--type', + 'standalone', + '--folder-id', + '1', + '--priority', + 'medium', + '--tags', + '' + ) + expect(lastRequest).toEqual({ + title: 'No tags', + type: 'standalone', + folderId: 1, + priority: 'medium', + tags: [], + }) + }) + + test('trims tag names and drops empty ones', async ({ project }) => { + await runCommand( + '--project-code', + project.code, + '--title', + 'Messy tags', + '--type', + 'standalone', + '--folder-id', + '1', + '--priority', + 'medium', + '--tags', + ' smoke , ,regression, ' + ) + expect(lastRequest).toEqual({ + title: 'Messy tags', + type: 'standalone', + folderId: 1, + priority: 'medium', + tags: ['smoke', 'regression'], + }) + }) }) test('creates a test case on live server', { tags: ['live'] }, async ({ project }) => { diff --git a/src/tests/api/test-cases/update.spec.ts b/src/tests/api/test-cases/update.spec.ts index e40af89..f9db2c8 100644 --- a/src/tests/api/test-cases/update.spec.ts +++ b/src/tests/api/test-cases/update.spec.ts @@ -151,6 +151,23 @@ describe('mocked', () => { }) }) + test('--tags "" clears tags by sending an empty array', async ({ project }) => { + await runCommand('--project-code', project.code, '--tcase-id', 'tc1', '--tags', '') + expect(lastRequest).toEqual({ tags: [] }) + }) + + test('trims tag names and drops empty ones', async ({ project }) => { + await runCommand( + '--project-code', + project.code, + '--tcase-id', + 'tc1', + '--tags', + ' smoke , ,e2e ' + ) + expect(lastRequest).toEqual({ tags: ['smoke', 'e2e'] }) + }) + test('updates a test case with custom fields', async ({ project }) => { const body = { customFields: {