@sentinelqa/playwright-reporter 0.1.34 → 0.1.35
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/runHistory.js +26 -3
- package/package.json +1 -1
package/dist/runHistory.js
CHANGED
|
@@ -54,6 +54,28 @@ const getPointerPaths = (branch) => [
|
|
|
54
54
|
node_path_1.default.join(".sentinel", `latest-${branch}.json`),
|
|
55
55
|
...(branch === "main" ? [node_path_1.default.join(".sentinel", "latest-main.json")] : [])
|
|
56
56
|
];
|
|
57
|
+
const normalizeFailures = (snapshot) => {
|
|
58
|
+
if (!snapshot)
|
|
59
|
+
return [];
|
|
60
|
+
if (Array.isArray(snapshot.failures)) {
|
|
61
|
+
return snapshot.failures.filter((failure) => Boolean(failure &&
|
|
62
|
+
typeof failure.id === "string" &&
|
|
63
|
+
typeof failure.matchKey === "string" &&
|
|
64
|
+
typeof failure.title === "string" &&
|
|
65
|
+
typeof failure.status === "string"));
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(snapshot.tests)) {
|
|
68
|
+
return snapshot.tests
|
|
69
|
+
.filter((test) => test && typeof test.id === "string")
|
|
70
|
+
.map((test) => ({
|
|
71
|
+
id: test.id,
|
|
72
|
+
matchKey: typeof test.matchKey === "string" ? test.matchKey : test.id,
|
|
73
|
+
title: typeof test.title === "string" ? test.title : test.id,
|
|
74
|
+
status: typeof test.status === "string" ? test.status : "failed"
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
return [];
|
|
78
|
+
};
|
|
57
79
|
const readSnapshot = (filePath) => {
|
|
58
80
|
if (!node_fs_1.default.existsSync(filePath))
|
|
59
81
|
return null;
|
|
@@ -78,13 +100,14 @@ const buildRunDiffSummary = (playwrightJsonPath) => {
|
|
|
78
100
|
const snapshot = buildSnapshot(playwrightJsonPath);
|
|
79
101
|
const previous = readSnapshot(node_path_1.default.resolve(process.cwd(), ".sentinel", `latest-${snapshot.branch}.json`)) ||
|
|
80
102
|
readSnapshot(node_path_1.default.resolve(process.cwd(), ".sentinel", "latest.json"));
|
|
103
|
+
const previousFailures = normalizeFailures(previous);
|
|
81
104
|
const currentFailureIds = new Set(snapshot.failures.map((test) => test.id));
|
|
82
105
|
const currentFailureMatchKeys = new Set(snapshot.failures.map((test) => test.matchKey));
|
|
83
106
|
const diff = previous && previous.generatedAt !== snapshot.generatedAt
|
|
84
107
|
? {
|
|
85
|
-
newFailures: snapshot.failures.filter((test) => !
|
|
86
|
-
fixedTests:
|
|
87
|
-
stillFailing: snapshot.failures.filter((test) =>
|
|
108
|
+
newFailures: snapshot.failures.filter((test) => !previousFailures.some((prev) => prev.id === test.id || prev.matchKey === test.matchKey)).length,
|
|
109
|
+
fixedTests: previousFailures.filter((test) => !currentFailureIds.has(test.id) && !currentFailureMatchKeys.has(test.matchKey)).length,
|
|
110
|
+
stillFailing: snapshot.failures.filter((test) => previousFailures.some((prev) => prev.id === test.id || prev.matchKey === test.matchKey)).length
|
|
88
111
|
}
|
|
89
112
|
: null;
|
|
90
113
|
writeSnapshot(snapshot);
|