Skip to content
Draft
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
1 change: 1 addition & 0 deletions AGENTS.md
14 changes: 8 additions & 6 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Node.js compatibility tests: `cd mnode-test && ./docker-test.sh` (requires Docke
### Entry Point & CLI Framework

- `src/bin/qasphere.ts` — Entry point (`#!/usr/bin/env node`). Validates Node version, delegates to `run()`.
- `src/commands/main.ts` — Yargs setup. Registers two commands (`junit-upload`, `playwright-json-upload`) as instances of the same `ResultUploadCommandModule` class.
- `src/commands/resultUpload.ts` — `ResultUploadCommandModule` defines CLI options shared by both commands. Loads env vars, then delegates to `ResultUploadCommandHandler`.
- `src/commands/main.ts` — Yargs setup. Registers three commands (`junit-upload`, `playwright-json-upload`, `allure-upload`) as instances of the same `ResultUploadCommandModule` class.
- `src/commands/resultUpload.ts` — `ResultUploadCommandModule` defines CLI options shared by all three commands. Loads env vars, then delegates to `ResultUploadCommandHandler`.

### Core Upload Pipeline (src/utils/result-upload/)

The upload flow has two stages handled by two classes:

1. **`ResultUploadCommandHandler`** — Orchestrates the overall flow:
- Parses report files using the appropriate parser (JUnit XML or Playwright JSON)
- Parses report files using the appropriate parser (JUnit XML, Playwright JSON, or Allure)
- Detects project code from test case names (or from `--run-url`)
- Creates a new test run (or reuses an existing one if title conflicts)
- Delegates actual result uploading to `ResultUploader`
Expand All @@ -51,7 +51,8 @@ The upload flow has two stages handled by two classes:

- `junitXmlParser.ts` — Parses JUnit XML via `xml2js` + Zod validation. Extracts attachments from `[[ATTACHMENT|path]]` markers in system-out/failure/error/skipped elements.
- `playwrightJsonParser.ts` — Parses Playwright JSON report. Supports two test case linking methods: (1) test annotations with `type: "test case"` and URL description, (2) marker in test name. Handles nested suites recursively.
- `types.ts` — Shared `TestCaseResult` and `Attachment` interfaces used by both parsers.
- `allureParser.ts` — Parses Allure results directory (`*-result.json` files). Directory-based input (not single file). Extracts test case markers from TMS links or test names. Maps `broken` → `blocked`, derives folders from suite/feature labels.
- `types.ts` — Shared `TestCaseResult` and `Attachment` interfaces used by all parsers.

### API Layer (src/api/)

Expand All @@ -72,12 +73,13 @@ Composable fetch wrappers using higher-order functions:

Tests use **Vitest** with **MSW** (Mock Service Worker) for API mocking. Test files are in `src/tests/`:

- `result-upload.spec.ts` — Integration tests for the full upload flow (both JUnit and Playwright), with MSW intercepting all API calls
- `result-upload.spec.ts` — Integration tests for the full upload flow (JUnit, Playwright, and Allure), with MSW intercepting all API calls
- `junit-xml-parsing.spec.ts` — Unit tests for JUnit XML parser
- `playwright-json-parsing.spec.ts` — Unit tests for Playwright JSON parser
- `allure-parsing.spec.ts` — Unit tests for Allure results directory parser
- `template-string-processing.spec.ts` — Unit tests for run name template processing

Test fixtures live in `src/tests/fixtures/` (XML files, JSON files, and mock test case data).
Test fixtures live in `src/tests/fixtures/` (XML files, JSON files, Allure result directories, and mock test case data).

The `tsconfig.json` excludes `src/tests` from compilation output.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.4.5",
"version": "0.4.6",
"description": "QAS CLI is a command line tool for submitting your automation test results to QA Sphere at https://qasphere.com/",
"type": "module",
"main": "./build/bin/qasphere.js",
Expand Down
1 change: 1 addition & 0 deletions src/commands/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Required variables: ${qasEnvs.join(', ')}
)
.command(new ResultUploadCommandModule('junit-upload'))
.command(new ResultUploadCommandModule('playwright-json-upload'))
.command(new ResultUploadCommandModule('allure-upload'))
.demandCommand(1, '')
.help('h')
.alias('h', 'help')
Expand Down
32 changes: 14 additions & 18 deletions src/commands/resultUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
const commandTypeDisplayStrings: Record<UploadCommandType, string> = {
'junit-upload': 'JUnit XML',
'playwright-json-upload': 'Playwright JSON',
'allure-upload': 'Allure',
}

const commandTypeFileExtensions: Record<UploadCommandType, string> = {
'junit-upload': 'xml',
'playwright-json-upload': 'json',
'allure-upload': '',
}

export class ResultUploadCommandModule implements CommandModule<unknown, ResultUploadCommandArgs> {
Expand All @@ -25,7 +27,8 @@ export class ResultUploadCommandModule implements CommandModule<unknown, ResultU
}

get describe() {
return `Upload ${commandTypeDisplayStrings[this.type]} files to a new or existing test run`
const input = this.type === 'allure-upload' ? 'results directory' : 'files'
return `Upload ${commandTypeDisplayStrings[this.type]} ${input} to a new or existing test run`
}

builder = (argv: Argv) => {
Expand Down Expand Up @@ -82,40 +85,33 @@ export class ResultUploadCommandModule implements CommandModule<unknown, ResultU
},
})

const examplePath =
this.type === 'allure-upload'
? './allure-results'
: `./test-results.${commandTypeFileExtensions[this.type]}`

argv.example(
`$0 ${this.type} -r https://qas.eu1.qasphere.com/project/P1/run/23 ./test-results.${
commandTypeFileExtensions[this.type]
}`,
`$0 ${this.type} -r https://qas.eu1.qasphere.com/project/P1/run/23 ${examplePath}`,
'Upload results to existing run ID 23 of project P1'
)

argv.example(
`$0 ${this.type} ./test-results.${commandTypeFileExtensions[this.type]}`,
`$0 ${this.type} ${examplePath}`,
'Create a new test run with default name template and upload results. Project code is detected from test case markers in the results'
)

argv.example(
`$0 ${this.type} --project-code P1 --run-name "v1.4.4-rc5" ./test-results.${
commandTypeFileExtensions[this.type]
}`,
`$0 ${this.type} --project-code P1 --run-name "v1.4.4-rc5" ${examplePath}`,
'Create a new test run with name template without any placeholders and upload results'
)

argv.example(
`$0 ${
this.type
} --project-code P1 --run-name "CI Build {env:BUILD_NUMBER} - {YYYY}-{MM}-{DD}" ./test-results.${
commandTypeFileExtensions[this.type]
}`,
`$0 ${this.type} --project-code P1 --run-name "CI Build {env:BUILD_NUMBER} - {YYYY}-{MM}-{DD}" ${examplePath}`,
'Create a new test run with name template using environment variable and date placeholders and upload results'
)

argv.example(
`$0 ${
this.type
} --project-code P1 --run-name "Nightly Tests {YYYY}/{MM}/{DD} {HH}:{mm}" --create-tcases ./test-results.${
commandTypeFileExtensions[this.type]
}`,
`$0 ${this.type} --project-code P1 --run-name "Nightly Tests {YYYY}/{MM}/{DD} {HH}:{mm}" --create-tcases ${examplePath}`,
'Create a new test run with name template using date and time placeholders and create test cases for results without valid markers and upload results'
)

Expand Down
Loading