@allurereport/plugin-classic 3.0.0-beta.9 → 3.0.1
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/categories.d.ts +3 -3
- package/dist/converters.d.ts +4 -4
- package/dist/converters.js +2 -0
- package/dist/generators.d.ts +12 -12
- package/dist/generators.js +40 -23
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/model.d.ts +7 -6
- package/dist/plugin.d.ts +6 -5
- package/dist/plugin.js +49 -22
- package/dist/writer.d.ts +9 -9
- package/dist/writer.js +9 -5
- package/package.json +9 -9
- package/dist/charts.d.ts +0 -14
- package/dist/charts.js +0 -26
package/dist/categories.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TestStatus } from "@allurereport/core-api";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const matchCategories: (categories:
|
|
2
|
+
import type { ClassicCategory } from "./model.js";
|
|
3
|
+
export declare const matchCategories: (categories: ClassicCategory[], result: {
|
|
4
4
|
message?: string;
|
|
5
5
|
trace?: string;
|
|
6
6
|
status: TestStatus;
|
|
7
7
|
flaky: boolean;
|
|
8
|
-
}) =>
|
|
8
|
+
}) => ClassicCategory[];
|
package/dist/converters.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TestFixtureResult, TestResult, TestStepResult } from "@allurereport/core-api";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const convertTestResult: (tr: TestResult) =>
|
|
4
|
-
export declare const convertTestStepResult: (tsr: TestStepResult) =>
|
|
5
|
-
export declare const convertFixtureResult: (fr: TestFixtureResult) =>
|
|
2
|
+
import type { ClassicFixtureResult, ClassicTestResult, ClassicTestStepResult } from "@allurereport/web-classic";
|
|
3
|
+
export declare const convertTestResult: (tr: TestResult) => ClassicTestResult;
|
|
4
|
+
export declare const convertTestStepResult: (tsr: TestStepResult) => ClassicTestStepResult;
|
|
5
|
+
export declare const convertFixtureResult: (fr: TestFixtureResult) => ClassicFixtureResult;
|
package/dist/converters.js
CHANGED
|
@@ -27,12 +27,14 @@ export const convertTestResult = (tr) => {
|
|
|
27
27
|
links: tr.links,
|
|
28
28
|
steps: tr.steps,
|
|
29
29
|
error: tr.error,
|
|
30
|
+
testCase: tr.testCase,
|
|
30
31
|
setup: [],
|
|
31
32
|
teardown: [],
|
|
32
33
|
history: [],
|
|
33
34
|
retries: [],
|
|
34
35
|
breadcrumbs: [],
|
|
35
36
|
retry: false,
|
|
37
|
+
transition: tr.transition,
|
|
36
38
|
};
|
|
37
39
|
};
|
|
38
40
|
export const convertTestStepResult = (tsr) => {
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { type AttachmentLink, type EnvironmentItem, type Statistic } from "@allurereport/core-api";
|
|
2
2
|
import { type AllureStore, type ReportFiles, type ResultFile } from "@allurereport/plugin-api";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import type { ClassicTestResult } from "@allurereport/web-classic";
|
|
4
|
+
import type { ClassicOptions, TemplateManifest } from "./model.js";
|
|
5
|
+
import type { ClassicDataWriter, ReportFile } from "./writer.js";
|
|
6
6
|
export declare const readTemplateManifest: (singleFileMode?: boolean) => Promise<TemplateManifest>;
|
|
7
|
-
export declare const generateTestResults: (writer:
|
|
8
|
-
export declare const generateTree: (writer:
|
|
9
|
-
export declare const generateEnvironmentJson: (writer:
|
|
10
|
-
export declare const generateStatistic: (writer:
|
|
11
|
-
export declare const generatePieChart: (writer:
|
|
12
|
-
export declare const generateAttachmentsFiles: (writer:
|
|
13
|
-
export declare const generateHistoryDataPoints: (writer:
|
|
14
|
-
export declare const generateStaticFiles: (payload:
|
|
7
|
+
export declare const generateTestResults: (writer: ClassicDataWriter, store: AllureStore) => Promise<ClassicTestResult[]>;
|
|
8
|
+
export declare const generateTree: (writer: ClassicDataWriter, treeName: string, labels: string[], tests: ClassicTestResult[]) => Promise<void>;
|
|
9
|
+
export declare const generateEnvironmentJson: (writer: ClassicDataWriter, env: EnvironmentItem[]) => Promise<void>;
|
|
10
|
+
export declare const generateStatistic: (writer: ClassicDataWriter, statistic: Statistic) => Promise<void>;
|
|
11
|
+
export declare const generatePieChart: (writer: ClassicDataWriter, statistic: Statistic) => Promise<void>;
|
|
12
|
+
export declare const generateAttachmentsFiles: (writer: ClassicDataWriter, attachmentLinks: AttachmentLink[], contentFunction: (id: string) => Promise<ResultFile | undefined>) => Promise<Map<string, string> | undefined>;
|
|
13
|
+
export declare const generateHistoryDataPoints: (writer: ClassicDataWriter, store: AllureStore) => Promise<Map<string, string>>;
|
|
14
|
+
export declare const generateStaticFiles: (payload: ClassicOptions & {
|
|
15
15
|
allureVersion: string;
|
|
16
16
|
reportFiles: ReportFiles;
|
|
17
17
|
reportDataFiles: ReportFile[];
|
|
18
18
|
reportUuid: string;
|
|
19
19
|
reportName: string;
|
|
20
20
|
}) => Promise<void>;
|
|
21
|
-
export declare const generateTreeByCategories: (writer:
|
|
21
|
+
export declare const generateTreeByCategories: (writer: ClassicDataWriter, treeName: string, tests: ClassicTestResult[]) => Promise<void>;
|
package/dist/generators.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { compareBy, incrementStatistic, nullsLast, ordinal, } from "@allurereport/core-api";
|
|
1
|
+
import { compareBy, createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, incrementStatistic, nullsLast, ordinal, } from "@allurereport/core-api";
|
|
2
2
|
import { createTreeByCategories, createTreeByLabels, filterTree, sortTree, transformTree, } from "@allurereport/plugin-api";
|
|
3
|
-
import {
|
|
3
|
+
import { getPieChartValues } from "@allurereport/web-commons";
|
|
4
4
|
import Handlebars from "handlebars";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { basename, join } from "node:path";
|
|
8
8
|
import { matchCategories } from "./categories.js";
|
|
9
|
-
import { getChartData } from "./charts.js";
|
|
10
9
|
import { convertFixtureResult, convertTestResult } from "./converters.js";
|
|
11
10
|
const require = createRequire(import.meta.url);
|
|
12
11
|
const template = `<!DOCTYPE html>
|
|
@@ -89,7 +88,7 @@ export const generateTestResults = async (writer, store) => {
|
|
|
89
88
|
flaky,
|
|
90
89
|
});
|
|
91
90
|
convertedTr.categories = matchedCategories;
|
|
92
|
-
convertedTr.history = await store.historyByTrId(tr.id);
|
|
91
|
+
convertedTr.history = (await store.historyByTrId(tr.id)) ?? [];
|
|
93
92
|
convertedTr.retries = await store.retriesByTrId(tr.id);
|
|
94
93
|
convertedTr.retry = convertedTr.retries.length > 0;
|
|
95
94
|
convertedTr.setup = convertedTrFixtures.filter((f) => f.type === "before");
|
|
@@ -113,14 +112,17 @@ export const generateTestResults = async (writer, store) => {
|
|
|
113
112
|
};
|
|
114
113
|
export const generateTree = async (writer, treeName, labels, tests) => {
|
|
115
114
|
const visibleTests = tests.filter((test) => !test.hidden);
|
|
116
|
-
const tree = createTreeByLabels(visibleTests, labels, ({ id, name, status, duration, flaky, start, retries }) => {
|
|
115
|
+
const tree = createTreeByLabels(visibleTests, labels, ({ id, name, status, duration, flaky, transition, start, retries }) => {
|
|
116
|
+
const retriesCount = retries?.length ?? 0;
|
|
117
117
|
return {
|
|
118
118
|
nodeId: id,
|
|
119
|
-
retry:
|
|
119
|
+
retry: Boolean(retriesCount),
|
|
120
|
+
retriesCount,
|
|
120
121
|
name,
|
|
121
122
|
status,
|
|
122
123
|
duration,
|
|
123
124
|
flaky,
|
|
125
|
+
transition,
|
|
124
126
|
start,
|
|
125
127
|
};
|
|
126
128
|
}, undefined, (group, leaf) => {
|
|
@@ -138,7 +140,7 @@ export const generateStatistic = async (writer, statistic) => {
|
|
|
138
140
|
await writer.writeWidget("allure_statistic.json", statistic);
|
|
139
141
|
};
|
|
140
142
|
export const generatePieChart = async (writer, statistic) => {
|
|
141
|
-
const chartData =
|
|
143
|
+
const chartData = getPieChartValues(statistic);
|
|
142
144
|
await writer.writeWidget("allure_pie_chart.json", chartData);
|
|
143
145
|
};
|
|
144
146
|
export const generateAttachmentsFiles = async (writer, attachmentLinks, contentFunction) => {
|
|
@@ -167,7 +169,7 @@ export const generateHistoryDataPoints = async (writer, store) => {
|
|
|
167
169
|
return result;
|
|
168
170
|
};
|
|
169
171
|
export const generateStaticFiles = async (payload) => {
|
|
170
|
-
const { reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "
|
|
172
|
+
const { reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "auto", groupBy, reportFiles, reportDataFiles, reportUuid, allureVersion, } = payload;
|
|
171
173
|
const compile = Handlebars.compile(template);
|
|
172
174
|
const manifest = await readTemplateManifest(payload.singleFile);
|
|
173
175
|
const headTags = [];
|
|
@@ -198,38 +200,53 @@ export const generateStaticFiles = async (payload) => {
|
|
|
198
200
|
const mainJsContentBuffer = await readFile(mainJsSource);
|
|
199
201
|
bodyTags.push(createScriptTag(`data:text/javascript;base64,${mainJsContentBuffer.toString("base64")}`));
|
|
200
202
|
}
|
|
203
|
+
const now = Date.now();
|
|
201
204
|
const reportOptions = {
|
|
202
205
|
reportName,
|
|
203
206
|
logo,
|
|
204
207
|
theme,
|
|
205
208
|
reportLanguage,
|
|
206
|
-
createdAt:
|
|
209
|
+
createdAt: now,
|
|
207
210
|
reportUuid,
|
|
208
211
|
groupBy: groupBy?.length ? groupBy : ["parentSuite", "suite", "subSuite"],
|
|
209
|
-
};
|
|
210
|
-
const html = compile({
|
|
211
|
-
headTags: headTags.join("\n"),
|
|
212
|
-
bodyTags: bodyTags.join("\n"),
|
|
213
|
-
reportFilesScript: createReportDataScript(reportDataFiles),
|
|
214
|
-
reportOptions: JSON.stringify(reportOptions),
|
|
215
|
-
analyticsEnable: true,
|
|
216
212
|
allureVersion,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
213
|
+
cacheKey: now.toString(),
|
|
214
|
+
};
|
|
215
|
+
try {
|
|
216
|
+
const html = compile({
|
|
217
|
+
headTags: headTags.join("\n"),
|
|
218
|
+
bodyTags: bodyTags.join("\n"),
|
|
219
|
+
reportFilesScript: createReportDataScript(reportDataFiles),
|
|
220
|
+
reportOptions: JSON.stringify(reportOptions),
|
|
221
|
+
analyticsEnable: true,
|
|
222
|
+
allureVersion,
|
|
223
|
+
reportUuid,
|
|
224
|
+
reportName,
|
|
225
|
+
singleFile: payload.singleFile,
|
|
226
|
+
});
|
|
227
|
+
await reportFiles.addFile("index.html", Buffer.from(html, "utf8"));
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
if (err instanceof RangeError) {
|
|
231
|
+
console.error("The report is too large to be generated in the single file mode!");
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
throw err;
|
|
235
|
+
}
|
|
222
236
|
};
|
|
223
237
|
export const generateTreeByCategories = async (writer, treeName, tests) => {
|
|
224
238
|
const visibleTests = tests.filter((test) => !test.hidden);
|
|
225
|
-
const tree = createTreeByCategories(visibleTests, ({ id, name, status, duration, flaky, start, retries }) => {
|
|
239
|
+
const tree = createTreeByCategories(visibleTests, ({ id, name, status, duration, flaky, transition, start, retries }) => {
|
|
240
|
+
const retriesCount = retries?.length ?? 0;
|
|
226
241
|
return {
|
|
227
242
|
nodeId: id,
|
|
228
|
-
retry:
|
|
243
|
+
retry: Boolean(retriesCount),
|
|
244
|
+
retriesCount,
|
|
229
245
|
name,
|
|
230
246
|
status,
|
|
231
247
|
duration,
|
|
232
248
|
flaky,
|
|
249
|
+
transition,
|
|
233
250
|
start,
|
|
234
251
|
};
|
|
235
252
|
}, undefined, (group, leaf) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
1
|
+
export type { ClassicPluginOptions } from "./model.js";
|
|
2
|
+
export { ClassicPlugin as default } from "./plugin.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export default AllureAwesomePlugin;
|
|
1
|
+
export { ClassicPlugin as default } from "./plugin.js";
|
package/dist/model.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type { TestStatus } from "@allurereport/core-api";
|
|
2
|
-
export type
|
|
1
|
+
import type { TestResult, TestStatus } from "@allurereport/core-api";
|
|
2
|
+
export type ClassicOptions = {
|
|
3
3
|
reportName?: string;
|
|
4
4
|
singleFile?: boolean;
|
|
5
5
|
logo?: string;
|
|
6
|
-
theme?: "light" | "dark";
|
|
7
|
-
reportLanguage?: "en"
|
|
6
|
+
theme?: "light" | "dark" | "auto";
|
|
7
|
+
reportLanguage?: "en";
|
|
8
8
|
groupBy?: string[];
|
|
9
9
|
ci?: {
|
|
10
10
|
type: "github" | "jenkins";
|
|
11
11
|
url: string;
|
|
12
12
|
name: string;
|
|
13
13
|
};
|
|
14
|
+
filter?: (tr: TestResult) => boolean;
|
|
14
15
|
};
|
|
15
16
|
export type TemplateManifest = Record<string, string>;
|
|
16
|
-
export type
|
|
17
|
-
export interface
|
|
17
|
+
export type ClassicPluginOptions = ClassicOptions;
|
|
18
|
+
export interface ClassicCategory {
|
|
18
19
|
name: string;
|
|
19
20
|
description?: string;
|
|
20
21
|
descriptionHtml?: string;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
export declare class
|
|
1
|
+
import { type AllureStore, type Plugin, type PluginContext, type PluginSummary } from "@allurereport/plugin-api";
|
|
2
|
+
import type { ClassicPluginOptions } from "./model.js";
|
|
3
|
+
export declare class ClassicPlugin implements Plugin {
|
|
4
4
|
#private;
|
|
5
|
-
readonly options:
|
|
6
|
-
constructor(options?:
|
|
5
|
+
readonly options: ClassicPluginOptions;
|
|
6
|
+
constructor(options?: ClassicPluginOptions);
|
|
7
7
|
start: (context: PluginContext) => Promise<void>;
|
|
8
8
|
update: (context: PluginContext, store: AllureStore) => Promise<void>;
|
|
9
9
|
done: (context: PluginContext, store: AllureStore) => Promise<void>;
|
|
10
|
+
info(context: PluginContext, store: AllureStore): Promise<PluginSummary>;
|
|
10
11
|
}
|
package/dist/plugin.js
CHANGED
|
@@ -9,37 +9,39 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var _ClassicPlugin_writer, _ClassicPlugin_generate;
|
|
13
|
+
import { getWorstStatus } from "@allurereport/core-api";
|
|
14
|
+
import { convertToSummaryTestResult, } from "@allurereport/plugin-api";
|
|
13
15
|
import { preciseTreeLabels } from "@allurereport/plugin-api";
|
|
14
16
|
import { generateAttachmentsFiles, generateEnvironmentJson, generateHistoryDataPoints, generatePieChart, generateStaticFiles, generateStatistic, generateTestResults, generateTree, generateTreeByCategories, } from "./generators.js";
|
|
15
17
|
import { InMemoryReportDataWriter, ReportFileDataWriter } from "./writer.js";
|
|
16
|
-
export class
|
|
18
|
+
export class ClassicPlugin {
|
|
17
19
|
constructor(options = {}) {
|
|
18
20
|
this.options = options;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
_ClassicPlugin_writer.set(this, void 0);
|
|
22
|
+
_ClassicPlugin_generate.set(this, async (context, store) => {
|
|
21
23
|
const { singleFile, groupBy = [] } = this.options ?? {};
|
|
22
24
|
const environmentItems = await store.metadataByKey("allure_environment");
|
|
23
25
|
const statistic = await store.testsStatistic();
|
|
24
26
|
const attachments = await store.allAttachments();
|
|
25
|
-
await generateStatistic(__classPrivateFieldGet(this,
|
|
26
|
-
await generatePieChart(__classPrivateFieldGet(this,
|
|
27
|
-
const convertedTrs = await generateTestResults(__classPrivateFieldGet(this,
|
|
27
|
+
await generateStatistic(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), statistic);
|
|
28
|
+
await generatePieChart(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), statistic);
|
|
29
|
+
const convertedTrs = await generateTestResults(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), store);
|
|
28
30
|
const treeLabels = preciseTreeLabels(!groupBy.length ? ["parentSuite", "suite", "subSuite"] : groupBy, convertedTrs, ({ labels }) => labels.map(({ name }) => name));
|
|
29
31
|
const behaviorLabels = preciseTreeLabels(!groupBy.length ? ["epic", "feature", "story"] : groupBy, convertedTrs, ({ labels }) => labels.map(({ name }) => name));
|
|
30
32
|
const packagesLabels = preciseTreeLabels(!groupBy.length ? ["package"] : groupBy, convertedTrs, ({ labels }) => labels.map(({ name }) => name));
|
|
31
|
-
await generateTreeByCategories(__classPrivateFieldGet(this,
|
|
32
|
-
await generateTree(__classPrivateFieldGet(this,
|
|
33
|
-
await generateTree(__classPrivateFieldGet(this,
|
|
34
|
-
await generateTree(__classPrivateFieldGet(this,
|
|
35
|
-
await generateHistoryDataPoints(__classPrivateFieldGet(this,
|
|
33
|
+
await generateTreeByCategories(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), "categories", convertedTrs);
|
|
34
|
+
await generateTree(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), "tree", treeLabels, convertedTrs);
|
|
35
|
+
await generateTree(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), "behaviors", behaviorLabels, convertedTrs);
|
|
36
|
+
await generateTree(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), "packages", packagesLabels, convertedTrs);
|
|
37
|
+
await generateHistoryDataPoints(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), store);
|
|
36
38
|
if (environmentItems?.length) {
|
|
37
|
-
await generateEnvironmentJson(__classPrivateFieldGet(this,
|
|
39
|
+
await generateEnvironmentJson(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), environmentItems);
|
|
38
40
|
}
|
|
39
41
|
if (attachments?.length) {
|
|
40
|
-
await generateAttachmentsFiles(__classPrivateFieldGet(this,
|
|
42
|
+
await generateAttachmentsFiles(__classPrivateFieldGet(this, _ClassicPlugin_writer, "f"), attachments, (id) => store.attachmentContentById(id));
|
|
41
43
|
}
|
|
42
|
-
const reportDataFiles = singleFile ? __classPrivateFieldGet(this,
|
|
44
|
+
const reportDataFiles = singleFile ? __classPrivateFieldGet(this, _ClassicPlugin_writer, "f").reportFiles() : [];
|
|
43
45
|
await generateStaticFiles({
|
|
44
46
|
...this.options,
|
|
45
47
|
allureVersion: context.allureVersion,
|
|
@@ -52,24 +54,49 @@ export class AllureAwesomePlugin {
|
|
|
52
54
|
this.start = async (context) => {
|
|
53
55
|
const { singleFile } = this.options;
|
|
54
56
|
if (singleFile) {
|
|
55
|
-
__classPrivateFieldSet(this,
|
|
57
|
+
__classPrivateFieldSet(this, _ClassicPlugin_writer, new InMemoryReportDataWriter(), "f");
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
|
-
__classPrivateFieldSet(this,
|
|
60
|
+
__classPrivateFieldSet(this, _ClassicPlugin_writer, new ReportFileDataWriter(context.reportFiles), "f");
|
|
59
61
|
await Promise.resolve();
|
|
60
62
|
};
|
|
61
63
|
this.update = async (context, store) => {
|
|
62
|
-
if (!__classPrivateFieldGet(this,
|
|
64
|
+
if (!__classPrivateFieldGet(this, _ClassicPlugin_writer, "f")) {
|
|
63
65
|
throw new Error("call start first");
|
|
64
66
|
}
|
|
65
|
-
await __classPrivateFieldGet(this,
|
|
67
|
+
await __classPrivateFieldGet(this, _ClassicPlugin_generate, "f").call(this, context, store);
|
|
66
68
|
};
|
|
67
69
|
this.done = async (context, store) => {
|
|
68
|
-
if (!__classPrivateFieldGet(this,
|
|
70
|
+
if (!__classPrivateFieldGet(this, _ClassicPlugin_writer, "f")) {
|
|
69
71
|
throw new Error("call start first");
|
|
70
72
|
}
|
|
71
|
-
await __classPrivateFieldGet(this,
|
|
73
|
+
await __classPrivateFieldGet(this, _ClassicPlugin_generate, "f").call(this, context, store);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async info(context, store) {
|
|
77
|
+
const allTrs = (await store.allTestResults()).filter(this.options.filter ? this.options.filter : () => true);
|
|
78
|
+
const newTrs = await store.allNewTestResults();
|
|
79
|
+
const retryTrs = allTrs.filter((tr) => !!tr?.retries?.length);
|
|
80
|
+
const flakyTrs = allTrs.filter((tr) => !!tr?.flaky);
|
|
81
|
+
const duration = allTrs.reduce((acc, { duration: trDuration = 0 }) => acc + trDuration, 0);
|
|
82
|
+
const worstStatus = getWorstStatus(allTrs.map(({ status }) => status));
|
|
83
|
+
const createdAt = allTrs.reduce((acc, { stop }) => Math.max(acc, stop || 0), 0);
|
|
84
|
+
return {
|
|
85
|
+
name: this.options.reportName || context.reportName,
|
|
86
|
+
stats: await store.testsStatistic(this.options.filter),
|
|
87
|
+
status: worstStatus ?? "passed",
|
|
88
|
+
createdAt,
|
|
89
|
+
duration,
|
|
90
|
+
plugin: "Classic",
|
|
91
|
+
newTests: newTrs.map(convertToSummaryTestResult),
|
|
92
|
+
flakyTests: flakyTrs.map(convertToSummaryTestResult),
|
|
93
|
+
retryTests: retryTrs.map(convertToSummaryTestResult),
|
|
94
|
+
meta: {
|
|
95
|
+
reportId: context.reportUuid,
|
|
96
|
+
singleFile: this.options.singleFile ?? false,
|
|
97
|
+
withTestResultsLinks: true,
|
|
98
|
+
},
|
|
72
99
|
};
|
|
73
100
|
}
|
|
74
101
|
}
|
|
75
|
-
|
|
102
|
+
_ClassicPlugin_writer = new WeakMap(), _ClassicPlugin_generate = new WeakMap();
|
package/dist/writer.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import type { ReportFiles, ResultFile } from "@allurereport/plugin-api";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AwesomeTestResult } from "@allurereport/web-awesome";
|
|
3
3
|
export interface ReportFile {
|
|
4
4
|
name: string;
|
|
5
5
|
value: string;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface ClassicDataWriter {
|
|
8
8
|
writeData(fileName: string, data: any): Promise<void>;
|
|
9
9
|
writeWidget(fileName: string, data: any): Promise<void>;
|
|
10
|
-
writeTestCase(test:
|
|
10
|
+
writeTestCase(test: AwesomeTestResult): Promise<void>;
|
|
11
11
|
writeAttachment(source: string, file: ResultFile): Promise<void>;
|
|
12
12
|
}
|
|
13
|
-
export declare class FileSystemReportDataWriter implements
|
|
13
|
+
export declare class FileSystemReportDataWriter implements ClassicDataWriter {
|
|
14
14
|
private readonly output;
|
|
15
15
|
constructor(output: string);
|
|
16
16
|
writeData(fileName: string, data: any): Promise<void>;
|
|
17
17
|
writeWidget(fileName: string, data: any): Promise<void>;
|
|
18
|
-
writeTestCase(test:
|
|
18
|
+
writeTestCase(test: AwesomeTestResult): Promise<void>;
|
|
19
19
|
writeAttachment(source: string, file: ResultFile): Promise<void>;
|
|
20
20
|
}
|
|
21
|
-
export declare class InMemoryReportDataWriter implements
|
|
21
|
+
export declare class InMemoryReportDataWriter implements ClassicDataWriter {
|
|
22
22
|
#private;
|
|
23
23
|
writeData(fileName: string, data: any): Promise<void>;
|
|
24
24
|
writeWidget(fileName: string, data: any): Promise<void>;
|
|
25
|
-
writeTestCase(test:
|
|
25
|
+
writeTestCase(test: AwesomeTestResult): Promise<void>;
|
|
26
26
|
writeAttachment(fileName: string, file: ResultFile): Promise<void>;
|
|
27
27
|
reportFiles(): ReportFile[];
|
|
28
28
|
}
|
|
29
|
-
export declare class ReportFileDataWriter implements
|
|
29
|
+
export declare class ReportFileDataWriter implements ClassicDataWriter {
|
|
30
30
|
readonly reportFiles: ReportFiles;
|
|
31
31
|
constructor(reportFiles: ReportFiles);
|
|
32
32
|
writeData(fileName: string, data: any): Promise<void>;
|
|
33
33
|
writeWidget(fileName: string, data: any): Promise<void>;
|
|
34
34
|
writeAttachment(source: string, file: ResultFile): Promise<void>;
|
|
35
|
-
writeTestCase(test:
|
|
35
|
+
writeTestCase(test: AwesomeTestResult): Promise<void>;
|
|
36
36
|
}
|
package/dist/writer.js
CHANGED
|
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _InMemoryReportDataWriter_data;
|
|
7
7
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
8
8
|
import { join, resolve } from "node:path";
|
|
9
|
+
import { join as joinPosix } from "node:path/posix";
|
|
9
10
|
export class FileSystemReportDataWriter {
|
|
10
11
|
constructor(output) {
|
|
11
12
|
this.output = output;
|
|
@@ -55,7 +56,10 @@ export class InMemoryReportDataWriter {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
reportFiles() {
|
|
58
|
-
return Object.keys(__classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")).map((key) => ({
|
|
59
|
+
return Object.keys(__classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")).map((key) => ({
|
|
60
|
+
name: key,
|
|
61
|
+
value: __classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")[key].toString("base64"),
|
|
62
|
+
}));
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
_InMemoryReportDataWriter_data = new WeakMap();
|
|
@@ -64,19 +68,19 @@ export class ReportFileDataWriter {
|
|
|
64
68
|
this.reportFiles = reportFiles;
|
|
65
69
|
}
|
|
66
70
|
async writeData(fileName, data) {
|
|
67
|
-
await this.reportFiles.addFile(
|
|
71
|
+
await this.reportFiles.addFile(joinPosix("data", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
|
|
68
72
|
}
|
|
69
73
|
async writeWidget(fileName, data) {
|
|
70
|
-
await this.reportFiles.addFile(
|
|
74
|
+
await this.reportFiles.addFile(joinPosix("widgets", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
|
|
71
75
|
}
|
|
72
76
|
async writeAttachment(source, file) {
|
|
73
77
|
const contentBuffer = await file.asBuffer();
|
|
74
78
|
if (!contentBuffer) {
|
|
75
79
|
return;
|
|
76
80
|
}
|
|
77
|
-
await this.reportFiles.addFile(
|
|
81
|
+
await this.reportFiles.addFile(joinPosix("data", "attachments", source), contentBuffer);
|
|
78
82
|
}
|
|
79
83
|
async writeTestCase(test) {
|
|
80
|
-
await this.reportFiles.addFile(
|
|
84
|
+
await this.reportFiles.addFile(joinPosix("data", "test-results", `${test.id}.json`), Buffer.from(JSON.stringify(test), "utf8"));
|
|
81
85
|
}
|
|
82
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-classic",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "The classic version of Allure HTML report",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"test": "rimraf ./out && vitest run"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@allurereport/core-api": "3.0.
|
|
34
|
-
"@allurereport/plugin-api": "3.0.
|
|
35
|
-
"@allurereport/web-awesome": "3.0.
|
|
36
|
-
"@allurereport/web-classic": "3.0.
|
|
37
|
-
"@allurereport/web-commons": "3.0.
|
|
33
|
+
"@allurereport/core-api": "3.0.1",
|
|
34
|
+
"@allurereport/plugin-api": "3.0.1",
|
|
35
|
+
"@allurereport/web-awesome": "3.0.1",
|
|
36
|
+
"@allurereport/web-classic": "3.0.1",
|
|
37
|
+
"@allurereport/web-commons": "3.0.1",
|
|
38
38
|
"d3-shape": "^3.2.0",
|
|
39
39
|
"handlebars": "^4.7.8"
|
|
40
40
|
},
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@types/node": "^20.17.9",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
47
47
|
"@typescript-eslint/parser": "^8.0.0",
|
|
48
|
-
"@vitest/runner": "^2.1.
|
|
49
|
-
"allure-vitest": "^3.
|
|
48
|
+
"@vitest/runner": "^2.1.9",
|
|
49
|
+
"allure-vitest": "^3.3.3",
|
|
50
50
|
"eslint": "^8.57.0",
|
|
51
51
|
"eslint-config-prettier": "^9.1.0",
|
|
52
52
|
"eslint-plugin-import": "^2.29.1",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
57
57
|
"rimraf": "^6.0.1",
|
|
58
58
|
"typescript": "^5.6.3",
|
|
59
|
-
"vitest": "^2.1.
|
|
59
|
+
"vitest": "^2.1.9"
|
|
60
60
|
}
|
|
61
61
|
}
|
package/dist/charts.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Statistic, TestStatus } from "@allurereport/core-api";
|
|
2
|
-
import type { PieArcDatum } from "d3-shape";
|
|
3
|
-
export type TestResultSlice = {
|
|
4
|
-
status: TestStatus;
|
|
5
|
-
count: number;
|
|
6
|
-
};
|
|
7
|
-
export type TestResultChartData = {
|
|
8
|
-
percentage: number;
|
|
9
|
-
slices: TestResultSlice[];
|
|
10
|
-
};
|
|
11
|
-
export declare const d3Arc: import("d3-shape").Arc<any, PieArcDatum<TestResultSlice>>;
|
|
12
|
-
export declare const d3Pie: import("d3-shape").Pie<any, TestResultSlice>;
|
|
13
|
-
export declare const getPercentage: (value: number, total: number) => number;
|
|
14
|
-
export declare const getChartData: (stats: Statistic) => TestResultChartData;
|
package/dist/charts.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { statusesList } from "@allurereport/core-api";
|
|
2
|
-
import { arc, pie } from "d3-shape";
|
|
3
|
-
export const d3Arc = arc().innerRadius(40).outerRadius(50).cornerRadius(2).padAngle(0.03);
|
|
4
|
-
export const d3Pie = pie()
|
|
5
|
-
.value((d) => d.count)
|
|
6
|
-
.padAngle(0.03)
|
|
7
|
-
.sortValues((a, b) => a - b);
|
|
8
|
-
export const getPercentage = (value, total) => Math.floor((value / total) * 10000) / 100;
|
|
9
|
-
export const getChartData = (stats) => {
|
|
10
|
-
const convertedStatuses = statusesList
|
|
11
|
-
.filter((status) => !!stats?.[status])
|
|
12
|
-
.map((status) => ({
|
|
13
|
-
status,
|
|
14
|
-
count: stats[status],
|
|
15
|
-
}));
|
|
16
|
-
const arcsData = d3Pie(convertedStatuses);
|
|
17
|
-
const slices = arcsData.map((arcData) => ({
|
|
18
|
-
d: d3Arc(arcData),
|
|
19
|
-
...arcData.data,
|
|
20
|
-
}));
|
|
21
|
-
const percentage = getPercentage(stats.passed ?? 0, stats.total);
|
|
22
|
-
return {
|
|
23
|
-
slices,
|
|
24
|
-
percentage,
|
|
25
|
-
};
|
|
26
|
-
};
|