@allurereport/core-api 3.8.0 → 3.8.1

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.
@@ -5,6 +5,7 @@ export declare const stringifyHistoryParams: (parameters?: TestParameter[]) => s
5
5
  export declare const getFallbackHistoryId: (tr: Pick<TestResult, "labels" | "parameters">) => string | undefined;
6
6
  export declare const getHistoryIdCandidates: (tr: Pick<TestResult, "historyId" | "labels" | "parameters">) => string[];
7
7
  export declare const filterUnknownByKnownIssues: (trs: TestResult[], knownIssueHistoryIds: ReadonlySet<string>) => TestResult[];
8
+ export declare const normalizeHistoryDataPoint: (historyDataPoint: HistoryDataPoint) => HistoryDataPoint;
8
9
  export declare const normalizeHistoryDataPointUrls: (historyDataPoint: HistoryDataPoint) => HistoryDataPoint;
9
10
  export declare const selectHistoryTestResults: (historyDataPoints: HistoryDataPoint[], historyIdCandidates: readonly string[]) => HistoryTestResult[];
10
11
  export declare const htrsByTr: (hdps: HistoryDataPoint[], tr: TestResult | HistoryTestResult) => HistoryTestResult[];
@@ -2,6 +2,13 @@ import { createHash } from "node:crypto";
2
2
  import { fallbackTestCaseIdLabelName } from "../constants.js";
3
3
  import { findLastByLabelName } from "./label.js";
4
4
  const md5 = (data) => createHash("md5").update(data).digest("hex");
5
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6
+ const normalizeHistoryTestResults = (testResults) => {
7
+ if (!isRecord(testResults)) {
8
+ return {};
9
+ }
10
+ return Object.fromEntries(Object.entries(testResults).filter(([, value]) => isRecord(value)));
11
+ };
5
12
  const parametersCompare = (a, b) => {
6
13
  return (a.name ?? "").localeCompare(b.name ?? "") || (a.value ?? "").localeCompare(b.value ?? "");
7
14
  };
@@ -39,29 +46,37 @@ export const filterUnknownByKnownIssues = (trs, knownIssueHistoryIds) => {
39
46
  return historyIdCandidates.every((historyId) => !knownIssueHistoryIds.has(historyId));
40
47
  });
41
48
  };
49
+ export const normalizeHistoryDataPoint = (historyDataPoint) => ({
50
+ ...historyDataPoint,
51
+ knownTestCaseIds: Array.isArray(historyDataPoint.knownTestCaseIds) ? historyDataPoint.knownTestCaseIds : [],
52
+ testResults: normalizeHistoryTestResults(historyDataPoint.testResults),
53
+ metrics: isRecord(historyDataPoint.metrics) ? historyDataPoint.metrics : {},
54
+ url: historyDataPoint.url ?? "",
55
+ });
42
56
  export const normalizeHistoryDataPointUrls = (historyDataPoint) => {
43
- const { url } = historyDataPoint;
57
+ const normalizedHistoryDataPoint = normalizeHistoryDataPoint(historyDataPoint);
58
+ const { url } = normalizedHistoryDataPoint;
44
59
  if (!url) {
45
- return historyDataPoint;
60
+ return normalizedHistoryDataPoint;
46
61
  }
47
- let testResults = historyDataPoint.testResults;
48
- for (const [historyId, historyTestResult] of Object.entries(historyDataPoint.testResults)) {
62
+ let testResults = normalizedHistoryDataPoint.testResults;
63
+ for (const [historyId, historyTestResult] of Object.entries(normalizedHistoryDataPoint.testResults)) {
49
64
  if (historyTestResult.url) {
50
65
  continue;
51
66
  }
52
- if (testResults === historyDataPoint.testResults) {
53
- testResults = { ...historyDataPoint.testResults };
67
+ if (testResults === normalizedHistoryDataPoint.testResults) {
68
+ testResults = { ...normalizedHistoryDataPoint.testResults };
54
69
  }
55
70
  testResults[historyId] = {
56
71
  ...historyTestResult,
57
72
  url,
58
73
  };
59
74
  }
60
- if (testResults === historyDataPoint.testResults) {
61
- return historyDataPoint;
75
+ if (testResults === normalizedHistoryDataPoint.testResults) {
76
+ return normalizedHistoryDataPoint;
62
77
  }
63
78
  return {
64
- ...historyDataPoint,
79
+ ...normalizedHistoryDataPoint,
65
80
  testResults,
66
81
  };
67
82
  };
@@ -71,7 +86,7 @@ export const selectHistoryTestResults = (historyDataPoints, historyIdCandidates)
71
86
  }
72
87
  return historyDataPoints.reduce((acc, historyDataPoint) => {
73
88
  for (const historyId of historyIdCandidates) {
74
- const historyTestResult = historyDataPoint.testResults[historyId];
89
+ const historyTestResult = historyDataPoint.testResults?.[historyId];
75
90
  if (!historyTestResult) {
76
91
  continue;
77
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core-api",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "Allure Core API",
5
5
  "keywords": [
6
6
  "allure"