@allurereport/core-api 3.7.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.
- package/dist/model.d.ts +11 -0
- package/dist/utils/history.d.ts +1 -0
- package/dist/utils/history.js +25 -10
- package/package.json +1 -1
package/dist/model.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { TestLabel, TestLink, TestParameter } from "./metadata.js";
|
|
2
2
|
import type { TestCase } from "./testCase.js";
|
|
3
3
|
export type TestStatus = "failed" | "broken" | "passed" | "skipped" | "unknown";
|
|
4
|
+
export type AllureCheckStatus = "passed" | "failed";
|
|
4
5
|
export type TestStatusTransition = "regressed" | "fixed" | "malfunctioned" | "new";
|
|
5
6
|
export type SeverityLevel = "blocker" | "critical" | "normal" | "minor" | "trivial";
|
|
7
|
+
export interface AllureCheckResult {
|
|
8
|
+
name: string;
|
|
9
|
+
status: AllureCheckStatus;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
details: {
|
|
12
|
+
message?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
command: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
6
17
|
export interface SourceMetadata {
|
|
7
18
|
readerId: string;
|
|
8
19
|
metadata: {
|
package/dist/utils/history.d.ts
CHANGED
|
@@ -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[];
|
package/dist/utils/history.js
CHANGED
|
@@ -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
|
|
57
|
+
const normalizedHistoryDataPoint = normalizeHistoryDataPoint(historyDataPoint);
|
|
58
|
+
const { url } = normalizedHistoryDataPoint;
|
|
44
59
|
if (!url) {
|
|
45
|
-
return
|
|
60
|
+
return normalizedHistoryDataPoint;
|
|
46
61
|
}
|
|
47
|
-
let testResults =
|
|
48
|
-
for (const [historyId, historyTestResult] of Object.entries(
|
|
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 ===
|
|
53
|
-
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 ===
|
|
61
|
-
return
|
|
75
|
+
if (testResults === normalizedHistoryDataPoint.testResults) {
|
|
76
|
+
return normalizedHistoryDataPoint;
|
|
62
77
|
}
|
|
63
78
|
return {
|
|
64
|
-
...
|
|
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
|
}
|