playwright-slack-report-burak 1.3.3 → 1.3.5

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,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 Run:*\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 failedSuites = [];
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 failedSuitesTitle = [];
174
+ const allSuitesTitle = [];
119
175
  const flakySuitesTitle = [];
120
176
  const skippedSuitesTitle = [];
121
177
  const failedNamesTitle = [];
@@ -135,7 +191,7 @@ const generateProblemCaseList = async (summaryResults) => {
135
191
  ? `${feature.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')} (${category})`
136
192
  : backSlashedParts;
137
193
  if (formattedSuiteName !== previousSuiteName) {
138
- failedSuites.push(formattedSuiteName);
194
+ allSuites.push(formattedSuiteName);
139
195
  previousSuiteName = formattedSuiteName;
140
196
  }
141
197
  }
@@ -223,11 +279,11 @@ const generateProblemCaseList = async (summaryResults) => {
223
279
  previousSuiteName = undefined;
224
280
 
225
281
  // Decide on Titles For Listing Failures, Skips & Flakies
226
- if (failedSuites.length === 1) {
227
- failedSuitesTitle[0] = '*Failed Suite:*\n';
282
+ if (allSuites.length === 1) {
283
+ allSuitesTitle[0] = '*Failed Suite:*\n';
228
284
  }
229
- if (failedSuites.length > 1) {
230
- failedSuitesTitle[0] = '*Failed Suites:*\n';
285
+ if (allSuites.length > 1) {
286
+ allSuitesTitle[0] = '*Failed Suites:*\n';
231
287
  }
232
288
  if (flakySuites.length === 1) {
233
289
  flakySuitesTitle[0] = '\n*Flaky Suite:*\n';
@@ -267,7 +323,7 @@ const generateProblemCaseList = async (summaryResults) => {
267
323
  text: {
268
324
  type: 'mrkdwn',
269
325
  text:
270
- `${failedSuitesTitle}${[...new Set(failedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
326
+ `${allSuitesTitle}${[...new Set(allSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
271
327
  `\n${flakySuitesTitle}${[...new Set(flakySuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
272
328
  `\n${skippedSuitesTitle}${[...new Set(skippedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `,
273
329
  },
@@ -420,3 +476,4 @@ const generateFailuresReasons = async (summaryResults) => {
420
476
  exports.generateFailures = generateFailures;
421
477
  exports.generateFailuresReasons = generateFailuresReasons;
422
478
  exports.generateProblemCaseList = generateProblemCaseList;
479
+ exports.generateAllRunSuites = generateAllRunSuites;
@@ -64,86 +64,102 @@ class SlackClient {
64
64
  return result;
65
65
  }
66
66
  async attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
67
- const result = [];
68
- const blocks = await (0, LayoutGenerator_1.generateFailures)(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
- }
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
- return result;
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
- const result = [];
92
- const blocks = await (0, LayoutGenerator_1.generateProblemCaseList)(summaryResults, maxNumberOfFailures);
93
- for (const channel of channelIds) {
94
- // under test
95
- let chatResponse;
96
- if (fakeRequest) {
97
- chatResponse = await fakeRequest();
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
- return result;
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
- const result = [];
116
- const blocks = await (0, LayoutGenerator_1.generateFailuresReasons)(summaryResults, maxNumberOfFailures);
117
- for (const channel of channelIds) {
118
- // under test
119
- let chatResponse;
120
- if (fakeRequest) {
121
- chatResponse = await fakeRequest();
122
- }
123
- else {
124
- chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
125
- }
126
- if (chatResponse.ok) {
127
- // eslint-disable-next-line no-console
128
- console.log(`✅ Message sent to ${channel} within thread ${ts}`);
129
- result.push({
130
- channel,
131
- outcome: `✅ Message sent to ${channel} within thread ${ts}`,
132
- ts: chatResponse.ts,
133
- });
134
- }
135
- }
136
- return result;
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
- const chatResponse = await slackWebClient.chat.postMessage({
140
- channel,
141
- text: ' ',
142
- unfurl_link: unfurl,
143
- blocks,
144
- thread_ts: threadTimestamp,
145
- });
146
- return chatResponse;
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.3",
33
+ "version": "1.3.5",
34
34
  "main": "index.js",
35
35
  "types": "dist/index.d.ts",
36
36
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",