@allurereport/plugin-dashboard 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/generators.d.ts +2 -2
- package/dist/generators.js +30 -33
- package/dist/model.d.ts +2 -85
- package/dist/model.js +1 -15
- package/package.json +5 -6
- package/dist/charts/severityTrend.d.ts +0 -3
- package/dist/charts/severityTrend.js +0 -47
- package/dist/charts/statusPie.d.ts +0 -9
- package/dist/charts/statusPie.js +0 -28
- package/dist/charts/statusTrend.d.ts +0 -3
- package/dist/charts/statusTrend.js +0 -38
- package/dist/utils/trend.d.ts +0 -9
- package/dist/utils/trend.js +0 -102
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { DashboardOptions, DashboardPluginOptions,
|
|
1
|
+
import { type AllureStore, type GeneratedChartsData, type PluginContext, type ReportFiles } from "@allurereport/plugin-api";
|
|
2
|
+
import type { DashboardOptions, DashboardPluginOptions, TemplateManifest } from "./model.js";
|
|
3
3
|
import type { DashboardDataWriter, ReportFile } from "./writer.js";
|
|
4
4
|
export declare const readTemplateManifest: (singleFileMode?: boolean) => Promise<TemplateManifest>;
|
|
5
5
|
export declare const generateCharts: (options: DashboardPluginOptions, store: AllureStore, context: PluginContext) => Promise<GeneratedChartsData | undefined>;
|
package/dist/generators.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChartType, createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
|
|
2
|
+
import { generateBarChart, generateComingSoonChart, generateHeatMapChart, generatePieChart, generateTreeMapChart, generateTrendChart, } from "@allurereport/plugin-api";
|
|
2
3
|
import { randomUUID } from "crypto";
|
|
3
4
|
import Handlebars from "handlebars";
|
|
4
5
|
import { readFile } from "node:fs/promises";
|
|
5
6
|
import { createRequire } from "node:module";
|
|
6
7
|
import { basename, join } from "node:path";
|
|
7
|
-
import { getSeverityTrendData } from "./charts/severityTrend.js";
|
|
8
|
-
import { getPieChartData } from "./charts/statusPie.js";
|
|
9
|
-
import { getStatusTrendData } from "./charts/statusTrend.js";
|
|
10
|
-
import { ChartData, ChartType } from "./model.js";
|
|
11
8
|
const require = createRequire(import.meta.url);
|
|
12
9
|
const template = `<!DOCTYPE html>
|
|
13
10
|
<html dir="ltr" lang="en">
|
|
@@ -50,47 +47,47 @@ export const readTemplateManifest = async (singleFileMode) => {
|
|
|
50
47
|
const templateManifest = await readFile(templateManifestSource, { encoding: "utf-8" });
|
|
51
48
|
return JSON.parse(templateManifest);
|
|
52
49
|
};
|
|
53
|
-
const generateTrendChart = (options, stores, context) => {
|
|
54
|
-
const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
|
|
55
|
-
const { dataType } = newOptions;
|
|
56
|
-
const { statistic, historyDataPoints, testResults } = stores;
|
|
57
|
-
if (dataType === ChartData.Status) {
|
|
58
|
-
return getStatusTrendData(statistic, context.reportName, historyDataPoints, newOptions);
|
|
59
|
-
}
|
|
60
|
-
else if (dataType === ChartData.Severity) {
|
|
61
|
-
return getSeverityTrendData(testResults, context.reportName, historyDataPoints, newOptions);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const generatePieChart = (options, stores) => {
|
|
65
|
-
const { statistic } = stores;
|
|
66
|
-
return getPieChartData(statistic, options);
|
|
67
|
-
};
|
|
68
50
|
export const generateCharts = async (options, store, context) => {
|
|
69
51
|
const { layout } = options;
|
|
70
52
|
if (!layout) {
|
|
71
53
|
return undefined;
|
|
72
54
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
55
|
+
const storeData = await Promise.all([
|
|
56
|
+
store.allHistoryDataPoints(),
|
|
57
|
+
store.allTestResults(),
|
|
58
|
+
store.testsStatistic(),
|
|
59
|
+
]).then(([historyDataPoints, testResults, statistic]) => ({
|
|
60
|
+
historyDataPoints,
|
|
61
|
+
testResults,
|
|
62
|
+
statistic,
|
|
63
|
+
}));
|
|
64
|
+
const chartsData = {};
|
|
65
|
+
for (const chartOptions of layout) {
|
|
77
66
|
const chartId = randomUUID();
|
|
78
67
|
let chart;
|
|
79
68
|
if (chartOptions.type === ChartType.Trend) {
|
|
80
|
-
chart = generateTrendChart(chartOptions,
|
|
81
|
-
historyDataPoints,
|
|
82
|
-
statistic,
|
|
83
|
-
testResults,
|
|
84
|
-
}, context);
|
|
69
|
+
chart = generateTrendChart(chartOptions, storeData, context);
|
|
85
70
|
}
|
|
86
71
|
else if (chartOptions.type === ChartType.Pie) {
|
|
87
|
-
chart = generatePieChart(chartOptions,
|
|
72
|
+
chart = generatePieChart(chartOptions, storeData);
|
|
73
|
+
}
|
|
74
|
+
else if (chartOptions.type === ChartType.Bar) {
|
|
75
|
+
chart = generateBarChart(chartOptions, storeData);
|
|
76
|
+
}
|
|
77
|
+
else if (chartOptions.type === ChartType.TreeMap) {
|
|
78
|
+
chart = generateTreeMapChart(chartOptions, storeData);
|
|
79
|
+
}
|
|
80
|
+
else if (chartOptions.type === ChartType.HeatMap) {
|
|
81
|
+
chart = generateHeatMapChart(chartOptions, storeData);
|
|
88
82
|
}
|
|
89
83
|
if (chart) {
|
|
90
|
-
|
|
84
|
+
chartsData[chartId] = chart;
|
|
91
85
|
}
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
else {
|
|
87
|
+
chartsData[chartId] = generateComingSoonChart(chartOptions);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return chartsData;
|
|
94
91
|
};
|
|
95
92
|
export const generateAllCharts = async (writer, store, options, context) => {
|
|
96
93
|
const charts = await generateCharts(options, store, context);
|
package/dist/model.d.ts
CHANGED
|
@@ -1,88 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
Trend = "trend",
|
|
4
|
-
Pie = "pie"
|
|
5
|
-
}
|
|
6
|
-
export declare enum ChartData {
|
|
7
|
-
Status = "status",
|
|
8
|
-
Severity = "severity"
|
|
9
|
-
}
|
|
10
|
-
export declare enum ChartMode {
|
|
11
|
-
Raw = "raw",
|
|
12
|
-
Percent = "percent"
|
|
13
|
-
}
|
|
14
|
-
export type ChartId = string;
|
|
15
|
-
export type ExecutionIdFn = (executionOrder: number) => string;
|
|
16
|
-
export type ExecutionNameFn = (executionOrder: number) => string;
|
|
17
|
-
export type TrendMetadataFnOverrides = {
|
|
18
|
-
executionIdAccessor?: ExecutionIdFn;
|
|
19
|
-
executionNameAccessor?: ExecutionNameFn;
|
|
20
|
-
};
|
|
21
|
-
export type TrendChartOptions = {
|
|
22
|
-
type: ChartType.Trend;
|
|
23
|
-
dataType: ChartData;
|
|
24
|
-
mode?: ChartMode;
|
|
25
|
-
title?: string;
|
|
26
|
-
limit?: number;
|
|
27
|
-
metadata?: TrendMetadataFnOverrides;
|
|
28
|
-
};
|
|
29
|
-
export type TrendPointId = string;
|
|
30
|
-
export type TrendSliceId = string;
|
|
31
|
-
export type BaseMetadata = Record<string, unknown>;
|
|
32
|
-
export interface BaseTrendSliceMetadata extends Record<string, unknown> {
|
|
33
|
-
executionId: string;
|
|
34
|
-
executionName: string;
|
|
35
|
-
}
|
|
36
|
-
export type TrendSliceMetadata<Metadata extends BaseMetadata> = BaseTrendSliceMetadata & Metadata;
|
|
37
|
-
export type TrendPoint = {
|
|
38
|
-
x: string;
|
|
39
|
-
y: number;
|
|
40
|
-
};
|
|
41
|
-
export type TrendSlice<Metadata extends BaseMetadata> = {
|
|
42
|
-
min: number;
|
|
43
|
-
max: number;
|
|
44
|
-
metadata: TrendSliceMetadata<Metadata>;
|
|
45
|
-
};
|
|
46
|
-
export type GenericTrendChartData<Metadata extends BaseMetadata, SeriesType extends string> = {
|
|
47
|
-
type: ChartType.Trend;
|
|
48
|
-
dataType: ChartData;
|
|
49
|
-
mode: ChartMode;
|
|
50
|
-
title?: string;
|
|
51
|
-
points: Record<TrendPointId, TrendPoint>;
|
|
52
|
-
slices: Record<TrendSliceId, TrendSlice<Metadata>>;
|
|
53
|
-
series: Record<SeriesType, TrendPointId[]>;
|
|
54
|
-
min: number;
|
|
55
|
-
max: number;
|
|
56
|
-
};
|
|
57
|
-
export interface StatusMetadata extends BaseTrendSliceMetadata {
|
|
58
|
-
}
|
|
59
|
-
export type StatusTrendSliceMetadata = TrendSliceMetadata<StatusMetadata>;
|
|
60
|
-
export type StatusTrendSlice = TrendSlice<StatusTrendSliceMetadata>;
|
|
61
|
-
export type StatusTrendChartData = GenericTrendChartData<StatusTrendSliceMetadata, TestStatus>;
|
|
62
|
-
export interface SeverityMetadata extends BaseTrendSliceMetadata {
|
|
63
|
-
}
|
|
64
|
-
export type SeverityTrendSliceMetadata = TrendSliceMetadata<SeverityMetadata>;
|
|
65
|
-
export type SeverityTrendSlice = TrendSlice<SeverityTrendSliceMetadata>;
|
|
66
|
-
export type SeverityTrendChartData = GenericTrendChartData<SeverityTrendSliceMetadata, SeverityLevel>;
|
|
67
|
-
export type TrendChartData = StatusTrendChartData | SeverityTrendChartData;
|
|
68
|
-
export type PieChartOptions = {
|
|
69
|
-
type: ChartType.Pie;
|
|
70
|
-
title?: string;
|
|
71
|
-
};
|
|
72
|
-
export type PieSlice = {
|
|
73
|
-
status: TestStatus;
|
|
74
|
-
count: number;
|
|
75
|
-
d: string | null;
|
|
76
|
-
};
|
|
77
|
-
export type PieChartData = {
|
|
78
|
-
type: ChartType.Pie;
|
|
79
|
-
title?: string;
|
|
80
|
-
slices: PieSlice[];
|
|
81
|
-
percentage: number;
|
|
82
|
-
};
|
|
83
|
-
export type GeneratedChartData = TrendChartData | PieChartData;
|
|
84
|
-
export type GeneratedChartsData = Record<ChartId, GeneratedChartData>;
|
|
85
|
-
export type ChartOptions = TrendChartOptions | PieChartOptions;
|
|
1
|
+
import type { TestResult } from "@allurereport/core-api";
|
|
2
|
+
import type { ChartOptions } from "@allurereport/plugin-api";
|
|
86
3
|
export type DashboardOptions = {
|
|
87
4
|
reportName?: string;
|
|
88
5
|
singleFile?: boolean;
|
package/dist/model.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
(function (ChartType) {
|
|
3
|
-
ChartType["Trend"] = "trend";
|
|
4
|
-
ChartType["Pie"] = "pie";
|
|
5
|
-
})(ChartType || (ChartType = {}));
|
|
6
|
-
export var ChartData;
|
|
7
|
-
(function (ChartData) {
|
|
8
|
-
ChartData["Status"] = "status";
|
|
9
|
-
ChartData["Severity"] = "severity";
|
|
10
|
-
})(ChartData || (ChartData = {}));
|
|
11
|
-
export var ChartMode;
|
|
12
|
-
(function (ChartMode) {
|
|
13
|
-
ChartMode["Raw"] = "raw";
|
|
14
|
-
ChartMode["Percent"] = "percent";
|
|
15
|
-
})(ChartMode || (ChartMode = {}));
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-dashboard",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.19",
|
|
4
4
|
"description": "Allure Dashboard Plugin – plugin for generating dashboard with a mix of charts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
"test": "rimraf ./out && vitest run"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
36
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
37
|
-
"@allurereport/web-
|
|
38
|
-
"@allurereport/web-dashboard": "3.0.0-beta.17",
|
|
35
|
+
"@allurereport/core-api": "3.0.0-beta.19",
|
|
36
|
+
"@allurereport/plugin-api": "3.0.0-beta.19",
|
|
37
|
+
"@allurereport/web-dashboard": "3.0.0-beta.19",
|
|
39
38
|
"d3-shape": "^3.2.0",
|
|
40
39
|
"handlebars": "^4.7.8"
|
|
41
40
|
},
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
48
47
|
"@typescript-eslint/parser": "^8.0.0",
|
|
49
48
|
"@vitest/runner": "^2.1.9",
|
|
50
|
-
"allure-vitest": "^3.3.
|
|
49
|
+
"allure-vitest": "^3.3.3",
|
|
51
50
|
"eslint": "^8.57.0",
|
|
52
51
|
"eslint-config-prettier": "^9.1.0",
|
|
53
52
|
"eslint-plugin-import": "^2.29.1",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { HistoryDataPoint, TestResult } from "@allurereport/core-api";
|
|
2
|
-
import type { SeverityTrendChartData, TrendChartOptions } from "../model.js";
|
|
3
|
-
export declare const getSeverityTrendData: (testResults: TestResult[], reportName: string, historyPoints: HistoryDataPoint[], chartOptions: TrendChartOptions) => SeverityTrendChartData;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { severityLabelName, severityLevels } from "@allurereport/core-api";
|
|
2
|
-
import { createEmptySeries, createEmptyStats, getTrendDataGeneric, mergeTrendDataGeneric, normalizeStatistic, } from "../utils/trend.js";
|
|
3
|
-
export const getSeverityTrendData = (testResults, reportName, historyPoints, chartOptions) => {
|
|
4
|
-
const { limit } = chartOptions;
|
|
5
|
-
const historyLimit = limit && limit > 0 ? Math.max(0, limit - 1) : undefined;
|
|
6
|
-
const limitedHistoryPoints = historyLimit !== undefined ? historyPoints.slice(-historyLimit) : historyPoints;
|
|
7
|
-
const firstOriginalIndex = historyLimit !== undefined ? Math.max(0, historyPoints.length - historyLimit) : 0;
|
|
8
|
-
const convertedHistoryPoints = limitedHistoryPoints.map((point, index) => {
|
|
9
|
-
const originalIndex = firstOriginalIndex + index;
|
|
10
|
-
return {
|
|
11
|
-
name: point.name,
|
|
12
|
-
originalIndex,
|
|
13
|
-
statistic: Object.values(point.testResults).reduce((stat, test) => {
|
|
14
|
-
const severityLabel = test.labels?.find((label) => label.name === severityLabelName);
|
|
15
|
-
const severity = severityLabel?.value?.toLowerCase();
|
|
16
|
-
if (severity) {
|
|
17
|
-
stat[severity] = (stat[severity] ?? 0) + 1;
|
|
18
|
-
}
|
|
19
|
-
return stat;
|
|
20
|
-
}, createEmptyStats(severityLevels)),
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
const currentSeverityStats = testResults.reduce((acc, test) => {
|
|
24
|
-
const severityLabel = test.labels.find((label) => label.name === severityLabelName);
|
|
25
|
-
const severity = severityLabel?.value?.toLowerCase();
|
|
26
|
-
if (severity) {
|
|
27
|
-
acc[severity] = (acc[severity] ?? 0) + 1;
|
|
28
|
-
}
|
|
29
|
-
return acc;
|
|
30
|
-
}, createEmptyStats(severityLevels));
|
|
31
|
-
const currentTrendData = getTrendDataGeneric(normalizeStatistic(currentSeverityStats, severityLevels), reportName, historyPoints.length + 1, severityLevels, chartOptions);
|
|
32
|
-
const historicalTrendData = convertedHistoryPoints.reduce((acc, historyPoint) => {
|
|
33
|
-
const trendDataPart = getTrendDataGeneric(normalizeStatistic(historyPoint.statistic, severityLevels), historyPoint.name, historyPoint.originalIndex + 1, severityLevels, chartOptions);
|
|
34
|
-
return mergeTrendDataGeneric(acc, trendDataPart, severityLevels);
|
|
35
|
-
}, {
|
|
36
|
-
type: chartOptions.type,
|
|
37
|
-
dataType: chartOptions.dataType,
|
|
38
|
-
mode: chartOptions.mode,
|
|
39
|
-
title: chartOptions.title,
|
|
40
|
-
points: {},
|
|
41
|
-
slices: {},
|
|
42
|
-
series: createEmptySeries(severityLevels),
|
|
43
|
-
min: Infinity,
|
|
44
|
-
max: -Infinity,
|
|
45
|
-
});
|
|
46
|
-
return mergeTrendDataGeneric(historicalTrendData, currentTrendData, severityLevels);
|
|
47
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Statistic } from "@allurereport/core-api";
|
|
2
|
-
import type { PieArcDatum } from "d3-shape";
|
|
3
|
-
import { type PieChartData, type PieChartOptions, type PieSlice } from "../model.js";
|
|
4
|
-
type BasePieSlice = Pick<PieSlice, "status" | "count">;
|
|
5
|
-
export declare const d3Arc: import("d3-shape").Arc<any, PieArcDatum<BasePieSlice>>;
|
|
6
|
-
export declare const d3Pie: import("d3-shape").Pie<any, BasePieSlice>;
|
|
7
|
-
export declare const getPercentage: (value: number, total: number) => number;
|
|
8
|
-
export declare const getPieChartData: (stats: Statistic, chartOptions: PieChartOptions) => PieChartData;
|
|
9
|
-
export {};
|
package/dist/charts/statusPie.js
DELETED
|
@@ -1,28 +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 getPieChartData = (stats, chartOptions) => {
|
|
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
|
-
type: chartOptions.type,
|
|
24
|
-
title: chartOptions?.title,
|
|
25
|
-
slices,
|
|
26
|
-
percentage,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { HistoryDataPoint, Statistic } from "@allurereport/core-api";
|
|
2
|
-
import type { StatusTrendChartData, TrendChartOptions } from "../model.js";
|
|
3
|
-
export declare const getStatusTrendData: (currentStatistic: Statistic, reportName: string, historyPoints: HistoryDataPoint[], chartOptions: TrendChartOptions) => StatusTrendChartData;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { statusesList } from "@allurereport/core-api";
|
|
2
|
-
import { createEmptySeries, createEmptyStats, getTrendDataGeneric, mergeTrendDataGeneric, normalizeStatistic, } from "../utils/trend.js";
|
|
3
|
-
export const getStatusTrendData = (currentStatistic, reportName, historyPoints, chartOptions) => {
|
|
4
|
-
const { limit } = chartOptions;
|
|
5
|
-
const historyLimit = limit && limit > 0 ? Math.max(0, limit - 1) : undefined;
|
|
6
|
-
const limitedHistoryPoints = historyLimit !== undefined ? historyPoints.slice(-historyLimit) : historyPoints;
|
|
7
|
-
const firstOriginalIndex = historyLimit !== undefined ? Math.max(0, historyPoints.length - historyLimit) : 0;
|
|
8
|
-
const convertedHistoryPoints = limitedHistoryPoints.map((point, index) => {
|
|
9
|
-
const originalIndex = firstOriginalIndex + index;
|
|
10
|
-
return {
|
|
11
|
-
name: point.name,
|
|
12
|
-
originalIndex,
|
|
13
|
-
statistic: Object.values(point.testResults).reduce((stat, test) => {
|
|
14
|
-
if (test.status) {
|
|
15
|
-
stat[test.status] = (stat[test.status] ?? 0) + 1;
|
|
16
|
-
stat.total = (stat.total ?? 0) + 1;
|
|
17
|
-
}
|
|
18
|
-
return stat;
|
|
19
|
-
}, { total: 0, ...createEmptyStats(statusesList) }),
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
const currentTrendData = getTrendDataGeneric(normalizeStatistic(currentStatistic, statusesList), reportName, historyPoints.length + 1, statusesList, chartOptions);
|
|
23
|
-
const historicalTrendData = convertedHistoryPoints.reduce((acc, historyPoint) => {
|
|
24
|
-
const trendDataPart = getTrendDataGeneric(normalizeStatistic(historyPoint.statistic, statusesList), historyPoint.name, historyPoint.originalIndex + 1, statusesList, chartOptions);
|
|
25
|
-
return mergeTrendDataGeneric(acc, trendDataPart, statusesList);
|
|
26
|
-
}, {
|
|
27
|
-
type: chartOptions.type,
|
|
28
|
-
dataType: chartOptions.dataType,
|
|
29
|
-
mode: chartOptions.mode,
|
|
30
|
-
title: chartOptions.title,
|
|
31
|
-
points: {},
|
|
32
|
-
slices: {},
|
|
33
|
-
series: createEmptySeries(statusesList),
|
|
34
|
-
min: Infinity,
|
|
35
|
-
max: -Infinity,
|
|
36
|
-
});
|
|
37
|
-
return mergeTrendDataGeneric(historicalTrendData, currentTrendData, statusesList);
|
|
38
|
-
};
|
package/dist/utils/trend.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SeverityLevel, TestStatus } from "@allurereport/core-api";
|
|
2
|
-
import { type BaseTrendSliceMetadata, type GenericTrendChartData, type TrendChartOptions } from "../model.js";
|
|
3
|
-
type TrendDataType = TestStatus | SeverityLevel;
|
|
4
|
-
export declare const createEmptyStats: <T extends TrendDataType>(items: readonly T[]) => Record<T, number>;
|
|
5
|
-
export declare const createEmptySeries: <T extends TrendDataType>(items: readonly T[]) => Record<T, string[]>;
|
|
6
|
-
export declare const normalizeStatistic: <T extends TrendDataType>(statistic: Partial<Record<T, number>>, itemType: readonly T[]) => Record<T, number>;
|
|
7
|
-
export declare const mergeTrendDataGeneric: <M extends BaseTrendSliceMetadata, T extends TrendDataType>(trendData: GenericTrendChartData<M, T>, trendDataPart: GenericTrendChartData<M, T>, itemType: readonly T[]) => GenericTrendChartData<M, T>;
|
|
8
|
-
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>;
|
|
9
|
-
export {};
|
package/dist/utils/trend.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { ChartMode, } from "../model.js";
|
|
2
|
-
export const createEmptyStats = (items) => items.reduce((acc, item) => ({ ...acc, [item]: 0 }), {});
|
|
3
|
-
export const createEmptySeries = (items) => items.reduce((acc, item) => ({ ...acc, [item]: [] }), {});
|
|
4
|
-
export const normalizeStatistic = (statistic, itemType) => {
|
|
5
|
-
return itemType.reduce((acc, item) => {
|
|
6
|
-
acc[item] = statistic[item] ?? 0;
|
|
7
|
-
return acc;
|
|
8
|
-
}, {});
|
|
9
|
-
};
|
|
10
|
-
const calculateRawValues = (stats, executionId, itemType) => {
|
|
11
|
-
const points = {};
|
|
12
|
-
const series = createEmptySeries(itemType);
|
|
13
|
-
itemType.forEach((item) => {
|
|
14
|
-
const pointId = `${executionId}-${item}`;
|
|
15
|
-
const value = stats[item] ?? 0;
|
|
16
|
-
points[pointId] = {
|
|
17
|
-
x: executionId,
|
|
18
|
-
y: value,
|
|
19
|
-
};
|
|
20
|
-
series[item].push(pointId);
|
|
21
|
-
});
|
|
22
|
-
return { points, series };
|
|
23
|
-
};
|
|
24
|
-
const calculatePercentValues = (stats, executionId, itemType) => {
|
|
25
|
-
const points = {};
|
|
26
|
-
const series = createEmptySeries(itemType);
|
|
27
|
-
const values = Object.values(stats);
|
|
28
|
-
const total = values.reduce((sum, value) => sum + value, 0);
|
|
29
|
-
if (total === 0) {
|
|
30
|
-
return { points, series };
|
|
31
|
-
}
|
|
32
|
-
itemType.forEach((item) => {
|
|
33
|
-
const pointId = `${executionId}-${item}`;
|
|
34
|
-
const value = stats[item] ?? 0;
|
|
35
|
-
points[pointId] = {
|
|
36
|
-
x: executionId,
|
|
37
|
-
y: value / total,
|
|
38
|
-
};
|
|
39
|
-
series[item].push(pointId);
|
|
40
|
-
});
|
|
41
|
-
return { points, series };
|
|
42
|
-
};
|
|
43
|
-
export const mergeTrendDataGeneric = (trendData, trendDataPart, itemType) => {
|
|
44
|
-
return {
|
|
45
|
-
...trendData,
|
|
46
|
-
points: {
|
|
47
|
-
...trendData.points,
|
|
48
|
-
...trendDataPart.points,
|
|
49
|
-
},
|
|
50
|
-
slices: {
|
|
51
|
-
...trendData.slices,
|
|
52
|
-
...trendDataPart.slices,
|
|
53
|
-
},
|
|
54
|
-
series: Object.entries(trendDataPart.series).reduce((series, [group, pointIds]) => {
|
|
55
|
-
if (Array.isArray(pointIds)) {
|
|
56
|
-
return {
|
|
57
|
-
...series,
|
|
58
|
-
[group]: [...(trendData.series?.[group] || []), ...pointIds],
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return series;
|
|
62
|
-
}, trendData.series || createEmptySeries(itemType)),
|
|
63
|
-
min: Math.min(trendData.min ?? Infinity, trendDataPart.min),
|
|
64
|
-
max: Math.max(trendData.max ?? -Infinity, trendDataPart.max),
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
export const getTrendDataGeneric = (stats, reportName, executionOrder, itemType, chartOptions) => {
|
|
68
|
-
const { type, dataType, title, mode = ChartMode.Raw, metadata = {} } = chartOptions;
|
|
69
|
-
const { executionIdAccessor, executionNameAccessor } = metadata;
|
|
70
|
-
const executionId = executionIdAccessor ? executionIdAccessor(executionOrder) : `execution-${executionOrder}`;
|
|
71
|
-
const { points, series } = mode === ChartMode.Percent
|
|
72
|
-
? calculatePercentValues(stats, executionId, itemType)
|
|
73
|
-
: calculateRawValues(stats, executionId, itemType);
|
|
74
|
-
const slices = {};
|
|
75
|
-
const pointsAsArray = Object.values(points);
|
|
76
|
-
const pointsCount = pointsAsArray.length;
|
|
77
|
-
const values = pointsAsArray.map((point) => point.y);
|
|
78
|
-
const min = pointsCount ? Math.min(...values) : 0;
|
|
79
|
-
const max = pointsCount ? Math.max(...values) : 0;
|
|
80
|
-
if (pointsCount > 0) {
|
|
81
|
-
const executionName = executionNameAccessor ? executionNameAccessor(executionOrder) : reportName;
|
|
82
|
-
slices[executionId] = {
|
|
83
|
-
min,
|
|
84
|
-
max,
|
|
85
|
-
metadata: {
|
|
86
|
-
executionId,
|
|
87
|
-
executionName,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
type,
|
|
93
|
-
dataType,
|
|
94
|
-
mode,
|
|
95
|
-
title,
|
|
96
|
-
points,
|
|
97
|
-
slices,
|
|
98
|
-
series,
|
|
99
|
-
min,
|
|
100
|
-
max,
|
|
101
|
-
};
|
|
102
|
-
};
|