playwright-slack-report-burak 1.3.5 → 1.3.7

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.
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateFailures = exports.generateFailuresReasons = exports.generateProblemCaseList = exports.generateBlocks = exports.generateAllRunSuites = void 0;
3
+ exports.generateFailures =
4
+ exports.generateFailuresReasons =
5
+ exports.generateProblemSuiteList =
6
+ exports.generateProblemCaseList =
7
+ exports.generateBlocks =
8
+ exports.generateAllRunSuites =
9
+ void 0;
10
+
4
11
  const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
5
12
  const meta = [];
6
13
  const header = {
@@ -137,47 +144,39 @@ const generateAllRunSuites = async (summaryResults) => {
137
144
  allSuitesTitle[0] = '*Suites Run:*\n';
138
145
  }
139
146
 
140
- // Push data into array to create the "List of Problematic Test Suites"
141
- if (summaryResults.tests.length !== summaryResults.passed){
142
- suitesResults.push({
143
- type: 'section',
144
- text: {
145
- type: 'mrkdwn',
146
- text:
147
- `${allSuitesTitle}${[...new Set(allSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}`
148
- },
149
- },
150
- {
151
- type: 'section',
152
- text: {
153
- type: 'mrkdwn',
154
- text: ` `,
155
- },
147
+ // Push data into array to create the "List of All Run Test Suites"
148
+ suitesResults.push({
149
+ type: 'section',
150
+ text: {
151
+ type: 'mrkdwn',
152
+ text:
153
+ `${allSuitesTitle}${[...new Set(allSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}`
156
154
  },
157
- {
158
- type: 'divider',
155
+ },
156
+ {
157
+ type: 'section',
158
+ text: {
159
+ type: 'mrkdwn',
160
+ text: ` `,
159
161
  },
160
- )}
161
- return [
162
- ...suitesResults,
163
- ];
162
+ },
163
+ {
164
+ type: 'divider',
165
+ },
166
+ )
167
+ return [
168
+ ...suitesResults,
169
+ ];
164
170
  };
165
171
 
166
- const generateProblemCaseList = async (summaryResults) => {
172
+ const generateProblemSuiteList = async (summaryResults) => {
167
173
  const suitesResults = [];
168
- const allSuites = [];
174
+ const failedSuites = [];
169
175
  const flakySuites = [];
170
176
  const skippedSuites = [];
171
- const failsList = [];
172
- const flakyList = [];
173
- const skipsList = [];
174
- const allSuitesTitle = [];
177
+ const failedSuitesTitle = [];
175
178
  const flakySuitesTitle = [];
176
179
  const skippedSuitesTitle = [];
177
- const failedNamesTitle = [];
178
- const flakyNamesTitle = [];
179
- const skippedNamesTitle = [];
180
- let previousTestName = undefined;
181
180
  let previousSuiteName = undefined;
182
181
 
183
182
  // Create a list for names of test suites with failed test cases
@@ -191,7 +190,7 @@ const generateProblemCaseList = async (summaryResults) => {
191
190
  ? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
192
191
  : backSlashedParts;
193
192
  if (formattedSuiteName !== previousSuiteName) {
194
- allSuites.push(formattedSuiteName);
193
+ failedSuites.push(formattedSuiteName);
195
194
  previousSuiteName = formattedSuiteName;
196
195
  }
197
196
  }
@@ -236,6 +235,65 @@ const generateProblemCaseList = async (summaryResults) => {
236
235
  }
237
236
  previousSuiteName = undefined;
238
237
 
238
+ // Decide on Titles For Listing Failures, Skips & Flakies
239
+ if (failedSuites.length === 1) {
240
+ failedSuitesTitle[0] = '*Suite With Failed Test Case(s):*\n';
241
+ }
242
+ if (failedSuites.length > 1) {
243
+ failedSuitesTitle[0] = '*Suites With Failed Test Case(s):*\n';
244
+ }
245
+ if (flakySuites.length === 1) {
246
+ flakySuitesTitle[0] = '\n*Suite With Flaky Test Case(s):*\n';
247
+ }
248
+ if (flakySuites.length > 1) {
249
+ flakySuitesTitle[0] = '\n*Suites With Flaky Test Case(s):*\n';
250
+ }
251
+ if (skippedSuites.length === 1) {
252
+ skippedSuitesTitle[0] = '\n*Suite With Skipped Test Case(s):*\n';
253
+ }
254
+ if (skippedSuites.length > 1) {
255
+ skippedSuitesTitle[0] = '\n*Suites With Skipped Test Case(s):*\n';
256
+ }
257
+
258
+ // Push data into array to create the "List of Problematic Test Suites"
259
+ if (summaryResults.tests.length !== summaryResults.passed){
260
+ suitesResults.push({
261
+ type: 'section',
262
+ text: {
263
+ type: 'mrkdwn',
264
+ text:
265
+ `${failedSuitesTitle}${[...new Set(failedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
266
+ `\n${flakySuitesTitle}${[...new Set(flakySuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
267
+ `\n${skippedSuitesTitle}${[...new Set(skippedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `,
268
+ },
269
+ },
270
+ {
271
+ type: 'section',
272
+ text: {
273
+ type: 'mrkdwn',
274
+ text: ` `,
275
+ },
276
+ },
277
+ {
278
+ type: 'divider',
279
+ },
280
+ )}
281
+ return [
282
+ ...suitesResults,
283
+ ];
284
+ };
285
+
286
+ const generateProblemCaseList = async (summaryResults) => {
287
+ const casesResults = [];
288
+ const failsList = [];
289
+ const flakyList = [];
290
+ const skipsList = [];
291
+ const failedNamesTitle = [];
292
+ const flakyNamesTitle = [];
293
+ const skippedNamesTitle = [];
294
+ let previousTestName = undefined;
295
+ let previousSuiteName = undefined;
296
+
239
297
  // Create a list for names of failed test cases
240
298
  for (let i = 0; i < summaryResults.failures.length; i += 1) {
241
299
  const { test, suiteName } = summaryResults.failures[i];
@@ -279,24 +337,6 @@ const generateProblemCaseList = async (summaryResults) => {
279
337
  previousSuiteName = undefined;
280
338
 
281
339
  // Decide on Titles For Listing Failures, Skips & Flakies
282
- if (allSuites.length === 1) {
283
- allSuitesTitle[0] = '*Failed Suite:*\n';
284
- }
285
- if (allSuites.length > 1) {
286
- allSuitesTitle[0] = '*Failed Suites:*\n';
287
- }
288
- if (flakySuites.length === 1) {
289
- flakySuitesTitle[0] = '\n*Flaky Suite:*\n';
290
- }
291
- if (flakySuites.length > 1) {
292
- flakySuitesTitle[0] = '\n*Flaky Suites:*\n';
293
- }
294
- if (skippedSuites.length === 1) {
295
- skippedSuitesTitle[0] = '\n*Skipped Suite:*\n';
296
- }
297
- if (skippedSuites.length > 1) {
298
- skippedSuitesTitle[0] = '\n*Skipped Suites:*\n';
299
- }
300
340
  if (summaryResults.failed === 1) {
301
341
  failedNamesTitle[0] = '\n*Failed Test Case:*\n';
302
342
  }
@@ -318,16 +358,7 @@ const generateProblemCaseList = async (summaryResults) => {
318
358
 
319
359
  // Push data into array to create the "List of Problematic Test Suites"
320
360
  if (summaryResults.tests.length !== summaryResults.passed){
321
- suitesResults.push({
322
- type: 'section',
323
- text: {
324
- type: 'mrkdwn',
325
- text:
326
- `${allSuitesTitle}${[...new Set(allSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
327
- `\n${flakySuitesTitle}${[...new Set(flakySuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
328
- `\n${skippedSuitesTitle}${[...new Set(skippedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `,
329
- },
330
- },
361
+ casesResults.push(
331
362
  {
332
363
  type: 'section',
333
364
  text: {
@@ -350,7 +381,7 @@ const generateProblemCaseList = async (summaryResults) => {
350
381
  },
351
382
  )}
352
383
  return [
353
- ...suitesResults,
384
+ ...casesResults,
354
385
  ];
355
386
  };
356
387
 
@@ -475,5 +506,6 @@ const generateFailuresReasons = async (summaryResults) => {
475
506
  };
476
507
  exports.generateFailures = generateFailures;
477
508
  exports.generateFailuresReasons = generateFailuresReasons;
509
+ exports.generateProblemSuiteList = generateProblemSuiteList;
478
510
  exports.generateProblemCaseList = generateProblemCaseList;
479
- exports.generateAllRunSuites = generateAllRunSuites;
511
+ exports.generateAllRunSuites = generateAllRunSuites;
@@ -102,7 +102,30 @@ class SlackClient {
102
102
  }
103
103
  return result;
104
104
  }
105
-
105
+ async attachDetailsToThreadSuites({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
106
+ const result = [];
107
+ const blocks = await (0, LayoutGenerator_1.generateProblemSuiteList)(summaryResults, maxNumberOfFailures);
108
+ for (const channel of channelIds) {
109
+ // under test
110
+ let chatResponse;
111
+ if (fakeRequest) {
112
+ chatResponse = await fakeRequest();
113
+ }
114
+ else {
115
+ chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
116
+ }
117
+ if (chatResponse.ok) {
118
+ // eslint-disable-next-line no-console
119
+ console.log(`✅ Message sent to ${channel} within thread ${ts}`);
120
+ result.push({
121
+ channel,
122
+ outcome: `✅ Message sent to ${channel} within thread ${ts}`,
123
+ ts: chatResponse.ts,
124
+ });
125
+ }
126
+ }
127
+ return result;
128
+ }
106
129
  async attachDetailsToThreadCases({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
107
130
  const result = [];
108
131
  const blocks = await (0, LayoutGenerator_1.generateProblemCaseList)(summaryResults, maxNumberOfFailures);
@@ -111,8 +111,8 @@ class SlackReporter {
111
111
  });
112
112
  // eslint-disable-next-line no-console
113
113
  console.log(JSON.stringify(result, null, 2));
114
- if (this.showInThread && (resultSummary.failures.length > 0 || resultSummary.skipped > 0 || resultSummary.flaky > 0)) {
115
- /* for (let i = 0; i < result.length; i += 1) {
114
+ if (this.showInThread) {
115
+ /*for (let i = 0; i < result.length; i += 1) {
116
116
  // eslint-disable-next-line no-await-in-loop
117
117
  await slackClient.attachDetailsToThread({
118
118
  channelIds: [result[i].channel],
@@ -120,7 +120,7 @@ class SlackReporter {
120
120
  summaryResults: resultSummary,
121
121
  maxNumberOfFailures: this.maxNumberOfFailuresToShow,
122
122
  });
123
- }*/
123
+ }*/
124
124
  for (let i = 0; i < result.length; i += 1) {
125
125
  // eslint-disable-next-line no-await-in-loop
126
126
  await slackClient.attachDetailsToThreadRuns({
@@ -131,25 +131,37 @@ class SlackReporter {
131
131
  });
132
132
  }
133
133
 
134
- for (let i = 0; i < result.length; i += 1) {
135
- // eslint-disable-next-line no-await-in-loop
136
- await slackClient.attachDetailsToThreadCases({
137
- channelIds: [result[i].channel],
138
- ts: result[i].ts,
139
- summaryResults: resultSummary,
140
- maxNumberOfFailures: this.maxNumberOfFailuresToShow,
141
- });
142
- }
143
-
144
- for (let i = 0; i < result.length; i += 1) {
145
- // eslint-disable-next-line no-await-in-loop
146
- await slackClient.attachDetailsToThreadReasons({
147
- channelIds: [result[i].channel],
148
- ts: result[i].ts,
149
- summaryResults: resultSummary,
150
- maxNumberOfFailures: this.maxNumberOfFailuresToShow,
151
- });
152
- }
134
+ if ((resultSummary.failures.length > 0 || resultSummary.skipped > 0 || resultSummary.flaky > 0)) {
135
+ for (let i = 0; i < result.length; i += 1) {
136
+ // eslint-disable-next-line no-await-in-loop
137
+ await slackClient.attachDetailsToThreadSuites({
138
+ channelIds: [result[i].channel],
139
+ ts: result[i].ts,
140
+ summaryResults: resultSummary,
141
+ maxNumberOfFailures: this.maxNumberOfFailuresToShow,
142
+ });
143
+ }
144
+
145
+ for (let i = 0; i < result.length; i += 1) {
146
+ // eslint-disable-next-line no-await-in-loop
147
+ await slackClient.attachDetailsToThreadCases({
148
+ channelIds: [result[i].channel],
149
+ ts: result[i].ts,
150
+ summaryResults: resultSummary,
151
+ maxNumberOfFailures: this.maxNumberOfFailuresToShow,
152
+ });
153
+ }
154
+
155
+ for (let i = 0; i < result.length; i += 1) {
156
+ // eslint-disable-next-line no-await-in-loop
157
+ await slackClient.attachDetailsToThreadReasons({
158
+ channelIds: [result[i].channel],
159
+ ts: result[i].ts,
160
+ summaryResults: resultSummary,
161
+ maxNumberOfFailures: this.maxNumberOfFailuresToShow,
162
+ });
163
+ }
164
+ }
153
165
  }
154
166
  }
155
167
  }
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "lint-fix": "npx eslint . --ext .ts --fix"
31
31
  },
32
32
  "name": "playwright-slack-report-burak",
33
- "version": "1.3.5",
33
+ "version": "1.3.7",
34
34
  "main": "index.js",
35
35
  "types": "dist/index.d.ts",
36
36
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",