@allurereport/core-api
Advanced tools
@@ -8,4 +8,5 @@ import type { HistoryDataPoint, HistoryTestResult } from "../history.js"; | ||
| export declare const filterUnknownByKnownIssues: (trs: TestResult[], knownIssueHistoryIds: ReadonlySet<string>) => TestResult[]; | ||
| export declare const normalizeHistoryDataPoint: (historyDataPoint: HistoryDataPoint) => HistoryDataPoint; | ||
| export declare const normalizeHistoryDataPointUrls: (historyDataPoint: HistoryDataPoint) => HistoryDataPoint; | ||
| export declare const selectHistoryTestResults: (historyDataPoints: HistoryDataPoint[], historyIdCandidates: readonly string[]) => HistoryTestResult[]; | ||
| export declare const htrsByTr: (hdps: HistoryDataPoint[], tr: TestResult | HistoryTestResult) => HistoryTestResult[]; |
+25
-10
@@ -5,2 +5,9 @@ import { createHash } from "node:crypto"; | ||
| const md5 = (data) => createHash("md5").update(data).digest("hex"); | ||
| const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value); | ||
| const normalizeHistoryTestResults = (testResults) => { | ||
| if (!isRecord(testResults)) { | ||
| return {}; | ||
| } | ||
| return Object.fromEntries(Object.entries(testResults).filter(([, value]) => isRecord(value))); | ||
| }; | ||
| const parametersCompare = (a, b) => { | ||
@@ -43,14 +50,22 @@ return (a.name ?? "").localeCompare(b.name ?? "") || (a.value ?? "").localeCompare(b.value ?? ""); | ||
| }; | ||
| export const normalizeHistoryDataPoint = (historyDataPoint) => ({ | ||
| ...historyDataPoint, | ||
| knownTestCaseIds: Array.isArray(historyDataPoint.knownTestCaseIds) ? historyDataPoint.knownTestCaseIds : [], | ||
| testResults: normalizeHistoryTestResults(historyDataPoint.testResults), | ||
| metrics: isRecord(historyDataPoint.metrics) ? historyDataPoint.metrics : {}, | ||
| url: historyDataPoint.url ?? "", | ||
| }); | ||
| export const normalizeHistoryDataPointUrls = (historyDataPoint) => { | ||
| const { url } = historyDataPoint; | ||
| const normalizedHistoryDataPoint = normalizeHistoryDataPoint(historyDataPoint); | ||
| const { url } = normalizedHistoryDataPoint; | ||
| if (!url) { | ||
| return historyDataPoint; | ||
| return normalizedHistoryDataPoint; | ||
| } | ||
| let testResults = historyDataPoint.testResults; | ||
| for (const [historyId, historyTestResult] of Object.entries(historyDataPoint.testResults)) { | ||
| let testResults = normalizedHistoryDataPoint.testResults; | ||
| for (const [historyId, historyTestResult] of Object.entries(normalizedHistoryDataPoint.testResults)) { | ||
| if (historyTestResult.url) { | ||
| continue; | ||
| } | ||
| if (testResults === historyDataPoint.testResults) { | ||
| testResults = { ...historyDataPoint.testResults }; | ||
| if (testResults === normalizedHistoryDataPoint.testResults) { | ||
| testResults = { ...normalizedHistoryDataPoint.testResults }; | ||
| } | ||
@@ -62,7 +77,7 @@ testResults[historyId] = { | ||
| } | ||
| if (testResults === historyDataPoint.testResults) { | ||
| return historyDataPoint; | ||
| if (testResults === normalizedHistoryDataPoint.testResults) { | ||
| return normalizedHistoryDataPoint; | ||
| } | ||
| return { | ||
| ...historyDataPoint, | ||
| ...normalizedHistoryDataPoint, | ||
| testResults, | ||
@@ -77,3 +92,3 @@ }; | ||
| for (const historyId of historyIdCandidates) { | ||
| const historyTestResult = historyDataPoint.testResults[historyId]; | ||
| const historyTestResult = historyDataPoint.testResults?.[historyId]; | ||
| if (!historyTestResult) { | ||
@@ -80,0 +95,0 @@ continue; |
+1
-1
| { | ||
| "name": "@allurereport/core-api", | ||
| "version": "3.8.0", | ||
| "version": "3.8.1", | ||
| "description": "Allure Core API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
53117
1.91%1398
1.16%