From d568885bb844f63e123544c2a20e75ad67f03a7c Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Tue, 29 Oct 2024 16:35:13 +0100 Subject: [PATCH] feature: support new version of qaseio Support new version of qaseio --- package-lock.json | 14 +----- qase-javascript-commons/package.json | 4 +- .../src/reporters/testops-reporter.ts | 50 ++++++++++++++++--- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index bf00fadf..43358817 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15245,7 +15245,7 @@ "lodash.merge": "^4.6.2", "lodash.mergewith": "^4.6.2", "mime-types": "^2.1.33", - "qaseio": "~2.3.1", + "qaseio": "~2.4.0", "strip-ansi": "^6.0.1", "uuid": "^9.0.0" }, @@ -15283,18 +15283,6 @@ "follow-redirects": "^1.14.0" } }, - "qase-javascript-commons/node_modules/qaseio": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/qaseio/-/qaseio-2.3.1.tgz", - "integrity": "sha512-VZFLEVGrGGAAPRik5uZuc3mgUfuBfADebRP7O83Ly1Kb+UxiQlSZxrn839gw7fEx0hLXpLXVWD7DTbdMOSPULQ==", - "dependencies": { - "axios": "^0.28.0", - "axios-retry": "^3.5.0" - }, - "engines": { - "node": ">=14" - } - }, "qase-javascript-commons/node_modules/qaseio/node_modules/axios": { "version": "0.28.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.28.1.tgz", diff --git a/qase-javascript-commons/package.json b/qase-javascript-commons/package.json index a5e87c70..8d37286b 100644 --- a/qase-javascript-commons/package.json +++ b/qase-javascript-commons/package.json @@ -1,6 +1,6 @@ { "name": "qase-javascript-commons", - "version": "2.2.1", + "version": "2.2.2", "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.1", + "qaseio": "~2.4.0", "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 d1226116..0f6941f6 100644 --- a/qase-javascript-commons/src/reporters/testops-reporter.ts +++ b/qase-javascript-commons/src/reporters/testops-reporter.ts @@ -215,12 +215,10 @@ export class TestOpsReporter extends AbstractReporter { public override async addTestResult(result: TestResultType): Promise { if (result.execution.status === TestStatusEnum.failed) { - if (Array.isArray(result.testops_id)) { - for (const id of result.testops_id) { - this.showLink(id, result.title); - } - } else { - this.showLink(result.testops_id, result.title); + const testOpsIds = Array.isArray(result.testops_id) ? result.testops_id : [result.testops_id]; + + for (const id of testOpsIds) { + this.showLink(id, result.title); } } @@ -339,8 +337,17 @@ export class TestOpsReporter extends AbstractReporter { return; } + const remainingResults = this.results.slice(this.firstIndex); + if (this.firstIndex < this.results.length) { - await this.publishResults(this.results.slice(this.firstIndex)); + if (remainingResults.length <= defaultChunkSize) { + await this.publishResults(remainingResults); + return; + } + + for (let i = 0; i < remainingResults.length; i += defaultChunkSize) { + await this.publishResults(remainingResults.slice(i, i + defaultChunkSize)); + } } // Clear results because we don't need to send them again then we use Cypress reporter @@ -376,15 +383,42 @@ export class TestOpsReporter extends AbstractReporter { const attachments = await this.uploadAttachments(result.attachments); const steps = await this.transformSteps(result.steps, result.title); + const param: Record = {}; + + for (const key in result.params) { + const value = result.params[key]; + if (!value) { + continue; + } + param[key] = value; + } + + const group_params: string[][] = []; + + const keys = Object.keys(result.group_params); + if (keys.length > 0) { + group_params.push(keys); + } + + for (const key in result.group_params) { + const value = result.group_params[key]; + if (!value) { + continue; + } + param[key] = value; + } + const model = { title: result.title, execution: this.getExecution(result.execution), testops_id: Array.isArray(result.testops_id) ? null : result.testops_id, attachments: attachments, steps: steps, - params: result.params, + params: param, + param_groups: group_params, relations: this.getRelation(result.relations), message: result.message, + fields: result.fields, }; this.logger.logDebug(`Transformed result: ${JSON.stringify(model)}`);