playwright-slack-report-burak 1.4.0 β 1.5.0
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 +0 -108
- package/dist/src/SlackClient.d.ts +1 -9
- package/dist/src/SlackClient.js +13 -28
- package/dist/src/SlackReporter.js +11 -18
- package/package.json +1 -1
|
@@ -8,114 +8,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.generateAllRunSuites =
|
|
9
9
|
void 0;
|
|
10
10
|
|
|
11
|
-
/*
|
|
12
|
-
const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
13
|
-
const meta = [];
|
|
14
|
-
const header = {
|
|
15
|
-
type: 'section',
|
|
16
|
-
text: {
|
|
17
|
-
type: 'mrkdwn',
|
|
18
|
-
text: 'π *Playwright Results*',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
const summary = {
|
|
22
|
-
type: 'section',
|
|
23
|
-
text: {
|
|
24
|
-
type: 'mrkdwn',
|
|
25
|
-
text: `β
*${summaryResults.passed}* | β *${summaryResults.failed}* |${summaryResults.flaky !== undefined
|
|
26
|
-
? ` π‘ *${summaryResults.flaky}* | `
|
|
27
|
-
: ' '}β© *${summaryResults.skipped}*`,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
const fails = await generateFailures(summaryResults, maxNumberOfFailures);
|
|
31
|
-
if (summaryResults.meta) {
|
|
32
|
-
for (let i = 0; i < summaryResults.meta.length; i += 1) {
|
|
33
|
-
const { key, value } = summaryResults.meta[i];
|
|
34
|
-
meta.push({
|
|
35
|
-
type: 'section',
|
|
36
|
-
text: {
|
|
37
|
-
type: 'mrkdwn',
|
|
38
|
-
text: `\n*${key}* :\t${value}`,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return [header, summary, ...meta, ...fails];
|
|
44
|
-
};
|
|
45
|
-
exports.generateBlocks = generateBlocks;
|
|
46
|
-
|
|
47
|
-
// Became obsolete with the introdΔ±ction of generateProblemCaseList()
|
|
48
|
-
const generateFailures = async (summaryResults) => {
|
|
49
|
-
const thread = [];
|
|
50
|
-
const failedNamesTitle = [];
|
|
51
|
-
const skippedNamesTitle = [];
|
|
52
|
-
const failsList = [];
|
|
53
|
-
const skipsList = [];
|
|
54
|
-
let previousTestName = undefined;
|
|
55
|
-
let previousSuiteName = undefined;
|
|
56
|
-
|
|
57
|
-
// Create a list for names of failed test cases
|
|
58
|
-
for (const result of summaryResults.tests) {
|
|
59
|
-
if (result.status === 'failed' || result.status === 'timedOut') {
|
|
60
|
-
const testName = result.name;
|
|
61
|
-
const suiteName = result.suiteName;
|
|
62
|
-
const parts = result.suiteName.split('/')[result.suiteName.split('/').length-1].replace('.spec.ts', '');
|
|
63
|
-
const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
|
|
64
|
-
if (testName !== previousTestName || (testName === previousSuiteName && suiteName !== previousSuiteName) ) {
|
|
65
|
-
failsList.push(testName + ' (' + backSlashedParts + ')');
|
|
66
|
-
previousTestName = testName;
|
|
67
|
-
previousSuiteName = suiteName;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
previousTestName = undefined;
|
|
72
|
-
previousSuiteName = undefined;
|
|
73
|
-
|
|
74
|
-
// Create a list for names of skipped test cases
|
|
75
|
-
for (const result of summaryResults.tests) {
|
|
76
|
-
if (result.status === 'skipped') {
|
|
77
|
-
const testName = result.name;
|
|
78
|
-
const suiteName = result.suiteName;
|
|
79
|
-
const parts = result.suiteName.split('/')[result.suiteName.split('/').length-1].replace('.spec.ts', '');
|
|
80
|
-
const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
|
|
81
|
-
if (testName !== previousTestName || (testName === previousSuiteName && suiteName !== previousSuiteName) ) {
|
|
82
|
-
skipsList.push(testName + ' (' + backSlashedParts + ')');
|
|
83
|
-
previousTestName = testName;
|
|
84
|
-
previousSuiteName = suiteName;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
previousTestName = undefined;
|
|
89
|
-
previousSuiteName = undefined;
|
|
90
|
-
|
|
91
|
-
// Decide on Titles For Listing Failures & Skips
|
|
92
|
-
if (summaryResults.failed === 1) {
|
|
93
|
-
failedNamesTitle[0] = '\n*Failed Test Case:*\n';
|
|
94
|
-
}
|
|
95
|
-
if (summaryResults.failed > 1) {
|
|
96
|
-
failedNamesTitle[0] = '\n*Failed Test Cases:*\n';
|
|
97
|
-
}
|
|
98
|
-
if (summaryResults.skipped === 1) {
|
|
99
|
-
skippedNamesTitle[0] = '\n*Skipped Test Case:*\n';
|
|
100
|
-
}
|
|
101
|
-
if (summaryResults.skipped > 1) {
|
|
102
|
-
skippedNamesTitle[0] = '\n*Skipped Test Cases:*\n';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
thread.push({
|
|
106
|
-
type: 'section',
|
|
107
|
-
text: {
|
|
108
|
-
type: 'mrkdwn',
|
|
109
|
-
text: `${failedNamesTitle}${failsList.map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` + // List of Failed Test Cases
|
|
110
|
-
`\n${skippedNamesTitle}${skipsList.map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `, // List of Skipped Test Cases
|
|
111
|
-
},
|
|
112
|
-
})
|
|
113
|
-
return [
|
|
114
|
-
...thread,
|
|
115
|
-
];
|
|
116
|
-
};
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
11
|
const generateAllRunSuites = async (summaryResults) => {
|
|
120
12
|
const suitesResults = [];
|
|
121
13
|
const allSuites = [];
|
|
@@ -25,15 +25,7 @@ export default class SlackClient {
|
|
|
25
25
|
outcome: string;
|
|
26
26
|
ts: string;
|
|
27
27
|
}>>;
|
|
28
|
-
|
|
29
|
-
channelIds: Array<string>;
|
|
30
|
-
ts: string;
|
|
31
|
-
summaryResults: SummaryResults;
|
|
32
|
-
maxNumberOfFailures: number;
|
|
33
|
-
disableUnfurl?: boolean;
|
|
34
|
-
fakeRequest?: Function;
|
|
35
|
-
}): Promise<any[]>;
|
|
36
|
-
attachDetailsToThreadReasons({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }: {
|
|
28
|
+
attachDetailsToThreadReasons({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }: {
|
|
37
29
|
channelIds: Array<string>;
|
|
38
30
|
ts: string;
|
|
39
31
|
summaryResults: SummaryResults;
|
package/dist/src/SlackClient.js
CHANGED
|
@@ -45,7 +45,7 @@ class SlackClient {
|
|
|
45
45
|
ts: chatResponse.ts,
|
|
46
46
|
});
|
|
47
47
|
// eslint-disable-next-line no-console
|
|
48
|
-
console.log(`β
|
|
48
|
+
console.log(`β
Test results posted to Slack channel ${channel}`);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
result.push({
|
|
@@ -63,30 +63,6 @@ class SlackClient {
|
|
|
63
63
|
}
|
|
64
64
|
return result;
|
|
65
65
|
}
|
|
66
|
-
async attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
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
66
|
async attachDetailsToThreadRuns({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
91
67
|
const result = [];
|
|
92
68
|
const blocks = await (0, LayoutGenerator_1.generateAllRunSuites)(summaryResults, maxNumberOfFailures);
|
|
@@ -99,6 +75,15 @@ class SlackClient {
|
|
|
99
75
|
else {
|
|
100
76
|
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
101
77
|
}
|
|
78
|
+
if (chatResponse.ok) {
|
|
79
|
+
// eslint-disable-next-line no-console
|
|
80
|
+
console.log(`β
List of run suites sent within a thread.`);
|
|
81
|
+
result.push({
|
|
82
|
+
channel,
|
|
83
|
+
outcome: `β
Message sent to ${channel} within thread ${ts}`,
|
|
84
|
+
ts: chatResponse.ts,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
102
87
|
}
|
|
103
88
|
return result;
|
|
104
89
|
}
|
|
@@ -116,7 +101,7 @@ class SlackClient {
|
|
|
116
101
|
}
|
|
117
102
|
if (chatResponse.ok) {
|
|
118
103
|
// eslint-disable-next-line no-console
|
|
119
|
-
console.log(`β
|
|
104
|
+
console.log(`β
List of problematical suites sent within a thread.`);
|
|
120
105
|
result.push({
|
|
121
106
|
channel,
|
|
122
107
|
outcome: `β
Message sent to ${channel} within thread ${ts}`,
|
|
@@ -140,7 +125,7 @@ class SlackClient {
|
|
|
140
125
|
}
|
|
141
126
|
if (chatResponse.ok) {
|
|
142
127
|
// eslint-disable-next-line no-console
|
|
143
|
-
console.log(`β
|
|
128
|
+
console.log(`β
List of problematical cases sent within a thread.`);
|
|
144
129
|
result.push({
|
|
145
130
|
channel,
|
|
146
131
|
outcome: `β
Message sent to ${channel} within thread ${ts}`,
|
|
@@ -164,7 +149,7 @@ class SlackClient {
|
|
|
164
149
|
}
|
|
165
150
|
if (chatResponse.ok) {
|
|
166
151
|
// eslint-disable-next-line no-console
|
|
167
|
-
console.log(`β
|
|
152
|
+
console.log(`β
List of failure reasons sent within a thread.`);
|
|
168
153
|
result.push({
|
|
169
154
|
channel,
|
|
170
155
|
outcome: `β
Message sent to ${channel} within thread ${ts}`,
|
|
@@ -110,17 +110,8 @@ class SlackReporter {
|
|
|
110
110
|
},
|
|
111
111
|
});
|
|
112
112
|
// eslint-disable-next-line no-console
|
|
113
|
-
console.log(JSON.stringify(result, null, 2));
|
|
113
|
+
//console.log(JSON.stringify(result, null, 2));
|
|
114
114
|
if (this.showInThread) {
|
|
115
|
-
/*for (let i = 0; i < result.length; i += 1) {
|
|
116
|
-
// eslint-disable-next-line no-await-in-loop
|
|
117
|
-
await slackClient.attachDetailsToThread({
|
|
118
|
-
channelIds: [result[i].channel],
|
|
119
|
-
ts: result[i].ts,
|
|
120
|
-
summaryResults: resultSummary,
|
|
121
|
-
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
122
|
-
});
|
|
123
|
-
}*/
|
|
124
115
|
for (let i = 0; i < result.length; i += 1) {
|
|
125
116
|
// eslint-disable-next-line no-await-in-loop
|
|
126
117
|
await slackClient.attachDetailsToThreadRuns({
|
|
@@ -152,14 +143,16 @@ class SlackReporter {
|
|
|
152
143
|
});
|
|
153
144
|
}
|
|
154
145
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
if ((resultSummary.failures.length > 0)) {
|
|
147
|
+
for (let i = 0; i < result.length; i += 1) {
|
|
148
|
+
// eslint-disable-next-line no-await-in-loop
|
|
149
|
+
await slackClient.attachDetailsToThreadReasons({
|
|
150
|
+
channelIds: [result[i].channel],
|
|
151
|
+
ts: result[i].ts,
|
|
152
|
+
summaryResults: resultSummary,
|
|
153
|
+
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
158
|
}
|
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.
|
|
33
|
+
"version": "1.5.0",
|
|
34
34
|
"main": "index.js",
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|