@testomatio/reporter 1.2.1 → 1.2.2-beta-html-pagination-feature
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/lib/pipe/html.js +78 -35
- package/lib/template/testomatio.hbs +1175 -337
- package/package.json +1 -1
- package/lib/template/template-draft.hbs +0 -249
package/lib/pipe/html.js
CHANGED
|
@@ -91,7 +91,7 @@ class HtmlPipe {
|
|
|
91
91
|
// GENERATE HTML reports based on the results data
|
|
92
92
|
this.buildReport({
|
|
93
93
|
runParams,
|
|
94
|
-
// TODO: this.tests=[] in case of Mocha
|
|
94
|
+
// TODO: this.tests=[] in case of Mocha, need retest by Vitalii
|
|
95
95
|
tests: this.tests,
|
|
96
96
|
outputPath: this.htmlOutputPath,
|
|
97
97
|
templatePath: this.templateHtmlPath,
|
|
@@ -198,8 +198,10 @@ class HtmlPipe {
|
|
|
198
198
|
const template = handlebars.compile(templateSource);
|
|
199
199
|
|
|
200
200
|
return template(data);
|
|
201
|
-
}
|
|
202
|
-
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
console.log(chalk.red("❌ Oops! An unknown error occurred when generating an HTML report"));
|
|
204
|
+
console.log(chalk.red(e));
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
|
|
@@ -209,43 +211,84 @@ class HtmlPipe {
|
|
|
209
211
|
(tests, status) => tests.filter(test => test.status.toLowerCase() === status.toLowerCase()).length,
|
|
210
212
|
);
|
|
211
213
|
|
|
212
|
-
handlebars.registerHelper(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
214
|
+
handlebars.registerHelper(
|
|
215
|
+
'selectComponent',
|
|
216
|
+
() => new handlebars.SafeString(
|
|
217
|
+
`<select style="width: 70px;height: 38px;" class="form-select" aria-label="Tests counter on page">
|
|
218
|
+
<option value="0">10</option>
|
|
219
|
+
<option value="1">25</option>
|
|
220
|
+
<option value="2">50</option>
|
|
221
|
+
</select>`
|
|
222
|
+
)
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
handlebars.registerHelper(
|
|
226
|
+
'emptyDataComponent',
|
|
227
|
+
() => new handlebars.SafeString(
|
|
228
|
+
`<div class="noData m-0">
|
|
229
|
+
NO MATCHING TESTS
|
|
230
|
+
</div>`
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
handlebars.registerHelper(
|
|
235
|
+
'pageDispleyElements',
|
|
236
|
+
tests => {
|
|
237
|
+
// We wrapp the lines to the HTML format we need
|
|
238
|
+
const totalTests =
|
|
239
|
+
JSON.parse(
|
|
240
|
+
JSON.stringify(tests)
|
|
241
|
+
.replace(/<script>/g, '<script>')
|
|
242
|
+
.replace(/<\/script>/g, '<\/script>') // eslint-disable-line
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
const paginationOptions = {
|
|
246
|
+
'0': 10,
|
|
247
|
+
'1': 25,
|
|
248
|
+
'2': 50
|
|
249
|
+
};
|
|
250
|
+
const statuses = [
|
|
251
|
+
'all',
|
|
252
|
+
'passed',
|
|
253
|
+
'failed',
|
|
254
|
+
'skipped'
|
|
255
|
+
];
|
|
256
|
+
const pageItemGroups = {
|
|
257
|
+
'all': {},
|
|
258
|
+
'passed': {},
|
|
259
|
+
'failed': {},
|
|
260
|
+
'skipped': {},
|
|
261
|
+
'totalTests': totalTests
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
function paginateItems(items, pageSize) {
|
|
265
|
+
const paginatedItems = [];
|
|
266
|
+
for (let i = 0; i < items.length; i += pageSize) {
|
|
267
|
+
paginatedItems.push(items.slice(i, i + pageSize));
|
|
268
|
+
}
|
|
269
|
+
return paginatedItems;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
statuses.forEach(status => {
|
|
273
|
+
for (const option in paginationOptions) {
|
|
274
|
+
if (Object.hasOwnProperty.call(paginationOptions, option)) {
|
|
275
|
+
const pageSize = paginationOptions[option];
|
|
276
|
+
let filteredItems = totalTests;
|
|
277
|
+
|
|
278
|
+
if (status !== 'all') {
|
|
279
|
+
filteredItems = totalTests.filter(item => item.status === status);
|
|
230
280
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
typeof obj[key] === 'string'
|
|
234
|
-
? obj[key].replace(/<script>/g, '<$cript>').replace(/<\/script>/g, '</$cript>')
|
|
235
|
-
: obj[key];
|
|
236
|
-
} else {
|
|
237
|
-
newObj[key] = obj[key];
|
|
281
|
+
|
|
282
|
+
pageItemGroups[status][option] = paginateItems(filteredItems, pageSize);
|
|
238
283
|
}
|
|
239
|
-
}
|
|
240
284
|
}
|
|
241
|
-
|
|
242
|
-
return newObj;
|
|
243
285
|
});
|
|
244
|
-
|
|
286
|
+
|
|
287
|
+
pageItemGroups.totalTests = totalTests;
|
|
245
288
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
289
|
+
return JSON.stringify(pageItemGroups);
|
|
290
|
+
}
|
|
291
|
+
);
|
|
249
292
|
}
|
|
250
293
|
|
|
251
294
|
toString() {
|