testit-adapter-playwright 3.7.0 → 3.7.1-TMS-5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/converter.js +20 -6
- package/dist/labels.js +2 -1
- package/dist/models/result.d.ts +3 -1
- package/dist/reporter.js +20 -14
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +15 -7
- package/package.json +2 -2
package/dist/converter.js
CHANGED
|
@@ -43,9 +43,16 @@ class Converter {
|
|
|
43
43
|
return autotestResult;
|
|
44
44
|
}
|
|
45
45
|
static convertTestStepsToShortSteps(steps) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const step of steps) {
|
|
48
|
+
if ((0, utils_1.isStep)(step)) {
|
|
49
|
+
out.push(this.convertTestStepToShortStep(step));
|
|
50
|
+
}
|
|
51
|
+
else if (step.steps?.length) {
|
|
52
|
+
out.push(...this.convertTestStepsToShortSteps(step.steps));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
49
56
|
}
|
|
50
57
|
static convertTestStepToShortStep(step) {
|
|
51
58
|
return {
|
|
@@ -54,9 +61,16 @@ class Converter {
|
|
|
54
61
|
};
|
|
55
62
|
}
|
|
56
63
|
static convertTestStepsToSteps(steps, attachmentsMap) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
const out = [];
|
|
65
|
+
for (const step of steps) {
|
|
66
|
+
if ((0, utils_1.isStep)(step)) {
|
|
67
|
+
out.push(this.convertTestStepToStep(step, attachmentsMap));
|
|
68
|
+
}
|
|
69
|
+
else if (step.steps?.length) {
|
|
70
|
+
out.push(...this.convertTestStepsToSteps(step.steps, attachmentsMap));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
60
74
|
}
|
|
61
75
|
static convertTestStepToStep(step, attachmentsMap) {
|
|
62
76
|
const steps = step.steps.length !== 0 ? this.convertTestStepsToSteps(step.steps, attachmentsMap) : [];
|
package/dist/labels.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.testit = exports.Extensions = exports.ContentType = void 0;
|
|
7
7
|
const crypto_1 = require("crypto");
|
|
8
8
|
const test_1 = __importDefault(require("@playwright/test"));
|
|
9
|
+
const utils_1 = require("./utils");
|
|
9
10
|
var ContentType;
|
|
10
11
|
(function (ContentType) {
|
|
11
12
|
ContentType["TEXT"] = "text/plain";
|
|
@@ -40,8 +41,8 @@ class testit {
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
static async addAttachment(name, content, options) {
|
|
43
|
-
const stepName = `stepattach_${(0, crypto_1.randomUUID)()}_${name}`;
|
|
44
44
|
const contentType = typeof options === "string" ? options : options.contentType;
|
|
45
|
+
const stepName = (0, utils_1.processAttachmentNameExtensions)(`stepattach_${(0, crypto_1.randomUUID)()}_${name}`, contentType);
|
|
45
46
|
await this.step(stepName, async () => {
|
|
46
47
|
await test_1.default.info().attach(stepName, {
|
|
47
48
|
body: content,
|
package/dist/models/result.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { TestStatus } from "@playwright/test";
|
|
2
|
-
import { TestError } from "@playwright/test/reporter";
|
|
2
|
+
import { TestError, TestStep } from "@playwright/test/reporter";
|
|
3
3
|
export interface Result {
|
|
4
4
|
status: TestStatus;
|
|
5
5
|
attachments: Array<ResultAttachment>;
|
|
6
6
|
duration: number;
|
|
7
7
|
error?: TestError;
|
|
8
8
|
errors: Array<TestError>;
|
|
9
|
+
/** Full Playwright step tree (fixtures, hooks, test.step); preferred over reporter cache. */
|
|
10
|
+
steps?: TestStep[];
|
|
9
11
|
}
|
|
10
12
|
export interface ResultAttachment {
|
|
11
13
|
/**
|
package/dist/reporter.js
CHANGED
|
@@ -47,6 +47,7 @@ class TmsReporter {
|
|
|
47
47
|
duration: result.duration,
|
|
48
48
|
errors: result.errors,
|
|
49
49
|
error: result.error,
|
|
50
|
+
steps: result.steps,
|
|
50
51
|
}));
|
|
51
52
|
}
|
|
52
53
|
// fix issues with trace and video files on playwright
|
|
@@ -86,6 +87,7 @@ class TmsReporter {
|
|
|
86
87
|
attachments: [],
|
|
87
88
|
duration: 0,
|
|
88
89
|
errors: [],
|
|
90
|
+
steps: [],
|
|
89
91
|
});
|
|
90
92
|
});
|
|
91
93
|
}
|
|
@@ -106,17 +108,6 @@ class TmsReporter {
|
|
|
106
108
|
addAttachments: [],
|
|
107
109
|
externalKey: test.title,
|
|
108
110
|
};
|
|
109
|
-
const dictionaries = this.getDictionariesByTest(test);
|
|
110
|
-
const namespace = dictionaries
|
|
111
|
-
.slice(0, -1)
|
|
112
|
-
.join(path_1.default.sep);
|
|
113
|
-
const classname = dictionaries[dictionaries.length - 1];
|
|
114
|
-
if (namespace != undefined && namespace.length > 0) {
|
|
115
|
-
autotestData.namespace = namespace;
|
|
116
|
-
}
|
|
117
|
-
if (classname != undefined && classname.length > 0) {
|
|
118
|
-
autotestData.classname = classname;
|
|
119
|
-
}
|
|
120
111
|
for (const attachment of result.attachments) {
|
|
121
112
|
if (!attachment.body) {
|
|
122
113
|
if (attachment.path && attachment.name !== "screenshot") {
|
|
@@ -184,13 +175,28 @@ class TmsReporter {
|
|
|
184
175
|
}
|
|
185
176
|
async loadTest(test, result) {
|
|
186
177
|
const autotestData = await this.getAutotestData(test, result);
|
|
178
|
+
const origin = await this.strategy.client.autoTests.getAutotestByExternalId(autotestData.externalId);
|
|
179
|
+
if (!origin) {
|
|
180
|
+
const dictionaries = this.getDictionariesByTest(test);
|
|
181
|
+
const pathNamespace = dictionaries.slice(0, -1).join(path_1.default.sep);
|
|
182
|
+
const pathClassname = dictionaries[dictionaries.length - 1];
|
|
183
|
+
// Prefer testit.namespace / testit.classname from attachments; file path is the default only when missing.
|
|
184
|
+
if (pathNamespace.length > 0 && autotestData.namespace == null) {
|
|
185
|
+
autotestData.namespace = pathNamespace;
|
|
186
|
+
}
|
|
187
|
+
if (pathClassname?.length && autotestData.classname == null) {
|
|
188
|
+
autotestData.classname = pathClassname;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
187
191
|
const autotest = converter_1.Converter.convertTestCaseToAutotestPost(autotestData);
|
|
188
|
-
const
|
|
189
|
-
|
|
192
|
+
const rawSteps = result.steps?.length
|
|
193
|
+
? result.steps
|
|
194
|
+
: [...this.stepsMap.keys()].filter((step) => this.stepsMap.get(step) === test);
|
|
195
|
+
const stepResults = converter_1.Converter.convertTestStepsToSteps(rawSteps, this.attachmentsMap);
|
|
190
196
|
if (!(0, utils_1.isAllStepsWithPassedOutcome)(stepResults)) {
|
|
191
197
|
result.status = "failed";
|
|
192
198
|
}
|
|
193
|
-
autotest.steps = converter_1.Converter.convertTestStepsToShortSteps(
|
|
199
|
+
autotest.steps = converter_1.Converter.convertTestStepsToShortSteps(rawSteps);
|
|
194
200
|
await this.strategy.loadAutotest(autotest, converter_1.Converter.convertStatus(result.status, test.expectedStatus));
|
|
195
201
|
const autotestResult = converter_1.Converter.convertAutotestPostToAutotestResult(autotestData, test, result);
|
|
196
202
|
autotestResult.stepResults = stepResults;
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare function isStep(step: TestStep): boolean;
|
|
|
11
11
|
export declare function stripAscii(str: string): string;
|
|
12
12
|
export declare const stepAttachRegexp: RegExp;
|
|
13
13
|
export declare function processAttachmentExtensions(attachment: ResultAttachment): ResultAttachment;
|
|
14
|
+
export declare function processAttachmentNameExtensions(name: string, contentType: string): string;
|
package/dist/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.isAllStepsWithPassedOutcome = isAllStepsWithPassedOutcome;
|
|
|
6
6
|
exports.isStep = isStep;
|
|
7
7
|
exports.stripAscii = stripAscii;
|
|
8
8
|
exports.processAttachmentExtensions = processAttachmentExtensions;
|
|
9
|
+
exports.processAttachmentNameExtensions = processAttachmentNameExtensions;
|
|
9
10
|
const converter_1 = require("./converter");
|
|
10
11
|
const labels_1 = require("./labels");
|
|
11
12
|
function getStatusDetails(error) {
|
|
@@ -33,14 +34,14 @@ function stripAscii(str) {
|
|
|
33
34
|
;
|
|
34
35
|
exports.stepAttachRegexp = /^stepattach_(\w{8}-\w{4}-\w{4}-\w{4}-\w{12})_/i;
|
|
35
36
|
const asciiRegex = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", "g");
|
|
37
|
+
const extensionMap = {
|
|
38
|
+
[labels_1.ContentType.ZIP]: labels_1.Extensions.ZIP,
|
|
39
|
+
[labels_1.ContentType.PNG]: labels_1.Extensions.PNG,
|
|
40
|
+
[labels_1.ContentType.WEBM]: labels_1.Extensions.WEBM,
|
|
41
|
+
[labels_1.ContentType.MD]: labels_1.Extensions.MD,
|
|
42
|
+
[labels_1.ContentType.JPEG]: labels_1.Extensions.JPEG,
|
|
43
|
+
};
|
|
36
44
|
function processAttachmentExtensions(attachment) {
|
|
37
|
-
const extensionMap = {
|
|
38
|
-
[labels_1.ContentType.ZIP]: labels_1.Extensions.ZIP,
|
|
39
|
-
[labels_1.ContentType.PNG]: labels_1.Extensions.PNG,
|
|
40
|
-
[labels_1.ContentType.WEBM]: labels_1.Extensions.WEBM,
|
|
41
|
-
[labels_1.ContentType.MD]: labels_1.Extensions.MD,
|
|
42
|
-
[labels_1.ContentType.JPEG]: labels_1.Extensions.JPEG,
|
|
43
|
-
};
|
|
44
45
|
const extension = extensionMap[attachment.contentType];
|
|
45
46
|
if (extension && !attachment.name.includes(extension)) {
|
|
46
47
|
return {
|
|
@@ -50,3 +51,10 @@ function processAttachmentExtensions(attachment) {
|
|
|
50
51
|
}
|
|
51
52
|
return attachment;
|
|
52
53
|
}
|
|
54
|
+
function processAttachmentNameExtensions(name, contentType) {
|
|
55
|
+
const extension = extensionMap[contentType];
|
|
56
|
+
if (extension && !name.includes(extension)) {
|
|
57
|
+
return name + extension;
|
|
58
|
+
}
|
|
59
|
+
return name;
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-playwright",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.1-TMS-5.6",
|
|
4
4
|
"description": "Playwright adapter for Test IT",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"prettier": "^3.0.1"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"testit-js-commons": "3.7.
|
|
43
|
+
"testit-js-commons": "3.7.1-TMS-5.6"
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
46
46
|
"dist"
|