@allurereport/web-commons 3.0.0-beta.25 → 3.0.0-beta.26

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.
@@ -0,0 +1,6 @@
1
+ import type { AllureChartsStoreData, StatusDynamicsChartOptions } from "@allurereport/charts-api";
2
+ import type { StatusDynamicsChartData } from "./types.js";
3
+ export declare const generateStatusDynamicsChart: (props: {
4
+ options: StatusDynamicsChartOptions;
5
+ storeData: AllureChartsStoreData;
6
+ }) => StatusDynamicsChartData;
@@ -0,0 +1,36 @@
1
+ import { ChartType, DEFAULT_CHART_HISTORY_LIMIT } from "@allurereport/charts-api";
2
+ import { emptyStatistic, incrementStatistic, statusesList } from "@allurereport/core-api";
3
+ import { limitHistoryDataPoints } from "./chart-utils.js";
4
+ export const generateStatusDynamicsChart = (props) => {
5
+ const { options, storeData } = props;
6
+ const { limit = DEFAULT_CHART_HISTORY_LIMIT, statuses = statusesList } = options;
7
+ const { historyDataPoints, testResults } = storeData;
8
+ const limitMinusCurrent = limit > 1 ? limit - 1 : limit;
9
+ const limitedHistoryPoints = limitHistoryDataPoints(historyDataPoints, limitMinusCurrent).sort((a, b) => a.timestamp - b.timestamp);
10
+ const latestStop = testResults.reduce((acc, testResult) => Math.max(acc, testResult.stop ?? 0), 0);
11
+ const historyData = limitedHistoryPoints.map((point) => {
12
+ const statistic = emptyStatistic();
13
+ for (const testResult of Object.values(point.testResults)) {
14
+ incrementStatistic(statistic, testResult.status);
15
+ }
16
+ return {
17
+ name: point.name,
18
+ statistic: statuses.reduce((acc, status) => {
19
+ acc[status] = statistic[status];
20
+ return acc;
21
+ }, { total: statistic.total }),
22
+ id: point.uuid,
23
+ timestamp: point.timestamp,
24
+ };
25
+ });
26
+ const currentStatistic = statuses.reduce((acc, status) => {
27
+ acc[status] = storeData.statistic[status];
28
+ return acc;
29
+ }, { total: storeData.statistic.total });
30
+ return {
31
+ type: ChartType.StatusDynamics,
32
+ title: options.title,
33
+ data: [...historyData, { statistic: currentStatistic, id: "current", timestamp: latestStop, name: "current" }],
34
+ statuses: options.statuses,
35
+ };
36
+ };
@@ -4,6 +4,7 @@ import { generateBarChart } from "./bar.js";
4
4
  import { generateComingSoonChart } from "./comingSoon.js";
5
5
  import { generateFunnelChart } from "./funnel/index.js";
6
6
  import { generateCurrentStatusChart } from "./generateCurrentStatusChart.js";
7
+ import { generateStatusDynamicsChart } from "./generateStatusDynamicsChart.js";
7
8
  import { generateHeatMapChart } from "./heatMap.js";
8
9
  import { generateTrendChart } from "./line.js";
9
10
  import { generateTreeMapChart } from "./treeMap.js";
@@ -28,6 +29,9 @@ const generateChartData = async (props) => {
28
29
  case ChartType.CurrentStatus:
29
30
  result[chartId] = generateCurrentStatusChart(chartOption, storeData);
30
31
  break;
32
+ case ChartType.StatusDynamics:
33
+ result[chartId] = generateStatusDynamicsChart({ options: chartOption, storeData });
34
+ break;
31
35
  case ChartType.Bar:
32
36
  result[chartId] = generateBarChart(chartOption, storeData);
33
37
  break;
@@ -28,6 +28,18 @@ export interface CurrentStatusChartData {
28
28
  statuses?: TestStatus[];
29
29
  metric?: TestStatus;
30
30
  }
31
+ export interface StatusDynamicsChartData {
32
+ type: ChartType.StatusDynamics;
33
+ title?: string;
34
+ data: {
35
+ statistic: Statistic;
36
+ id: string;
37
+ timestamp: number;
38
+ name: string;
39
+ }[];
40
+ limit?: number;
41
+ statuses?: TestStatus[];
42
+ }
31
43
  export interface ResponseBarChartData {
32
44
  type: ChartType.Bar;
33
45
  dataType: BarChartType;
@@ -70,6 +82,7 @@ export interface UITrendChartData<Metadata extends BaseTrendSliceMetadata = Base
70
82
  title?: string;
71
83
  }
72
84
  export type UICurrentStatusChartData = CurrentStatusChartData;
85
+ export type UIStatusDynamicsChartData = StatusDynamicsChartData;
73
86
  export interface UIBarChartData extends ResponseBarChartData {
74
87
  colors: Record<string, string>;
75
88
  xAxisConfig?: {
@@ -109,8 +122,8 @@ export interface ResponseTestingPyramidChartData {
109
122
  percentage: number;
110
123
  }[];
111
124
  }
112
- export type ChartData<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = ResponseTrendChartData<SeriesType, Metadata> | CurrentStatusChartData | ResponseBarChartData | ResponseComingSoonChartData | ResponseTreeMapChartData | ResponseHeatMapChartData | ResponseTestingPyramidChartData;
113
- export type UIChartData<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = UITrendChartData<Metadata> | UICurrentStatusChartData | UIBarChartData | UIComingSoonChartData | UITreeMapChartData | UIHeatMapChartData | UITestingPyramidChartData;
125
+ export type ChartData<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = ResponseTrendChartData<SeriesType, Metadata> | CurrentStatusChartData | StatusDynamicsChartData | ResponseBarChartData | ResponseComingSoonChartData | ResponseTreeMapChartData | ResponseHeatMapChartData | ResponseTestingPyramidChartData;
126
+ export type UIChartData<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = UITrendChartData<Metadata> | UICurrentStatusChartData | UIStatusDynamicsChartData | UIBarChartData | UIComingSoonChartData | UITreeMapChartData | UIHeatMapChartData | UITestingPyramidChartData;
114
127
  export type ChartsData<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = Record<ChartId, ChartData<SeriesType, Metadata>>;
115
128
  export type ChartsDataWithEnvs<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = {
116
129
  general: Record<ChartId, ChartData<SeriesType, Metadata>>;
@@ -201,6 +201,9 @@ export const createCharts = (res) => {
201
201
  if (chart.type === ChartType.CurrentStatus) {
202
202
  acc[chartId] = res[chartId];
203
203
  }
204
+ else if (chart.type === ChartType.StatusDynamics) {
205
+ acc[chartId] = res[chartId];
206
+ }
204
207
  else if (chart.type === ChartType.Trend) {
205
208
  const chartData = createaTrendChartData(chartId, chart, res);
206
209
  if (chartData) {
package/dist/i18n.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const AVAILABLE_LOCALES: readonly ["en", "ru", "pl", "es", "pt", "de", "hy", "az", "fr", "it", "ja", "he", "ka", "kr", "nl", "sv", "tr", "zh"];
1
+ export declare const AVAILABLE_LOCALES: readonly ["en", "ru", "ua", "pl", "es", "pt", "de", "hy", "az", "fr", "it", "ja", "he", "ka", "kr", "nl", "sv", "tr", "zh"];
2
2
  export declare const DEFAULT_LOCALE = "en";
3
3
  export type LangLocale = (typeof AVAILABLE_LOCALES)[number];
4
4
  export declare const LANG_LOCALE: Record<LangLocale, {
package/dist/i18n.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export const AVAILABLE_LOCALES = [
2
2
  "en",
3
3
  "ru",
4
+ "ua",
4
5
  "pl",
5
6
  "es",
6
7
  "pt",
@@ -30,6 +31,11 @@ export const LANG_LOCALE = {
30
31
  full: "Русский",
31
32
  iso: "ru-RU",
32
33
  },
34
+ ua: {
35
+ short: "Ук",
36
+ full: "Українська",
37
+ iso: "uk-UA",
38
+ },
33
39
  pl: {
34
40
  short: "Pl",
35
41
  full: "Polski",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/web-commons",
3
- "version": "3.0.0-beta.25",
3
+ "version": "3.0.0-beta.26",
4
4
  "description": "Collection of utilities used across the web Allure reports",
5
5
  "keywords": [
6
6
  "allure",
@@ -23,9 +23,9 @@
23
23
  "clean": "rimraf ./dist"
24
24
  },
25
25
  "dependencies": {
26
- "@allurereport/charts-api": "3.0.0-beta.25",
27
- "@allurereport/core-api": "3.0.0-beta.25",
28
- "@allurereport/plugin-api": "3.0.0-beta.25",
26
+ "@allurereport/charts-api": "3.0.0-beta.26",
27
+ "@allurereport/core-api": "3.0.0-beta.26",
28
+ "@allurereport/plugin-api": "3.0.0-beta.26",
29
29
  "ansi-to-html": "^0.7.2",
30
30
  "d3-interpolate": "^3.0.1",
31
31
  "d3-scale": "^4.0.2",