From 054ac4983da801f24fcc4d7bc85b63b68da0e031 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Tue, 30 Jul 2024 12:37:22 +0200 Subject: [PATCH] fix: return the ability to add the QaseID to the test name This allows using the standard playwright mechanism to filter the tests being run. --- qase-playwright/changelog.md | 7 +++++++ qase-playwright/package.json | 2 +- qase-playwright/src/playwright.ts | 2 +- qase-playwright/src/reporter.ts | 10 +++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qase-playwright/changelog.md b/qase-playwright/changelog.md index 3110b368..925beb62 100644 --- a/qase-playwright/changelog.md +++ b/qase-playwright/changelog.md @@ -1,3 +1,10 @@ +# playwright-qase-reporter@2.0.7 + +## What's new + +Returned the ability to add the QaseID to the test name. +This allows using the standard playwright mechanism to filter the tests being run. + # playwright-qase-reporter@2.0.6 ## What's new diff --git a/qase-playwright/package.json b/qase-playwright/package.json index f1e84a5e..e7bf041d 100644 --- a/qase-playwright/package.json +++ b/qase-playwright/package.json @@ -1,6 +1,6 @@ { "name": "playwright-qase-reporter", - "version": "2.0.6", + "version": "2.0.7", "description": "Qase TMS Playwright Reporter", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/qase-playwright/src/playwright.ts b/qase-playwright/src/playwright.ts index 283f5a3a..6120180e 100644 --- a/qase-playwright/src/playwright.ts +++ b/qase-playwright/src/playwright.ts @@ -53,7 +53,7 @@ export const qase = ( PlaywrightQaseReporter.addIds(ids, name); - return `${name}`; + return `${name} (Qase ID: ${caseIds.join(',')})`; }; /** diff --git a/qase-playwright/src/reporter.ts b/qase-playwright/src/reporter.ts index 52281f4d..b24d58d6 100644 --- a/qase-playwright/src/reporter.ts +++ b/qase-playwright/src/reporter.ts @@ -383,7 +383,7 @@ export class PlaywrightQaseReporter implements Reporter { signature: '', steps: this.transformSteps(result.steps, null), testops_id: null, - title: testCaseMetadata.title === '' ? test.title : testCaseMetadata.title, + title: testCaseMetadata.title === '' ? this.removeQaseIdsFromTitle(test.title) : testCaseMetadata.title, }; if (this.reporter.isCaptureLogs()) { @@ -476,4 +476,12 @@ export class PlaywrightQaseReporter implements Reporter { return signature; } + + private removeQaseIdsFromTitle(title: string): string { + const matches = title.match(/\(Qase ID: ([0-9,]+)\)$/i); + if (matches) { + return title.replace(matches[0], ''); + } + return title; + } }