playwright-slack-report-burak 1.3.4 → 1.3.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/src/LayoutGenerator.js +76 -43
- package/dist/src/SlackClient.js +24 -1
- package/dist/src/SlackReporter.js +10 -0
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateFailures =
|
|
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 = {
|
|
@@ -134,7 +141,7 @@ const generateAllRunSuites = async (summaryResults) => {
|
|
|
134
141
|
allSuitesTitle[0] = '*Suite Run:*\n';
|
|
135
142
|
}
|
|
136
143
|
if (allSuites.length > 1) {
|
|
137
|
-
allSuitesTitle[0] = '*Suites
|
|
144
|
+
allSuitesTitle[0] = '*Suites Run:*\n';
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
// Push data into array to create the "List of Problematic Test Suites"
|
|
@@ -163,21 +170,14 @@ const generateAllRunSuites = async (summaryResults) => {
|
|
|
163
170
|
];
|
|
164
171
|
};
|
|
165
172
|
|
|
166
|
-
const
|
|
173
|
+
const generateProblemSuiteList = async (summaryResults) => {
|
|
167
174
|
const suitesResults = [];
|
|
168
|
-
const
|
|
175
|
+
const failedSuites = [];
|
|
169
176
|
const flakySuites = [];
|
|
170
177
|
const skippedSuites = [];
|
|
171
|
-
const
|
|
172
|
-
const flakyList = [];
|
|
173
|
-
const skipsList = [];
|
|
174
|
-
const allSuitesTitle = [];
|
|
178
|
+
const failedSuitesTitle = [];
|
|
175
179
|
const flakySuitesTitle = [];
|
|
176
180
|
const skippedSuitesTitle = [];
|
|
177
|
-
const failedNamesTitle = [];
|
|
178
|
-
const flakyNamesTitle = [];
|
|
179
|
-
const skippedNamesTitle = [];
|
|
180
|
-
let previousTestName = undefined;
|
|
181
181
|
let previousSuiteName = undefined;
|
|
182
182
|
|
|
183
183
|
// Create a list for names of test suites with failed test cases
|
|
@@ -191,7 +191,7 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
191
191
|
? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
|
|
192
192
|
: backSlashedParts;
|
|
193
193
|
if (formattedSuiteName !== previousSuiteName) {
|
|
194
|
-
|
|
194
|
+
failedSuites.push(formattedSuiteName);
|
|
195
195
|
previousSuiteName = formattedSuiteName;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -236,6 +236,65 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
236
236
|
}
|
|
237
237
|
previousSuiteName = undefined;
|
|
238
238
|
|
|
239
|
+
// Decide on Titles For Listing Failures, Skips & Flakies
|
|
240
|
+
if (failedSuites.length === 1) {
|
|
241
|
+
failedSuitesTitle[0] = '*Suite With Failed Test Case(s):*\n';
|
|
242
|
+
}
|
|
243
|
+
if (failedSuites.length > 1) {
|
|
244
|
+
failedSuitesTitle[0] = '*Suites With Failed Test Case(s):*\n';
|
|
245
|
+
}
|
|
246
|
+
if (flakySuites.length === 1) {
|
|
247
|
+
flakySuitesTitle[0] = '\n*Suite With Flaky Test Case(s):*\n';
|
|
248
|
+
}
|
|
249
|
+
if (flakySuites.length > 1) {
|
|
250
|
+
flakySuitesTitle[0] = '\n*Suites With Flaky Test Case(s):*\n';
|
|
251
|
+
}
|
|
252
|
+
if (skippedSuites.length === 1) {
|
|
253
|
+
skippedSuitesTitle[0] = '\n*Suite With Skipped Test Case(s):*\n';
|
|
254
|
+
}
|
|
255
|
+
if (skippedSuites.length > 1) {
|
|
256
|
+
skippedSuitesTitle[0] = '\n*Suites With Skipped Test Case(s):*\n';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Push data into array to create the "List of Problematic Test Suites"
|
|
260
|
+
if (summaryResults.tests.length !== summaryResults.passed){
|
|
261
|
+
suitesResults.push({
|
|
262
|
+
type: 'section',
|
|
263
|
+
text: {
|
|
264
|
+
type: 'mrkdwn',
|
|
265
|
+
text:
|
|
266
|
+
`${failedSuitesTitle}${[...new Set(failedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
|
|
267
|
+
`\n${flakySuitesTitle}${[...new Set(flakySuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
|
|
268
|
+
`\n${skippedSuitesTitle}${[...new Set(skippedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
type: 'section',
|
|
273
|
+
text: {
|
|
274
|
+
type: 'mrkdwn',
|
|
275
|
+
text: ` `,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
type: 'divider',
|
|
280
|
+
},
|
|
281
|
+
)}
|
|
282
|
+
return [
|
|
283
|
+
...suitesResults,
|
|
284
|
+
];
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const generateProblemCaseList = async (summaryResults) => {
|
|
288
|
+
const casesResults = [];
|
|
289
|
+
const failsList = [];
|
|
290
|
+
const flakyList = [];
|
|
291
|
+
const skipsList = [];
|
|
292
|
+
const failedNamesTitle = [];
|
|
293
|
+
const flakyNamesTitle = [];
|
|
294
|
+
const skippedNamesTitle = [];
|
|
295
|
+
let previousTestName = undefined;
|
|
296
|
+
let previousSuiteName = undefined;
|
|
297
|
+
|
|
239
298
|
// Create a list for names of failed test cases
|
|
240
299
|
for (let i = 0; i < summaryResults.failures.length; i += 1) {
|
|
241
300
|
const { test, suiteName } = summaryResults.failures[i];
|
|
@@ -279,24 +338,6 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
279
338
|
previousSuiteName = undefined;
|
|
280
339
|
|
|
281
340
|
// 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
341
|
if (summaryResults.failed === 1) {
|
|
301
342
|
failedNamesTitle[0] = '\n*Failed Test Case:*\n';
|
|
302
343
|
}
|
|
@@ -318,16 +359,7 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
318
359
|
|
|
319
360
|
// Push data into array to create the "List of Problematic Test Suites"
|
|
320
361
|
if (summaryResults.tests.length !== summaryResults.passed){
|
|
321
|
-
|
|
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
|
-
},
|
|
362
|
+
casesResults.push(
|
|
331
363
|
{
|
|
332
364
|
type: 'section',
|
|
333
365
|
text: {
|
|
@@ -350,7 +382,7 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
350
382
|
},
|
|
351
383
|
)}
|
|
352
384
|
return [
|
|
353
|
-
...
|
|
385
|
+
...casesResults,
|
|
354
386
|
];
|
|
355
387
|
};
|
|
356
388
|
|
|
@@ -475,5 +507,6 @@ const generateFailuresReasons = async (summaryResults) => {
|
|
|
475
507
|
};
|
|
476
508
|
exports.generateFailures = generateFailures;
|
|
477
509
|
exports.generateFailuresReasons = generateFailuresReasons;
|
|
510
|
+
exports.generateProblemSuiteList = generateProblemSuiteList;
|
|
478
511
|
exports.generateProblemCaseList = generateProblemCaseList;
|
|
479
|
-
exports.generateAllRunSuites = generateAllRunSuites;
|
|
512
|
+
exports.generateAllRunSuites = generateAllRunSuites;
|
package/dist/src/SlackClient.js
CHANGED
|
@@ -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);
|
|
@@ -131,6 +131,16 @@ 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.attachDetailsToThreadSuites({
|
|
137
|
+
channelIds: [result[i].channel],
|
|
138
|
+
ts: result[i].ts,
|
|
139
|
+
summaryResults: resultSummary,
|
|
140
|
+
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
for (let i = 0; i < result.length; i += 1) {
|
|
135
145
|
// eslint-disable-next-line no-await-in-loop
|
|
136
146
|
await slackClient.attachDetailsToThreadCases({
|
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.
|
|
33
|
+
"version": "1.3.6",
|
|
34
34
|
"main": "index.js",
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|