@allurereport/plugin-awesome 3.0.0-beta.17 → 3.0.0-beta.19

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/charts.d.ts CHANGED
@@ -1,108 +1,5 @@
1
- import type { HistoryDataPoint, SeverityLevel, Statistic, TestResult, TestStatus } from "@allurereport/core-api";
2
- import type { AllureStore, PluginContext } from "@allurereport/plugin-api";
3
- import { ChartDataType, ChartMode, ChartType } from "@allurereport/web-commons";
4
- import type { PieArcDatum } from "d3-shape";
1
+ import { type AllureStore, type GeneratedChartsData, type PluginContext } from "@allurereport/plugin-api";
5
2
  import type { AwesomeOptions } from "./model.js";
6
3
  import type { AwesomeDataWriter } from "./writer.js";
7
- export type BasePieSlice = Pick<PieSlice, "status" | "count">;
8
- export declare const d3Arc: import("d3-shape").Arc<any, PieArcDatum<BasePieSlice>>;
9
- export declare const d3Pie: import("d3-shape").Pie<any, BasePieSlice>;
10
- export declare const getPercentage: (value: number, total: number) => number;
11
- export type ChartId = string;
12
- export type ExecutionIdFn = (executionOrder: number) => string;
13
- export type ExecutionNameFn = (executionOrder: number) => string;
14
- export type TrendMetadataFnOverrides = {
15
- executionIdAccessor?: ExecutionIdFn;
16
- executionNameAccessor?: ExecutionNameFn;
17
- };
18
- export type TrendChartOptions = {
19
- type: ChartType.Trend;
20
- dataType: ChartDataType;
21
- mode?: ChartMode;
22
- title?: string;
23
- limit?: number;
24
- metadata?: TrendMetadataFnOverrides;
25
- };
26
- export type TrendPointId = string;
27
- export type TrendSliceId = string;
28
- export type BaseMetadata = Record<string, unknown>;
29
- export interface BaseTrendSliceMetadata extends Record<string, unknown> {
30
- executionId: string;
31
- executionName: string;
32
- }
33
- export type TrendSliceMetadata<Metadata extends BaseMetadata> = BaseTrendSliceMetadata & Metadata;
34
- export type TrendPoint = {
35
- x: string;
36
- y: number;
37
- };
38
- export type TrendSlice<Metadata extends BaseMetadata> = {
39
- min: number;
40
- max: number;
41
- metadata: TrendSliceMetadata<Metadata>;
42
- };
43
- export type GenericTrendChartData<Metadata extends BaseMetadata, SeriesType extends string> = {
44
- type: ChartType.Trend;
45
- dataType: ChartDataType;
46
- mode: ChartMode;
47
- title?: string;
48
- points: Record<TrendPointId, TrendPoint>;
49
- slices: Record<TrendSliceId, TrendSlice<Metadata>>;
50
- series: Record<SeriesType, TrendPointId[]>;
51
- min: number;
52
- max: number;
53
- };
54
- export interface StatusMetadata extends BaseTrendSliceMetadata {
55
- }
56
- export type StatusTrendSliceMetadata = TrendSliceMetadata<StatusMetadata>;
57
- export type StatusTrendSlice = TrendSlice<StatusTrendSliceMetadata>;
58
- export type StatusTrendChartData = GenericTrendChartData<StatusTrendSliceMetadata, TestStatus>;
59
- export interface SeverityMetadata extends BaseTrendSliceMetadata {
60
- }
61
- export type SeverityTrendSliceMetadata = TrendSliceMetadata<SeverityMetadata>;
62
- export type SeverityTrendSlice = TrendSlice<SeverityTrendSliceMetadata>;
63
- export type SeverityTrendChartData = GenericTrendChartData<SeverityTrendSliceMetadata, SeverityLevel>;
64
- export type TrendChartData = StatusTrendChartData | SeverityTrendChartData;
65
- export type PieChartOptions = {
66
- type: ChartType.Pie;
67
- title?: string;
68
- };
69
- export type PieSlice = {
70
- status: TestStatus;
71
- count: number;
72
- d: string | null;
73
- };
74
- export type PieChartData = {
75
- type: ChartType.Pie;
76
- title?: string;
77
- slices: PieSlice[];
78
- percentage: number;
79
- };
80
- export type GeneratedChartData = TrendChartData | PieChartData;
81
- export type GeneratedChartsData = Record<ChartId, GeneratedChartData>;
82
- export type ChartOptions = TrendChartOptions | PieChartOptions;
83
- export type DashboardOptions = {
84
- reportName?: string;
85
- singleFile?: boolean;
86
- logo?: string;
87
- theme?: "light" | "dark";
88
- reportLanguage?: "en" | "ru";
89
- layout?: ChartOptions[];
90
- filter?: (testResult: TestResult) => boolean;
91
- };
92
- export type TrendDataType = TestStatus | SeverityLevel;
93
- export type TrendCalculationResult<T extends TrendDataType> = {
94
- points: Record<TrendPointId, TrendPoint>;
95
- series: Record<T, TrendPointId[]>;
96
- };
97
- export declare const createEmptyStats: <T extends TrendDataType>(items: readonly T[]) => Record<T, number>;
98
- export declare const createEmptySeries: <T extends TrendDataType>(items: readonly T[]) => Record<T, string[]>;
99
- export declare const normalizeStatistic: <T extends TrendDataType>(statistic: Partial<Record<T, number>>, itemType: readonly T[]) => Record<T, number>;
100
- export declare const mergeTrendDataGeneric: <M extends BaseTrendSliceMetadata, T extends TrendDataType>(trendData: GenericTrendChartData<M, T>, trendDataPart: GenericTrendChartData<M, T>, itemType: readonly T[]) => GenericTrendChartData<M, T>;
101
- export declare const getTrendDataGeneric: <M extends BaseTrendSliceMetadata, T extends TrendDataType>(stats: Record<T, number>, reportName: string, executionOrder: number, itemType: readonly T[], chartOptions: TrendChartOptions) => GenericTrendChartData<M, T>;
102
4
  export declare const generateCharts: (options: AwesomeOptions, store: AllureStore, context: PluginContext) => Promise<GeneratedChartsData | undefined>;
103
- export declare const generateTrendChart: (options: TrendChartOptions, stores: {
104
- historyDataPoints: HistoryDataPoint[];
105
- statistic: Statistic;
106
- testResults: TestResult[];
107
- }, context: PluginContext) => TrendChartData | undefined;
108
5
  export declare const generateAllCharts: (writer: AwesomeDataWriter, store: AllureStore, options: AwesomeOptions, context: PluginContext) => Promise<void>;
package/dist/charts.js CHANGED
@@ -1,154 +1,47 @@
1
- import { ChartDataType, ChartMode, ChartType, DEFAULT_CHART_HISTORY_LIMIT, getPieChartDataDashboard, getSeverityTrendData, getStatusTrendData, } from "@allurereport/web-commons";
1
+ import { ChartType } from "@allurereport/core-api";
2
+ import { generateBarChart, generateComingSoonChart, generateHeatMapChart, generatePieChart, generateTreeMapChart, generateTrendChart, } from "@allurereport/plugin-api";
2
3
  import { randomUUID } from "crypto";
3
- import { arc, pie } from "d3-shape";
4
- export const d3Arc = arc().innerRadius(40).outerRadius(50).cornerRadius(2).padAngle(0.03);
5
- export const d3Pie = pie()
6
- .value((d) => d.count)
7
- .padAngle(0.03)
8
- .sortValues((a, b) => a - b);
9
- export const getPercentage = (value, total) => Math.floor((value / total) * 10000) / 100;
10
- export const createEmptyStats = (items) => items.reduce((acc, item) => ({ ...acc, [item]: 0 }), {});
11
- export const createEmptySeries = (items) => items.reduce((acc, item) => ({ ...acc, [item]: [] }), {});
12
- export const normalizeStatistic = (statistic, itemType) => {
13
- return itemType.reduce((acc, item) => {
14
- acc[item] = statistic[item] ?? 0;
15
- return acc;
16
- }, {});
17
- };
18
- const calculateRawValues = (stats, executionId, itemType) => {
19
- const points = {};
20
- const series = createEmptySeries(itemType);
21
- itemType.forEach((item) => {
22
- const pointId = `${executionId}-${item}`;
23
- const value = stats[item] ?? 0;
24
- points[pointId] = {
25
- x: executionId,
26
- y: value,
27
- };
28
- series[item].push(pointId);
29
- });
30
- return { points, series };
31
- };
32
- const calculatePercentValues = (stats, executionId, itemType) => {
33
- const points = {};
34
- const series = createEmptySeries(itemType);
35
- const values = Object.values(stats);
36
- const total = values.reduce((sum, value) => sum + value, 0);
37
- if (total === 0) {
38
- return { points, series };
39
- }
40
- itemType.forEach((item) => {
41
- const pointId = `${executionId}-${item}`;
42
- const value = stats[item] ?? 0;
43
- points[pointId] = {
44
- x: executionId,
45
- y: value / total,
46
- };
47
- series[item].push(pointId);
48
- });
49
- return { points, series };
50
- };
51
- export const mergeTrendDataGeneric = (trendData, trendDataPart, itemType) => {
52
- return {
53
- ...trendData,
54
- points: {
55
- ...trendData.points,
56
- ...trendDataPart.points,
57
- },
58
- slices: {
59
- ...trendData.slices,
60
- ...trendDataPart.slices,
61
- },
62
- series: Object.entries(trendDataPart.series).reduce((series, [group, pointIds]) => {
63
- if (Array.isArray(pointIds)) {
64
- return {
65
- ...series,
66
- [group]: [...(trendData.series?.[group] || []), ...pointIds],
67
- };
68
- }
69
- return series;
70
- }, trendData.series || createEmptySeries(itemType)),
71
- min: Math.min(trendData.min ?? Infinity, trendDataPart.min),
72
- max: Math.max(trendData.max ?? -Infinity, trendDataPart.max),
73
- };
74
- };
75
- export const getTrendDataGeneric = (stats, reportName, executionOrder, itemType, chartOptions) => {
76
- const { type, dataType, title, mode = ChartMode.Raw, metadata = {} } = chartOptions;
77
- const { executionIdAccessor, executionNameAccessor } = metadata;
78
- const executionId = executionIdAccessor ? executionIdAccessor(executionOrder) : `execution-${executionOrder}`;
79
- const { points, series } = mode === ChartMode.Percent
80
- ? calculatePercentValues(stats, executionId, itemType)
81
- : calculateRawValues(stats, executionId, itemType);
82
- const slices = {};
83
- const pointsAsArray = Object.values(points);
84
- const pointsCount = pointsAsArray.length;
85
- const values = pointsAsArray.map((point) => point.y);
86
- const min = pointsCount ? Math.min(...values) : 0;
87
- const max = pointsCount ? Math.max(...values) : 0;
88
- if (pointsCount > 0) {
89
- const executionName = executionNameAccessor ? executionNameAccessor(executionOrder) : reportName;
90
- slices[executionId] = {
91
- min,
92
- max,
93
- metadata: {
94
- executionId,
95
- executionName,
96
- },
97
- };
98
- }
99
- return {
100
- type,
101
- dataType,
102
- mode,
103
- title,
104
- points,
105
- slices,
106
- series,
107
- min,
108
- max,
109
- };
110
- };
111
- const generatePieChart = (options, stores) => {
112
- const { statistic } = stores;
113
- return getPieChartDataDashboard(statistic, options);
114
- };
115
4
  export const generateCharts = async (options, store, context) => {
116
5
  const { charts } = options;
117
6
  if (!charts) {
118
7
  return undefined;
119
8
  }
120
- const historyDataPoints = await store.allHistoryDataPoints();
121
- const statistic = await store.testsStatistic();
122
- const testResults = await store.allTestResults();
123
- return charts.reduce((acc, chartOptions) => {
9
+ const storeData = await Promise.all([
10
+ store.allHistoryDataPoints(),
11
+ store.allTestResults(),
12
+ store.testsStatistic(),
13
+ ]).then(([historyDataPoints, testResults, statistic]) => ({
14
+ historyDataPoints,
15
+ testResults,
16
+ statistic,
17
+ }));
18
+ const chartsData = {};
19
+ for (const chartOptions of charts) {
124
20
  const chartId = randomUUID();
125
21
  let chart;
126
22
  if (chartOptions.type === ChartType.Trend) {
127
- chart = generateTrendChart(chartOptions, {
128
- historyDataPoints,
129
- statistic,
130
- testResults,
131
- }, context);
23
+ chart = generateTrendChart(chartOptions, storeData, context);
132
24
  }
133
25
  else if (chartOptions.type === ChartType.Pie) {
134
- chart = generatePieChart(chartOptions, { statistic });
26
+ chart = generatePieChart(chartOptions, storeData);
27
+ }
28
+ else if (chartOptions.type === ChartType.Bar) {
29
+ chart = generateBarChart(chartOptions, storeData);
30
+ }
31
+ else if (chartOptions.type === ChartType.TreeMap) {
32
+ chart = generateTreeMapChart(chartOptions, storeData);
33
+ }
34
+ else if (chartOptions.type === ChartType.HeatMap) {
35
+ chart = generateHeatMapChart(chartOptions, storeData);
135
36
  }
136
37
  if (chart) {
137
- acc[chartId] = chart;
38
+ chartsData[chartId] = chart;
39
+ }
40
+ else {
41
+ chartsData[chartId] = generateComingSoonChart(chartOptions);
138
42
  }
139
- return acc;
140
- }, {});
141
- };
142
- export const generateTrendChart = (options, stores, context) => {
143
- const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
144
- const { dataType } = newOptions;
145
- const { statistic, historyDataPoints, testResults } = stores;
146
- if (dataType === ChartDataType.Status) {
147
- return getStatusTrendData(statistic, context.reportName, historyDataPoints, newOptions);
148
- }
149
- else if (dataType === ChartDataType.Severity) {
150
- return getSeverityTrendData(testResults, context.reportName, historyDataPoints, newOptions);
151
43
  }
44
+ return chartsData;
152
45
  };
153
46
  export const generateAllCharts = async (writer, store, options, context) => {
154
47
  const charts = await generateCharts(options, store, context);
@@ -1,21 +1,30 @@
1
- import { type AttachmentLink, type EnvironmentItem } from "@allurereport/core-api";
2
- import { type AllureStore, type ReportFiles, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
1
+ import { type AttachmentLink, type EnvironmentItem, type Statistic, type TestEnvGroup, type TestError, type TestResult } from "@allurereport/core-api";
2
+ import { type AllureStore, type ExitCode, type ReportFiles, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
3
3
  import type { AwesomeTestResult } from "@allurereport/web-awesome";
4
4
  import type { AwesomeOptions, TemplateManifest } from "./model.js";
5
5
  import type { AwesomeDataWriter, ReportFile } from "./writer.js";
6
6
  export declare const readTemplateManifest: (singleFileMode?: boolean) => Promise<TemplateManifest>;
7
- export declare const generateTestResults: (writer: AwesomeDataWriter, store: AllureStore, filter?: TestResultFilter) => Promise<AwesomeTestResult[]>;
7
+ export declare const generateTestResults: (writer: AwesomeDataWriter, store: AllureStore, trs: TestResult[], filter?: TestResultFilter) => Promise<AwesomeTestResult[]>;
8
8
  export declare const generateTestCases: (writer: AwesomeDataWriter, trs: AwesomeTestResult[]) => Promise<void>;
9
- export declare const generateTestEnvGroups: (writer: AwesomeDataWriter, store: AllureStore) => Promise<void>;
9
+ export declare const generateTestEnvGroups: (writer: AwesomeDataWriter, groups: TestEnvGroup[]) => Promise<void>;
10
10
  export declare const generateNav: (writer: AwesomeDataWriter, trs: AwesomeTestResult[], filename?: string) => Promise<void>;
11
11
  export declare const generateTree: (writer: AwesomeDataWriter, treeFilename: string, labels: string[], tests: AwesomeTestResult[]) => Promise<void>;
12
12
  export declare const generateEnvironmentJson: (writer: AwesomeDataWriter, env: EnvironmentItem[]) => Promise<void>;
13
13
  export declare const generateEnvirontmentsList: (writer: AwesomeDataWriter, store: AllureStore) => Promise<void>;
14
14
  export declare const generateVariables: (writer: AwesomeDataWriter, store: AllureStore) => Promise<void>;
15
- export declare const generateStatistic: (writer: AwesomeDataWriter, store: AllureStore, filter?: TestResultFilter) => Promise<void>;
16
- export declare const generatePieChart: (writer: AwesomeDataWriter, store: AllureStore, filter?: TestResultFilter) => Promise<void>;
15
+ export declare const generateStatistic: (writer: AwesomeDataWriter, data: {
16
+ stats: Statistic;
17
+ statsByEnv: Map<string, Statistic>;
18
+ envs: string[];
19
+ }) => Promise<void>;
17
20
  export declare const generateAttachmentsFiles: (writer: AwesomeDataWriter, attachmentLinks: AttachmentLink[], contentFunction: (id: string) => Promise<ResultFile | undefined>) => Promise<Map<string, string> | undefined>;
18
21
  export declare const generateHistoryDataPoints: (writer: AwesomeDataWriter, store: AllureStore) => Promise<Map<string, string>>;
22
+ export declare const generateGlobals: (writer: AwesomeDataWriter, payload: {
23
+ globalExitCode?: ExitCode;
24
+ globalAttachments?: AttachmentLink[];
25
+ globalErrors?: TestError[];
26
+ contentFunction: (id: string) => Promise<ResultFile | undefined>;
27
+ }) => Promise<void>;
19
28
  export declare const generateStaticFiles: (payload: AwesomeOptions & {
20
29
  id: string;
21
30
  allureVersion: string;
@@ -1,12 +1,10 @@
1
- import { compareBy, incrementStatistic, nullsLast, ordinal, } from "@allurereport/core-api";
1
+ import { compareBy, createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, getPieChartValues, incrementStatistic, nullsLast, ordinal, } from "@allurereport/core-api";
2
2
  import { createTreeByLabels, createTreeByTitlePath, filterTree, preciseTreeLabels, sortTree, transformTree, } from "@allurereport/plugin-api";
3
- import { createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, getPieChartData, } from "@allurereport/web-commons";
4
3
  import Handlebars from "handlebars";
5
4
  import { readFile } from "node:fs/promises";
6
5
  import { createRequire } from "node:module";
7
6
  import { basename, join } from "node:path";
8
7
  import { convertFixtureResult, convertTestResult } from "./converters.js";
9
- import { filterEnv } from "./environments.js";
10
8
  const require = createRequire(import.meta.url);
11
9
  const template = `<!DOCTYPE html>
12
10
  <html dir="ltr" lang="en">
@@ -72,8 +70,8 @@ const createBreadcrumbs = (convertedTr) => {
72
70
  return acc;
73
71
  }, []);
74
72
  };
75
- export const generateTestResults = async (writer, store, filter) => {
76
- const allTr = (await store.allTestResults({ includeHidden: true })).filter((tr) => (filter ? filter(tr) : true));
73
+ export const generateTestResults = async (writer, store, trs, filter) => {
74
+ const allTr = trs.filter((tr) => (filter ? filter(tr) : true));
77
75
  let convertedTrs = [];
78
76
  for (const tr of allTr) {
79
77
  const trFixtures = await store.fixturesByTrId(tr.id);
@@ -106,8 +104,7 @@ export const generateTestCases = async (writer, trs) => {
106
104
  await writer.writeTestCase(tr);
107
105
  }
108
106
  };
109
- export const generateTestEnvGroups = async (writer, store) => {
110
- const groups = await store.allTestEnvGroups();
107
+ export const generateTestEnvGroups = async (writer, groups) => {
111
108
  for (const group of groups) {
112
109
  const src = join("test-env-groups", `${group.id}.json`);
113
110
  await writer.writeData(src, group);
@@ -183,22 +180,17 @@ export const generateVariables = async (writer, store) => {
183
180
  await writer.writeWidget(join(env, "variables.json"), envVariables);
184
181
  }
185
182
  };
186
- export const generateStatistic = async (writer, store, filter) => {
187
- const statistic = await store.testsStatistic(filter);
188
- const environments = await store.allEnvironments();
189
- await writer.writeWidget("statistic.json", statistic);
190
- for (const env of environments) {
191
- const envStatistic = await store.testsStatistic(filterEnv(env, filter));
192
- await writer.writeWidget(join(env, "statistic.json"), envStatistic);
193
- }
194
- };
195
- export const generatePieChart = async (writer, store, filter) => {
196
- const reportStatistic = await store.testsStatistic(filter);
197
- const environments = await store.allEnvironments();
198
- await writer.writeWidget("pie_chart.json", getPieChartData(reportStatistic));
199
- for (const env of environments) {
200
- const envStatistic = await store.testsStatistic(filterEnv(env, filter));
201
- await writer.writeWidget(join(env, "pie_chart.json"), getPieChartData(envStatistic));
183
+ export const generateStatistic = async (writer, data) => {
184
+ const { stats, statsByEnv, envs } = data;
185
+ await writer.writeWidget("statistic.json", stats);
186
+ await writer.writeWidget("pie_chart.json", getPieChartValues(stats));
187
+ for (const env of envs) {
188
+ const envStats = statsByEnv.get(env);
189
+ if (!envStats) {
190
+ continue;
191
+ }
192
+ await writer.writeWidget(join(env, "statistic.json"), envStats);
193
+ await writer.writeWidget(join(env, "pie_chart.json"), envStats);
202
194
  }
203
195
  };
204
196
  export const generateAttachmentsFiles = async (writer, attachmentLinks, contentFunction) => {
@@ -226,6 +218,24 @@ export const generateHistoryDataPoints = async (writer, store) => {
226
218
  }
227
219
  return result;
228
220
  };
221
+ export const generateGlobals = async (writer, payload) => {
222
+ const { globalExitCode = { original: 0 }, globalAttachments = [], globalErrors = [], contentFunction } = payload;
223
+ const globals = {
224
+ exitCode: globalExitCode,
225
+ errors: globalErrors,
226
+ attachments: [],
227
+ };
228
+ for (const attachment of globalAttachments) {
229
+ const src = `${attachment.id}${attachment.ext}`;
230
+ const content = await contentFunction(attachment.id);
231
+ if (!content) {
232
+ continue;
233
+ }
234
+ await writer.writeAttachment(src, content);
235
+ globals.attachments.push(attachment);
236
+ }
237
+ await writer.writeWidget("globals.json", globals);
238
+ };
229
239
  export const generateStaticFiles = async (payload) => {
230
240
  const { id, reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "light", groupBy, reportFiles, reportDataFiles, reportUuid, allureVersion, layout = "base", charts = [], defaultSection = "", ci, } = payload;
231
241
  const compile = Handlebars.compile(template);
package/dist/model.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CiDescriptor, EnvironmentsConfig, TestResult } from "@allurereport/core-api";
2
- import type { ChartOptions } from "./charts.js";
2
+ import type { ChartOptions } from "@allurereport/plugin-api";
3
3
  export type AwesomeOptions = {
4
4
  reportName?: string;
5
5
  singleFile?: boolean;
package/dist/plugin.js CHANGED
@@ -15,21 +15,36 @@ import { convertToSummaryTestResult, } from "@allurereport/plugin-api";
15
15
  import { preciseTreeLabels } from "@allurereport/plugin-api";
16
16
  import { join } from "node:path";
17
17
  import { generateAllCharts } from "./charts.js";
18
- import { generateAttachmentsFiles, generateEnvironmentJson, generateEnvirontmentsList, generateHistoryDataPoints, generateNav, generatePieChart, generateStaticFiles, generateStatistic, generateTestCases, generateTestEnvGroups, generateTestResults, generateTree, generateVariables, } from "./generators.js";
18
+ import { filterEnv } from "./environments.js";
19
+ import { generateAttachmentsFiles, generateEnvironmentJson, generateEnvirontmentsList, generateGlobals, generateHistoryDataPoints, generateNav, generateStaticFiles, generateStatistic, generateTestCases, generateTestEnvGroups, generateTestResults, generateTree, generateVariables, } from "./generators.js";
19
20
  import { InMemoryReportDataWriter, ReportFileDataWriter } from "./writer.js";
20
21
  export class AwesomePlugin {
21
22
  constructor(options = {}) {
22
23
  this.options = options;
23
24
  _AwesomePlugin_writer.set(this, void 0);
24
25
  _AwesomePlugin_generate.set(this, async (context, store) => {
25
- const { singleFile, groupBy = [] } = this.options ?? {};
26
+ const { singleFile, groupBy = [], filter } = this.options ?? {};
26
27
  const environmentItems = await store.metadataByKey("allure_environment");
27
28
  const reportEnvironments = await store.allEnvironments();
28
29
  const attachments = await store.allAttachments();
29
- await generateStatistic(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options.filter);
30
- await generatePieChart(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options.filter);
30
+ const allTrs = await store.allTestResults({ includeHidden: true });
31
+ const statistics = await store.testsStatistic(filter);
32
+ const environments = await store.allEnvironments();
33
+ const envStatistics = new Map();
34
+ const allTestEnvGroups = await store.allTestEnvGroups();
35
+ const globalAttachments = await store.allGlobalAttachments();
36
+ const globalExitCode = await store.globalExitCode();
37
+ const globalErrors = await store.allGlobalErrors();
38
+ for (const env of environments) {
39
+ envStatistics.set(env, await store.testsStatistic(filterEnv(env, filter)));
40
+ }
41
+ await generateStatistic(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), {
42
+ stats: statistics,
43
+ statsByEnv: envStatistics,
44
+ envs: environments,
45
+ });
31
46
  await generateAllCharts(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options, context);
32
- const convertedTrs = await generateTestResults(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, this.options.filter);
47
+ const convertedTrs = await generateTestResults(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store, allTrs, this.options.filter);
33
48
  const hasGroupBy = groupBy.length > 0;
34
49
  const treeLabels = hasGroupBy
35
50
  ? preciseTreeLabels(groupBy, convertedTrs, ({ labels }) => labels.map(({ name }) => name))
@@ -38,11 +53,9 @@ export class AwesomePlugin {
38
53
  await generateTestCases(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), convertedTrs);
39
54
  await generateTree(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), "tree.json", treeLabels, convertedTrs);
40
55
  await generateNav(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), convertedTrs, "nav.json");
41
- await generateTestEnvGroups(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), store);
56
+ await generateTestEnvGroups(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), allTestEnvGroups);
42
57
  for (const reportEnvironment of reportEnvironments) {
43
- const envTrs = await store.testResultsByEnvironment(reportEnvironment);
44
- const envTrsIds = envTrs.map(({ id }) => id);
45
- const envConvertedTrs = convertedTrs.filter(({ id }) => envTrsIds.includes(id));
58
+ const envConvertedTrs = convertedTrs.filter(({ environment }) => environment === reportEnvironment);
46
59
  await generateTree(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), join(reportEnvironment, "tree.json"), treeLabels, envConvertedTrs);
47
60
  await generateNav(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), envConvertedTrs, join(reportEnvironment, "nav.json"));
48
61
  }
@@ -55,14 +68,21 @@ export class AwesomePlugin {
55
68
  await generateAttachmentsFiles(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), attachments, (id) => store.attachmentContentById(id));
56
69
  }
57
70
  const reportDataFiles = singleFile ? __classPrivateFieldGet(this, _AwesomePlugin_writer, "f").reportFiles() : [];
71
+ await generateGlobals(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), {
72
+ globalAttachments,
73
+ globalErrors,
74
+ globalExitCode,
75
+ contentFunction: (id) => store.attachmentContentById(id),
76
+ });
58
77
  await generateStaticFiles({
59
78
  ...this.options,
60
79
  id: context.id,
61
80
  allureVersion: context.allureVersion,
62
81
  reportFiles: context.reportFiles,
63
- reportDataFiles,
64
82
  reportUuid: context.reportUuid,
65
83
  reportName: context.reportName,
84
+ ci: context.ci,
85
+ reportDataFiles,
66
86
  });
67
87
  });
68
88
  this.start = async (context) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-awesome",
3
- "version": "3.0.0-beta.17",
3
+ "version": "3.0.0-beta.19",
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,9 @@
30
30
  "test": "rimraf ./out && vitest run"
31
31
  },
32
32
  "dependencies": {
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",
33
+ "@allurereport/core-api": "3.0.0-beta.19",
34
+ "@allurereport/plugin-api": "3.0.0-beta.19",
35
+ "@allurereport/web-awesome": "3.0.0-beta.19",
37
36
  "d3-shape": "^3.2.0",
38
37
  "handlebars": "^4.7.8"
39
38
  },
@@ -45,7 +44,7 @@
45
44
  "@typescript-eslint/eslint-plugin": "^8.0.0",
46
45
  "@typescript-eslint/parser": "^8.0.0",
47
46
  "@vitest/runner": "^2.1.9",
48
- "allure-vitest": "^3.3.0",
47
+ "allure-vitest": "^3.3.3",
49
48
  "eslint": "^8.57.0",
50
49
  "eslint-config-prettier": "^9.1.0",
51
50
  "eslint-plugin-import": "^2.29.1",