@allurereport/core-api 3.16.1 → 3.17.0

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.
@@ -13,4 +13,9 @@ export type Statistic = DiffStatistic & {
13
13
  total: number;
14
14
  retries?: number;
15
15
  flaky?: number;
16
+ resolutions?: {
17
+ issues?: number;
18
+ muted?: number;
19
+ accepted?: number;
20
+ };
16
21
  };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export type * from "./environment.js";
6
6
  export type * from "./history.js";
7
7
  export type * from "./resolutions.js";
8
8
  export type * from "./metadata.js";
9
+ export * from "./metrics.js";
9
10
  export type * from "./model.js";
10
11
  export type * from "./testCase.js";
11
12
  export type * from "./testPlan.js";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./constants.js";
2
2
  export * from "./ci.js";
3
3
  export * from "./gitFlow.js";
4
+ export * from "./metrics.js";
4
5
  export * from "./static.js";
5
6
  export * from "./categories.js";
6
7
  export * from "./utils/step.js";
@@ -0,0 +1,32 @@
1
+ export type MetricBetter = "lower" | "higher" | "neutral";
2
+ export interface PerformanceGroupConfig {
3
+ title: string;
4
+ }
5
+ export interface PerformanceMetricConfig {
6
+ title: string;
7
+ unit: string;
8
+ better: Exclude<MetricBetter, "neutral">;
9
+ group?: string;
10
+ }
11
+ export interface PerformanceConfig {
12
+ groups?: Record<string, PerformanceGroupConfig>;
13
+ metrics?: Record<string, PerformanceMetricConfig>;
14
+ }
15
+ export interface AllurePerformanceResult {
16
+ id: string;
17
+ key: string;
18
+ value: any;
19
+ start: number;
20
+ stop: number;
21
+ }
22
+ export interface MetricSample extends AllurePerformanceResult {
23
+ value: number;
24
+ source?: string;
25
+ title?: string;
26
+ unit?: string;
27
+ group?: string;
28
+ groupTitle?: string;
29
+ better?: MetricBetter;
30
+ }
31
+ export type ResolvableMetric = AllurePerformanceResult & Partial<Pick<MetricSample, "source" | "title" | "unit" | "group" | "groupTitle" | "better">>;
32
+ export declare const resolveMetricSamples: (metrics: readonly ResolvableMetric[], performance?: PerformanceConfig) => MetricSample[];
@@ -0,0 +1,29 @@
1
+ const isValidMetricResult = (metric) => typeof metric.id === "string" &&
2
+ metric.id !== "" &&
3
+ typeof metric.key === "string" &&
4
+ metric.key !== "" &&
5
+ Number.isFinite(metric.start) &&
6
+ Number.isFinite(metric.stop);
7
+ export const resolveMetricSamples = (metrics, performance = {}) => {
8
+ const metricsConfig = performance.metrics ?? {};
9
+ const groupsConfig = performance.groups ?? {};
10
+ return metrics.reduce((acc, metric) => {
11
+ const value = Number.isFinite(metric.value) ? Number(metric.value) : undefined;
12
+ if (value === undefined || !isValidMetricResult(metric)) {
13
+ return acc;
14
+ }
15
+ const metricConfig = metricsConfig[metric.key];
16
+ const group = metricConfig?.group ?? metric.group;
17
+ const groupConfig = group ? groupsConfig[group] : undefined;
18
+ acc.push({
19
+ ...metric,
20
+ value,
21
+ ...(metricConfig?.title ? { title: metricConfig.title } : {}),
22
+ ...(metricConfig?.unit ? { unit: metricConfig.unit } : {}),
23
+ ...(group ? { group } : {}),
24
+ ...(groupConfig?.title ? { groupTitle: groupConfig.title } : {}),
25
+ ...(metricConfig?.better ? { better: metricConfig.better } : {}),
26
+ });
27
+ return acc;
28
+ }, []);
29
+ };
package/dist/model.d.ts CHANGED
@@ -49,6 +49,7 @@ export interface TestResult {
49
49
  flaky: boolean;
50
50
  muted: boolean;
51
51
  resolution?: ResolutionCategory;
52
+ resolutionComment?: string;
52
53
  transition?: TestStatusTransition;
53
54
  retryHash?: string;
54
55
  isRetry: boolean;
@@ -9,6 +9,12 @@ const normalizeHistoryTestResults = (testResults) => {
9
9
  }
10
10
  return Object.fromEntries(Object.entries(testResults).filter(([, value]) => isRecord(value)));
11
11
  };
12
+ const normalizeHistoryMetrics = (metrics) => {
13
+ if (!isRecord(metrics)) {
14
+ return {};
15
+ }
16
+ return Object.fromEntries(Object.entries(metrics).filter(([, value]) => Number.isFinite(value)));
17
+ };
12
18
  const parametersCompare = (a, b) => {
13
19
  return (a.name ?? "").localeCompare(b.name ?? "") || (a.value ?? "").localeCompare(b.value ?? "");
14
20
  };
@@ -41,7 +47,7 @@ export const normalizeHistoryDataPoint = (historyDataPoint) => ({
41
47
  ...historyDataPoint,
42
48
  knownTestCaseIds: Array.isArray(historyDataPoint.knownTestCaseIds) ? historyDataPoint.knownTestCaseIds : [],
43
49
  testResults: normalizeHistoryTestResults(historyDataPoint.testResults),
44
- metrics: isRecord(historyDataPoint.metrics) ? historyDataPoint.metrics : {},
50
+ metrics: normalizeHistoryMetrics(historyDataPoint.metrics),
45
51
  url: historyDataPoint.url ?? "",
46
52
  });
47
53
  export const normalizeHistoryDataPointUrls = (historyDataPoint) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core-api",
3
- "version": "3.16.1",
3
+ "version": "3.17.0",
4
4
  "description": "Allure Core API",
5
5
  "keywords": [
6
6
  "allure"