Skip to content

Commit

Permalink
fix: ability to add the QaseID to the test name
Browse files Browse the repository at this point in the history
Fix the issue where QaseID was not assigned to the test.
  • Loading branch information
gibiw committed Jul 31, 2024
1 parent 054ac49 commit 267dfe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qase-playwright/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playwright-qase-reporter",
"version": "2.0.7",
"version": "2.0.8",
"description": "Qase TMS Playwright Reporter",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
13 changes: 10 additions & 3 deletions qase-playwright/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ export class PlaywrightQaseReporter implements Reporter {
message += error.message;
}

const testTitle = this.removeQaseIdsFromTitle(test.title);

const testResult: TestResultType = {
attachments: testCaseMetadata.attachments,
author: null,
Expand Down Expand Up @@ -383,7 +385,7 @@ export class PlaywrightQaseReporter implements Reporter {
signature: '',
steps: this.transformSteps(result.steps, null),
testops_id: null,
title: testCaseMetadata.title === '' ? this.removeQaseIdsFromTitle(test.title) : testCaseMetadata.title,
title: testCaseMetadata.title === '' ? testTitle : testCaseMetadata.title,
};

if (this.reporter.isCaptureLogs()) {
Expand All @@ -399,7 +401,7 @@ export class PlaywrightQaseReporter implements Reporter {
if (testCaseMetadata.ids.length > 0) {
testResult.testops_id = testCaseMetadata.ids;
} else {
const ids = PlaywrightQaseReporter.qaseIds.get(test.title) ?? null;
const ids = PlaywrightQaseReporter.qaseIds.get(testTitle) ?? null;
testResult.testops_id = ids;
if (ids) {
const path = `${test.location.file}:${test.location.line}:${test.location.column}`;
Expand Down Expand Up @@ -477,10 +479,15 @@ export class PlaywrightQaseReporter implements Reporter {
return signature;
}

/**
* @param {string} title
* @returns {string}
* @private
*/
private removeQaseIdsFromTitle(title: string): string {
const matches = title.match(/\(Qase ID: ([0-9,]+)\)$/i);
if (matches) {
return title.replace(matches[0], '');
return title.replace(matches[0], '').trimEnd();
}
return title;
}
Expand Down

0 comments on commit 267dfe3

Please sign in to comment.