From 3fe524987a78033f8b328e295e496137e70de492 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Wed, 18 Sep 2024 15:26:36 +0200 Subject: [PATCH] feature: support `author` field You can specify author name or email in fields. --- package-lock.json | 10 ++-- qase-javascript-commons/changelog.md | 52 +++++++++++-------- qase-javascript-commons/package.json | 4 +- .../src/reporters/testops-reporter.ts | 8 +++ 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1eda35d7..8edd7d76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15224,7 +15224,7 @@ "lodash.merge": "^4.6.2", "lodash.mergewith": "^4.6.2", "mime-types": "^2.1.33", - "qaseio": "~2.3.0", + "qaseio": "~2.3.1", "strip-ansi": "^6.0.1", "uuid": "^9.0.0" }, @@ -15360,7 +15360,7 @@ }, "qase-playwright": { "name": "playwright-qase-reporter", - "version": "2.0.12", + "version": "2.0.13", "license": "Apache-2.0", "dependencies": { "chalk": "^4.1.2", @@ -15382,7 +15382,7 @@ }, "qase-testcafe": { "name": "testcafe-reporter-qase", - "version": "2.0.1", + "version": "2.0.2", "license": "Apache-2.0", "dependencies": { "qase-javascript-commons": "~2.2.0", @@ -15403,7 +15403,7 @@ }, "qase-wdio": { "name": "wdio-qase-reporter", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.4", "license": "Apache-2.0", "dependencies": { "@types/node": "^20.1.0", @@ -15473,7 +15473,7 @@ } }, "qaseio": { - "version": "2.3.0", + "version": "2.3.1", "license": "Apache-2.0", "dependencies": { "axios": "^0.28.0", diff --git a/qase-javascript-commons/changelog.md b/qase-javascript-commons/changelog.md index c58b0500..331ab130 100644 --- a/qase-javascript-commons/changelog.md +++ b/qase-javascript-commons/changelog.md @@ -1,10 +1,16 @@ +# qase-javascript-commons@2.2.1 + +## What's new + +Support `author` field in the test result data. +You can specify author name or email in fields. + # qase-javascript-commons@2.1.3 ## What's new Reporters will send all data on the results of the autotests. Including the data of the title, the description, etc. - # qase-javascript-commons@2.1.1 ## What's new @@ -21,8 +27,10 @@ Minor release of the commons package ## What's new -- update a `InternalReporterInterface`. Added a new methods `sendResults` and `complete` to send the results and complete the test run. -- add `StateManager` class to manage and share the state of the reporter between the different instances of the reporter. +- update a `InternalReporterInterface`. Added a new methods `sendResults` and `complete` to send the results and + complete the test run. +- add `StateManager` class to manage and share the state of the reporter between the different instances of the + reporter. # qase-javascript-commons@2.0.13 @@ -37,7 +45,6 @@ Minor release of the commons package Support qaseio package version 2.2.0 - # qase-javascript-commons@2.0.11 ## What's new @@ -60,7 +67,6 @@ Now the reporter will send the test results only once. The Cypress calls the `publish` method multiple times for the same test results because of the Cypress architecture. It calls the `publish` method for each test file. - # qase-javascript-commons@2.0.9 ## What's new @@ -82,13 +88,15 @@ This option is available in the config file and the `QASE_ROOT_SUITE` env variab ## What's new -Fixed an issue with creating a test run with environment when the reporter ignored the `environment` parameter in the configuration. +Fixed an issue with creating a test run with environment when the reporter ignored the `environment` parameter in the +configuration. # qase-javascript-commons@2.0.7 ## What's new -Fixed an issue with creating a defect for failed tests when the reporter ignored the `defect` parameter in the configuration. +Fixed an issue with creating a defect for failed tests when the reporter ignored the `defect` parameter in the +configuration. # qase-javascript-commons@2.0.6 @@ -143,7 +151,7 @@ Before this fix, the reporter added ANSI escape codes to the message and stack t ## What's new This is the first release version of the Qase JavaScript SDK. -It is numbered `2.0.0` (and not `1.0.0`) to match the release series of +It is numbered `2.0.0` (and not `1.0.0`) to match the release series of test reporters for Playwright, Cypress, Jest, and other frameworks. ### Annotating test with field data @@ -153,9 +161,9 @@ This feature is already implemented in the Playwright reporter: ```js test('Test with annotated fields', () => { - qase.id(1); - qase.fields({ 'severity': 'high', 'priority': 'medium' }) - // ... + qase.id(1); + qase.fields({ 'severity': 'high', 'priority': 'medium' }) + // ... }); ``` @@ -182,7 +190,8 @@ It helps bring test results faster and enables acting on them long before the te Qase JavaScript SDK brings configuration with config files and environment variables to a common standard, used with Qase reporters in all languages and frameworks. -For details, see the [Configuration](https://github.com/qase-tms/qase-javascript/tree/main/qase-javascript-commons#configuration) +For details, see +the [Configuration](https://github.com/qase-tms/qase-javascript/tree/main/qase-javascript-commons#configuration) section in the README. ### Latest API @@ -221,17 +230,17 @@ Fixed an issue when the results published before the test run creation. Improved debug logging for better testing and reporting errors. -- Separate `logger` class for use in reporters, supporting logging to console and files. -- Extra debug logs in both reporter modes: TestOps and Local. +- Separate `logger` class for use in reporters, supporting logging to console and files. +- Extra debug logs in both reporter modes: TestOps and Local. Fixed an issue with duplicate test runs created when the testing framework (such as Cypress) uses more than one instance of the Qase reporter. Now reporter handles Qase test runs in the following way: -1. The first instance of the reporter creates a Qase test run and stores the run ID - in the ENV variable `QASE_TESTOPS_RUN_ID`. -2. Other instances of the reporter read this variable and report test results - to the existing test run. +1. The first instance of the reporter creates a Qase test run and stores the run ID + in the ENV variable `QASE_TESTOPS_RUN_ID`. +2. Other instances of the reporter read this variable and report test results + to the existing test run. Nothing has changed in cases when there is a single instance of a reporter or when it is using a test run, created with other tools, such as with an API request @@ -303,7 +312,7 @@ This commit introduces a way to select the API version to use. It enables using all new features of v2 JS reporters with the stable v1 API, and elso experimenting with the new v2 API. -**Warning**: v2 API is still in beta. +**Warning**: v2 API is still in beta. If you want to try the v2 JS reporters, you don't have to enable the new API. To enable using API v2, set an environment variable before running the tests: @@ -319,16 +328,17 @@ Such description can be collected from test's location and attributes or explicitly declared in the test. Add new data models: + - Relation - Suite - SuiteData - # qase-javascript-commons@2.0.0-beta.5 ## What's new -* Update the config of reporters. Added `captureLogs` field. If it is set to `true`, the reporter will capture logs from the test framework. +* Update the config of reporters. Added `captureLogs` field. If it is set to `true`, the reporter will capture logs from + the test framework. * Added `getMimeType` function to the commons package. It returns the MIME type of the file by its extension. # qase-javascript-commons@2.0.0-beta.4 diff --git a/qase-javascript-commons/package.json b/qase-javascript-commons/package.json index 164a3a50..a5e87c70 100644 --- a/qase-javascript-commons/package.json +++ b/qase-javascript-commons/package.json @@ -1,6 +1,6 @@ { "name": "qase-javascript-commons", - "version": "2.2.0", + "version": "2.2.1", "description": "Qase JS Reporters", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -33,7 +33,7 @@ "lodash.merge": "^4.6.2", "lodash.mergewith": "^4.6.2", "mime-types": "^2.1.33", - "qaseio": "~2.3.0", + "qaseio": "~2.3.1", "strip-ansi": "^6.0.1", "uuid": "^9.0.0" }, diff --git a/qase-javascript-commons/src/reporters/testops-reporter.ts b/qase-javascript-commons/src/reporters/testops-reporter.ts index 58d79ff2..d1226116 100644 --- a/qase-javascript-commons/src/reporters/testops-reporter.ts +++ b/qase-javascript-commons/src/reporters/testops-reporter.ts @@ -467,6 +467,14 @@ export class TestOpsReporter extends AbstractReporter { resultCreate.case.layer = result.fields['layer']; } + if (result.fields['author']) { + const resp = await this.api.authors.getAuthors(result.fields['author']); + if (resp.data.result?.entities && resp.data.result.entities.length > 0) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + resultCreate.author_id = resp.data.result.entities[0]?.author_id ?? null; + } + } + this.logger.logDebug(`Transformed result: ${JSON.stringify(resultCreate)}`); return resultCreate;