@allurereport/plugin-api 3.0.0-beta.20 → 3.0.0-beta.21
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/index.d.ts +0 -7
- package/dist/index.js +0 -7
- package/dist/plugin.d.ts +1 -0
- package/dist/store.d.ts +4 -1
- package/dist/store.js +1 -0
- package/package.json +2 -2
- package/dist/charts/accessors/coverageDiffTreeMapAccessor.d.ts +0 -17
- package/dist/charts/accessors/coverageDiffTreeMapAccessor.js +0 -181
- package/dist/charts/accessors/problemsDistributionHeatMap.d.ts +0 -2
- package/dist/charts/accessors/problemsDistributionHeatMap.js +0 -65
- package/dist/charts/accessors/severityTrendAccessor.d.ts +0 -3
- package/dist/charts/accessors/severityTrendAccessor.js +0 -21
- package/dist/charts/accessors/statusBySeverityBarAccessor.d.ts +0 -3
- package/dist/charts/accessors/statusBySeverityBarAccessor.js +0 -33
- package/dist/charts/accessors/statusChangeTrendBarAccessor.d.ts +0 -4
- package/dist/charts/accessors/statusChangeTrendBarAccessor.js +0 -92
- package/dist/charts/accessors/statusTrendAccessor.d.ts +0 -3
- package/dist/charts/accessors/statusTrendAccessor.js +0 -19
- package/dist/charts/accessors/statusTrendBarAccessor.d.ts +0 -5
- package/dist/charts/accessors/statusTrendBarAccessor.js +0 -63
- package/dist/charts/accessors/successRateDistributionTreeMapAccessor.d.ts +0 -14
- package/dist/charts/accessors/successRateDistributionTreeMapAccessor.js +0 -111
- package/dist/charts/accessors/utils/behavior.d.ts +0 -5
- package/dist/charts/accessors/utils/behavior.js +0 -4
- package/dist/charts/bar.d.ts +0 -3
- package/dist/charts/bar.js +0 -50
- package/dist/charts/comingSoon.d.ts +0 -2
- package/dist/charts/comingSoon.js +0 -7
- package/dist/charts/heatmap.d.ts +0 -3
- package/dist/charts/heatmap.js +0 -9
- package/dist/charts/line.d.ts +0 -8
- package/dist/charts/line.js +0 -140
- package/dist/charts/pie.d.ts +0 -6
- package/dist/charts/pie.js +0 -10
- package/dist/charts/treeMap.d.ts +0 -6
- package/dist/charts/treeMap.js +0 -88
- package/dist/charts.d.ts +0 -130
- package/dist/charts.js +0 -83
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { isChildrenLeavesOnly } from "../../charts.js";
|
|
2
|
-
import { md5 } from "../../utils/misc.js";
|
|
3
|
-
import { createTreeByLabels } from "../../utils/tree.js";
|
|
4
|
-
import { convertTreeDataToTreeMapNode, transformTreeMapNode } from "../treeMap.js";
|
|
5
|
-
import { behaviorLabels, filterTestsWithBehaviorLabels } from "./utils/behavior.js";
|
|
6
|
-
const leafFactoryFn = ({ id, name, status }) => ({
|
|
7
|
-
nodeId: id,
|
|
8
|
-
name,
|
|
9
|
-
status,
|
|
10
|
-
value: 1,
|
|
11
|
-
});
|
|
12
|
-
const groupFactoryFn = (parentId, groupClassifier) => ({
|
|
13
|
-
nodeId: md5((parentId ? `${parentId}.` : "") + groupClassifier),
|
|
14
|
-
name: groupClassifier,
|
|
15
|
-
value: 0,
|
|
16
|
-
passedTests: 0,
|
|
17
|
-
failedTests: 0,
|
|
18
|
-
otherTests: 0,
|
|
19
|
-
});
|
|
20
|
-
const addLeafToGroupFn = (group, leaf) => {
|
|
21
|
-
group.value += leaf.value;
|
|
22
|
-
group.passedTests += leaf.status === "passed" ? 1 : 0;
|
|
23
|
-
group.failedTests += leaf.status === "failed" ? 1 : 0;
|
|
24
|
-
group.otherTests += leaf?.status && !["passed", "failed"].includes(leaf.status) ? 1 : 0;
|
|
25
|
-
};
|
|
26
|
-
const calculateColorValue = ({ totalTests, passedTests }) => {
|
|
27
|
-
return totalTests > 0 ? passedTests / totalTests : 0;
|
|
28
|
-
};
|
|
29
|
-
const calculateSubtreeMetrics = (node) => {
|
|
30
|
-
if (!node.children || node.children.length === 0) {
|
|
31
|
-
return {
|
|
32
|
-
totalTests: 1,
|
|
33
|
-
passedTests: node?.status === "passed" ? 1 : 0,
|
|
34
|
-
failedTests: node?.status === "failed" ? 1 : 0,
|
|
35
|
-
otherTests: node?.status && !["passed", "failed"].includes(node.status) ? 1 : 0,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
let totalTests = 0;
|
|
39
|
-
let passedTests = 0;
|
|
40
|
-
let failedTests = 0;
|
|
41
|
-
let otherTests = 0;
|
|
42
|
-
for (const child of node.children) {
|
|
43
|
-
const childMetrics = calculateSubtreeMetrics(child);
|
|
44
|
-
totalTests += childMetrics.totalTests;
|
|
45
|
-
passedTests += childMetrics.passedTests;
|
|
46
|
-
failedTests += childMetrics.failedTests;
|
|
47
|
-
otherTests += childMetrics.otherTests;
|
|
48
|
-
}
|
|
49
|
-
return { totalTests, passedTests, failedTests, otherTests };
|
|
50
|
-
};
|
|
51
|
-
export const createSuccessRateDistributionTreeMap = (testResults) => {
|
|
52
|
-
const treeByLabels = createTreeByLabels(testResults, behaviorLabels, leafFactoryFn, groupFactoryFn, addLeafToGroupFn);
|
|
53
|
-
const convertedTree = convertTreeDataToTreeMapNode(treeByLabels, (node, isGroup) => {
|
|
54
|
-
const baseNode = {
|
|
55
|
-
id: node.name,
|
|
56
|
-
value: isGroup ? undefined : node.value,
|
|
57
|
-
};
|
|
58
|
-
if (isGroup) {
|
|
59
|
-
const group = node;
|
|
60
|
-
return {
|
|
61
|
-
...baseNode,
|
|
62
|
-
passedTests: group.passedTests,
|
|
63
|
-
failedTests: group.failedTests,
|
|
64
|
-
otherTests: group.otherTests,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const leaf = node;
|
|
69
|
-
return {
|
|
70
|
-
...baseNode,
|
|
71
|
-
status: leaf.status,
|
|
72
|
-
passedTests: leaf?.status === "passed" ? 1 : 0,
|
|
73
|
-
failedTests: leaf?.status === "failed" ? 1 : 0,
|
|
74
|
-
otherTests: leaf?.status && !["passed", "failed"].includes(leaf.status) ? 1 : 0,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}, () => ({
|
|
78
|
-
id: "root",
|
|
79
|
-
passedTests: 0,
|
|
80
|
-
failedTests: 0,
|
|
81
|
-
otherTests: 0,
|
|
82
|
-
}));
|
|
83
|
-
return transformTreeMapNode(convertedTree, (node) => {
|
|
84
|
-
const subtreeMetrics = calculateSubtreeMetrics(node);
|
|
85
|
-
const colorValue = calculateColorValue(subtreeMetrics);
|
|
86
|
-
const { totalTests, ...restSubtreeMetrics } = subtreeMetrics;
|
|
87
|
-
if (isChildrenLeavesOnly(node)) {
|
|
88
|
-
const value = node.children?.reduce((acc, child) => {
|
|
89
|
-
return acc + (child.value ?? 0);
|
|
90
|
-
}, 0);
|
|
91
|
-
return {
|
|
92
|
-
...node,
|
|
93
|
-
value,
|
|
94
|
-
children: undefined,
|
|
95
|
-
colorValue,
|
|
96
|
-
...restSubtreeMetrics,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
...node,
|
|
101
|
-
colorValue,
|
|
102
|
-
...restSubtreeMetrics,
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
export const successRateDistributionTreeMapAccessor = {
|
|
107
|
-
getTreeMap: ({ testResults }) => {
|
|
108
|
-
const testsWithBehaviorLabels = filterTestsWithBehaviorLabels(testResults);
|
|
109
|
-
return createSuccessRateDistributionTreeMap(testsWithBehaviorLabels);
|
|
110
|
-
},
|
|
111
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { HistoryTestResult, TestResult } from "@allurereport/core-api";
|
|
2
|
-
export type BehaviorLabel = "epic" | "feature" | "story";
|
|
3
|
-
export declare const behaviorLabels: BehaviorLabel[];
|
|
4
|
-
export declare const hasBehaviorLabels: <T extends TestResult | HistoryTestResult>(test: T) => boolean;
|
|
5
|
-
export declare const filterTestsWithBehaviorLabels: <T extends TestResult | HistoryTestResult>(tests: T[]) => T[];
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { hasLabels } from "../../../charts.js";
|
|
2
|
-
export const behaviorLabels = ["epic", "feature", "story"];
|
|
3
|
-
export const hasBehaviorLabels = (test) => hasLabels(test, behaviorLabels);
|
|
4
|
-
export const filterTestsWithBehaviorLabels = (tests) => tests.filter(hasBehaviorLabels);
|
package/dist/charts/bar.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { AllureChartsStoreData, BarChartData, BarChartOptions, BarDataAccessor } from "../charts.js";
|
|
2
|
-
export declare const generateBarChartGeneric: <P extends string, T extends string>(options: BarChartOptions, storeData: AllureChartsStoreData, dataAccessor: BarDataAccessor<P, T>) => BarChartData | undefined;
|
|
3
|
-
export declare const generateBarChart: (options: BarChartOptions, storeData: AllureChartsStoreData) => BarChartData | undefined;
|
package/dist/charts/bar.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { BarChartType, ChartMode } from "@allurereport/core-api";
|
|
2
|
-
import { DEFAULT_CHART_HISTORY_LIMIT, limitHistoryDataPoints } from "../charts.js";
|
|
3
|
-
import { statusBySeverityBarDataAccessor } from "./accessors/statusBySeverityBarAccessor.js";
|
|
4
|
-
import { statusChangeTrendBarAccessor } from "./accessors/statusChangeTrendBarAccessor.js";
|
|
5
|
-
import { statusTrendBarAccessor } from "./accessors/statusTrendBarAccessor.js";
|
|
6
|
-
export const generateBarChartGeneric = (options, storeData, dataAccessor) => {
|
|
7
|
-
const { type, dataType, title, limit = DEFAULT_CHART_HISTORY_LIMIT, mode = ChartMode.Raw } = options;
|
|
8
|
-
const { historyDataPoints } = storeData;
|
|
9
|
-
const limitedHistoryPoints = limitHistoryDataPoints(historyDataPoints, limit);
|
|
10
|
-
const isFullHistory = limitedHistoryPoints.length === historyDataPoints.length;
|
|
11
|
-
const items = dataAccessor.getItems(storeData, limitedHistoryPoints, isFullHistory);
|
|
12
|
-
let processedData = items;
|
|
13
|
-
if (mode === ChartMode.Percent) {
|
|
14
|
-
processedData = items.map((group) => {
|
|
15
|
-
const { groupId, ...values } = group;
|
|
16
|
-
const total = Object.values(values).reduce((sum, value) => sum + value, 0);
|
|
17
|
-
const nextValues = Object.keys(values).reduce((acc, valueKey) => {
|
|
18
|
-
acc[valueKey] = values[valueKey] / total;
|
|
19
|
-
return acc;
|
|
20
|
-
}, {});
|
|
21
|
-
return {
|
|
22
|
-
groupId,
|
|
23
|
-
...nextValues,
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
type,
|
|
29
|
-
dataType,
|
|
30
|
-
mode,
|
|
31
|
-
title,
|
|
32
|
-
data: processedData,
|
|
33
|
-
keys: dataAccessor.getGroupKeys(),
|
|
34
|
-
groupMode: dataAccessor.getGroupMode(),
|
|
35
|
-
indexBy: "groupId",
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export const generateBarChart = (options, storeData) => {
|
|
39
|
-
const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
|
|
40
|
-
const { dataType } = newOptions;
|
|
41
|
-
if (dataType === BarChartType.StatusBySeverity) {
|
|
42
|
-
return generateBarChartGeneric(newOptions, storeData, statusBySeverityBarDataAccessor);
|
|
43
|
-
}
|
|
44
|
-
else if (dataType === BarChartType.StatusTrend) {
|
|
45
|
-
return generateBarChartGeneric(newOptions, storeData, statusTrendBarAccessor);
|
|
46
|
-
}
|
|
47
|
-
else if (dataType === BarChartType.StatusChangeTrend) {
|
|
48
|
-
return generateBarChartGeneric(newOptions, storeData, statusChangeTrendBarAccessor);
|
|
49
|
-
}
|
|
50
|
-
};
|
package/dist/charts/heatmap.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { AllureChartsStoreData, HeatMapChartData, HeatMapChartOptions, HeatMapDataAccessor } from "../charts.js";
|
|
2
|
-
export declare const generateHeatMapChartGeneric: <T extends Record<string, unknown>>(options: HeatMapChartOptions, storeData: AllureChartsStoreData, dataAccessor: HeatMapDataAccessor<T>) => HeatMapChartData | undefined;
|
|
3
|
-
export declare const generateHeatMapChart: (options: HeatMapChartOptions, storeData: AllureChartsStoreData) => HeatMapChartData | undefined;
|
package/dist/charts/heatmap.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { problemsDistributionHeatMapAccessor } from "./accessors/problemsDistributionHeatMap.js";
|
|
2
|
-
export const generateHeatMapChartGeneric = (options, storeData, dataAccessor) => ({
|
|
3
|
-
type: options.type,
|
|
4
|
-
title: options.title,
|
|
5
|
-
data: dataAccessor.getHeatMap(storeData),
|
|
6
|
-
});
|
|
7
|
-
export const generateHeatMapChart = (options, storeData) => {
|
|
8
|
-
return generateHeatMapChartGeneric(options, storeData, problemsDistributionHeatMapAccessor);
|
|
9
|
-
};
|
package/dist/charts/line.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BaseTrendSliceMetadata } from "@allurereport/core-api";
|
|
2
|
-
import type { AllureChartsStoreData, GenericTrendChartData, TrendCalculationResult, TrendChartData, TrendChartOptions, TrendDataAccessor, TrendDataType } from "../charts.js";
|
|
3
|
-
import type { PluginContext } from "../plugin.js";
|
|
4
|
-
export declare const calculatePercentValues: <T extends TrendDataType>(stats: Record<T, number>, executionId: string, itemType: readonly T[]) => TrendCalculationResult<T>;
|
|
5
|
-
export declare const getTrendDataGeneric: <T extends TrendDataType, M extends BaseTrendSliceMetadata>(stats: Record<T, number>, reportName: string, executionOrder: number, itemType: readonly T[], chartOptions: TrendChartOptions) => GenericTrendChartData<T, M>;
|
|
6
|
-
export declare const mergeTrendDataGeneric: <T extends TrendDataType, M extends BaseTrendSliceMetadata>(trendData: GenericTrendChartData<T, M>, trendDataPart: GenericTrendChartData<T, M>, itemType: readonly T[]) => GenericTrendChartData<T, M>;
|
|
7
|
-
export declare const generateTrendChartGeneric: <T extends TrendDataType>(options: TrendChartOptions, storeData: AllureChartsStoreData, context: PluginContext, dataAccessor: TrendDataAccessor<T>) => GenericTrendChartData<T> | undefined;
|
|
8
|
-
export declare const generateTrendChart: (options: TrendChartOptions, storeData: AllureChartsStoreData, context: PluginContext) => TrendChartData | undefined;
|
package/dist/charts/line.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { ChartDataType, ChartMode } from "@allurereport/core-api";
|
|
2
|
-
import { DEFAULT_CHART_HISTORY_LIMIT, createEmptySeries, normalizeStatistic } from "../charts.js";
|
|
3
|
-
import { severityTrendDataAccessor } from "./accessors/severityTrendAccessor.js";
|
|
4
|
-
import { statusTrendDataAccessor } from "./accessors/statusTrendAccessor.js";
|
|
5
|
-
export const calculatePercentValues = (stats, executionId, itemType) => {
|
|
6
|
-
const points = {};
|
|
7
|
-
const series = createEmptySeries(itemType);
|
|
8
|
-
const values = Object.values(stats);
|
|
9
|
-
const total = values.reduce((sum, value) => sum + value, 0);
|
|
10
|
-
if (total === 0) {
|
|
11
|
-
return { points, series };
|
|
12
|
-
}
|
|
13
|
-
itemType.forEach((item) => {
|
|
14
|
-
const pointId = `${executionId}-${item}`;
|
|
15
|
-
const value = stats[item] ?? 0;
|
|
16
|
-
points[pointId] = {
|
|
17
|
-
x: executionId,
|
|
18
|
-
y: value / total,
|
|
19
|
-
};
|
|
20
|
-
series[item].push(pointId);
|
|
21
|
-
});
|
|
22
|
-
return { points, series };
|
|
23
|
-
};
|
|
24
|
-
const calculateRawValues = (stats, executionId, itemType) => {
|
|
25
|
-
const points = {};
|
|
26
|
-
const series = createEmptySeries(itemType);
|
|
27
|
-
itemType.forEach((item) => {
|
|
28
|
-
const pointId = `${executionId}-${item}`;
|
|
29
|
-
const value = stats[item] ?? 0;
|
|
30
|
-
points[pointId] = {
|
|
31
|
-
x: executionId,
|
|
32
|
-
y: value,
|
|
33
|
-
};
|
|
34
|
-
series[item].push(pointId);
|
|
35
|
-
});
|
|
36
|
-
return { points, series };
|
|
37
|
-
};
|
|
38
|
-
export const getTrendDataGeneric = (stats, reportName, executionOrder, itemType, chartOptions) => {
|
|
39
|
-
const { type, dataType, title, mode = ChartMode.Raw, metadata = {} } = chartOptions;
|
|
40
|
-
const { executionIdAccessor, executionNameAccessor } = metadata;
|
|
41
|
-
const executionId = executionIdAccessor ? executionIdAccessor(executionOrder) : `execution-${executionOrder}`;
|
|
42
|
-
const { points, series } = mode === ChartMode.Percent
|
|
43
|
-
? calculatePercentValues(stats, executionId, itemType)
|
|
44
|
-
: calculateRawValues(stats, executionId, itemType);
|
|
45
|
-
const slices = {};
|
|
46
|
-
const pointsAsArray = Object.values(points);
|
|
47
|
-
const pointsCount = pointsAsArray.length;
|
|
48
|
-
const values = pointsAsArray.map((point) => point.y);
|
|
49
|
-
const min = pointsCount ? Math.min(...values) : 0;
|
|
50
|
-
const max = pointsCount ? Math.max(...values) : 0;
|
|
51
|
-
if (pointsCount > 0) {
|
|
52
|
-
const executionName = executionNameAccessor ? executionNameAccessor(executionOrder) : reportName;
|
|
53
|
-
slices[executionId] = {
|
|
54
|
-
min,
|
|
55
|
-
max,
|
|
56
|
-
metadata: {
|
|
57
|
-
executionId,
|
|
58
|
-
executionName,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
type,
|
|
64
|
-
dataType,
|
|
65
|
-
mode,
|
|
66
|
-
title,
|
|
67
|
-
points,
|
|
68
|
-
slices,
|
|
69
|
-
series,
|
|
70
|
-
min,
|
|
71
|
-
max,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export const mergeTrendDataGeneric = (trendData, trendDataPart, itemType) => {
|
|
75
|
-
return {
|
|
76
|
-
...trendData,
|
|
77
|
-
points: {
|
|
78
|
-
...trendData.points,
|
|
79
|
-
...trendDataPart.points,
|
|
80
|
-
},
|
|
81
|
-
slices: {
|
|
82
|
-
...trendData.slices,
|
|
83
|
-
...trendDataPart.slices,
|
|
84
|
-
},
|
|
85
|
-
series: Object.entries(trendDataPart.series).reduce((series, [group, pointIds]) => {
|
|
86
|
-
if (Array.isArray(pointIds)) {
|
|
87
|
-
return {
|
|
88
|
-
...series,
|
|
89
|
-
[group]: [...(trendData.series?.[group] || []), ...pointIds],
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return series;
|
|
93
|
-
}, trendData.series || createEmptySeries(itemType)),
|
|
94
|
-
min: Math.min(trendData.min ?? Infinity, trendDataPart.min),
|
|
95
|
-
max: Math.max(trendData.max ?? -Infinity, trendDataPart.max),
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
export const generateTrendChartGeneric = (options, storeData, context, dataAccessor) => {
|
|
99
|
-
const { limit } = options;
|
|
100
|
-
const historyLimit = limit && limit > 0 ? Math.max(0, limit - 1) : undefined;
|
|
101
|
-
const { historyDataPoints } = storeData;
|
|
102
|
-
const currentData = dataAccessor.getCurrentData(storeData);
|
|
103
|
-
const limitedHistoryPoints = historyLimit !== undefined ? historyDataPoints.slice(-historyLimit) : historyDataPoints;
|
|
104
|
-
const firstOriginalIndex = historyLimit !== undefined ? Math.max(0, historyDataPoints.length - historyLimit) : 0;
|
|
105
|
-
const convertedHistoryPoints = limitedHistoryPoints.map((point, index) => {
|
|
106
|
-
const originalIndex = firstOriginalIndex + index;
|
|
107
|
-
return {
|
|
108
|
-
name: point.name,
|
|
109
|
-
originalIndex,
|
|
110
|
-
statistic: dataAccessor.getHistoricalData(point),
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
const allValues = dataAccessor.getAllValues();
|
|
114
|
-
const currentTrendData = getTrendDataGeneric(normalizeStatistic(currentData, allValues), context.reportName, historyDataPoints.length + 1, allValues, options);
|
|
115
|
-
const historicalTrendData = convertedHistoryPoints.reduce((acc, historyPoint) => {
|
|
116
|
-
const trendDataPart = getTrendDataGeneric(normalizeStatistic(historyPoint.statistic, allValues), historyPoint.name, historyPoint.originalIndex + 1, allValues, options);
|
|
117
|
-
return mergeTrendDataGeneric(acc, trendDataPart, allValues);
|
|
118
|
-
}, {
|
|
119
|
-
type: options.type,
|
|
120
|
-
dataType: options.dataType,
|
|
121
|
-
mode: options.mode,
|
|
122
|
-
title: options.title,
|
|
123
|
-
points: {},
|
|
124
|
-
slices: {},
|
|
125
|
-
series: createEmptySeries(allValues),
|
|
126
|
-
min: Infinity,
|
|
127
|
-
max: -Infinity,
|
|
128
|
-
});
|
|
129
|
-
return mergeTrendDataGeneric(historicalTrendData, currentTrendData, allValues);
|
|
130
|
-
};
|
|
131
|
-
export const generateTrendChart = (options, storeData, context) => {
|
|
132
|
-
const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
|
|
133
|
-
const { dataType } = newOptions;
|
|
134
|
-
if (dataType === ChartDataType.Status) {
|
|
135
|
-
return generateTrendChartGeneric(newOptions, storeData, context, statusTrendDataAccessor);
|
|
136
|
-
}
|
|
137
|
-
else if (dataType === ChartDataType.Severity) {
|
|
138
|
-
return generateTrendChartGeneric(newOptions, storeData, context, severityTrendDataAccessor);
|
|
139
|
-
}
|
|
140
|
-
};
|
package/dist/charts/pie.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Statistic } from "@allurereport/core-api";
|
|
2
|
-
import type { PieChartData, PieChartOptions } from "../charts.js";
|
|
3
|
-
export declare const getPieChartData: (stats: Statistic, chartOptions: PieChartOptions) => PieChartData;
|
|
4
|
-
export declare const generatePieChart: (options: PieChartOptions, stores: {
|
|
5
|
-
statistic: Statistic;
|
|
6
|
-
}) => PieChartData;
|
package/dist/charts/pie.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getPieChartValues } from "@allurereport/core-api";
|
|
2
|
-
export const getPieChartData = (stats, chartOptions) => ({
|
|
3
|
-
type: chartOptions.type,
|
|
4
|
-
title: chartOptions?.title,
|
|
5
|
-
...getPieChartValues(stats),
|
|
6
|
-
});
|
|
7
|
-
export const generatePieChart = (options, stores) => {
|
|
8
|
-
const { statistic } = stores;
|
|
9
|
-
return getPieChartData(statistic, options);
|
|
10
|
-
};
|
package/dist/charts/treeMap.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TreeData, TreeGroup, TreeLeaf, TreeMapNode, WithChildren } from "@allurereport/core-api";
|
|
2
|
-
import type { AllureChartsStoreData, TreeMapChartData, TreeMapChartOptions, TreeMapDataAccessor } from "../charts.js";
|
|
3
|
-
export declare const convertTreeDataToTreeMapNode: <T extends TreeMapNode, L, G>(treeData: TreeData<L, G>, transform: (treeDataNode: TreeLeaf<L> | TreeGroup<G>, isGroup: boolean, parentNode?: TreeGroup<G>) => T, transformRoot?: (root: WithChildren) => T) => T;
|
|
4
|
-
export declare const transformTreeMapNode: <T extends TreeMapNode>(tree: T, transform: (node: T) => T) => T;
|
|
5
|
-
export declare const generateTreeMapChartGeneric: <T extends TreeMapNode>(options: TreeMapChartOptions, storeData: AllureChartsStoreData, dataAccessor: TreeMapDataAccessor<T>) => TreeMapChartData | undefined;
|
|
6
|
-
export declare const generateTreeMapChart: (options: TreeMapChartOptions, storeData: AllureChartsStoreData) => TreeMapChartData | undefined;
|
package/dist/charts/treeMap.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { TreeMapChartType } from "@allurereport/core-api";
|
|
2
|
-
import { coverageDiffTreeMapAccessor } from "./accessors/coverageDiffTreeMapAccessor.js";
|
|
3
|
-
import { successRateDistributionTreeMapAccessor } from "./accessors/successRateDistributionTreeMapAccessor.js";
|
|
4
|
-
export const convertTreeDataToTreeMapNode = (treeData, transform, transformRoot = () => ({
|
|
5
|
-
id: "root",
|
|
6
|
-
value: undefined,
|
|
7
|
-
})) => {
|
|
8
|
-
const { root, leavesById, groupsById } = treeData;
|
|
9
|
-
const convertNode = (nodeId, parentGroup, isGroup) => {
|
|
10
|
-
const node = isGroup ? groupsById[nodeId] : leavesById[nodeId];
|
|
11
|
-
if (!node) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const treeMapNode = transform(node, isGroup, parentGroup);
|
|
15
|
-
if (isGroup) {
|
|
16
|
-
const group = node;
|
|
17
|
-
const children = [];
|
|
18
|
-
if (group.groups) {
|
|
19
|
-
group.groups.forEach((groupId) => {
|
|
20
|
-
const childNode = convertNode(groupId, group, true);
|
|
21
|
-
if (childNode) {
|
|
22
|
-
children.push(childNode);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (group.leaves) {
|
|
27
|
-
group.leaves.forEach((leafId) => {
|
|
28
|
-
const childNode = convertNode(leafId, group, false);
|
|
29
|
-
if (childNode) {
|
|
30
|
-
children.push(childNode);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (children.length === 0) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
treeMapNode.children = children;
|
|
38
|
-
}
|
|
39
|
-
return treeMapNode;
|
|
40
|
-
};
|
|
41
|
-
const rootChildren = [];
|
|
42
|
-
if (root.groups) {
|
|
43
|
-
root.groups.forEach((groupId) => {
|
|
44
|
-
const childNode = convertNode(groupId, root, true);
|
|
45
|
-
if (childNode) {
|
|
46
|
-
rootChildren.push(childNode);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (root.leaves) {
|
|
51
|
-
root.leaves.forEach((leafId) => {
|
|
52
|
-
const childNode = convertNode(leafId, root, false);
|
|
53
|
-
if (childNode) {
|
|
54
|
-
rootChildren.push(childNode);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
children: rootChildren.length > 0 ? rootChildren : undefined,
|
|
60
|
-
...transformRoot(root),
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export const transformTreeMapNode = (tree, transform) => {
|
|
64
|
-
const transformedNode = transform(tree);
|
|
65
|
-
if (transformedNode.children) {
|
|
66
|
-
const transformedChildren = transformedNode.children.map((child) => transformTreeMapNode(child, transform));
|
|
67
|
-
return {
|
|
68
|
-
...transformedNode,
|
|
69
|
-
children: transformedChildren,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return transformedNode;
|
|
73
|
-
};
|
|
74
|
-
export const generateTreeMapChartGeneric = (options, storeData, dataAccessor) => ({
|
|
75
|
-
type: options.type,
|
|
76
|
-
dataType: options.dataType,
|
|
77
|
-
title: options.title,
|
|
78
|
-
treeMap: dataAccessor.getTreeMap(storeData),
|
|
79
|
-
});
|
|
80
|
-
export const generateTreeMapChart = (options, storeData) => {
|
|
81
|
-
const { dataType } = options;
|
|
82
|
-
if (dataType === TreeMapChartType.SuccessRateDistribution) {
|
|
83
|
-
return generateTreeMapChartGeneric(options, storeData, successRateDistributionTreeMapAccessor);
|
|
84
|
-
}
|
|
85
|
-
else if (dataType === TreeMapChartType.CoverageDiff) {
|
|
86
|
-
return generateTreeMapChartGeneric(options, storeData, coverageDiffTreeMapAccessor);
|
|
87
|
-
}
|
|
88
|
-
};
|
package/dist/charts.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { BarChartType, BarGroup, BarGroupMode, BaseTrendSliceMetadata, ChartDataType, ChartId, ChartMode, ChartType, HeatMapSerie, HistoryDataPoint, HistoryTestResult, PieSlice, SeverityLevel, Statistic, TestResult, TestStatus, TreeMapChartType, TreeMapNode, TrendPoint, TrendPointId, TrendSlice, TrendSliceId } from "@allurereport/core-api";
|
|
2
|
-
export type ExecutionIdFn = (executionOrder: number) => string;
|
|
3
|
-
export type ExecutionNameFn = (executionOrder: number) => string;
|
|
4
|
-
export type TrendMetadataFnOverrides = {
|
|
5
|
-
executionIdAccessor?: ExecutionIdFn;
|
|
6
|
-
executionNameAccessor?: ExecutionNameFn;
|
|
7
|
-
};
|
|
8
|
-
export type TrendDataType = TestStatus | SeverityLevel;
|
|
9
|
-
export type TrendStats<T extends TrendDataType> = Record<T, number>;
|
|
10
|
-
export type TrendCalculationResult<T extends TrendDataType> = {
|
|
11
|
-
points: Record<TrendPointId, TrendPoint>;
|
|
12
|
-
series: Record<T, TrendPointId[]>;
|
|
13
|
-
};
|
|
14
|
-
export interface GenericTrendChartData<SeriesType extends string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> {
|
|
15
|
-
type: ChartType.Trend;
|
|
16
|
-
dataType: ChartDataType;
|
|
17
|
-
mode: ChartMode;
|
|
18
|
-
title?: string;
|
|
19
|
-
points: Record<TrendPointId, TrendPoint>;
|
|
20
|
-
slices: Record<TrendSliceId, TrendSlice<Metadata>>;
|
|
21
|
-
series: Record<SeriesType, TrendPointId[]>;
|
|
22
|
-
min: number;
|
|
23
|
-
max: number;
|
|
24
|
-
}
|
|
25
|
-
export type StatusTrendChartData = GenericTrendChartData<TestStatus>;
|
|
26
|
-
export type SeverityTrendChartData = GenericTrendChartData<SeverityLevel>;
|
|
27
|
-
export type TrendChartData = StatusTrendChartData | SeverityTrendChartData;
|
|
28
|
-
export interface BarChartData {
|
|
29
|
-
type: ChartType.Bar;
|
|
30
|
-
dataType: BarChartType;
|
|
31
|
-
mode: ChartMode;
|
|
32
|
-
title?: string;
|
|
33
|
-
data: BarGroup<string, string>[];
|
|
34
|
-
keys: readonly string[];
|
|
35
|
-
indexBy: string;
|
|
36
|
-
groupMode: BarGroupMode;
|
|
37
|
-
}
|
|
38
|
-
export interface TreeMapChartData {
|
|
39
|
-
type: ChartType.TreeMap;
|
|
40
|
-
dataType: TreeMapChartType;
|
|
41
|
-
title?: string;
|
|
42
|
-
treeMap: TreeMapNode;
|
|
43
|
-
}
|
|
44
|
-
export interface HeatMapChartData<T extends Record<string, any> = {}> {
|
|
45
|
-
type: ChartType.HeatMap;
|
|
46
|
-
title?: string;
|
|
47
|
-
data: HeatMapSerie<T>[];
|
|
48
|
-
}
|
|
49
|
-
export interface PieChartData {
|
|
50
|
-
type: ChartType.Pie;
|
|
51
|
-
title?: string;
|
|
52
|
-
slices: PieSlice[];
|
|
53
|
-
percentage: number;
|
|
54
|
-
}
|
|
55
|
-
export interface ComingSoonChartData {
|
|
56
|
-
type: ChartType.ComingSoon;
|
|
57
|
-
title?: string;
|
|
58
|
-
}
|
|
59
|
-
export type GeneratedChartData = TrendChartData | PieChartData | BarChartData | ComingSoonChartData | TreeMapChartData | HeatMapChartData;
|
|
60
|
-
export type GeneratedChartsData = Record<ChartId, GeneratedChartData>;
|
|
61
|
-
export type TrendChartOptions = {
|
|
62
|
-
type: ChartType.Trend;
|
|
63
|
-
dataType: ChartDataType;
|
|
64
|
-
mode?: ChartMode;
|
|
65
|
-
title?: string;
|
|
66
|
-
limit?: number;
|
|
67
|
-
metadata?: TrendMetadataFnOverrides;
|
|
68
|
-
};
|
|
69
|
-
export type PieChartOptions = {
|
|
70
|
-
type: ChartType.Pie;
|
|
71
|
-
title?: string;
|
|
72
|
-
};
|
|
73
|
-
export type BarChartOptions = {
|
|
74
|
-
type: ChartType.Bar;
|
|
75
|
-
dataType: BarChartType;
|
|
76
|
-
mode?: ChartMode;
|
|
77
|
-
title?: string;
|
|
78
|
-
limit?: number;
|
|
79
|
-
};
|
|
80
|
-
export type TreeMapChartOptions = {
|
|
81
|
-
type: ChartType.TreeMap;
|
|
82
|
-
dataType: TreeMapChartType;
|
|
83
|
-
title?: string;
|
|
84
|
-
};
|
|
85
|
-
export type HeatMapChartOptions = {
|
|
86
|
-
type: ChartType.HeatMap;
|
|
87
|
-
title?: string;
|
|
88
|
-
};
|
|
89
|
-
export type ComingSoonChartOptions = {
|
|
90
|
-
type: ChartType.ComingSoon;
|
|
91
|
-
title?: string;
|
|
92
|
-
};
|
|
93
|
-
export type ChartOptions = TrendChartOptions | PieChartOptions | BarChartOptions | ComingSoonChartOptions | TreeMapChartOptions | HeatMapChartOptions;
|
|
94
|
-
export interface AllureChartsStoreData {
|
|
95
|
-
historyDataPoints: HistoryDataPoint[];
|
|
96
|
-
testResults: TestResult[];
|
|
97
|
-
statistic: Statistic;
|
|
98
|
-
}
|
|
99
|
-
export interface TrendDataAccessor<T extends TrendDataType> {
|
|
100
|
-
getCurrentData: (storeData: AllureChartsStoreData) => TrendStats<T>;
|
|
101
|
-
getHistoricalData: (historyPoint: HistoryDataPoint) => TrendStats<T>;
|
|
102
|
-
getAllValues: () => readonly T[];
|
|
103
|
-
}
|
|
104
|
-
export interface BarDataAccessor<G extends string, T extends string> {
|
|
105
|
-
getItems: (storeData: AllureChartsStoreData, limitedHistoryDataPoints: HistoryDataPoint[], isFullHistory: boolean) => BarGroup<G, T>[];
|
|
106
|
-
getGroupKeys: () => readonly T[];
|
|
107
|
-
getGroupMode: () => BarGroupMode;
|
|
108
|
-
}
|
|
109
|
-
export interface TreeMapDataAccessor<T extends TreeMapNode> {
|
|
110
|
-
getTreeMap: (storeData: AllureChartsStoreData) => T;
|
|
111
|
-
}
|
|
112
|
-
export interface HeatMapDataAccessor<T extends Record<string, unknown> = {}> {
|
|
113
|
-
getHeatMap: (storeData: AllureChartsStoreData) => HeatMapSerie<T>[];
|
|
114
|
-
}
|
|
115
|
-
export declare const DEFAULT_CHART_HISTORY_LIMIT = 10;
|
|
116
|
-
export declare const limitHistoryDataPoints: (historyDataPoints: HistoryDataPoint[], limit: number) => HistoryDataPoint[];
|
|
117
|
-
export declare const createEmptySeries: <T extends string>(items: readonly T[]) => Record<T, string[]>;
|
|
118
|
-
export declare const createEmptyStats: <T extends string>(items: readonly T[]) => Record<T, number>;
|
|
119
|
-
export declare const normalizeStatistic: <T extends string>(statistic: Partial<Record<T, number>>, itemType: readonly T[]) => Record<T, number>;
|
|
120
|
-
export declare const hasLabels: <T extends string, TR extends TestResult | HistoryTestResult>(test: TR, labelHierarchy: T[]) => boolean;
|
|
121
|
-
export declare const isChildrenLeavesOnly: <T extends TreeMapNode>(node: T) => boolean;
|
|
122
|
-
export declare const defaultChartsConfig: ({
|
|
123
|
-
type: string;
|
|
124
|
-
title: string;
|
|
125
|
-
dataType?: undefined;
|
|
126
|
-
} | {
|
|
127
|
-
type: string;
|
|
128
|
-
dataType: string;
|
|
129
|
-
title: string;
|
|
130
|
-
})[];
|