testit-adapter-playwright 5.0.8 → 5.0.9

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.
@@ -12,9 +12,21 @@ export type StatusDetails = {
12
12
  message?: string;
13
13
  trace?: string;
14
14
  };
15
+ export type PlaywrightStepsTree = {
16
+ setup: ShortStep[];
17
+ steps: ShortStep[];
18
+ teardown: ShortStep[];
19
+ setupResults: Step[];
20
+ stepResults: Step[];
21
+ teardownResults: Step[];
22
+ };
15
23
  export declare class Converter {
16
24
  static convertTestCaseToAutotestPost(autotestData: MetadataMessage): AutotestPost;
17
25
  static convertAutotestPostToAutotestResult(autotestData: MetadataMessage, test: TestCase, result: Result): AutotestResult;
26
+ static convertPlaywrightStepsTree(rawSteps: TestStep[], attachmentsMap: Map<Attachment, TestStep>): PlaywrightStepsTree;
27
+ private static collectTestSteps;
28
+ private static convertPhaseSteps;
29
+ private static convertPhaseShortSteps;
18
30
  static convertTestStepsToShortSteps(steps: TestStep[]): ShortStep[];
19
31
  static convertTestStepToShortStep(step: TestStep): ShortStep;
20
32
  static convertTestStepsToSteps(steps: TestStep[], attachmentsMap: Map<Attachment, TestStep>): Step[];
package/dist/converter.js CHANGED
@@ -44,6 +44,92 @@ class Converter {
44
44
  }
45
45
  return autotestResult;
46
46
  }
47
+ static convertPlaywrightStepsTree(rawSteps, attachmentsMap) {
48
+ const setupRaw = [];
49
+ const bodyRaw = [];
50
+ const teardownRaw = [];
51
+ for (const step of rawSteps) {
52
+ if ((0, utils_1.isBeforeHook)(step)) {
53
+ setupRaw.push(...(step.steps ?? []));
54
+ }
55
+ else if ((0, utils_1.isAfterHook)(step)) {
56
+ teardownRaw.push(...(step.steps ?? []));
57
+ }
58
+ else if ((0, utils_1.isStep)(step)) {
59
+ bodyRaw.push(step);
60
+ }
61
+ else if (step.steps?.length) {
62
+ bodyRaw.push(...this.collectTestSteps(step.steps));
63
+ }
64
+ }
65
+ return {
66
+ setup: this.convertPhaseShortSteps(setupRaw),
67
+ steps: this.convertTestStepsToShortSteps(bodyRaw),
68
+ teardown: this.convertPhaseShortSteps(teardownRaw),
69
+ setupResults: this.convertPhaseSteps(setupRaw, attachmentsMap),
70
+ stepResults: this.convertTestStepsToSteps(bodyRaw, attachmentsMap),
71
+ teardownResults: this.convertPhaseSteps(teardownRaw, attachmentsMap),
72
+ };
73
+ }
74
+ static collectTestSteps(steps) {
75
+ const out = [];
76
+ for (const step of steps) {
77
+ if ((0, utils_1.isStep)(step)) {
78
+ out.push(step);
79
+ }
80
+ else if (step.steps?.length) {
81
+ out.push(...this.collectTestSteps(step.steps));
82
+ }
83
+ }
84
+ return out;
85
+ }
86
+ static convertPhaseSteps(steps, attachmentsMap) {
87
+ const out = [];
88
+ for (const step of steps) {
89
+ if ((0, utils_1.isFixtureStep)(step)) {
90
+ const nested = this.convertTestStepsToSteps(step.steps ?? [], attachmentsMap);
91
+ if (nested.length === 0) {
92
+ continue;
93
+ }
94
+ out.push({
95
+ title: step.title,
96
+ outcome: step.error || !(0, utils_1.isAllStepsWithPassedOutcome)(nested) ? Status.FAILED : Status.PASSED,
97
+ info: JSON.stringify(step.error),
98
+ steps: nested,
99
+ attachments: [...attachmentsMap.keys()].filter((attachmentId) => attachmentsMap.get(attachmentId) === step),
100
+ });
101
+ }
102
+ else if ((0, utils_1.isStep)(step)) {
103
+ out.push(this.convertTestStepToStep(step, attachmentsMap));
104
+ }
105
+ else if (step.steps?.length) {
106
+ out.push(...this.convertPhaseSteps(step.steps, attachmentsMap));
107
+ }
108
+ }
109
+ return out;
110
+ }
111
+ static convertPhaseShortSteps(steps) {
112
+ const out = [];
113
+ for (const step of steps) {
114
+ if ((0, utils_1.isFixtureStep)(step)) {
115
+ const nested = this.convertTestStepsToShortSteps(step.steps ?? []);
116
+ if (nested.length === 0) {
117
+ continue;
118
+ }
119
+ out.push({
120
+ title: step.title,
121
+ steps: nested,
122
+ });
123
+ }
124
+ else if ((0, utils_1.isStep)(step)) {
125
+ out.push(this.convertTestStepToShortStep(step));
126
+ }
127
+ else if (step.steps?.length) {
128
+ out.push(...this.convertPhaseShortSteps(step.steps));
129
+ }
130
+ }
131
+ return out;
132
+ }
47
133
  static convertTestStepsToShortSteps(steps) {
48
134
  const out = [];
49
135
  for (const step of steps) {
package/dist/reporter.js CHANGED
@@ -332,14 +332,18 @@ class TmsReporter {
332
332
  const rawSteps = result.steps?.length
333
333
  ? result.steps
334
334
  : [...this.stepsMap.keys()].filter((step) => this.stepsMap.get(step) === test);
335
- const stepResults = converter_1.Converter.convertTestStepsToSteps(rawSteps, this.attachmentsMap);
336
- autotest.steps = converter_1.Converter.convertTestStepsToShortSteps(rawSteps);
335
+ const tree = converter_1.Converter.convertPlaywrightStepsTree(rawSteps, this.attachmentsMap);
336
+ autotest.setup = tree.setup;
337
+ autotest.steps = tree.steps;
338
+ autotest.teardown = tree.teardown;
337
339
  if (!this.registeredExternalIds.has(externalId)) {
338
340
  await this.strategy.loadAutotest(autotest, converter_1.Converter.convertStatus(result.status, test.expectedStatus));
339
341
  this.registeredExternalIds.add(externalId);
340
342
  }
341
343
  const autotestResult = converter_1.Converter.convertAutotestPostToAutotestResult(autotestData, test, result);
342
- autotestResult.stepResults = stepResults;
344
+ autotestResult.setupResults = tree.setupResults;
345
+ autotestResult.stepResults = tree.stepResults;
346
+ autotestResult.teardownResults = tree.teardownResults;
343
347
  return autotestResult;
344
348
  }
345
349
  async loadTest(test, result) {
package/dist/utils.d.ts CHANGED
@@ -8,6 +8,10 @@ export type StatusDetails = {
8
8
  export declare function getStatusDetails(error: TestError): StatusDetails;
9
9
  export declare function isAllStepsWithPassedOutcome(steps: Step[]): boolean;
10
10
  export declare function isStep(step: TestStep): boolean;
11
+ export declare function isFixtureStep(step: TestStep): boolean;
12
+ export declare function isHookStep(step: TestStep): boolean;
13
+ export declare function isBeforeHook(step: TestStep): boolean;
14
+ export declare function isAfterHook(step: TestStep): boolean;
11
15
  export declare function resolveAttachmentParentStep(step: TestStep | undefined): TestStep | undefined;
12
16
  export declare function stripAscii(str: string): string;
13
17
  export declare const stepAttachRegexp: RegExp;
package/dist/utils.js CHANGED
@@ -4,6 +4,10 @@ exports.stepAttachRegexp = void 0;
4
4
  exports.getStatusDetails = getStatusDetails;
5
5
  exports.isAllStepsWithPassedOutcome = isAllStepsWithPassedOutcome;
6
6
  exports.isStep = isStep;
7
+ exports.isFixtureStep = isFixtureStep;
8
+ exports.isHookStep = isHookStep;
9
+ exports.isBeforeHook = isBeforeHook;
10
+ exports.isAfterHook = isAfterHook;
7
11
  exports.resolveAttachmentParentStep = resolveAttachmentParentStep;
8
12
  exports.stripAscii = stripAscii;
9
13
  exports.processAttachmentExtensions = processAttachmentExtensions;
@@ -28,6 +32,18 @@ function isAllStepsWithPassedOutcome(steps) {
28
32
  function isStep(step) {
29
33
  return step.category === "test.step" && !step.title.match(exports.stepAttachRegexp);
30
34
  }
35
+ function isFixtureStep(step) {
36
+ return step.category === "fixture";
37
+ }
38
+ function isHookStep(step) {
39
+ return step.category === "hook";
40
+ }
41
+ function isBeforeHook(step) {
42
+ return isHookStep(step) && /before/i.test(step.title);
43
+ }
44
+ function isAfterHook(step) {
45
+ return isHookStep(step) && /after/i.test(step.title);
46
+ }
31
47
  function resolveAttachmentParentStep(step) {
32
48
  let current = step?.parent;
33
49
  while (current) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-playwright",
3
- "version": "5.0.8",
3
+ "version": "5.0.9",
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": "5.0.8"
43
+ "testit-js-commons": "5.0.9"
44
44
  },
45
45
  "files": [
46
46
  "dist"