testit-adapter-playwright 3.7.6 → 3.7.8

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Test IT TMS adapters for Playwright
2
- ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/master/images/banner.png)
2
+ ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/main/images/banner.png)
3
3
 
4
4
  ## Getting Started
5
5
 
package/dist/converter.js CHANGED
@@ -44,9 +44,16 @@ class Converter {
44
44
  return autotestResult;
45
45
  }
46
46
  static convertTestStepsToShortSteps(steps) {
47
- return steps
48
- .filter((step) => (0, utils_1.isStep)(step))
49
- .map(step => this.convertTestStepToShortStep(step));
47
+ const out = [];
48
+ for (const step of steps) {
49
+ if ((0, utils_1.isStep)(step)) {
50
+ out.push(this.convertTestStepToShortStep(step));
51
+ }
52
+ else if (step.steps?.length) {
53
+ out.push(...this.convertTestStepsToShortSteps(step.steps));
54
+ }
55
+ }
56
+ return out;
50
57
  }
51
58
  static convertTestStepToShortStep(step) {
52
59
  return {
@@ -55,9 +62,16 @@ class Converter {
55
62
  };
56
63
  }
57
64
  static convertTestStepsToSteps(steps, attachmentsMap) {
58
- return steps
59
- .filter((step) => (0, utils_1.isStep)(step))
60
- .map(step => this.convertTestStepToStep(step, attachmentsMap));
65
+ const out = [];
66
+ for (const step of steps) {
67
+ if ((0, utils_1.isStep)(step)) {
68
+ out.push(this.convertTestStepToStep(step, attachmentsMap));
69
+ }
70
+ else if (step.steps?.length) {
71
+ out.push(...this.convertTestStepsToSteps(step.steps, attachmentsMap));
72
+ }
73
+ }
74
+ return out;
61
75
  }
62
76
  static convertTestStepToStep(step, attachmentsMap) {
63
77
  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,
@@ -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") {
@@ -187,13 +178,27 @@ class TmsReporter {
187
178
  }
188
179
  async loadTest(test, result) {
189
180
  const autotestData = await this.getAutotestData(test, result);
181
+ const origin = await this.strategy.client.autoTests.getAutotestByExternalId(autotestData.externalId);
182
+ if (!origin) {
183
+ const dictionaries = this.getDictionariesByTest(test);
184
+ const namespace = dictionaries.slice(0, -1).join(path_1.default.sep);
185
+ const classname = dictionaries[dictionaries.length - 1];
186
+ if (namespace.length > 0) {
187
+ autotestData.namespace = namespace;
188
+ }
189
+ if (classname?.length) {
190
+ autotestData.classname = classname;
191
+ }
192
+ }
190
193
  const autotest = converter_1.Converter.convertTestCaseToAutotestPost(autotestData);
191
- const steps = [...this.stepsMap.keys()].filter((step) => this.stepsMap.get(step) === test);
192
- const stepResults = converter_1.Converter.convertTestStepsToSteps(steps, this.attachmentsMap);
194
+ const rawSteps = result.steps?.length
195
+ ? result.steps
196
+ : [...this.stepsMap.keys()].filter((step) => this.stepsMap.get(step) === test);
197
+ const stepResults = converter_1.Converter.convertTestStepsToSteps(rawSteps, this.attachmentsMap);
193
198
  if (!(0, utils_1.isAllStepsWithPassedOutcome)(stepResults)) {
194
199
  result.status = "failed";
195
200
  }
196
- autotest.steps = converter_1.Converter.convertTestStepsToShortSteps(steps);
201
+ autotest.steps = converter_1.Converter.convertTestStepsToShortSteps(rawSteps);
197
202
  await this.strategy.loadAutotest(autotest, converter_1.Converter.convertStatus(result.status, test.expectedStatus));
198
203
  const autotestResult = converter_1.Converter.convertAutotestPostToAutotestResult(autotestData, test, result);
199
204
  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.6",
3
+ "version": "3.7.8",
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.6"
43
+ "testit-js-commons": "3.7.8"
44
44
  },
45
45
  "files": [
46
46
  "dist"