@allurereport/plugin-awesome 3.0.0-beta.16 → 3.0.0-beta.17
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/README.md +9 -8
- package/dist/converters.js +1 -0
- package/dist/generators.js +70 -29
- package/dist/model.d.ts +2 -6
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +11 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -47,11 +47,12 @@ export default defineConfig({
|
|
|
47
47
|
|
|
48
48
|
The plugin accepts the following options:
|
|
49
49
|
|
|
50
|
-
| Option | Description | Type
|
|
51
|
-
|
|
52
|
-
| `reportName` | Name of the report | `string`
|
|
53
|
-
| `singleFile` | Writes the report as a single `index.html` file | `boolean`
|
|
54
|
-
| `logo` | Path to the logo image | `string`
|
|
55
|
-
| `theme` | Default color theme of the report | `light \| dark`
|
|
56
|
-
| `reportLanguage` | Default language of the report | `string`
|
|
57
|
-
| `ci` | CI data which will be rendered in the report | `{ type: "github" \| "jenkins", url: string, name: string }` | `undefined`
|
|
50
|
+
| Option | Description | Type | Default |
|
|
51
|
+
|------------------|-------------------------------------------------|---------|-------------------------|
|
|
52
|
+
| `reportName` | Name of the report | `string` | `Allure Report` |
|
|
53
|
+
| `singleFile` | Writes the report as a single `index.html` file | `boolean` | `false` |
|
|
54
|
+
| `logo` | Path to the logo image | `string` | `null` |
|
|
55
|
+
| `theme` | Default color theme of the report | `light \| dark` | OS theme |
|
|
56
|
+
| `reportLanguage` | Default language of the report | `string` | OS language |
|
|
57
|
+
| `ci` | CI data which will be rendered in the report | `{ type: "github" \| "jenkins", url: string, name: string }` | `undefined` |
|
|
58
|
+
| `groupBy` | By default, tests are grouped using the `titlePath` provided by the test framework. | `string`| Grouping by `titlepath` |
|
package/dist/converters.js
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { compareBy, incrementStatistic, nullsLast, ordinal, } from "@allurereport/core-api";
|
|
2
|
-
import { filterTree, } from "@allurereport/plugin-api";
|
|
3
|
-
import { createTreeByLabels, sortTree, transformTree } from "@allurereport/plugin-api";
|
|
2
|
+
import { createTreeByLabels, createTreeByTitlePath, filterTree, preciseTreeLabels, sortTree, transformTree, } from "@allurereport/plugin-api";
|
|
4
3
|
import { createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, getPieChartData, } from "@allurereport/web-commons";
|
|
5
4
|
import Handlebars from "handlebars";
|
|
6
5
|
import { readFile } from "node:fs/promises";
|
|
@@ -119,24 +118,55 @@ export const generateNav = async (writer, trs, filename = "nav.json") => {
|
|
|
119
118
|
};
|
|
120
119
|
export const generateTree = async (writer, treeFilename, labels, tests) => {
|
|
121
120
|
const visibleTests = tests.filter((test) => !test.hidden);
|
|
122
|
-
const tree =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
retriesCount,
|
|
126
|
-
name,
|
|
127
|
-
status,
|
|
128
|
-
start,
|
|
129
|
-
duration,
|
|
130
|
-
flaky,
|
|
131
|
-
transition,
|
|
132
|
-
}), undefined, (group, leaf) => {
|
|
133
|
-
incrementStatistic(group.statistic, leaf.status);
|
|
134
|
-
});
|
|
121
|
+
const tree = labels.length
|
|
122
|
+
? buildTreeByLabels(visibleTests, labels)
|
|
123
|
+
: buildTreeByTitlePath(visibleTests);
|
|
135
124
|
filterTree(tree, (leaf) => !leaf.hidden);
|
|
136
125
|
sortTree(tree, nullsLast(compareBy("start", ordinal())));
|
|
137
126
|
transformTree(tree, (leaf, idx) => ({ ...leaf, groupOrder: idx + 1 }));
|
|
138
127
|
await writer.writeWidget(treeFilename, tree);
|
|
139
128
|
};
|
|
129
|
+
const buildTreeByLabels = (tests, labels) => {
|
|
130
|
+
return createTreeByLabels(tests, labels, leafFactory, undefined, (group, leaf) => incrementStatistic(group.statistic, leaf.status));
|
|
131
|
+
};
|
|
132
|
+
const buildTreeByTitlePath = (tests) => {
|
|
133
|
+
const testsWithTitlePath = [];
|
|
134
|
+
const testsWithoutTitlePath = [];
|
|
135
|
+
for (const test of tests) {
|
|
136
|
+
if (Array.isArray(test.titlePath) && test.titlePath.length > 0) {
|
|
137
|
+
testsWithTitlePath.push(test);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
testsWithoutTitlePath.push(test);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const treeByTitlePath = createTreeByTitlePath(testsWithTitlePath, leafFactory, undefined, (group, leaf) => incrementStatistic(group.statistic, leaf.status));
|
|
144
|
+
const defaultLabels = preciseTreeLabels(["parentSuite", "suite", "subSuite"], testsWithoutTitlePath, ({ labels }) => labels.map(({ name }) => name));
|
|
145
|
+
const treeByDefaultLabels = createTreeByLabels(testsWithoutTitlePath, defaultLabels, leafFactory, undefined, (group, leaf) => incrementStatistic(group.statistic, leaf.status));
|
|
146
|
+
const mergedLeavesById = { ...treeByTitlePath.leavesById, ...treeByDefaultLabels.leavesById };
|
|
147
|
+
const mergedGroupsById = { ...treeByTitlePath.groupsById, ...treeByDefaultLabels.groupsById };
|
|
148
|
+
const mergedRootLeaves = Array.from(new Set([...(treeByTitlePath.root.leaves ?? []), ...(treeByDefaultLabels.root.leaves ?? [])]));
|
|
149
|
+
const mergedRootGroups = Array.from(new Set([...(treeByTitlePath.root.groups ?? []), ...(treeByDefaultLabels.root.groups ?? [])]));
|
|
150
|
+
return {
|
|
151
|
+
root: {
|
|
152
|
+
leaves: mergedRootLeaves,
|
|
153
|
+
groups: mergedRootGroups,
|
|
154
|
+
},
|
|
155
|
+
leavesById: mergedLeavesById,
|
|
156
|
+
groupsById: mergedGroupsById,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const leafFactory = ({ id, name, status, duration, flaky, start, transition, retry, retriesCount, }) => ({
|
|
160
|
+
nodeId: id,
|
|
161
|
+
name,
|
|
162
|
+
status,
|
|
163
|
+
duration,
|
|
164
|
+
flaky,
|
|
165
|
+
start,
|
|
166
|
+
retry,
|
|
167
|
+
retriesCount,
|
|
168
|
+
transition,
|
|
169
|
+
});
|
|
140
170
|
export const generateEnvironmentJson = async (writer, env) => {
|
|
141
171
|
await writer.writeWidget("allure_environment.json", env);
|
|
142
172
|
};
|
|
@@ -197,7 +227,7 @@ export const generateHistoryDataPoints = async (writer, store) => {
|
|
|
197
227
|
return result;
|
|
198
228
|
};
|
|
199
229
|
export const generateStaticFiles = async (payload) => {
|
|
200
|
-
const { id, reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "light", groupBy, reportFiles, reportDataFiles, reportUuid, allureVersion, layout = "base", charts = [], defaultSection = "", } = payload;
|
|
230
|
+
const { id, reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "light", groupBy, reportFiles, reportDataFiles, reportUuid, allureVersion, layout = "base", charts = [], defaultSection = "", ci, } = payload;
|
|
201
231
|
const compile = Handlebars.compile(template);
|
|
202
232
|
const manifest = await readTemplateManifest(payload.singleFile);
|
|
203
233
|
const headTags = [];
|
|
@@ -241,23 +271,34 @@ export const generateStaticFiles = async (payload) => {
|
|
|
241
271
|
reportLanguage,
|
|
242
272
|
createdAt: now,
|
|
243
273
|
reportUuid,
|
|
244
|
-
groupBy: groupBy?.length ? groupBy : [
|
|
274
|
+
groupBy: groupBy?.length ? groupBy : [],
|
|
245
275
|
cacheKey: now.toString(),
|
|
276
|
+
ci,
|
|
246
277
|
layout,
|
|
247
278
|
allureVersion,
|
|
248
279
|
sections,
|
|
249
280
|
defaultSection,
|
|
250
281
|
};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
282
|
+
try {
|
|
283
|
+
const html = compile({
|
|
284
|
+
headTags: headTags.join("\n"),
|
|
285
|
+
bodyTags: bodyTags.join("\n"),
|
|
286
|
+
reportFilesScript: createReportDataScript(reportDataFiles),
|
|
287
|
+
reportOptions: JSON.stringify(reportOptions),
|
|
288
|
+
analyticsEnable: true,
|
|
289
|
+
allureVersion,
|
|
290
|
+
reportUuid,
|
|
291
|
+
reportName,
|
|
292
|
+
singleFile: payload.singleFile,
|
|
293
|
+
});
|
|
294
|
+
await reportFiles.addFile("index.html", Buffer.from(html, "utf8"));
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
if (err instanceof RangeError) {
|
|
298
|
+
console.error("The report is too large to be generated in the single file mode!");
|
|
299
|
+
process.exit(1);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
throw err;
|
|
303
|
+
}
|
|
263
304
|
};
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EnvironmentsConfig, TestResult } from "@allurereport/core-api";
|
|
1
|
+
import type { CiDescriptor, EnvironmentsConfig, TestResult } from "@allurereport/core-api";
|
|
2
2
|
import type { ChartOptions } from "./charts.js";
|
|
3
3
|
export type AwesomeOptions = {
|
|
4
4
|
reportName?: string;
|
|
@@ -9,11 +9,7 @@ export type AwesomeOptions = {
|
|
|
9
9
|
groupBy?: string[];
|
|
10
10
|
layout?: "base" | "split";
|
|
11
11
|
environments?: Record<string, EnvironmentsConfig>;
|
|
12
|
-
ci?:
|
|
13
|
-
type: "github" | "jenkins";
|
|
14
|
-
url: string;
|
|
15
|
-
name: string;
|
|
16
|
-
};
|
|
12
|
+
ci?: CiDescriptor;
|
|
17
13
|
filter?: (testResult: TestResult) => boolean;
|
|
18
14
|
charts?: ChartOptions[];
|
|
19
15
|
sections?: string[];
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AllureStore, type Plugin, type PluginContext, type PluginSummary } from "@allurereport/plugin-api";
|
|
2
2
|
import type { AwesomePluginOptions } from "./model.js";
|
|
3
3
|
export declare class AwesomePlugin implements Plugin {
|
|
4
4
|
#private;
|
package/dist/plugin.js
CHANGED
|
@@ -11,6 +11,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _AwesomePlugin_writer, _AwesomePlugin_generate;
|
|
13
13
|
import { getWorstStatus } from "@allurereport/core-api";
|
|
14
|
+
import { convertToSummaryTestResult, } from "@allurereport/plugin-api";
|
|
14
15
|
import { preciseTreeLabels } from "@allurereport/plugin-api";
|
|
15
16
|
import { join } from "node:path";
|
|
16
17
|
import { generateAllCharts } from "./charts.js";
|
|
@@ -29,7 +30,10 @@ export class AwesomePlugin {
|
|
|
29
30
|
await generatePieChart(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options.filter);
|
|
30
31
|
await generateAllCharts(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options, context);
|
|
31
32
|
const convertedTrs = await generateTestResults(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options.filter);
|
|
32
|
-
const
|
|
33
|
+
const hasGroupBy = groupBy.length > 0;
|
|
34
|
+
const treeLabels = hasGroupBy
|
|
35
|
+
? preciseTreeLabels(groupBy, convertedTrs, ({ labels }) => labels.map(({ name }) => name))
|
|
36
|
+
: [];
|
|
33
37
|
await generateHistoryDataPoints(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store);
|
|
34
38
|
await generateTestCases(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), convertedTrs);
|
|
35
39
|
await generateTree(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), "tree.json", treeLabels, convertedTrs);
|
|
@@ -85,6 +89,9 @@ export class AwesomePlugin {
|
|
|
85
89
|
}
|
|
86
90
|
async info(context, store) {
|
|
87
91
|
const allTrs = (await store.allTestResults()).filter((tr) => this.options.filter ? this.options.filter(tr) : true);
|
|
92
|
+
const newTrs = await store.allNewTestResults();
|
|
93
|
+
const retryTrs = allTrs.filter((tr) => !!tr?.retries?.length);
|
|
94
|
+
const flakyTrs = allTrs.filter((tr) => !!tr?.flaky);
|
|
88
95
|
const duration = allTrs.reduce((acc, { duration: trDuration = 0 }) => acc + trDuration, 0);
|
|
89
96
|
const worstStatus = getWorstStatus(allTrs.map(({ status }) => status));
|
|
90
97
|
const createdAt = allTrs.reduce((acc, { stop }) => Math.max(acc, stop || 0), 0);
|
|
@@ -95,6 +102,9 @@ export class AwesomePlugin {
|
|
|
95
102
|
duration,
|
|
96
103
|
createdAt,
|
|
97
104
|
plugin: "Awesome",
|
|
105
|
+
newTests: newTrs.map(convertToSummaryTestResult),
|
|
106
|
+
flakyTests: flakyTrs.map(convertToSummaryTestResult),
|
|
107
|
+
retryTests: retryTrs.map(convertToSummaryTestResult),
|
|
98
108
|
};
|
|
99
109
|
}
|
|
100
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-awesome",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.17",
|
|
4
4
|
"description": "Allure Awesome Plugin – brand new HTML report with modern design and new features",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"test": "rimraf ./out && vitest run"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
34
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
35
|
-
"@allurereport/web-awesome": "3.0.0-beta.
|
|
36
|
-
"@allurereport/web-commons": "3.0.0-beta.
|
|
33
|
+
"@allurereport/core-api": "3.0.0-beta.17",
|
|
34
|
+
"@allurereport/plugin-api": "3.0.0-beta.17",
|
|
35
|
+
"@allurereport/web-awesome": "3.0.0-beta.17",
|
|
36
|
+
"@allurereport/web-commons": "3.0.0-beta.17",
|
|
37
37
|
"d3-shape": "^3.2.0",
|
|
38
38
|
"handlebars": "^4.7.8"
|
|
39
39
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
46
46
|
"@typescript-eslint/parser": "^8.0.0",
|
|
47
47
|
"@vitest/runner": "^2.1.9",
|
|
48
|
-
"allure-vitest": "^3.0
|
|
48
|
+
"allure-vitest": "^3.3.0",
|
|
49
49
|
"eslint": "^8.57.0",
|
|
50
50
|
"eslint-config-prettier": "^9.1.0",
|
|
51
51
|
"eslint-plugin-import": "^2.29.1",
|