From b77dbe21e5aa8f6b211c28c5f90e7a76fddf7feb Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Thu, 4 Apr 2024 17:55:14 +0200 Subject: [PATCH] qase-reporters: support a new logic of commons Support a new logic of the qase-javascript-commons package. --- qase-cucumberjs/src/reporter.ts | 2 +- qase-cypress/src/reporter.ts | 2 +- qase-jest/src/reporter.ts | 3 ++- qase-newman/src/reporter.ts | 4 ++-- qase-playwright/src/reporter.ts | 25 +++---------------------- qase-testcafe/src/reporter.ts | 3 ++- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/qase-cucumberjs/src/reporter.ts b/qase-cucumberjs/src/reporter.ts index a5f185e2..daa83086 100644 --- a/qase-cucumberjs/src/reporter.ts +++ b/qase-cucumberjs/src/reporter.ts @@ -255,7 +255,7 @@ export class CucumberQaseReporter extends Formatter { run_id: null, signature: '', steps: [], - testops_id: info.caseIds[0] ?? null, + testops_id: info.caseIds.length > 0 ? info.caseIds : null, id: tcs.id, title: info.name, // suiteTitle: info.lastAstNodeId && this.scenarios[info.lastAstNodeId], diff --git a/qase-cypress/src/reporter.ts b/qase-cypress/src/reporter.ts index b9bf38a6..fc2736c3 100644 --- a/qase-cypress/src/reporter.ts +++ b/qase-cypress/src/reporter.ts @@ -183,7 +183,7 @@ export class CypressQaseReporter extends reporters.Base { stacktrace: test.err?.stack ?? null, thread: null, }, - testops_id: ids[0] ?? null, + testops_id: ids.length > 0 ? ids : null, title: test.title, // suiteTitle: test.parent?.titlePath(), }; diff --git a/qase-jest/src/reporter.ts b/qase-jest/src/reporter.ts index 16a0733c..1382abd3 100644 --- a/qase-jest/src/reporter.ts +++ b/qase-jest/src/reporter.ts @@ -110,6 +110,7 @@ export class JestQaseReporter implements Reporter { error.stack = failureMessages.join('\n\n'); } + const ids = JestQaseReporter.getCaseId(title); this.reporter.addTestResult({ attachments: [], author: null, @@ -129,7 +130,7 @@ export class JestQaseReporter implements Reporter { run_id: null, signature: '', steps: [], - testops_id: JestQaseReporter.getCaseId(title)[0] ?? null, + testops_id: ids.length > 0 ? ids : null, id: uuidv4(), title: title, // suiteTitle: ancestorTitles, diff --git a/qase-newman/src/reporter.ts b/qase-newman/src/reporter.ts index 62bef345..29b3586e 100644 --- a/qase-newman/src/reporter.ts +++ b/qase-newman/src/reporter.ts @@ -124,7 +124,7 @@ export class NewmanQaseReporter { (_err: Error | undefined, exec: NewmanRunExecution) => { const { item } = exec; // const parent = item.parent(); - + const ids = NewmanQaseReporter.getCaseIds(item.events); this.pendingResultMap.set(item.id, { attachments: [], author: null, @@ -144,7 +144,7 @@ export class NewmanQaseReporter { run_id: null, signature: '', steps: [], - testops_id: NewmanQaseReporter.getCaseIds(item.events)[0] ?? null, + testops_id: ids.length > 0 ? ids : null, id: item.id, title: item.name, // suiteTitle: parent ? NewmanQaseReporter.getParentTitles(parent) : [], diff --git a/qase-playwright/src/reporter.ts b/qase-playwright/src/reporter.ts index 1348362a..e21edae4 100644 --- a/qase-playwright/src/reporter.ts +++ b/qase-playwright/src/reporter.ts @@ -275,32 +275,13 @@ export class PlaywrightQaseReporter implements Reporter { title: testCaseMetadata.title === '' ? test.title : testCaseMetadata.title, }; - let ids: number[]; if (testCaseMetadata.ids.length > 0) { - ids = testCaseMetadata.ids; + testResult.testops_id = testCaseMetadata.ids; } else { - ids = PlaywrightQaseReporter.qaseIds.get(test.title) ?? []; + testResult.testops_id = PlaywrightQaseReporter.qaseIds.get(test.title) ?? null; } - if (ids.length == 0) { - this.reporter.addTestResult(testResult); - return; - } - - // if we have multiple ids, we need to create multiple test results and set duration to 0 for all but the first one - let firstCase = true; - for (const id of ids) { - const testResultCopy = { ...testResult }; - testResultCopy.testops_id = id; - testResultCopy.id = uuidv4(); - - if (!firstCase) { - testResultCopy.execution.duration = 0; - } - firstCase = false; - - this.reporter.addTestResult(testResultCopy); - } + this.reporter.addTestResult(testResult); } /** diff --git a/qase-testcafe/src/reporter.ts b/qase-testcafe/src/reporter.ts index 2466713b..554c4c76 100644 --- a/qase-testcafe/src/reporter.ts +++ b/qase-testcafe/src/reporter.ts @@ -179,6 +179,7 @@ export class TestcafeQaseReporter { meta: Record, ) => { const error = TestcafeQaseReporter.transformErrors(testRunInfo.errs); + const ids = TestcafeQaseReporter.getCaseId(meta); this.reporter.addTestResult({ author: null, execution: { @@ -198,7 +199,7 @@ export class TestcafeQaseReporter { signature: '', steps: [], id: uuidv4(), - testops_id: TestcafeQaseReporter.getCaseId(meta)[0] ?? null, + testops_id: ids.length > 0 ? ids : null, title: title, // suiteTitle: testRunInfo.fixture.name, attachments: TestcafeQaseReporter.transformAttachments(