Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 5 additions & 2 deletions src/commands/api/manifests/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -223,7 +223,10 @@ function transformTCaseFields(fields: Record<string, unknown>): Record<string, u

// Handle comma-separated tags
if (typeof fields.tags === 'string') {
result.tags = fields.tags.split(',')
result.tags = fields.tags
.split(',')
.map((tag) => tag.trim())
.filter((tag) => !!tag)
}

return result
Expand Down
48 changes: 48 additions & 0 deletions src/tests/api/test-cases/create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
17 changes: 17 additions & 0 deletions src/tests/api/test-cases/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down