playwright-slack-report-burak 1.3.2 → 1.3.4
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.d.ts +2 -1
- package/dist/src/LayoutGenerator.js +89 -20
- package/dist/src/SlackClient.js +88 -72
- package/dist/src/SlackReporter.js +10 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KnownBlock, Block } from '@slack/types';
|
|
2
2
|
import { SummaryResults } from '.';
|
|
3
3
|
declare const generateBlocks: (summaryResults: SummaryResults, maxNumberOfFailures: number) => Promise<Array<KnownBlock | Block>>;
|
|
4
|
+
declare const generateRuns: (summaryResults: SummaryResults, maxNumberOfFailures: number) => Promise<Array<KnownBlock | Block>>;
|
|
4
5
|
declare const generateFailures: (summaryResults: SummaryResults, maxNumberOfFailures: number) => Promise<Array<KnownBlock | Block>>;
|
|
5
6
|
declare const generateFailuresReasons: (summaryResults: SummaryResults, maxNumberOfFailures: number) => Promise<Array<KnownBlock | Block>>;
|
|
6
|
-
export { generateBlocks, generateFailures, generateFailuresReasons };
|
|
7
|
+
export { generateBlocks, generateRuns, generateFailures, generateFailuresReasons };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateFailures = exports.generateFailuresReasons = exports.generateProblemCaseList = exports.generateBlocks = void 0;
|
|
3
|
+
exports.generateFailures = exports.generateFailuresReasons = exports.generateProblemCaseList = exports.generateBlocks = exports.generateAllRunSuites = void 0;
|
|
4
4
|
const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
5
5
|
const meta = [];
|
|
6
6
|
const header = {
|
|
@@ -107,15 +107,71 @@ const generateFailures = async (summaryResults) => {
|
|
|
107
107
|
];
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
+
const generateAllRunSuites = async (summaryResults) => {
|
|
111
|
+
const suitesResults = [];
|
|
112
|
+
const allSuites = [];
|
|
113
|
+
const allSuitesTitle = [];
|
|
114
|
+
let previousSuiteName = undefined;
|
|
115
|
+
|
|
116
|
+
// Create a list for names of all run test suites
|
|
117
|
+
for (const result of summaryResults.tests) {
|
|
118
|
+
const suiteName = result.suiteName;
|
|
119
|
+
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
120
|
+
const parts = capitalizedSuiteName.split('/').slice(0, 2).join('/');
|
|
121
|
+
const backSlashedParts = parts.split('\\')[0];
|
|
122
|
+
const [category, feature] = backSlashedParts.split('/');
|
|
123
|
+
const formattedSuiteName = feature
|
|
124
|
+
? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
|
|
125
|
+
: backSlashedParts;
|
|
126
|
+
if (formattedSuiteName !== previousSuiteName) {
|
|
127
|
+
allSuites.push(formattedSuiteName);
|
|
128
|
+
previousSuiteName = formattedSuiteName;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Decide on Titles For Listing Failures, Skips & Flakies
|
|
133
|
+
if (allSuites.length === 1) {
|
|
134
|
+
allSuitesTitle[0] = '*Suite Run:*\n';
|
|
135
|
+
}
|
|
136
|
+
if (allSuites.length > 1) {
|
|
137
|
+
allSuitesTitle[0] = '*Suites Runs:*\n';
|
|
138
|
+
}
|
|
139
|
+
|
|
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
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: 'divider',
|
|
159
|
+
},
|
|
160
|
+
)}
|
|
161
|
+
return [
|
|
162
|
+
...suitesResults,
|
|
163
|
+
];
|
|
164
|
+
};
|
|
165
|
+
|
|
110
166
|
const generateProblemCaseList = async (summaryResults) => {
|
|
111
167
|
const suitesResults = [];
|
|
112
|
-
const
|
|
168
|
+
const allSuites = [];
|
|
113
169
|
const flakySuites = [];
|
|
114
170
|
const skippedSuites = [];
|
|
115
171
|
const failsList = [];
|
|
116
172
|
const flakyList = [];
|
|
117
173
|
const skipsList = [];
|
|
118
|
-
const
|
|
174
|
+
const allSuitesTitle = [];
|
|
119
175
|
const flakySuitesTitle = [];
|
|
120
176
|
const skippedSuitesTitle = [];
|
|
121
177
|
const failedNamesTitle = [];
|
|
@@ -128,11 +184,15 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
128
184
|
for (let i = 0; i < summaryResults.failures.length; i += 1) {
|
|
129
185
|
const { suiteName } = summaryResults.failures[i];
|
|
130
186
|
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
131
|
-
const parts = capitalizedSuiteName.split('/')
|
|
187
|
+
const parts = capitalizedSuiteName.split('/').slice(0, 2).join('/');
|
|
132
188
|
const backSlashedParts = parts.split('\\')[0];
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
189
|
+
const [category, feature] = backSlashedParts.split('/');
|
|
190
|
+
const formattedSuiteName = feature
|
|
191
|
+
? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
|
|
192
|
+
: backSlashedParts;
|
|
193
|
+
if (formattedSuiteName !== previousSuiteName) {
|
|
194
|
+
allSuites.push(formattedSuiteName);
|
|
195
|
+
previousSuiteName = formattedSuiteName;
|
|
136
196
|
}
|
|
137
197
|
}
|
|
138
198
|
previousSuiteName = undefined;
|
|
@@ -142,11 +202,15 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
142
202
|
if (result.retry > 0 && result.status === 'passed') {
|
|
143
203
|
const suiteName = result.suiteName;
|
|
144
204
|
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
145
|
-
const parts = capitalizedSuiteName.split('/')
|
|
205
|
+
const parts = capitalizedSuiteName.split('/').slice(0, 2).join('/');
|
|
146
206
|
const backSlashedParts = parts.split('\\')[0];
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
207
|
+
const [category, feature] = backSlashedParts.split('/');
|
|
208
|
+
const formattedSuiteName = feature
|
|
209
|
+
? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
|
|
210
|
+
: backSlashedParts;
|
|
211
|
+
if (formattedSuiteName !== previousSuiteName) {
|
|
212
|
+
flakySuites.push(formattedSuiteName);
|
|
213
|
+
previousSuiteName = formattedSuiteName;
|
|
150
214
|
}
|
|
151
215
|
}
|
|
152
216
|
}
|
|
@@ -158,11 +222,15 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
158
222
|
if (result.status === 'skipped') {
|
|
159
223
|
const suiteName = result.suiteName;
|
|
160
224
|
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
161
|
-
const parts = capitalizedSuiteName.split('/')
|
|
225
|
+
const parts = capitalizedSuiteName.split('/').slice(0, 2).join('/');
|
|
162
226
|
const backSlashedParts = parts.split('\\')[0];
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
227
|
+
const [category, feature] = backSlashedParts.split('/');
|
|
228
|
+
const formattedSuiteName = feature
|
|
229
|
+
? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
|
|
230
|
+
: backSlashedParts;
|
|
231
|
+
if (formattedSuiteName !== previousSuiteName) {
|
|
232
|
+
skippedSuites.push(formattedSuiteName);
|
|
233
|
+
previousSuiteName = formattedSuiteName;
|
|
166
234
|
}
|
|
167
235
|
}
|
|
168
236
|
}
|
|
@@ -211,11 +279,11 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
211
279
|
previousSuiteName = undefined;
|
|
212
280
|
|
|
213
281
|
// Decide on Titles For Listing Failures, Skips & Flakies
|
|
214
|
-
if (
|
|
215
|
-
|
|
282
|
+
if (allSuites.length === 1) {
|
|
283
|
+
allSuitesTitle[0] = '*Failed Suite:*\n';
|
|
216
284
|
}
|
|
217
|
-
if (
|
|
218
|
-
|
|
285
|
+
if (allSuites.length > 1) {
|
|
286
|
+
allSuitesTitle[0] = '*Failed Suites:*\n';
|
|
219
287
|
}
|
|
220
288
|
if (flakySuites.length === 1) {
|
|
221
289
|
flakySuitesTitle[0] = '\n*Flaky Suite:*\n';
|
|
@@ -255,7 +323,7 @@ const generateProblemCaseList = async (summaryResults) => {
|
|
|
255
323
|
text: {
|
|
256
324
|
type: 'mrkdwn',
|
|
257
325
|
text:
|
|
258
|
-
`${
|
|
326
|
+
`${allSuitesTitle}${[...new Set(allSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
|
|
259
327
|
`\n${flakySuitesTitle}${[...new Set(flakySuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
|
|
260
328
|
`\n${skippedSuitesTitle}${[...new Set(skippedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `,
|
|
261
329
|
},
|
|
@@ -408,3 +476,4 @@ const generateFailuresReasons = async (summaryResults) => {
|
|
|
408
476
|
exports.generateFailures = generateFailures;
|
|
409
477
|
exports.generateFailuresReasons = generateFailuresReasons;
|
|
410
478
|
exports.generateProblemCaseList = generateProblemCaseList;
|
|
479
|
+
exports.generateAllRunSuites = generateAllRunSuites;
|
package/dist/src/SlackClient.js
CHANGED
|
@@ -64,86 +64,102 @@ class SlackClient {
|
|
|
64
64
|
return result;
|
|
65
65
|
}
|
|
66
66
|
async attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
const result = [];
|
|
68
|
+
const blocks = await (0, LayoutGenerator_1.generateRuns)(summaryResults, maxNumberOfFailures);
|
|
69
|
+
for (const channel of channelIds) {
|
|
70
|
+
// under test
|
|
71
|
+
let chatResponse;
|
|
72
|
+
if (fakeRequest) {
|
|
73
|
+
chatResponse = await fakeRequest();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
77
|
+
}
|
|
78
|
+
if (chatResponse.ok) {
|
|
79
|
+
// eslint-disable-next-line no-console
|
|
80
|
+
console.log(`✅ Message sent to ${channel} within thread ${ts}`);
|
|
81
|
+
result.push({
|
|
82
|
+
channel,
|
|
83
|
+
outcome: `✅ Message sent to ${channel} within thread ${ts}`,
|
|
84
|
+
ts: chatResponse.ts,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
async attachDetailsToThreadRuns({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
91
|
+
const result = [];
|
|
92
|
+
const blocks = await (0, LayoutGenerator_1.generateAllRunSuites)(summaryResults, maxNumberOfFailures);
|
|
93
|
+
for (const channel of channelIds) {
|
|
94
|
+
// under test
|
|
95
|
+
let chatResponse;
|
|
96
|
+
if (fakeRequest) {
|
|
97
|
+
chatResponse = await fakeRequest();
|
|
87
98
|
}
|
|
88
|
-
|
|
99
|
+
else {
|
|
100
|
+
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
89
104
|
}
|
|
105
|
+
|
|
90
106
|
async attachDetailsToThreadCases({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
101
|
-
}
|
|
102
|
-
if (chatResponse.ok) {
|
|
103
|
-
// eslint-disable-next-line no-console
|
|
104
|
-
console.log(`✅ Message sent to ${channel} within thread ${ts}`);
|
|
105
|
-
result.push({
|
|
106
|
-
channel,
|
|
107
|
-
outcome: `✅ Message sent to ${channel} within thread ${ts}`,
|
|
108
|
-
ts: chatResponse.ts,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
107
|
+
const result = [];
|
|
108
|
+
const blocks = await (0, LayoutGenerator_1.generateProblemCaseList)(summaryResults, maxNumberOfFailures);
|
|
109
|
+
for (const channel of channelIds) {
|
|
110
|
+
// under test
|
|
111
|
+
let chatResponse;
|
|
112
|
+
if (fakeRequest) {
|
|
113
|
+
chatResponse = await fakeRequest();
|
|
111
114
|
}
|
|
112
|
-
|
|
115
|
+
else {
|
|
116
|
+
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
117
|
+
}
|
|
118
|
+
if (chatResponse.ok) {
|
|
119
|
+
// eslint-disable-next-line no-console
|
|
120
|
+
console.log(`✅ Message sent to ${channel} within thread ${ts}`);
|
|
121
|
+
result.push({
|
|
122
|
+
channel,
|
|
123
|
+
outcome: `✅ Message sent to ${channel} within thread ${ts}`,
|
|
124
|
+
ts: chatResponse.ts,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
113
129
|
}
|
|
114
130
|
async attachDetailsToThreadReasons({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
const result = [];
|
|
132
|
+
const blocks = await (0, LayoutGenerator_1.generateFailuresReasons)(summaryResults, maxNumberOfFailures);
|
|
133
|
+
for (const channel of channelIds) {
|
|
134
|
+
// under test
|
|
135
|
+
let chatResponse;
|
|
136
|
+
if (fakeRequest) {
|
|
137
|
+
chatResponse = await fakeRequest();
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
141
|
+
}
|
|
142
|
+
if (chatResponse.ok) {
|
|
143
|
+
// eslint-disable-next-line no-console
|
|
144
|
+
console.log(`✅ Message sent to ${channel} within thread ${ts}`);
|
|
145
|
+
result.push({
|
|
146
|
+
channel,
|
|
147
|
+
outcome: `✅ Message sent to ${channel} within thread ${ts}`,
|
|
148
|
+
ts: chatResponse.ts,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
137
153
|
}
|
|
138
154
|
static async doPostRequest(slackWebClient, channel, blocks, unfurl, threadTimestamp) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
const chatResponse = await slackWebClient.chat.postMessage({
|
|
156
|
+
channel,
|
|
157
|
+
text: ' ',
|
|
158
|
+
unfurl_link: unfurl,
|
|
159
|
+
blocks,
|
|
160
|
+
thread_ts: threadTimestamp,
|
|
161
|
+
});
|
|
162
|
+
return chatResponse;
|
|
147
163
|
}
|
|
148
164
|
}
|
|
149
165
|
exports.default = SlackClient;
|
|
@@ -121,6 +121,16 @@ class SlackReporter {
|
|
|
121
121
|
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
122
122
|
});
|
|
123
123
|
}*/
|
|
124
|
+
for (let i = 0; i < result.length; i += 1) {
|
|
125
|
+
// eslint-disable-next-line no-await-in-loop
|
|
126
|
+
await slackClient.attachDetailsToThreadRuns({
|
|
127
|
+
channelIds: [result[i].channel],
|
|
128
|
+
ts: result[i].ts,
|
|
129
|
+
summaryResults: resultSummary,
|
|
130
|
+
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
for (let i = 0; i < result.length; i += 1) {
|
|
125
135
|
// eslint-disable-next-line no-await-in-loop
|
|
126
136
|
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.4",
|
|
34
34
|
"main": "index.js",
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|