testit-adapter-playwright 5.0.8 → 5.0.9-TMS-5.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
@@ -137,14 +137,12 @@ first-job:
137
137
  Methods can be used to specify information about autotest.
138
138
 
139
139
  Description of metadata methods:
140
- - `testit.workItemId` - linking an autotest to a test case. Receives a single globalId
141
- - `testit.workItemIds` - deprecated, use `testit.workItemId` instead
140
+ - `testit.workItemIds` - linking an autotest to a test case
142
141
  - `testit.displayName` - name of the autotest in the Test IT system (can be replaced with documentation strings)
143
142
  - `testit.externalId` - ID of the autotest within the project in the Test IT System
144
143
  - `testit.title` - title in the autotest card
145
144
  - `testit.description` - description in the autotest card
146
145
  - `testit.labels` - labels in the autotest card
147
- - `testit.layer` - test pyramid layer in the autotest card (source **Run**). Use `TestLayers` from `testit-js-commons` for recommended values (`E2E`, `UI`, `API`, `Contract`, `Integration`, `Component`, `Unit`), or any custom string
148
146
  - `testit.tags` - tags in the autotest card
149
147
  - `testit.links` - links in the autotest card
150
148
  - `testit.namespace` - directory in the TMS system (default - directory's name of test)
@@ -162,7 +160,6 @@ Description of methods:
162
160
  ```js
163
161
  import { test } from "@playwright/test";
164
162
  import { testit } from "testit-adapter-playwright";
165
- import { TestLayers } from "testit-js-commons";
166
163
 
167
164
  test('All annotations', async () => {
168
165
  testit.externalId('all_annotations');
@@ -170,7 +167,6 @@ test('All annotations', async () => {
170
167
  testit.title('All annotations title');
171
168
  testit.description('Test with all annotations');
172
169
  testit.labels(['label1', 'label2']);
173
- await testit.layer(TestLayers.API);
174
170
 
175
171
  testit.addMessage('This is a message');
176
172
  testit.addLinks([
@@ -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
@@ -16,7 +16,6 @@ class Converter {
16
16
  title: autotestData.title,
17
17
  description: autotestData.description,
18
18
  labels: autotestData.labels,
19
- layer: autotestData.layer,
20
19
  tags: autotestData.tags,
21
20
  links: autotestData.links,
22
21
  namespace: autotestData.namespace,
@@ -44,6 +43,92 @@ class Converter {
44
43
  }
45
44
  return autotestResult;
46
45
  }
46
+ static convertPlaywrightStepsTree(rawSteps, attachmentsMap) {
47
+ const setupRaw = [];
48
+ const bodyRaw = [];
49
+ const teardownRaw = [];
50
+ for (const step of rawSteps) {
51
+ if ((0, utils_1.isBeforeHook)(step)) {
52
+ setupRaw.push(...(step.steps ?? []));
53
+ }
54
+ else if ((0, utils_1.isAfterHook)(step)) {
55
+ teardownRaw.push(...(step.steps ?? []));
56
+ }
57
+ else if ((0, utils_1.isStep)(step)) {
58
+ bodyRaw.push(step);
59
+ }
60
+ else if (step.steps?.length) {
61
+ bodyRaw.push(...this.collectTestSteps(step.steps));
62
+ }
63
+ }
64
+ return {
65
+ setup: this.convertPhaseShortSteps(setupRaw),
66
+ steps: this.convertTestStepsToShortSteps(bodyRaw),
67
+ teardown: this.convertPhaseShortSteps(teardownRaw),
68
+ setupResults: this.convertPhaseSteps(setupRaw, attachmentsMap),
69
+ stepResults: this.convertTestStepsToSteps(bodyRaw, attachmentsMap),
70
+ teardownResults: this.convertPhaseSteps(teardownRaw, attachmentsMap),
71
+ };
72
+ }
73
+ static collectTestSteps(steps) {
74
+ const out = [];
75
+ for (const step of steps) {
76
+ if ((0, utils_1.isStep)(step)) {
77
+ out.push(step);
78
+ }
79
+ else if (step.steps?.length) {
80
+ out.push(...this.collectTestSteps(step.steps));
81
+ }
82
+ }
83
+ return out;
84
+ }
85
+ static convertPhaseSteps(steps, attachmentsMap) {
86
+ const out = [];
87
+ for (const step of steps) {
88
+ if ((0, utils_1.isFixtureStep)(step)) {
89
+ const nested = this.convertTestStepsToSteps(step.steps ?? [], attachmentsMap);
90
+ if (nested.length === 0) {
91
+ continue;
92
+ }
93
+ out.push({
94
+ title: step.title,
95
+ outcome: step.error || !(0, utils_1.isAllStepsWithPassedOutcome)(nested) ? Status.FAILED : Status.PASSED,
96
+ info: JSON.stringify(step.error),
97
+ steps: nested,
98
+ attachments: [...attachmentsMap.keys()].filter((attachmentId) => attachmentsMap.get(attachmentId) === step),
99
+ });
100
+ }
101
+ else if ((0, utils_1.isStep)(step)) {
102
+ out.push(this.convertTestStepToStep(step, attachmentsMap));
103
+ }
104
+ else if (step.steps?.length) {
105
+ out.push(...this.convertPhaseSteps(step.steps, attachmentsMap));
106
+ }
107
+ }
108
+ return out;
109
+ }
110
+ static convertPhaseShortSteps(steps) {
111
+ const out = [];
112
+ for (const step of steps) {
113
+ if ((0, utils_1.isFixtureStep)(step)) {
114
+ const nested = this.convertTestStepsToShortSteps(step.steps ?? []);
115
+ if (nested.length === 0) {
116
+ continue;
117
+ }
118
+ out.push({
119
+ title: step.title,
120
+ steps: nested,
121
+ });
122
+ }
123
+ else if ((0, utils_1.isStep)(step)) {
124
+ out.push(this.convertTestStepToShortStep(step));
125
+ }
126
+ else if (step.steps?.length) {
127
+ out.push(...this.convertPhaseShortSteps(step.steps));
128
+ }
129
+ }
130
+ return out;
131
+ }
47
132
  static convertTestStepsToShortSteps(steps) {
48
133
  const out = [];
49
134
  for (const step of steps) {
package/dist/labels.d.ts CHANGED
@@ -6,7 +6,6 @@ export interface MetadataMessage {
6
6
  title?: string;
7
7
  description?: string;
8
8
  labels?: Label[];
9
- layer?: string;
10
9
  tags?: string[];
11
10
  links?: Link[];
12
11
  namespace?: string;
@@ -53,17 +52,12 @@ export declare class testit {
53
52
  private static addMetadataAttachment;
54
53
  static addAttachment(name: string, content: Buffer | string, options: ContentType | string | Pick<AttachmentOptions, "contentType">): Promise<void>;
55
54
  private static mapParams;
56
- static workItemId(globalId: string): Promise<void>;
57
- /**
58
- * @deprecated Use workItemId with a single globalId instead.
59
- */
60
55
  static workItemIds(value: string[]): Promise<void>;
61
56
  static displayName(value: string): Promise<void>;
62
57
  static externalId(value: string): Promise<void>;
63
58
  static title(value: string): Promise<void>;
64
59
  static description(value: string): Promise<void>;
65
60
  static labels(value: string[]): Promise<void>;
66
- static layer(value: string): Promise<void>;
67
61
  static tags(value: string[]): Promise<void>;
68
62
  static links(value: Link[]): Promise<void>;
69
63
  static namespace(value: string): Promise<void>;
package/dist/labels.js CHANGED
@@ -106,16 +106,7 @@ class testit {
106
106
  return {};
107
107
  }
108
108
  }
109
- static async workItemId(globalId) {
110
- await this.addMetadataAttachment({
111
- workItemIds: [globalId],
112
- });
113
- }
114
- /**
115
- * @deprecated Use workItemId with a single globalId instead.
116
- */
117
109
  static async workItemIds(value) {
118
- testit_js_commons_1.logger.warn("workItemIds is deprecated. Use workItemId with a single globalId instead.");
119
110
  await this.addMetadataAttachment({
120
111
  workItemIds: value,
121
112
  });
@@ -145,11 +136,6 @@ class testit {
145
136
  labels: value.map((label) => ({ name: label })),
146
137
  });
147
138
  }
148
- static async layer(value) {
149
- await this.addMetadataAttachment({
150
- layer: value,
151
- });
152
- }
153
139
  static async tags(value) {
154
140
  await this.addMetadataAttachment({
155
141
  tags: value,
@@ -77,9 +77,6 @@ function applyMetadataTo(target, source) {
77
77
  if (source.labels) {
78
78
  target.labels = source.labels;
79
79
  }
80
- if (source.layer) {
81
- target.layer = source.layer;
82
- }
83
80
  if (source.tags) {
84
81
  target.tags = source.tags;
85
82
  }
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-TMS-5.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": "5.0.8"
43
+ "testit-js-commons": "5.0.9-TMS-5.8"
44
44
  },
45
45
  "files": [
46
46
  "dist"