@alejandrojca/elmulo-reporter 2.0.0-beta.5
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/README.md +412 -0
- package/VERSION.json +9 -0
- package/assets/app.css +4457 -0
- package/assets/app.js +3014 -0
- package/assets/donkey-favicon.png +0 -0
- package/assets/donkey-silhouette-white.png +0 -0
- package/assets/donkey-silhouette.png +0 -0
- package/assets/fonts/NotoSans-Variable.ttf +0 -0
- package/assets/fonts/OFL.txt +93 -0
- package/cli.cjs +272 -0
- package/core.cjs +274 -0
- package/executive-pdf.cjs +713 -0
- package/finalize.cjs +982 -0
- package/package.json +65 -0
- package/plugin.cjs +249 -0
- package/rerun.cjs +298 -0
- package/security.cjs +56 -0
- package/server.cjs +569 -0
- package/support.ts +210 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
package/cli.cjs
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const { createRunId, ensureDir, stableId, writeJson } = require("./core.cjs");
|
|
6
|
+
const { finalizeRun } = require("./finalize.cjs");
|
|
7
|
+
const { serveReport } = require("./server.cjs");
|
|
8
|
+
|
|
9
|
+
function createDemoRun(projectRoot) {
|
|
10
|
+
const outputDir = path.resolve(
|
|
11
|
+
projectRoot,
|
|
12
|
+
process.env.ELMULO_OUTPUT_DIR || "elmulo-results",
|
|
13
|
+
);
|
|
14
|
+
const startedAt = new Date(Date.now() - 84_000).toISOString();
|
|
15
|
+
const endedAt = new Date().toISOString();
|
|
16
|
+
const runId = createRunId(startedAt);
|
|
17
|
+
const runDir = path.join(outputDir, "runs", runId);
|
|
18
|
+
ensureDir(runDir);
|
|
19
|
+
|
|
20
|
+
const definitions = [
|
|
21
|
+
{
|
|
22
|
+
spec: "cypress/e2e/decidir/mtt/mtt-payment.feature",
|
|
23
|
+
title: "MTT payment with brand TARJETA NARANJA and DUKPT",
|
|
24
|
+
status: "passed",
|
|
25
|
+
durationMs: 22430,
|
|
26
|
+
retries: 0,
|
|
27
|
+
flaky: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
spec: "cypress/e2e/decidir/mtt/mtt-payment.feature",
|
|
31
|
+
title: "MTT payment with brand CABAL DEBIT and DUKPT",
|
|
32
|
+
status: "passed",
|
|
33
|
+
durationMs: 28190,
|
|
34
|
+
retries: 1,
|
|
35
|
+
flaky: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
spec: "cypress/e2e/decidir/mtt/mtt-payment.feature",
|
|
39
|
+
title: "MTT payment with brand CABAL CREDIT and DUKPT",
|
|
40
|
+
status: "failed",
|
|
41
|
+
durationMs: 33380,
|
|
42
|
+
retries: 1,
|
|
43
|
+
flaky: false,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
spec: "cypress/e2e/decidir/mtt/mtt-payment-negative.feature",
|
|
47
|
+
title: "Reject MTT payment with an invalid cryptogram",
|
|
48
|
+
status: "skipped",
|
|
49
|
+
durationMs: 0,
|
|
50
|
+
retries: 0,
|
|
51
|
+
flaky: false,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const tests = definitions.map((definition, index) => ({
|
|
56
|
+
id: stableId(definition.spec, definition.title),
|
|
57
|
+
...definition,
|
|
58
|
+
titlePath: ["MTT payment from API", definition.title],
|
|
59
|
+
suite: "MTT payment from API",
|
|
60
|
+
error:
|
|
61
|
+
definition.status === "failed"
|
|
62
|
+
? {
|
|
63
|
+
name: "AssertionError",
|
|
64
|
+
message: "expected response status 201 but received 500",
|
|
65
|
+
stack:
|
|
66
|
+
"AssertionError: expected response status 201 but received 500\n at Context.eval (mtt-payment.feature:25:5)",
|
|
67
|
+
}
|
|
68
|
+
: null,
|
|
69
|
+
attempts: Array.from(
|
|
70
|
+
{ length: definition.retries + 1 },
|
|
71
|
+
(_, attemptIndex) => ({
|
|
72
|
+
index: attemptIndex,
|
|
73
|
+
number: attemptIndex + 1,
|
|
74
|
+
state:
|
|
75
|
+
attemptIndex < definition.retries
|
|
76
|
+
? "failed"
|
|
77
|
+
: definition.status,
|
|
78
|
+
durationMs: Math.round(
|
|
79
|
+
definition.durationMs / (definition.retries + 1),
|
|
80
|
+
),
|
|
81
|
+
startedAt,
|
|
82
|
+
error:
|
|
83
|
+
attemptIndex < definition.retries ||
|
|
84
|
+
definition.status === "failed"
|
|
85
|
+
? {
|
|
86
|
+
name: "AssertionError",
|
|
87
|
+
message: "La respuesta no coincidió con el contrato esperado",
|
|
88
|
+
stack: "AssertionError: respuesta inesperada",
|
|
89
|
+
}
|
|
90
|
+
: null,
|
|
91
|
+
screenshots: [],
|
|
92
|
+
video: null,
|
|
93
|
+
}),
|
|
94
|
+
),
|
|
95
|
+
steps: [
|
|
96
|
+
{
|
|
97
|
+
index: 0,
|
|
98
|
+
keyword: "Given",
|
|
99
|
+
name: "A random amount is generated for the MTT payment",
|
|
100
|
+
status: "passed",
|
|
101
|
+
durationMs: 120,
|
|
102
|
+
error: "",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
index: 1,
|
|
106
|
+
keyword: "When",
|
|
107
|
+
name: "The MTT payment request is sent",
|
|
108
|
+
status: definition.status === "failed" ? "failed" : "passed",
|
|
109
|
+
durationMs: Math.max(0, definition.durationMs - 120),
|
|
110
|
+
error:
|
|
111
|
+
definition.status === "failed"
|
|
112
|
+
? "El servicio respondió HTTP 500"
|
|
113
|
+
: "",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
index: 2,
|
|
117
|
+
keyword: "Then",
|
|
118
|
+
name: "The MTT payment response is successful",
|
|
119
|
+
status:
|
|
120
|
+
definition.status === "failed"
|
|
121
|
+
? "skipped"
|
|
122
|
+
: definition.status,
|
|
123
|
+
durationMs: 0,
|
|
124
|
+
error: "",
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
tags: ["@mtt", "@smoke"],
|
|
128
|
+
logs: [
|
|
129
|
+
{
|
|
130
|
+
name: "request",
|
|
131
|
+
message: "POST /api/v1/payments",
|
|
132
|
+
timestamp: startedAt,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "assert",
|
|
136
|
+
message: `status: ${definition.status}`,
|
|
137
|
+
timestamp: endedAt,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
attachments: [],
|
|
141
|
+
}));
|
|
142
|
+
|
|
143
|
+
const counts = tests.reduce(
|
|
144
|
+
(summary, test) => {
|
|
145
|
+
summary.total += 1;
|
|
146
|
+
summary[test.status] += 1;
|
|
147
|
+
if (test.flaky) summary.flaky += 1;
|
|
148
|
+
return summary;
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
total: 0,
|
|
152
|
+
passed: 0,
|
|
153
|
+
failed: 0,
|
|
154
|
+
pending: 0,
|
|
155
|
+
skipped: 0,
|
|
156
|
+
unknown: 0,
|
|
157
|
+
flaky: 0,
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const run = {
|
|
162
|
+
schemaVersion: 3,
|
|
163
|
+
id: runId,
|
|
164
|
+
projectName: "acceptance-tests",
|
|
165
|
+
environment: "sandbox",
|
|
166
|
+
tagExpression: "@mtt and not @negative",
|
|
167
|
+
status: "failed",
|
|
168
|
+
startedAt,
|
|
169
|
+
endedAt,
|
|
170
|
+
durationMs: 84000,
|
|
171
|
+
browser: { name: "chrome", version: "150" },
|
|
172
|
+
cypressVersion: "14.5.4",
|
|
173
|
+
system: { name: "win32", version: "11" },
|
|
174
|
+
counts,
|
|
175
|
+
specs: [
|
|
176
|
+
{
|
|
177
|
+
path: "cypress/e2e/decidir/mtt/mtt-payment.feature",
|
|
178
|
+
name: "mtt-payment.feature",
|
|
179
|
+
durationMs: 84000,
|
|
180
|
+
video: null,
|
|
181
|
+
testIds: tests.map((test) => test.id),
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
tests,
|
|
185
|
+
attachments: [],
|
|
186
|
+
trends: [],
|
|
187
|
+
generatedAt: endedAt,
|
|
188
|
+
lifecycle: "completed",
|
|
189
|
+
source: {
|
|
190
|
+
branch: "feature/elmulo-v2",
|
|
191
|
+
commit: "demo",
|
|
192
|
+
pipelineId: "local-demo",
|
|
193
|
+
jobId: "",
|
|
194
|
+
jobUrl: "",
|
|
195
|
+
},
|
|
196
|
+
execution: {
|
|
197
|
+
runner: "npm",
|
|
198
|
+
script: "demo",
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
writeJson(path.join(runDir, "run.raw.json"), run);
|
|
203
|
+
writeJson(path.join(runDir, "run.json"), run);
|
|
204
|
+
fs.writeFileSync(path.join(outputDir, "latest-run.txt"), runId, "utf8");
|
|
205
|
+
return run;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function applyRetention(projectRoot, keepValue) {
|
|
209
|
+
const outputDir = path.resolve(
|
|
210
|
+
projectRoot,
|
|
211
|
+
process.env.ELMULO_OUTPUT_DIR || "elmulo-results",
|
|
212
|
+
);
|
|
213
|
+
const runsDir = path.join(outputDir, "runs");
|
|
214
|
+
const keep = Math.max(1, Math.min(1000, Number(keepValue || 50)));
|
|
215
|
+
if (!fs.existsSync(runsDir)) return { keep, removed: 0 };
|
|
216
|
+
const runs = fs.readdirSync(runsDir, { withFileTypes: true })
|
|
217
|
+
.filter((entry) => entry.isDirectory() && /^[a-zA-Z0-9_-]+$/.test(entry.name))
|
|
218
|
+
.map((entry) => ({
|
|
219
|
+
name: entry.name,
|
|
220
|
+
path: path.join(runsDir, entry.name),
|
|
221
|
+
modifiedAt: fs.statSync(path.join(runsDir, entry.name)).mtimeMs,
|
|
222
|
+
}))
|
|
223
|
+
.sort((left, right) => right.modifiedAt - left.modifiedAt);
|
|
224
|
+
const removable = runs.slice(keep);
|
|
225
|
+
for (const run of removable) {
|
|
226
|
+
const resolved = path.resolve(run.path);
|
|
227
|
+
if (!resolved.startsWith(`${path.resolve(runsDir)}${path.sep}`)) {
|
|
228
|
+
throw new Error("La retención intentó salir del directorio de corridas.");
|
|
229
|
+
}
|
|
230
|
+
fs.rmSync(resolved, { recursive: true, force: false });
|
|
231
|
+
}
|
|
232
|
+
return { keep, removed: removable.length };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async function main() {
|
|
236
|
+
const projectRoot = process.cwd();
|
|
237
|
+
const command = process.argv[2] || "finalize";
|
|
238
|
+
|
|
239
|
+
if (command === "serve") {
|
|
240
|
+
const result = await serveReport({
|
|
241
|
+
projectRoot,
|
|
242
|
+
outputDir: process.env.ELMULO_OUTPUT_DIR,
|
|
243
|
+
port: process.argv[3],
|
|
244
|
+
});
|
|
245
|
+
console.log(`[elmulo] Reporte disponible en ${result.url}`);
|
|
246
|
+
console.log("[elmulo] Las clasificaciones se persisten en SQLite.");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (command === "retention") {
|
|
251
|
+
const result = applyRetention(projectRoot, process.argv[3]);
|
|
252
|
+
console.log(`[elmulo-v2] Retención aplicada: ${result.keep} corridas conservadas, ${result.removed} eliminadas.`);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (command === "demo") createDemoRun(projectRoot);
|
|
257
|
+
if (!["demo", "finalize", "serve", "retention"].includes(command)) {
|
|
258
|
+
throw new Error(`Comando desconocido: ${command}`);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const result = await finalizeRun({
|
|
262
|
+
projectRoot,
|
|
263
|
+
outputDir: process.env.ELMULO_OUTPUT_DIR,
|
|
264
|
+
});
|
|
265
|
+
console.log(`[elmulo] Reporte generado: ${path.join(result.reportDir, "index.html")}`);
|
|
266
|
+
console.log(`[elmulo] Historial SQLite: ${path.join(result.outputDir, "elmulo.sqlite")}`);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
main().catch((error) => {
|
|
270
|
+
console.error(`[elmulo] ${error.stack || error.message}`);
|
|
271
|
+
process.exitCode = 1;
|
|
272
|
+
});
|
package/core.cjs
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
const crypto = require("node:crypto");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
|
|
5
|
+
const SCHEMA_VERSION = 3;
|
|
6
|
+
|
|
7
|
+
function ensureDir(directory) {
|
|
8
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function safeFileName(value) {
|
|
12
|
+
return String(value || "artifact")
|
|
13
|
+
.normalize("NFKD")
|
|
14
|
+
.replace(/[^\w.-]+/g, "-")
|
|
15
|
+
.replace(/^-+|-+$/g, "")
|
|
16
|
+
.slice(0, 120) || "artifact";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function stableId(...parts) {
|
|
20
|
+
return crypto
|
|
21
|
+
.createHash("sha1")
|
|
22
|
+
.update(parts.filter(Boolean).join("\u001f"))
|
|
23
|
+
.digest("hex");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function atomicWriteFile(filePath, content) {
|
|
27
|
+
ensureDir(path.dirname(filePath));
|
|
28
|
+
const temporaryPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
29
|
+
fs.writeFileSync(temporaryPath, content);
|
|
30
|
+
fs.renameSync(temporaryPath, filePath);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function createRunId(startedAt = new Date().toISOString()) {
|
|
34
|
+
const compactDate = startedAt.replace(/\D/g, "").slice(0, 14);
|
|
35
|
+
return `${compactDate}-${crypto.randomBytes(4).toString("hex")}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function normalizeStatus(status) {
|
|
39
|
+
const value = String(status || "").toLowerCase();
|
|
40
|
+
|
|
41
|
+
if (value === "passed") return "passed";
|
|
42
|
+
if (value === "failed") return "failed";
|
|
43
|
+
if (value === "pending") return "pending";
|
|
44
|
+
if (value === "skipped") return "skipped";
|
|
45
|
+
return value || "unknown";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function normalizePath(projectRoot, candidate) {
|
|
49
|
+
if (!candidate) return null;
|
|
50
|
+
const absolutePath = path.isAbsolute(candidate)
|
|
51
|
+
? candidate
|
|
52
|
+
: path.resolve(projectRoot, candidate);
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
absolutePath,
|
|
56
|
+
projectPath: path.relative(projectRoot, absolutePath).replaceAll("\\", "/"),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function comparableText(value) {
|
|
61
|
+
return String(value || "")
|
|
62
|
+
.normalize("NFKD")
|
|
63
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
64
|
+
.replace(/[^a-zA-Z0-9]+/g, " ")
|
|
65
|
+
.trim()
|
|
66
|
+
.toLowerCase();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function normalizeAttempt(projectRoot, attempt, index, specVideo) {
|
|
70
|
+
const screenshots = (attempt?.screenshots || [])
|
|
71
|
+
.map((screenshot) => normalizePath(projectRoot, screenshot.path))
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.map((screenshot) => ({
|
|
74
|
+
...screenshot,
|
|
75
|
+
takenAt: null,
|
|
76
|
+
width: null,
|
|
77
|
+
height: null,
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
index,
|
|
82
|
+
number: index + 1,
|
|
83
|
+
state: normalizeStatus(attempt?.state),
|
|
84
|
+
durationMs: Number(attempt?.duration || 0),
|
|
85
|
+
startedAt: attempt?.startedAt || null,
|
|
86
|
+
error: attempt?.error
|
|
87
|
+
? {
|
|
88
|
+
name: attempt.error.name || "Error",
|
|
89
|
+
message: attempt.error.message || "",
|
|
90
|
+
stack: attempt.error.stack || attempt.error.message || "",
|
|
91
|
+
}
|
|
92
|
+
: null,
|
|
93
|
+
screenshots,
|
|
94
|
+
video: normalizePath(projectRoot, specVideo),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function normalizeCypressResults(results, context) {
|
|
99
|
+
const projectRoot = context.projectRoot;
|
|
100
|
+
const startedAt =
|
|
101
|
+
results?.startedTestsAt || context.startedAt || new Date().toISOString();
|
|
102
|
+
const endedAt = results?.endedTestsAt || new Date().toISOString();
|
|
103
|
+
const runId = context.runId || createRunId(startedAt);
|
|
104
|
+
const tests = [];
|
|
105
|
+
const specs = [];
|
|
106
|
+
|
|
107
|
+
for (const specRun of results?.runs || []) {
|
|
108
|
+
const specPath =
|
|
109
|
+
specRun?.spec?.relative || specRun?.spec?.name || "unknown-spec";
|
|
110
|
+
const specVideo = specRun?.video || null;
|
|
111
|
+
const specTests = [];
|
|
112
|
+
const normalizedSpecTests = [];
|
|
113
|
+
const specScreenshots = (specRun?.screenshots || [])
|
|
114
|
+
.map((screenshot) => {
|
|
115
|
+
const normalized = normalizePath(projectRoot, screenshot.path);
|
|
116
|
+
return normalized
|
|
117
|
+
? {
|
|
118
|
+
...normalized,
|
|
119
|
+
name: screenshot.name || path.basename(screenshot.path),
|
|
120
|
+
takenAt: screenshot.takenAt || null,
|
|
121
|
+
width: screenshot.width || null,
|
|
122
|
+
height: screenshot.height || null,
|
|
123
|
+
}
|
|
124
|
+
: null;
|
|
125
|
+
})
|
|
126
|
+
.filter(Boolean);
|
|
127
|
+
|
|
128
|
+
for (const test of specRun?.tests || []) {
|
|
129
|
+
const titlePath = Array.isArray(test.title)
|
|
130
|
+
? test.title
|
|
131
|
+
: Array.isArray(test.titlePath)
|
|
132
|
+
? test.titlePath
|
|
133
|
+
: [test.title || "Unnamed test"];
|
|
134
|
+
const attempts = (test.attempts || []).map((attempt, index) =>
|
|
135
|
+
normalizeAttempt(projectRoot, attempt, index, specVideo),
|
|
136
|
+
);
|
|
137
|
+
const finalAttempt = attempts.at(-1);
|
|
138
|
+
const status = normalizeStatus(test.state || finalAttempt?.state);
|
|
139
|
+
const testId = stableId(
|
|
140
|
+
context.projectName || "acceptance-tests",
|
|
141
|
+
specPath,
|
|
142
|
+
...titlePath,
|
|
143
|
+
);
|
|
144
|
+
const normalizedTest = {
|
|
145
|
+
id: testId,
|
|
146
|
+
identityVersion: 2,
|
|
147
|
+
spec: specPath.replaceAll("\\", "/"),
|
|
148
|
+
title: titlePath.at(-1),
|
|
149
|
+
titlePath,
|
|
150
|
+
suite: titlePath.slice(0, -1).join(" › "),
|
|
151
|
+
status,
|
|
152
|
+
durationMs: attempts.reduce(
|
|
153
|
+
(total, attempt) => total + attempt.durationMs,
|
|
154
|
+
0,
|
|
155
|
+
),
|
|
156
|
+
retries: Math.max(0, attempts.length - 1),
|
|
157
|
+
flaky: status === "passed" && attempts.some((attempt) => attempt.state === "failed"),
|
|
158
|
+
error:
|
|
159
|
+
finalAttempt?.error ||
|
|
160
|
+
(test.displayError
|
|
161
|
+
? {
|
|
162
|
+
name: "Error",
|
|
163
|
+
message: test.displayError,
|
|
164
|
+
stack: test.displayError,
|
|
165
|
+
}
|
|
166
|
+
: null),
|
|
167
|
+
attempts,
|
|
168
|
+
steps: [],
|
|
169
|
+
tags: [],
|
|
170
|
+
logs: [],
|
|
171
|
+
http: [],
|
|
172
|
+
attachments: [],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
tests.push(normalizedTest);
|
|
176
|
+
normalizedSpecTests.push(normalizedTest);
|
|
177
|
+
specTests.push(testId);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const failedSpecTests = normalizedSpecTests.filter(
|
|
181
|
+
(test) => test.status === "failed",
|
|
182
|
+
);
|
|
183
|
+
for (const screenshot of specScreenshots) {
|
|
184
|
+
const screenshotText = comparableText(
|
|
185
|
+
`${screenshot.name} ${screenshot.projectPath}`,
|
|
186
|
+
);
|
|
187
|
+
const matchingTest =
|
|
188
|
+
normalizedSpecTests.find((test) =>
|
|
189
|
+
screenshotText.includes(comparableText(test.title)),
|
|
190
|
+
) ||
|
|
191
|
+
(failedSpecTests.length === 1 ? failedSpecTests[0] : null);
|
|
192
|
+
const finalAttempt = matchingTest?.attempts?.at(-1);
|
|
193
|
+
if (finalAttempt) finalAttempt.screenshots.push(screenshot);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
specs.push({
|
|
197
|
+
path: specPath.replaceAll("\\", "/"),
|
|
198
|
+
name: specRun?.spec?.name || path.basename(specPath),
|
|
199
|
+
durationMs: Number(specRun?.stats?.duration || 0),
|
|
200
|
+
video: normalizePath(projectRoot, specVideo),
|
|
201
|
+
screenshots: specScreenshots,
|
|
202
|
+
testIds: specTests,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const counts = tests.reduce(
|
|
207
|
+
(summary, test) => {
|
|
208
|
+
summary.total += 1;
|
|
209
|
+
summary[test.status] = (summary[test.status] || 0) + 1;
|
|
210
|
+
if (test.flaky) summary.flaky += 1;
|
|
211
|
+
return summary;
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
total: 0,
|
|
215
|
+
passed: 0,
|
|
216
|
+
failed: 0,
|
|
217
|
+
pending: 0,
|
|
218
|
+
skipped: 0,
|
|
219
|
+
unknown: 0,
|
|
220
|
+
flaky: 0,
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
schemaVersion: SCHEMA_VERSION,
|
|
226
|
+
id: runId,
|
|
227
|
+
projectName: context.projectName || "acceptance-tests",
|
|
228
|
+
environment: context.environment || "unknown",
|
|
229
|
+
tagExpression: context.tagExpression || "",
|
|
230
|
+
status: counts.failed > 0 ? "failed" : "passed",
|
|
231
|
+
startedAt,
|
|
232
|
+
endedAt,
|
|
233
|
+
durationMs: Number(results?.totalDuration || 0),
|
|
234
|
+
browser: {
|
|
235
|
+
name: results?.browserName || "",
|
|
236
|
+
version: results?.browserVersion || "",
|
|
237
|
+
},
|
|
238
|
+
cypressVersion: results?.cypressVersion || "",
|
|
239
|
+
source: {
|
|
240
|
+
branch: context.branch || process.env.CI_COMMIT_REF_NAME || "",
|
|
241
|
+
commit: context.commit || process.env.CI_COMMIT_SHA || "",
|
|
242
|
+
pipelineId: context.pipelineId || process.env.CI_PIPELINE_ID || "",
|
|
243
|
+
jobId: context.jobId || process.env.CI_JOB_ID || "",
|
|
244
|
+
jobUrl: context.jobUrl || process.env.CI_JOB_URL || "",
|
|
245
|
+
},
|
|
246
|
+
execution: context.execution || null,
|
|
247
|
+
lifecycle: "completed",
|
|
248
|
+
system: {
|
|
249
|
+
name: results?.osName || process.platform,
|
|
250
|
+
version: results?.osVersion || "",
|
|
251
|
+
},
|
|
252
|
+
counts,
|
|
253
|
+
specs,
|
|
254
|
+
tests,
|
|
255
|
+
attachments: [],
|
|
256
|
+
trends: [],
|
|
257
|
+
generatedAt: new Date().toISOString(),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function writeJson(filePath, value) {
|
|
262
|
+
atomicWriteFile(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
module.exports = {
|
|
266
|
+
SCHEMA_VERSION,
|
|
267
|
+
atomicWriteFile,
|
|
268
|
+
createRunId,
|
|
269
|
+
ensureDir,
|
|
270
|
+
normalizeCypressResults,
|
|
271
|
+
safeFileName,
|
|
272
|
+
stableId,
|
|
273
|
+
writeJson,
|
|
274
|
+
};
|