@allurereport/plugin-dashboard 3.0.0-beta.14 → 3.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,7 +66,7 @@ Trend charts allow you to track metrics over time. Available configurations:
66
66
  type: "trend",
67
67
  dataType: "status",
68
68
  mode: "percent", // optional, default: "raw"
69
- limit: 10, // optional: limit number of builds
69
+ limit: 10, // optional: limit number of builds, default: 10
70
70
  title: "Custom Status Trend", // optional
71
71
  metadata: { // optional
72
72
  executionIdAccessor: (executionOrder) => `build-${executionOrder}`,
@@ -35,6 +35,7 @@ export const getSeverityTrendData = (testResults, reportName, historyPoints, cha
35
35
  }, {
36
36
  type: chartOptions.type,
37
37
  dataType: chartOptions.dataType,
38
+ mode: chartOptions.mode,
38
39
  title: chartOptions.title,
39
40
  points: {},
40
41
  slices: {},
@@ -26,6 +26,7 @@ export const getStatusTrendData = (currentStatistic, reportName, historyPoints,
26
26
  }, {
27
27
  type: chartOptions.type,
28
28
  dataType: chartOptions.dataType,
29
+ mode: chartOptions.mode,
29
30
  title: chartOptions.title,
30
31
  points: {},
31
32
  slices: {},
@@ -1,4 +1,4 @@
1
- import { createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, } from "@allurereport/web-commons";
1
+ import { DEFAULT_CHART_HISTORY_LIMIT, createBaseUrlScript, createFontLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, } from "@allurereport/web-commons";
2
2
  import { randomUUID } from "crypto";
3
3
  import Handlebars from "handlebars";
4
4
  import { readFile } from "node:fs/promises";
@@ -51,13 +51,14 @@ export const readTemplateManifest = async (singleFileMode) => {
51
51
  return JSON.parse(templateManifest);
52
52
  };
53
53
  const generateTrendChart = (options, stores, context) => {
54
- const { dataType } = options;
54
+ const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
55
+ const { dataType } = newOptions;
55
56
  const { statistic, historyDataPoints, testResults } = stores;
56
57
  if (dataType === ChartData.Status) {
57
- return getStatusTrendData(statistic, context.reportName, historyDataPoints, options);
58
+ return getStatusTrendData(statistic, context.reportName, historyDataPoints, newOptions);
58
59
  }
59
60
  else if (dataType === ChartData.Severity) {
60
- return getSeverityTrendData(testResults, context.reportName, historyDataPoints, options);
61
+ return getSeverityTrendData(testResults, context.reportName, historyDataPoints, newOptions);
61
62
  }
62
63
  };
63
64
  const generatePieChart = (options, stores) => {
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export type { DashboardPluginOptions } from "./model.js";
1
2
  export { DashboardPlugin as default } from "./plugin.js";
package/dist/model.d.ts CHANGED
@@ -7,7 +7,10 @@ export declare enum ChartData {
7
7
  Status = "status",
8
8
  Severity = "severity"
9
9
  }
10
- export type ChartMode = "raw" | "percent";
10
+ export declare enum ChartMode {
11
+ Raw = "raw",
12
+ Percent = "percent"
13
+ }
11
14
  export type ChartId = string;
12
15
  export type ExecutionIdFn = (executionOrder: number) => string;
13
16
  export type ExecutionNameFn = (executionOrder: number) => string;
@@ -43,6 +46,7 @@ export type TrendSlice<Metadata extends BaseMetadata> = {
43
46
  export type GenericTrendChartData<Metadata extends BaseMetadata, SeriesType extends string> = {
44
47
  type: ChartType.Trend;
45
48
  dataType: ChartData;
49
+ mode: ChartMode;
46
50
  title?: string;
47
51
  points: Record<TrendPointId, TrendPoint>;
48
52
  slices: Record<TrendSliceId, TrendSlice<Metadata>>;
package/dist/model.js CHANGED
@@ -8,3 +8,8 @@ export var ChartData;
8
8
  ChartData["Status"] = "status";
9
9
  ChartData["Severity"] = "severity";
10
10
  })(ChartData || (ChartData = {}));
11
+ export var ChartMode;
12
+ (function (ChartMode) {
13
+ ChartMode["Raw"] = "raw";
14
+ ChartMode["Percent"] = "percent";
15
+ })(ChartMode || (ChartMode = {}));
@@ -1,5 +1,5 @@
1
1
  import type { SeverityLevel, TestStatus } from "@allurereport/core-api";
2
- import type { BaseTrendSliceMetadata, GenericTrendChartData, TrendChartOptions } from "../model.js";
2
+ import { type BaseTrendSliceMetadata, type GenericTrendChartData, type TrendChartOptions } from "../model.js";
3
3
  type TrendDataType = TestStatus | SeverityLevel;
4
4
  export declare const createEmptyStats: <T extends TrendDataType>(items: readonly T[]) => Record<T, number>;
5
5
  export declare const createEmptySeries: <T extends TrendDataType>(items: readonly T[]) => Record<T, string[]>;
@@ -1,3 +1,4 @@
1
+ import { ChartMode, } from "../model.js";
1
2
  export const createEmptyStats = (items) => items.reduce((acc, item) => ({ ...acc, [item]: 0 }), {});
2
3
  export const createEmptySeries = (items) => items.reduce((acc, item) => ({ ...acc, [item]: [] }), {});
3
4
  export const normalizeStatistic = (statistic, itemType) => {
@@ -33,7 +34,7 @@ const calculatePercentValues = (stats, executionId, itemType) => {
33
34
  const value = stats[item] ?? 0;
34
35
  points[pointId] = {
35
36
  x: executionId,
36
- y: (value / total) * 100,
37
+ y: value / total,
37
38
  };
38
39
  series[item].push(pointId);
39
40
  });
@@ -64,10 +65,10 @@ export const mergeTrendDataGeneric = (trendData, trendDataPart, itemType) => {
64
65
  };
65
66
  };
66
67
  export const getTrendDataGeneric = (stats, reportName, executionOrder, itemType, chartOptions) => {
67
- const { type, dataType, title, mode = "raw", metadata = {} } = chartOptions;
68
+ const { type, dataType, title, mode = ChartMode.Raw, metadata = {} } = chartOptions;
68
69
  const { executionIdAccessor, executionNameAccessor } = metadata;
69
70
  const executionId = executionIdAccessor ? executionIdAccessor(executionOrder) : `execution-${executionOrder}`;
70
- const { points, series } = mode === "percent"
71
+ const { points, series } = mode === ChartMode.Percent
71
72
  ? calculatePercentValues(stats, executionId, itemType)
72
73
  : calculateRawValues(stats, executionId, itemType);
73
74
  const slices = {};
@@ -90,6 +91,7 @@ export const getTrendDataGeneric = (stats, reportName, executionOrder, itemType,
90
91
  return {
91
92
  type,
92
93
  dataType,
94
+ mode,
93
95
  title,
94
96
  points,
95
97
  slices,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-dashboard",
3
- "version": "3.0.0-beta.14",
3
+ "version": "3.0.0-beta.16",
4
4
  "description": "Allure Dashboard Plugin – plugin for generating dashboard with a mix of charts",
5
5
  "keywords": [
6
6
  "allure",
@@ -32,10 +32,10 @@
32
32
  "test": "rimraf ./out && vitest run"
33
33
  },
34
34
  "dependencies": {
35
- "@allurereport/core-api": "3.0.0-beta.14",
36
- "@allurereport/plugin-api": "3.0.0-beta.14",
37
- "@allurereport/web-commons": "3.0.0-beta.14",
38
- "@allurereport/web-dashboard": "3.0.0-beta.14",
35
+ "@allurereport/core-api": "3.0.0-beta.16",
36
+ "@allurereport/plugin-api": "3.0.0-beta.16",
37
+ "@allurereport/web-commons": "3.0.0-beta.16",
38
+ "@allurereport/web-dashboard": "3.0.0-beta.16",
39
39
  "d3-shape": "^3.2.0",
40
40
  "handlebars": "^4.7.8"
41
41
  },
@@ -46,7 +46,7 @@
46
46
  "@types/node": "^20.17.9",
47
47
  "@typescript-eslint/eslint-plugin": "^8.0.0",
48
48
  "@typescript-eslint/parser": "^8.0.0",
49
- "@vitest/runner": "^2.1.8",
49
+ "@vitest/runner": "^2.1.9",
50
50
  "allure-vitest": "^3.0.9",
51
51
  "eslint": "^8.57.0",
52
52
  "eslint-config-prettier": "^9.1.0",
@@ -57,6 +57,6 @@
57
57
  "eslint-plugin-prefer-arrow": "^1.2.3",
58
58
  "rimraf": "^6.0.1",
59
59
  "typescript": "^5.6.3",
60
- "vitest": "^2.1.8"
60
+ "vitest": "^2.1.9"
61
61
  }
62
62
  }