tolkira 0.2.0 → 0.3.0
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/GLOSSARY.md +93 -0
- package/README.md +207 -15
- package/SECURITY.md +3 -0
- package/dist/cli.js +1455 -579
- package/dist/cli.js.map +4 -4
- package/dist/compat/cucumber-html-reporter.cjs +12 -0
- package/dist/compat/cucumber-html-reporter.d.cts +10 -0
- package/dist/compat/cucumber-html-reporter.js +95 -24
- package/dist/compat/cucumber-html-reporter.js.map +4 -4
- package/dist/compat/options.d.ts +2 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.js +1449 -552
- package/dist/index.js.map +4 -4
- package/dist/input/background.d.ts +4 -0
- package/dist/input/load.d.ts +2 -0
- package/dist/options.d.ts +12 -0
- package/dist/output.d.ts +2 -0
- package/dist/render/ansi.d.ts +2 -0
- package/dist/render/client-bundle.d.ts +1 -0
- package/dist/render/markdown.d.ts +1 -0
- package/dist/render/search.d.ts +18 -0
- package/dist/report/attachment.d.ts +10 -0
- package/dist/report/model.d.ts +85 -4
- package/dist/report/status.d.ts +12 -0
- package/dist/stream.d.ts +15 -0
- package/dist/summary.d.ts +14 -2
- package/dist/text.d.ts +15 -0
- package/docs/AGENT-INTERFACE.md +158 -21
- package/docs/COMPATIBILITY.md +51 -7
- package/docs/CUCUMBER-COMPATIBILITY.md +193 -0
- package/docs/JUNIT-XML.md +27 -2
- package/docs/LIMITATIONS.md +17 -0
- package/llms.txt +31 -0
- package/package.json +30 -8
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { realpathSync } from "node:fs";
|
|
5
|
-
import { readFile as readFile2, stat as
|
|
4
|
+
import { realpathSync as realpathSync2 } from "node:fs";
|
|
5
|
+
import { readFile as readFile2, stat as stat3 } from "node:fs/promises";
|
|
6
6
|
import path4 from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
@@ -18,6 +18,17 @@ import {
|
|
|
18
18
|
HookType,
|
|
19
19
|
TestStepResultStatus
|
|
20
20
|
} from "@cucumber/messages";
|
|
21
|
+
|
|
22
|
+
// src/input/background.ts
|
|
23
|
+
var synthetic = /* @__PURE__ */ new WeakSet();
|
|
24
|
+
function markSyntheticBackground(background) {
|
|
25
|
+
synthetic.add(background);
|
|
26
|
+
}
|
|
27
|
+
function isSyntheticBackground(background) {
|
|
28
|
+
return synthetic.has(background);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/input/legacy.ts
|
|
21
32
|
function isRecord(value) {
|
|
22
33
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23
34
|
}
|
|
@@ -338,26 +349,10 @@ function resultOf(legacyStep, scale = 1) {
|
|
|
338
349
|
}
|
|
339
350
|
return result;
|
|
340
351
|
}
|
|
341
|
-
var MIME_EXTENSIONS = {
|
|
342
|
-
"application/json": "json",
|
|
343
|
-
"application/octet-stream": "bin",
|
|
344
|
-
"image/gif": "gif",
|
|
345
|
-
"image/jpeg": "jpg",
|
|
346
|
-
"image/png": "png",
|
|
347
|
-
"image/svg+xml": "svg",
|
|
348
|
-
"text/html": "html",
|
|
349
|
-
"text/plain": "txt",
|
|
350
|
-
"video/mp4": "mp4",
|
|
351
|
-
"video/webm": "webm"
|
|
352
|
-
};
|
|
353
352
|
function isLikelyBase64(value) {
|
|
354
353
|
const compact = value.replace(/\s/g, "");
|
|
355
354
|
return compact.length > 0 && compact.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(compact);
|
|
356
355
|
}
|
|
357
|
-
function attachmentFileName(mediaType, index) {
|
|
358
|
-
const extension = MIME_EXTENSIONS[mediaType.toLowerCase()] ?? mediaType.split("/")[1]?.split(";")[0]?.trim() ?? "bin";
|
|
359
|
-
return `attachment-${index + 1}.${extension}`;
|
|
360
|
-
}
|
|
361
356
|
function parseLegacyJson(content, source, options = {}) {
|
|
362
357
|
let parsed;
|
|
363
358
|
try {
|
|
@@ -379,7 +374,6 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
379
374
|
const runId = nextId("run");
|
|
380
375
|
const envelopes = [];
|
|
381
376
|
const statuses = [];
|
|
382
|
-
let attachmentCounter = 0;
|
|
383
377
|
const meta = {
|
|
384
378
|
protocolVersion: "",
|
|
385
379
|
implementation: { name: "tolkira-legacy-json" },
|
|
@@ -424,14 +418,18 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
424
418
|
description: normalizeText(backgroundElement.description),
|
|
425
419
|
steps: backgroundNodes
|
|
426
420
|
};
|
|
421
|
+
markSyntheticBackground(background);
|
|
427
422
|
featureChildren.push({ background });
|
|
428
423
|
}
|
|
429
424
|
const scenarios = (legacyFeature.elements ?? []).filter(
|
|
430
425
|
(element) => !isBackgroundElement(element)
|
|
431
426
|
);
|
|
427
|
+
const featureTagNames = new Set(featureTags.map((tag) => tag.name));
|
|
432
428
|
for (const [scenarioIndex, element] of scenarios.entries()) {
|
|
433
429
|
const scenarioId = nextId("scenario");
|
|
434
|
-
const scenarioTags2 = mapTags(element.tags, nextId)
|
|
430
|
+
const scenarioTags2 = mapTags(element.tags, nextId).filter(
|
|
431
|
+
(tag) => !featureTagNames.has(tag.name)
|
|
432
|
+
);
|
|
435
433
|
const scenarioSteps = (element.steps ?? []).filter((step) => !isHook(step));
|
|
436
434
|
const stepNodes = scenarioSteps.map((step) => mapStep(step, nextId));
|
|
437
435
|
const backgroundInline = backgroundSteps.length > 0 && backgroundSteps.every(
|
|
@@ -576,7 +574,6 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
576
574
|
body: embedding.data,
|
|
577
575
|
contentEncoding: isLikelyBase64(embedding.data) ? AttachmentContentEncoding.BASE64 : AttachmentContentEncoding.IDENTITY,
|
|
578
576
|
mediaType,
|
|
579
|
-
fileName: attachmentFileName(mediaType, attachmentCounter++),
|
|
580
577
|
testCaseStartedId,
|
|
581
578
|
testStepId: plan.testStep.id,
|
|
582
579
|
timestamp: finishedAt
|
|
@@ -687,12 +684,12 @@ function secondsToNanoseconds(value) {
|
|
|
687
684
|
function isXmlChar(code) {
|
|
688
685
|
return code === 9 || code === 10 || code === 13 || code >= 32 && code <= 55295 || code >= 57344 && code <= 65533 || code >= 65536 && code <= 1114111;
|
|
689
686
|
}
|
|
690
|
-
function checkEntityReferences(fragment, source
|
|
687
|
+
function checkEntityReferences(fragment, source) {
|
|
691
688
|
const entityPattern = /&([^;]{1,32});/g;
|
|
692
689
|
let match;
|
|
693
690
|
while ((match = entityPattern.exec(fragment)) !== null) {
|
|
694
691
|
const entity = match[1];
|
|
695
|
-
if (entity === "amp" || entity === "lt" || entity === "gt" || entity === "quot" || entity === "apos"
|
|
692
|
+
if (entity === "amp" || entity === "lt" || entity === "gt" || entity === "quot" || entity === "apos") {
|
|
696
693
|
continue;
|
|
697
694
|
}
|
|
698
695
|
let code;
|
|
@@ -708,8 +705,7 @@ function checkEntityReferences(fragment, source, allowedNames) {
|
|
|
708
705
|
}
|
|
709
706
|
}
|
|
710
707
|
}
|
|
711
|
-
function
|
|
712
|
-
const allowedNames = /* @__PURE__ */ new Set();
|
|
708
|
+
function assertSafeMarkup(content, source) {
|
|
713
709
|
const scanTag = (start) => {
|
|
714
710
|
let index2 = start + 1;
|
|
715
711
|
let quote = "";
|
|
@@ -718,11 +714,7 @@ function assertValidEntities(content, source) {
|
|
|
718
714
|
const char = content[index2];
|
|
719
715
|
if (quote) {
|
|
720
716
|
if (char === quote) {
|
|
721
|
-
checkEntityReferences(
|
|
722
|
-
content.slice(valueStart, index2),
|
|
723
|
-
source,
|
|
724
|
-
allowedNames
|
|
725
|
-
);
|
|
717
|
+
checkEntityReferences(content.slice(valueStart, index2), source);
|
|
726
718
|
quote = "";
|
|
727
719
|
}
|
|
728
720
|
} else if (char === '"' || char === "'") {
|
|
@@ -735,47 +727,15 @@ function assertValidEntities(content, source) {
|
|
|
735
727
|
}
|
|
736
728
|
return index2;
|
|
737
729
|
};
|
|
738
|
-
const scanDoctype = (start) => {
|
|
739
|
-
let index2 = start + "<!DOCTYPE".length;
|
|
740
|
-
let quote = "";
|
|
741
|
-
let depth = 0;
|
|
742
|
-
while (index2 < content.length) {
|
|
743
|
-
const char = content[index2];
|
|
744
|
-
if (quote) {
|
|
745
|
-
if (char === quote) quote = "";
|
|
746
|
-
} else if (char === '"' || char === "'") {
|
|
747
|
-
quote = char;
|
|
748
|
-
} else if (char === "[") {
|
|
749
|
-
depth += 1;
|
|
750
|
-
} else if (char === "]") {
|
|
751
|
-
depth -= 1;
|
|
752
|
-
} else if (char === ">" && depth <= 0) {
|
|
753
|
-
const doctype = content.slice(start, index2 + 1);
|
|
754
|
-
for (const entity of doctype.matchAll(
|
|
755
|
-
/<!ENTITY\s+([A-Za-z_:][\w.:-]*)/g
|
|
756
|
-
)) {
|
|
757
|
-
const name = entity[1];
|
|
758
|
-
if (name) allowedNames.add(name);
|
|
759
|
-
}
|
|
760
|
-
return index2 + 1;
|
|
761
|
-
}
|
|
762
|
-
index2 += 1;
|
|
763
|
-
}
|
|
764
|
-
return index2;
|
|
765
|
-
};
|
|
766
730
|
let index = 0;
|
|
767
731
|
while (index < content.length) {
|
|
768
732
|
const start = content.indexOf("<", index);
|
|
769
733
|
if (start === -1) {
|
|
770
|
-
checkEntityReferences(content.slice(index), source
|
|
734
|
+
checkEntityReferences(content.slice(index), source);
|
|
771
735
|
return;
|
|
772
736
|
}
|
|
773
737
|
if (start > index) {
|
|
774
|
-
checkEntityReferences(
|
|
775
|
-
content.slice(index, start),
|
|
776
|
-
source,
|
|
777
|
-
allowedNames
|
|
778
|
-
);
|
|
738
|
+
checkEntityReferences(content.slice(index, start), source);
|
|
779
739
|
}
|
|
780
740
|
if (content.startsWith("<!--", start)) {
|
|
781
741
|
const end = content.indexOf("-->", start + 4);
|
|
@@ -786,9 +746,15 @@ function assertValidEntities(content, source) {
|
|
|
786
746
|
} else if (content.startsWith("<?", start)) {
|
|
787
747
|
const end = content.indexOf("?>", start + 2);
|
|
788
748
|
index = end === -1 ? content.length : end + 2;
|
|
789
|
-
} else if (content.startsWith("<!DOCTYPE", start)) {
|
|
790
|
-
index = scanDoctype(start);
|
|
791
749
|
} else if (content.startsWith("<!", start)) {
|
|
750
|
+
const declaration = /^<!(DOCTYPE|ENTITY)\b/i.exec(
|
|
751
|
+
content.slice(start, start + 10)
|
|
752
|
+
);
|
|
753
|
+
if (declaration) {
|
|
754
|
+
throw new Error(
|
|
755
|
+
`Invalid JUnit XML in ${source}: <!${declaration[1].toUpperCase()}> declarations are not supported.`
|
|
756
|
+
);
|
|
757
|
+
}
|
|
792
758
|
const end = content.indexOf(">", start + 2);
|
|
793
759
|
index = end === -1 ? content.length : end + 1;
|
|
794
760
|
} else {
|
|
@@ -841,6 +807,7 @@ function elementFromTestcase(testcase, index) {
|
|
|
841
807
|
const skipped = asArray(testcase.skipped).length > 0;
|
|
842
808
|
const status = hasFailure ? "failed" : skipped ? "skipped" : "passed";
|
|
843
809
|
const name = stringOf(testcase.name) || stringOf(testcase.classname) || `Test ${index + 1}`;
|
|
810
|
+
const description = stringOf(testcase.description);
|
|
844
811
|
const result = {
|
|
845
812
|
status,
|
|
846
813
|
duration: secondsToNanoseconds(testcase.time)
|
|
@@ -869,6 +836,7 @@ function elementFromTestcase(testcase, index) {
|
|
|
869
836
|
type: "scenario",
|
|
870
837
|
keyword: "Scenario",
|
|
871
838
|
name,
|
|
839
|
+
description,
|
|
872
840
|
line: 1,
|
|
873
841
|
tags: [],
|
|
874
842
|
steps: [step]
|
|
@@ -880,6 +848,7 @@ function featureFromSuite(suite, source, index) {
|
|
|
880
848
|
return {
|
|
881
849
|
keyword: "Feature",
|
|
882
850
|
name,
|
|
851
|
+
description: stringOf(suite.description),
|
|
883
852
|
uri: source,
|
|
884
853
|
line: 1,
|
|
885
854
|
tags: [],
|
|
@@ -894,7 +863,7 @@ function looksLikeJUnit(content) {
|
|
|
894
863
|
}
|
|
895
864
|
async function parseJUnitXml(content, source, options = {}) {
|
|
896
865
|
const { XMLParser, XMLValidator } = await import("fast-xml-parser");
|
|
897
|
-
|
|
866
|
+
assertSafeMarkup(content, source);
|
|
898
867
|
const validation = XMLValidator.validate(content);
|
|
899
868
|
if (validation !== true) {
|
|
900
869
|
const line = Number.isFinite(validation.err.line) ? validation.err.line : 1;
|
|
@@ -1157,6 +1126,14 @@ function parseMessages(content, source) {
|
|
|
1157
1126
|
// src/input/load.ts
|
|
1158
1127
|
var MESSAGES_EXTENSIONS = /* @__PURE__ */ new Set([".jsonl", ".ndjson"]);
|
|
1159
1128
|
var MAX_TOTAL_INPUT_BYTES = 100 * 1024 * 1024;
|
|
1129
|
+
function addInputBytes(totalBytes, size) {
|
|
1130
|
+
if (totalBytes + size > MAX_TOTAL_INPUT_BYTES) {
|
|
1131
|
+
throw new Error(
|
|
1132
|
+
"Inputs exceed 100 MB in total. Split the report or use external attachments."
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1135
|
+
return totalBytes + size;
|
|
1136
|
+
}
|
|
1160
1137
|
function isObject3(value) {
|
|
1161
1138
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1162
1139
|
}
|
|
@@ -1251,16 +1228,12 @@ async function loadInputs(inputs) {
|
|
|
1251
1228
|
let totalBytes = 0;
|
|
1252
1229
|
for (const [index, input] of ordered.entries()) {
|
|
1253
1230
|
const info = await stat(input.file);
|
|
1254
|
-
|
|
1255
|
-
throw new Error(
|
|
1256
|
-
"Inputs exceed 100 MB in total. Split the report or use external attachments."
|
|
1257
|
-
);
|
|
1258
|
-
}
|
|
1231
|
+
const nextTotal = addInputBytes(totalBytes, info.size);
|
|
1259
1232
|
const content = await readFile(input.file, "utf8");
|
|
1260
1233
|
const hash = createHash("sha256").update(content).digest("hex");
|
|
1261
1234
|
if (seenContent.has(hash)) continue;
|
|
1262
1235
|
seenContent.add(hash);
|
|
1263
|
-
totalBytes
|
|
1236
|
+
totalBytes = nextTotal;
|
|
1264
1237
|
const extension = path2.extname(input.file).toLowerCase();
|
|
1265
1238
|
const legacy = sniffLegacy(content);
|
|
1266
1239
|
let parsed = [];
|
|
@@ -1364,19 +1337,28 @@ function provenanceFor(groups) {
|
|
|
1364
1337
|
return provenance;
|
|
1365
1338
|
}
|
|
1366
1339
|
|
|
1340
|
+
// src/options.ts
|
|
1341
|
+
function renderOptions(options) {
|
|
1342
|
+
return {
|
|
1343
|
+
title: options.title ?? "Tolkira report",
|
|
1344
|
+
metadata: options.metadata,
|
|
1345
|
+
logo: options.logo,
|
|
1346
|
+
accent: options.accent
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1367
1350
|
// src/render/html.ts
|
|
1368
1351
|
import { createHash as createHash2 } from "node:crypto";
|
|
1369
1352
|
|
|
1370
1353
|
// src/input/sanitize.ts
|
|
1371
1354
|
var REMOTE_MARKDOWN_IMAGE = /!\[([^\]]*)\]\(\s*(?:https?:)?\/\/[^)\s]+(?:\s+["'][^"']*["'])?\s*\)/gi;
|
|
1372
1355
|
var REMOTE_ANGLE_IMAGE = /!\[([^\]]*)\]\(\s*<(?:https?:)?\/\/[^>]+>\s*\)/gi;
|
|
1373
|
-
var REMOTE_REFERENCE_DEFINITION = /^\s*\[[^\]]+\]:\s*(?:https?:)?\/\/\S+.*$/gim;
|
|
1374
1356
|
var RAW_IMAGE_TAG = /<img\b[^>]*>/gi;
|
|
1375
1357
|
var MAX_ATTACHMENT_BYTES = 50 * 1024 * 1024;
|
|
1376
1358
|
var MAX_TOTAL_ATTACHMENT_BYTES = 100 * 1024 * 1024;
|
|
1377
1359
|
function stripRemoteImages(value) {
|
|
1378
1360
|
if (typeof value !== "string") return "";
|
|
1379
|
-
return value.replace(REMOTE_ANGLE_IMAGE, "$1").replace(REMOTE_MARKDOWN_IMAGE, "$1
|
|
1361
|
+
return value.replace(REMOTE_ANGLE_IMAGE, "![$1]()").replace(REMOTE_MARKDOWN_IMAGE, "![$1]()").replace(RAW_IMAGE_TAG, "");
|
|
1380
1362
|
}
|
|
1381
1363
|
function base64Bytes(value) {
|
|
1382
1364
|
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
@@ -1445,11 +1427,35 @@ function sanitizeEnvelopes(envelopes) {
|
|
|
1445
1427
|
return envelopes;
|
|
1446
1428
|
}
|
|
1447
1429
|
|
|
1430
|
+
// src/report/attachment.ts
|
|
1431
|
+
var MAX_TEXT_ATTACHMENT_BYTES = 262144;
|
|
1432
|
+
var MEDIA_EXTENSIONS = {
|
|
1433
|
+
"application/json": "json",
|
|
1434
|
+
"application/octet-stream": "bin",
|
|
1435
|
+
"image/gif": "gif",
|
|
1436
|
+
"image/jpeg": "jpg",
|
|
1437
|
+
"image/png": "png",
|
|
1438
|
+
"image/svg+xml": "svg",
|
|
1439
|
+
"image/webp": "webp",
|
|
1440
|
+
"text/csv": "csv",
|
|
1441
|
+
"text/html": "html",
|
|
1442
|
+
"text/plain": "txt",
|
|
1443
|
+
"text/uri-list": "txt",
|
|
1444
|
+
"text/x.cucumber.log+plain": "log",
|
|
1445
|
+
"video/mp4": "mp4",
|
|
1446
|
+
"video/webm": "webm"
|
|
1447
|
+
};
|
|
1448
|
+
function normalizedMediaType(mediaType) {
|
|
1449
|
+
return mediaType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
1450
|
+
}
|
|
1451
|
+
var SAFE_MEDIA_TYPES = new Set(Object.keys(MEDIA_EXTENSIONS));
|
|
1452
|
+
function safeMediaType(mediaType) {
|
|
1453
|
+
const base = normalizedMediaType(mediaType || "");
|
|
1454
|
+
return SAFE_MEDIA_TYPES.has(base) ? base : "application/octet-stream";
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1448
1457
|
// src/report/model.ts
|
|
1449
|
-
import {
|
|
1450
|
-
getWorstTestStepResult,
|
|
1451
|
-
TestStepResultStatus as TestStepResultStatus3
|
|
1452
|
-
} from "@cucumber/messages";
|
|
1458
|
+
import { getWorstTestStepResult } from "@cucumber/messages";
|
|
1453
1459
|
|
|
1454
1460
|
// src/result-message.ts
|
|
1455
1461
|
function stepResultMessage(result) {
|
|
@@ -1462,7 +1468,89 @@ ${message}`;
|
|
|
1462
1468
|
return message || exception || void 0;
|
|
1463
1469
|
}
|
|
1464
1470
|
|
|
1465
|
-
// src/
|
|
1471
|
+
// src/text.ts
|
|
1472
|
+
var BIDI_CONTROLS = /[\u202A-\u202E\u2066-\u2069]/g;
|
|
1473
|
+
var ANSI_CONTROLS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/;
|
|
1474
|
+
var STRING_INTRODUCERS = /* @__PURE__ */ new Set([144, 152, 157, 158, 159]);
|
|
1475
|
+
function stripBidiControls(value) {
|
|
1476
|
+
return value.replace(BIDI_CONTROLS, "");
|
|
1477
|
+
}
|
|
1478
|
+
function csiEnd(text, start) {
|
|
1479
|
+
let index = start + 1;
|
|
1480
|
+
while (index < text.length && text.charCodeAt(index) >= 48 && text.charCodeAt(index) <= 63) {
|
|
1481
|
+
index += 1;
|
|
1482
|
+
}
|
|
1483
|
+
while (index < text.length && text.charCodeAt(index) >= 32 && text.charCodeAt(index) <= 47) {
|
|
1484
|
+
index += 1;
|
|
1485
|
+
}
|
|
1486
|
+
return index < text.length ? index + 1 : index;
|
|
1487
|
+
}
|
|
1488
|
+
function stringEnd(text, start, allowBel) {
|
|
1489
|
+
let end = start;
|
|
1490
|
+
while (end < text.length) {
|
|
1491
|
+
if (allowBel && text[end] === "\x07") return end + 1;
|
|
1492
|
+
if (text[end] === "\x9C") return end + 1;
|
|
1493
|
+
if (text[end] === "\x1B" && text[end + 1] === "\\") return end + 2;
|
|
1494
|
+
end += 1;
|
|
1495
|
+
}
|
|
1496
|
+
return void 0;
|
|
1497
|
+
}
|
|
1498
|
+
function isEscapeIntroducer(code) {
|
|
1499
|
+
return code === 27 || code === 155 || STRING_INTRODUCERS.has(code);
|
|
1500
|
+
}
|
|
1501
|
+
function scanEscape(text, start) {
|
|
1502
|
+
const first = text.charCodeAt(start);
|
|
1503
|
+
if (first === 155) {
|
|
1504
|
+
const end2 = csiEnd(text, start);
|
|
1505
|
+
const final = end2 > start + 1 ? text[end2 - 1] : "";
|
|
1506
|
+
return final === "m" ? { end: end2, sgr: text.slice(start + 1, end2 - 1) } : { end: end2 };
|
|
1507
|
+
}
|
|
1508
|
+
if (STRING_INTRODUCERS.has(first)) {
|
|
1509
|
+
return {
|
|
1510
|
+
end: stringEnd(text, start + 1, first === 157) ?? start + 1
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
let index = start + 1;
|
|
1514
|
+
if (index >= text.length) return { end: index };
|
|
1515
|
+
const introducer = text[index];
|
|
1516
|
+
if (introducer === "[") {
|
|
1517
|
+
const end2 = csiEnd(text, index);
|
|
1518
|
+
const final = end2 > index + 1 ? text[end2 - 1] : "";
|
|
1519
|
+
return final === "m" ? { end: end2, sgr: text.slice(index + 1, end2 - 1) } : { end: end2 };
|
|
1520
|
+
}
|
|
1521
|
+
if (introducer === "]" || introducer === "P" || introducer === "_" || introducer === "^" || introducer === "X") {
|
|
1522
|
+
return { end: stringEnd(text, index + 1, introducer === "]") ?? text.length };
|
|
1523
|
+
}
|
|
1524
|
+
let end = index;
|
|
1525
|
+
while (end < text.length && text.charCodeAt(end) >= 32 && text.charCodeAt(end) <= 47) {
|
|
1526
|
+
end += 1;
|
|
1527
|
+
}
|
|
1528
|
+
if (end < text.length && text.charCodeAt(end) >= 48 && text.charCodeAt(end) <= 126) {
|
|
1529
|
+
end += 1;
|
|
1530
|
+
}
|
|
1531
|
+
return { end };
|
|
1532
|
+
}
|
|
1533
|
+
function isControl(code) {
|
|
1534
|
+
return code === 127 || code >= 128 && code <= 159 || code < 32 && code !== 9 && code !== 10;
|
|
1535
|
+
}
|
|
1536
|
+
function stripAnsi(text) {
|
|
1537
|
+
if (!ANSI_CONTROLS.test(text)) return text;
|
|
1538
|
+
let output = "";
|
|
1539
|
+
let chunkStart = 0;
|
|
1540
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
1541
|
+
const code = text.charCodeAt(index);
|
|
1542
|
+
const escape = isEscapeIntroducer(code);
|
|
1543
|
+
if (escape || isControl(code)) {
|
|
1544
|
+
if (index > chunkStart) output += text.slice(chunkStart, index);
|
|
1545
|
+
if (escape) index = scanEscape(text, index).end - 1;
|
|
1546
|
+
chunkStart = index + 1;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return output + text.slice(chunkStart);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// src/report/status.ts
|
|
1553
|
+
import { TestStepResultStatus as TestStepResultStatus3 } from "@cucumber/messages";
|
|
1466
1554
|
var STATUS_ORDER = [
|
|
1467
1555
|
TestStepResultStatus3.UNKNOWN,
|
|
1468
1556
|
TestStepResultStatus3.PASSED,
|
|
@@ -1475,6 +1563,22 @@ var STATUS_ORDER = [
|
|
|
1475
1563
|
function statusSeverity(status) {
|
|
1476
1564
|
return STATUS_ORDER.indexOf(status.toUpperCase());
|
|
1477
1565
|
}
|
|
1566
|
+
function worstExecutedStatus(scenarios) {
|
|
1567
|
+
const executed = scenarios.filter((scenario) => scenario.executed);
|
|
1568
|
+
if (executed.length === 0) return "unknown";
|
|
1569
|
+
let worst = "unknown";
|
|
1570
|
+
let hasNonPassed = false;
|
|
1571
|
+
for (const scenario of executed) {
|
|
1572
|
+
if (scenario.status === "passed") continue;
|
|
1573
|
+
hasNonPassed = true;
|
|
1574
|
+
if (statusSeverity(scenario.status) > statusSeverity(worst)) {
|
|
1575
|
+
worst = scenario.status;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
return hasNonPassed ? worst : "passed";
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
// src/report/model.ts
|
|
1478
1582
|
var VALID_STATUS = /* @__PURE__ */ new Set([
|
|
1479
1583
|
"passed",
|
|
1480
1584
|
"failed",
|
|
@@ -1517,60 +1621,67 @@ function productLabel(product) {
|
|
|
1517
1621
|
const label = [product.name, product.version].filter(Boolean).join(" ");
|
|
1518
1622
|
return label || void 0;
|
|
1519
1623
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
function
|
|
1525
|
-
|
|
1624
|
+
function nonEmpty(value) {
|
|
1625
|
+
const trimmed = stripBidiControls(value ?? "").trim();
|
|
1626
|
+
return trimmed ? trimmed : void 0;
|
|
1627
|
+
}
|
|
1628
|
+
function ciFromMeta(ci) {
|
|
1629
|
+
if (!ci) return void 0;
|
|
1630
|
+
const git = ci.git;
|
|
1631
|
+
const name = nonEmpty(ci.name);
|
|
1632
|
+
const url = nonEmpty(ci.url);
|
|
1633
|
+
const remote = nonEmpty(git?.remote);
|
|
1634
|
+
const revision = nonEmpty(git?.revision);
|
|
1635
|
+
const branch = nonEmpty(git?.branch);
|
|
1636
|
+
const tag = nonEmpty(git?.tag);
|
|
1637
|
+
const result = {
|
|
1638
|
+
...name ? { name } : {},
|
|
1639
|
+
...url ? { url } : {},
|
|
1640
|
+
...remote ? { remote } : {},
|
|
1641
|
+
...revision ? { revision } : {},
|
|
1642
|
+
...branch ? { branch } : {},
|
|
1643
|
+
...tag ? { tag } : {}
|
|
1644
|
+
};
|
|
1645
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
1526
1646
|
}
|
|
1527
1647
|
function hookLabel(type) {
|
|
1528
1648
|
switch (type) {
|
|
1529
1649
|
case "BEFORE_TEST_CASE":
|
|
1530
|
-
return "Before
|
|
1650
|
+
return "Before";
|
|
1531
1651
|
case "AFTER_TEST_CASE":
|
|
1532
|
-
return "After
|
|
1652
|
+
return "After";
|
|
1533
1653
|
case "BEFORE_TEST_STEP":
|
|
1534
|
-
return "
|
|
1654
|
+
return "BeforeStep";
|
|
1535
1655
|
case "AFTER_TEST_STEP":
|
|
1536
|
-
return "
|
|
1656
|
+
return "AfterStep";
|
|
1537
1657
|
case "BEFORE_TEST_RUN":
|
|
1538
|
-
return "
|
|
1658
|
+
return "BeforeAll";
|
|
1539
1659
|
case "AFTER_TEST_RUN":
|
|
1540
|
-
return "
|
|
1660
|
+
return "AfterAll";
|
|
1541
1661
|
default:
|
|
1542
1662
|
return "Hook";
|
|
1543
1663
|
}
|
|
1544
1664
|
}
|
|
1545
|
-
function
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
"image/gif": "gif",
|
|
1550
|
-
"image/jpeg": "jpg",
|
|
1551
|
-
"image/png": "png",
|
|
1552
|
-
"image/svg+xml": "svg",
|
|
1553
|
-
"text/html": "html",
|
|
1554
|
-
"text/plain": "txt",
|
|
1555
|
-
"video/mp4": "mp4",
|
|
1556
|
-
"video/webm": "webm"
|
|
1557
|
-
};
|
|
1558
|
-
return map[mediaType.toLowerCase()] ?? mediaType.split("/")[1]?.split(";")[0] ?? "bin";
|
|
1665
|
+
function attachmentFileName(fileName, mediaType) {
|
|
1666
|
+
if (fileName) return fileName;
|
|
1667
|
+
const extension = MEDIA_EXTENSIONS[normalizedMediaType(mediaType)];
|
|
1668
|
+
return extension ? `attachment.${extension}` : "attachment";
|
|
1559
1669
|
}
|
|
1560
1670
|
function attachmentKind(mediaType) {
|
|
1561
|
-
|
|
1562
|
-
if (
|
|
1563
|
-
if (
|
|
1564
|
-
if (
|
|
1671
|
+
const base = normalizedMediaType(mediaType);
|
|
1672
|
+
if (base.startsWith("image/")) return "image";
|
|
1673
|
+
if (base.startsWith("video/")) return "video";
|
|
1674
|
+
if (base.startsWith("audio/")) return "audio";
|
|
1675
|
+
if (base.startsWith("text/") || base.includes("json")) {
|
|
1565
1676
|
return "text";
|
|
1566
1677
|
}
|
|
1567
1678
|
return "binary";
|
|
1568
1679
|
}
|
|
1569
|
-
function toAttachment(attachment
|
|
1680
|
+
function toAttachment(attachment) {
|
|
1570
1681
|
const body = attachment.body ?? "";
|
|
1571
|
-
const mediaType = attachment.mediaType || "application/octet-stream";
|
|
1682
|
+
const mediaType = safeMediaType(attachment.mediaType || "application/octet-stream");
|
|
1572
1683
|
const kind = attachmentKind(mediaType);
|
|
1573
|
-
const fileName = attachment.fileName
|
|
1684
|
+
const fileName = attachmentFileName(attachment.fileName, mediaType);
|
|
1574
1685
|
const isBase64 = attachment.contentEncoding === "BASE64";
|
|
1575
1686
|
const bytes = isBase64 ? Math.max(0, Math.floor(body.length * 3 / 4) - (body.endsWith("==") ? 2 : body.endsWith("=") ? 1 : 0)) : Buffer.byteLength(body, "utf8");
|
|
1576
1687
|
if (kind === "image" || kind === "video" || kind === "audio") {
|
|
@@ -1631,13 +1742,70 @@ function count(counts, status) {
|
|
|
1631
1742
|
counts.total += 1;
|
|
1632
1743
|
counts[status] += 1;
|
|
1633
1744
|
}
|
|
1745
|
+
function backgroundRow(background) {
|
|
1746
|
+
if (isSyntheticBackground(background)) return void 0;
|
|
1747
|
+
return {
|
|
1748
|
+
id: background.id,
|
|
1749
|
+
keyword: background.keyword || "Background",
|
|
1750
|
+
name: background.name ?? "",
|
|
1751
|
+
description: normalizeText2(background.description)
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
function backgroundsOf(children) {
|
|
1755
|
+
const rows = [];
|
|
1756
|
+
for (const child of children ?? []) {
|
|
1757
|
+
if (!child.background) continue;
|
|
1758
|
+
const row = backgroundRow(child.background);
|
|
1759
|
+
if (row) rows.push(row);
|
|
1760
|
+
}
|
|
1761
|
+
return rows;
|
|
1762
|
+
}
|
|
1763
|
+
function ruleMetadata(rule) {
|
|
1764
|
+
return {
|
|
1765
|
+
id: rule.id,
|
|
1766
|
+
keyword: rule.keyword || "Rule",
|
|
1767
|
+
name: rule.name ?? "",
|
|
1768
|
+
description: normalizeText2(rule.description),
|
|
1769
|
+
tags: (rule.tags ?? []).map((tag) => tag.name),
|
|
1770
|
+
backgrounds: backgroundsOf(rule.children ?? [])
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1634
1773
|
function featureTree(document) {
|
|
1635
1774
|
const map = /* @__PURE__ */ new Map();
|
|
1636
1775
|
if (!document) return map;
|
|
1637
|
-
const visit = (children,
|
|
1776
|
+
const visit = (children, rule) => {
|
|
1777
|
+
for (const child of children) {
|
|
1778
|
+
if (child.scenario) {
|
|
1779
|
+
map.set(child.scenario.id, { scenario: child.scenario, ...rule ? { rule } : {} });
|
|
1780
|
+
}
|
|
1781
|
+
if ("rule" in child && child.rule) {
|
|
1782
|
+
visit(child.rule.children ?? [], ruleMetadata(child.rule));
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1786
|
+
visit(document.children ?? []);
|
|
1787
|
+
return map;
|
|
1788
|
+
}
|
|
1789
|
+
function exampleRowTree(document, uri) {
|
|
1790
|
+
const map = /* @__PURE__ */ new Map();
|
|
1791
|
+
if (!document) return map;
|
|
1792
|
+
const visit = (children) => {
|
|
1638
1793
|
for (const child of children) {
|
|
1639
|
-
if (child.scenario)
|
|
1640
|
-
|
|
1794
|
+
if (child.scenario) {
|
|
1795
|
+
const scenario = child.scenario;
|
|
1796
|
+
(scenario.examples ?? []).forEach((examples, examplesIndex) => {
|
|
1797
|
+
(examples.tableBody ?? []).forEach((row, exampleIndex) => {
|
|
1798
|
+
map.set(row.id, {
|
|
1799
|
+
uri,
|
|
1800
|
+
scenario,
|
|
1801
|
+
examples,
|
|
1802
|
+
examplesIndex,
|
|
1803
|
+
exampleIndex
|
|
1804
|
+
});
|
|
1805
|
+
});
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
if ("rule" in child && child.rule) visit(child.rule.children ?? []);
|
|
1641
1809
|
}
|
|
1642
1810
|
};
|
|
1643
1811
|
visit(document.children ?? []);
|
|
@@ -1649,17 +1817,21 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1649
1817
|
const featureSeen = /* @__PURE__ */ new Set();
|
|
1650
1818
|
const featureOrder = [];
|
|
1651
1819
|
const scenarioTree = /* @__PURE__ */ new Map();
|
|
1820
|
+
const outlineRows = /* @__PURE__ */ new Map();
|
|
1652
1821
|
const featureByScenarioId = /* @__PURE__ */ new Map();
|
|
1653
1822
|
const stepById = /* @__PURE__ */ new Map();
|
|
1654
1823
|
const pickles = /* @__PURE__ */ new Map();
|
|
1655
1824
|
const testCases = /* @__PURE__ */ new Map();
|
|
1656
1825
|
const started = /* @__PURE__ */ new Map();
|
|
1657
1826
|
const hooks = /* @__PURE__ */ new Map();
|
|
1827
|
+
const runHookStarts = /* @__PURE__ */ new Map();
|
|
1828
|
+
const runHookFinishes = /* @__PURE__ */ new Map();
|
|
1658
1829
|
const results = /* @__PURE__ */ new Map();
|
|
1659
1830
|
const attachments = /* @__PURE__ */ new Map();
|
|
1660
|
-
const
|
|
1831
|
+
const runHookAttachments = /* @__PURE__ */ new Map();
|
|
1832
|
+
const suggestions = /* @__PURE__ */ new Map();
|
|
1833
|
+
const stepDefinitions = /* @__PURE__ */ new Map();
|
|
1661
1834
|
const attachmentCache = /* @__PURE__ */ new Map();
|
|
1662
|
-
let attachmentIndex = 0;
|
|
1663
1835
|
let startedAt;
|
|
1664
1836
|
let finishedAt;
|
|
1665
1837
|
let source = "Cucumber";
|
|
@@ -1667,7 +1839,7 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1667
1839
|
const mapAttachments = (list) => list.map((attachment) => {
|
|
1668
1840
|
const cached = attachmentCache.get(attachment);
|
|
1669
1841
|
if (cached) return cached;
|
|
1670
|
-
const mapped = toAttachment(attachment
|
|
1842
|
+
const mapped = toAttachment(attachment);
|
|
1671
1843
|
attachmentCache.set(attachment, mapped);
|
|
1672
1844
|
return mapped;
|
|
1673
1845
|
});
|
|
@@ -1675,12 +1847,14 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1675
1847
|
if (envelope.meta) {
|
|
1676
1848
|
const { implementation, runtime, os, cpu, protocolVersion } = envelope.meta;
|
|
1677
1849
|
source = productLabel(implementation) ?? "Cucumber";
|
|
1850
|
+
const ci = environment?.ci ?? ciFromMeta(envelope.meta.ci);
|
|
1678
1851
|
const next = {
|
|
1679
1852
|
...implementation && productLabel(implementation) ? { producer: productLabel(implementation) } : {},
|
|
1680
1853
|
...runtime && productLabel(runtime) ? { runtime: productLabel(runtime) } : {},
|
|
1681
1854
|
...os && productLabel(os) ? { os: productLabel(os) } : {},
|
|
1682
1855
|
...cpu && productLabel(cpu) ? { cpu: productLabel(cpu) } : {},
|
|
1683
|
-
...protocolVersion ? { protocol: protocolVersion } : {}
|
|
1856
|
+
...protocolVersion ? { protocol: protocolVersion } : {},
|
|
1857
|
+
...ci ? { ci } : {}
|
|
1684
1858
|
};
|
|
1685
1859
|
if (Object.keys(next).length > 0) environment = next;
|
|
1686
1860
|
}
|
|
@@ -1706,6 +1880,9 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1706
1880
|
scenarioTree.set(id, value);
|
|
1707
1881
|
featureByScenarioId.set(id, feature);
|
|
1708
1882
|
}
|
|
1883
|
+
for (const [id, value] of exampleRowTree(feature, uri ?? "")) {
|
|
1884
|
+
outlineRows.set(id, value);
|
|
1885
|
+
}
|
|
1709
1886
|
const collectSteps = (children) => {
|
|
1710
1887
|
for (const child of children) {
|
|
1711
1888
|
if (child.background) {
|
|
@@ -1722,17 +1899,49 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1722
1899
|
if (envelope.pickle) pickles.set(envelope.pickle.id, envelope.pickle);
|
|
1723
1900
|
if (envelope.testCase) testCases.set(envelope.testCase.id, envelope.testCase);
|
|
1724
1901
|
if (envelope.testCaseStarted) started.set(envelope.testCaseStarted.id, envelope.testCaseStarted);
|
|
1725
|
-
if (envelope.testCaseFinished) finishedStarted.add(envelope.testCaseFinished.testCaseStartedId);
|
|
1726
1902
|
if (envelope.hook) hooks.set(envelope.hook.id, envelope.hook);
|
|
1903
|
+
if (envelope.testRunHookStarted) {
|
|
1904
|
+
runHookStarts.set(envelope.testRunHookStarted.id, envelope.testRunHookStarted);
|
|
1905
|
+
}
|
|
1906
|
+
if (envelope.testRunHookFinished) {
|
|
1907
|
+
runHookFinishes.set(
|
|
1908
|
+
envelope.testRunHookFinished.testRunHookStartedId,
|
|
1909
|
+
envelope.testRunHookFinished
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1727
1912
|
if (envelope.testStepFinished) {
|
|
1728
1913
|
const list = results.get(envelope.testStepFinished.testCaseStartedId) ?? [];
|
|
1729
1914
|
list.push(envelope.testStepFinished);
|
|
1730
1915
|
results.set(envelope.testStepFinished.testCaseStartedId, list);
|
|
1731
1916
|
}
|
|
1732
1917
|
if (envelope.attachment) {
|
|
1733
|
-
const
|
|
1918
|
+
const key = envelope.attachment.testRunHookStartedId;
|
|
1919
|
+
const target = key ? runHookAttachments : attachments;
|
|
1920
|
+
const id = key ?? envelope.attachment.testCaseStartedId ?? "";
|
|
1921
|
+
const list = target.get(id) ?? [];
|
|
1734
1922
|
list.push(envelope.attachment);
|
|
1735
|
-
|
|
1923
|
+
target.set(id, list);
|
|
1924
|
+
}
|
|
1925
|
+
if (envelope.suggestion) {
|
|
1926
|
+
const snippets = Array.isArray(envelope.suggestion.snippets) ? envelope.suggestion.snippets : [];
|
|
1927
|
+
const list = snippets.filter((snippet) => typeof snippet?.code === "string").map((snippet) => ({
|
|
1928
|
+
...typeof snippet.language === "string" && snippet.language ? { language: snippet.language } : {},
|
|
1929
|
+
code: snippet.code
|
|
1930
|
+
}));
|
|
1931
|
+
if (list.length > 0) suggestions.set(envelope.suggestion.pickleStepId, list);
|
|
1932
|
+
}
|
|
1933
|
+
if (envelope.stepDefinition) {
|
|
1934
|
+
const pattern = envelope.stepDefinition.pattern;
|
|
1935
|
+
if (typeof pattern?.source === "string") {
|
|
1936
|
+
const reference = envelope.stepDefinition.sourceReference;
|
|
1937
|
+
const uri = typeof reference?.uri === "string" ? reference.uri : "";
|
|
1938
|
+
const line = typeof reference?.location?.line === "number" ? reference.location.line : void 0;
|
|
1939
|
+
const source2 = uri ? line ? `${uri}:${line}` : uri : void 0;
|
|
1940
|
+
stepDefinitions.set(envelope.stepDefinition.id, {
|
|
1941
|
+
pattern: pattern.source,
|
|
1942
|
+
...source2 ? { source: source2 } : {}
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1736
1945
|
}
|
|
1737
1946
|
}
|
|
1738
1947
|
const testCasesByPickle = /* @__PURE__ */ new Map();
|
|
@@ -1750,34 +1959,39 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1750
1959
|
const scenarioRows = [];
|
|
1751
1960
|
const scenarioCounts = emptyStatusCounts();
|
|
1752
1961
|
const stepCounts = emptyStatusCounts();
|
|
1962
|
+
const hookCounts = emptyStatusCounts();
|
|
1753
1963
|
const featureScenarios = /* @__PURE__ */ new Map();
|
|
1754
1964
|
for (const pickle of pickles.values()) {
|
|
1755
1965
|
const testCasesForPickle = testCasesByPickle.get(pickle.id) ?? [];
|
|
1756
1966
|
const candidates = testCasesForPickle.flatMap(
|
|
1757
1967
|
(testCase2) => startedByTestCase.get(testCase2.id) ?? []
|
|
1758
1968
|
);
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
if (candidate.attempt < current.attempt) return current;
|
|
1765
|
-
const cSeconds = candidate.timestamp?.seconds ?? 0;
|
|
1969
|
+
const latest = candidates.reduce((current, candidate2) => {
|
|
1970
|
+
if (!current) return candidate2;
|
|
1971
|
+
if (candidate2.attempt > current.attempt) return candidate2;
|
|
1972
|
+
if (candidate2.attempt < current.attempt) return current;
|
|
1973
|
+
const cSeconds = candidate2.timestamp?.seconds ?? 0;
|
|
1766
1974
|
const currentSeconds = current.timestamp?.seconds ?? 0;
|
|
1767
|
-
if (cSeconds !== currentSeconds) return cSeconds > currentSeconds ?
|
|
1768
|
-
const cNanos =
|
|
1975
|
+
if (cSeconds !== currentSeconds) return cSeconds > currentSeconds ? candidate2 : current;
|
|
1976
|
+
const cNanos = candidate2.timestamp?.nanos ?? 0;
|
|
1769
1977
|
const currentNanos = current.timestamp?.nanos ?? 0;
|
|
1770
|
-
return cNanos > currentNanos ?
|
|
1978
|
+
return cNanos > currentNanos ? candidate2 : current;
|
|
1771
1979
|
}, void 0);
|
|
1772
1980
|
if (!latest) continue;
|
|
1773
1981
|
const testCase = testCases.get(latest.testCaseId);
|
|
1774
1982
|
if (!testCase) continue;
|
|
1775
1983
|
const pickleSteps = new Map(pickle.steps.map((step) => [step.id, step]));
|
|
1776
|
-
const
|
|
1984
|
+
const rawResults = (results.get(latest.id) ?? []).map(
|
|
1985
|
+
(entry) => entry.testStepResult
|
|
1986
|
+
);
|
|
1987
|
+
const executed = rawResults.length > 0;
|
|
1988
|
+
const startedAttachments = executed ? attachments.get(latest.id) ?? [] : [];
|
|
1777
1989
|
const resultsByStep = new Map(
|
|
1778
1990
|
(results.get(latest.id) ?? []).map((entry) => [entry.testStepId, entry.testStepResult])
|
|
1779
1991
|
);
|
|
1780
1992
|
const stepRows = [];
|
|
1993
|
+
const hookRows = [];
|
|
1994
|
+
let testStepOrder = 0;
|
|
1781
1995
|
for (const testStep of testCase.testSteps) {
|
|
1782
1996
|
const result = resultsByStep.get(testStep.id);
|
|
1783
1997
|
if (!result) continue;
|
|
@@ -1789,8 +2003,30 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1789
2003
|
startedAttachments.filter((attachment) => attachment.testStepId === testStep.id)
|
|
1790
2004
|
);
|
|
1791
2005
|
const message = stepResultMessage(result);
|
|
2006
|
+
const stepSuggestions = suggestions.get(testStep.pickleStepId) ?? [];
|
|
2007
|
+
const definitionIds = Array.isArray(testStep.stepDefinitionIds) ? testStep.stepDefinitionIds : [];
|
|
2008
|
+
const stepMatches = definitionIds.map((id) => stepDefinitions.get(id)).filter(
|
|
2009
|
+
(definition) => Boolean(definition)
|
|
2010
|
+
);
|
|
2011
|
+
const matchLists = testStep.stepMatchArgumentsLists ?? [];
|
|
2012
|
+
const parameters = [];
|
|
2013
|
+
if (matchLists.length === 1) {
|
|
2014
|
+
for (const argument of matchLists[0]?.stepMatchArguments ?? []) {
|
|
2015
|
+
const start = argument.group?.start;
|
|
2016
|
+
const value = argument.group?.value;
|
|
2017
|
+
if (typeof start !== "number" || !Number.isFinite(start) || typeof value !== "string" || value.length === 0) {
|
|
2018
|
+
continue;
|
|
2019
|
+
}
|
|
2020
|
+
parameters.push({
|
|
2021
|
+
start,
|
|
2022
|
+
value,
|
|
2023
|
+
type: argument.parameterTypeName || "anonymous"
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
1792
2027
|
stepRows.push({
|
|
1793
2028
|
id: testStep.id,
|
|
2029
|
+
order: testStepOrder++,
|
|
1794
2030
|
keyword: data.keyword,
|
|
1795
2031
|
text: pickleStep?.text ?? "",
|
|
1796
2032
|
status: statusOf2(result.status),
|
|
@@ -1798,36 +2034,66 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1798
2034
|
...message ? { message: stripAnsi(message) } : {},
|
|
1799
2035
|
...data.docString ? { docString: data.docString } : {},
|
|
1800
2036
|
...data.dataTable ? { dataTable: data.dataTable } : {},
|
|
2037
|
+
...stepSuggestions.length > 0 ? { suggestions: stepSuggestions } : {},
|
|
2038
|
+
...stepMatches.length > 0 ? { definitions: stepMatches } : {},
|
|
2039
|
+
...parameters.length > 0 ? { parameters } : {},
|
|
1801
2040
|
attachments: stepAttachments2
|
|
1802
2041
|
});
|
|
1803
2042
|
} else if (testStep.hookId) {
|
|
1804
2043
|
const hook = hooks.get(testStep.hookId);
|
|
1805
|
-
const
|
|
2044
|
+
const hookAttachments2 = mapAttachments(
|
|
1806
2045
|
startedAttachments.filter((attachment) => attachment.testStepId === testStep.id)
|
|
1807
2046
|
);
|
|
1808
2047
|
const message = stepResultMessage(result);
|
|
1809
|
-
|
|
2048
|
+
hookRows.push({
|
|
1810
2049
|
id: testStep.id,
|
|
1811
|
-
|
|
1812
|
-
|
|
2050
|
+
order: testStepOrder++,
|
|
2051
|
+
type: hookLabel(hook?.type),
|
|
2052
|
+
...hook?.name ? { name: hook.name } : {},
|
|
1813
2053
|
status: statusOf2(result.status),
|
|
1814
2054
|
durationMs: durationMs(result.duration),
|
|
1815
2055
|
...message ? { message: stripAnsi(message) } : {},
|
|
1816
|
-
attachments:
|
|
1817
|
-
hook: hook?.type
|
|
2056
|
+
attachments: hookAttachments2
|
|
1818
2057
|
});
|
|
1819
2058
|
}
|
|
1820
2059
|
}
|
|
1821
|
-
const
|
|
1822
|
-
const
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
2060
|
+
const status = executed ? statusOf2(getWorstTestStepResult(rawResults).status) : "unknown";
|
|
2061
|
+
const duration2 = [...stepRows, ...hookRows].reduce(
|
|
2062
|
+
(sum, entry) => sum + entry.durationMs,
|
|
2063
|
+
0
|
|
2064
|
+
);
|
|
2065
|
+
const astIds = pickle.astNodeIds ?? [];
|
|
2066
|
+
const candidate = astIds.length ? outlineRows.get(astIds.at(-1) ?? "") : void 0;
|
|
2067
|
+
const outlineExample = candidate && astIds.includes(candidate.scenario.id) && (!candidate.uri || !pickle.uri || candidate.uri === pickle.uri) ? candidate : void 0;
|
|
2068
|
+
const scenarioId = outlineExample?.scenario.id ?? astIds[0] ?? "";
|
|
2069
|
+
const tree = outlineExample ?? scenarioTree.get(scenarioId);
|
|
2070
|
+
const astEntry = outlineExample ? scenarioTree.get(outlineExample.scenario.id) : scenarioTree.get(scenarioId);
|
|
2071
|
+
const rule = astEntry?.rule;
|
|
2072
|
+
const feature = featureByScenarioId.get(scenarioId) ?? features.get(pickle.uri);
|
|
1826
2073
|
const stepAttachments = stepRows.flatMap((step) => step.attachments);
|
|
2074
|
+
const hookAttachments = hookRows.flatMap((hook) => hook.attachments);
|
|
1827
2075
|
const extraAttachments = mapAttachments(
|
|
1828
2076
|
startedAttachments.filter((attachment) => !attachment.testStepId)
|
|
1829
2077
|
);
|
|
1830
|
-
const scenarioAttachments = [
|
|
2078
|
+
const scenarioAttachments = [
|
|
2079
|
+
...stepAttachments,
|
|
2080
|
+
...hookAttachments,
|
|
2081
|
+
...extraAttachments
|
|
2082
|
+
];
|
|
2083
|
+
const outline = outlineExample ? {
|
|
2084
|
+
id: outlineExample.scenario.id,
|
|
2085
|
+
keyword: outlineExample.scenario.keyword,
|
|
2086
|
+
name: outlineExample.scenario.name,
|
|
2087
|
+
description: normalizeText2(outlineExample.scenario.description),
|
|
2088
|
+
tags: (outlineExample.scenario.tags ?? []).map((tag) => tag.name),
|
|
2089
|
+
examplesId: outlineExample.examples.id,
|
|
2090
|
+
examplesKeyword: outlineExample.examples.keyword,
|
|
2091
|
+
examplesName: outlineExample.examples.name,
|
|
2092
|
+
examplesDescription: normalizeText2(outlineExample.examples.description),
|
|
2093
|
+
examplesTags: (outlineExample.examples.tags ?? []).map((tag) => tag.name),
|
|
2094
|
+
examplesIndex: outlineExample.examplesIndex,
|
|
2095
|
+
exampleIndex: outlineExample.exampleIndex
|
|
2096
|
+
} : void 0;
|
|
1831
2097
|
const row = {
|
|
1832
2098
|
id: pickle.id,
|
|
1833
2099
|
name: pickle.name,
|
|
@@ -1835,19 +2101,27 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1835
2101
|
description: normalizeText2(tree?.scenario.description),
|
|
1836
2102
|
uri: pickle.uri,
|
|
1837
2103
|
featureName: feature?.name ?? pickle.uri,
|
|
1838
|
-
...
|
|
2104
|
+
...rule ? { rule } : {},
|
|
2105
|
+
...rule?.name ? { ruleName: rule.name } : {},
|
|
1839
2106
|
status,
|
|
2107
|
+
executed,
|
|
1840
2108
|
durationMs: finiteDuration(duration2),
|
|
1841
2109
|
attempt: Number.isFinite(latest.attempt) ? latest.attempt : 0,
|
|
1842
2110
|
...timestampIso(latest.timestamp) ? { startedAt: timestampIso(latest.timestamp) } : {},
|
|
1843
|
-
tags: pickle.tags.map((tag) => tag.name),
|
|
2111
|
+
ownTags: outlineExample ? (outlineExample.examples.tags ?? []).map((tag) => tag.name) : tree ? (tree.scenario.tags ?? []).map((tag) => tag.name) : (pickle.tags ?? []).map((tag) => tag.name),
|
|
2112
|
+
tags: (pickle.tags ?? []).map((tag) => tag.name),
|
|
2113
|
+
...outline ? { outline } : {},
|
|
1844
2114
|
steps: stepRows,
|
|
2115
|
+
hooks: hookRows,
|
|
1845
2116
|
attachments: scenarioAttachments,
|
|
1846
2117
|
extraAttachments
|
|
1847
2118
|
};
|
|
1848
2119
|
scenarioRows.push(row);
|
|
1849
|
-
|
|
1850
|
-
|
|
2120
|
+
if (executed) {
|
|
2121
|
+
count(scenarioCounts, status);
|
|
2122
|
+
for (const step of stepRows) count(stepCounts, step.status);
|
|
2123
|
+
for (const hook of hookRows) count(hookCounts, hook.status);
|
|
2124
|
+
}
|
|
1851
2125
|
if (feature) {
|
|
1852
2126
|
const list = featureScenarios.get(feature) ?? [];
|
|
1853
2127
|
list.push(row);
|
|
@@ -1865,10 +2139,7 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1865
2139
|
for (const feature of orderedFeatures) {
|
|
1866
2140
|
const scenarios = featureScenarios.get(feature) ?? [];
|
|
1867
2141
|
if (scenarios.length === 0) continue;
|
|
1868
|
-
const status =
|
|
1869
|
-
if (scenario.status === "passed") return worst;
|
|
1870
|
-
return statusSeverity(scenario.status) > statusSeverity(worst) ? scenario.status : worst;
|
|
1871
|
-
}, "unknown") : "passed";
|
|
2142
|
+
const status = worstExecutedStatus(scenarios);
|
|
1872
2143
|
const featureUri = featureUris.get(feature) ?? scenarios[0]?.uri ?? "";
|
|
1873
2144
|
const sourceFiles = /* @__PURE__ */ new Set([
|
|
1874
2145
|
...scenarios.map((scenario) => provenance?.get(scenario.uri)),
|
|
@@ -1881,7 +2152,8 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1881
2152
|
keyword: feature.keyword,
|
|
1882
2153
|
uri: scenarios[0]?.uri ?? "",
|
|
1883
2154
|
description: normalizeText2(feature.description),
|
|
1884
|
-
tags: feature.tags.map((tag) => tag.name),
|
|
2155
|
+
tags: (feature.tags ?? []).map((tag) => tag.name),
|
|
2156
|
+
backgrounds: backgroundsOf(feature.children ?? []),
|
|
1885
2157
|
status,
|
|
1886
2158
|
durationMs: finiteDuration(
|
|
1887
2159
|
scenarios.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
@@ -1894,22 +2166,51 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1894
2166
|
if (featureRows.some((feature) => !feature.sourceFile)) {
|
|
1895
2167
|
for (const feature of featureRows) delete feature.sourceFile;
|
|
1896
2168
|
}
|
|
2169
|
+
const runHooks = [];
|
|
2170
|
+
const orderedRunHooks = [...runHookStarts.values()].map((start, index) => ({ start, index })).sort((a, b) => {
|
|
2171
|
+
const seconds = (a.start.timestamp?.seconds ?? 0) - (b.start.timestamp?.seconds ?? 0);
|
|
2172
|
+
if (seconds !== 0) return seconds;
|
|
2173
|
+
const nanos = (a.start.timestamp?.nanos ?? 0) - (b.start.timestamp?.nanos ?? 0);
|
|
2174
|
+
return nanos !== 0 ? nanos : a.index - b.index;
|
|
2175
|
+
});
|
|
2176
|
+
for (const { start } of orderedRunHooks) {
|
|
2177
|
+
const finish = runHookFinishes.get(start.id);
|
|
2178
|
+
const hook = hooks.get(start.hookId);
|
|
2179
|
+
const result = finish?.result;
|
|
2180
|
+
const message = result ? stepResultMessage(result) : "";
|
|
2181
|
+
runHooks.push({
|
|
2182
|
+
id: start.id,
|
|
2183
|
+
type: hookLabel(hook?.type),
|
|
2184
|
+
...hook?.name ? { name: hook.name } : {},
|
|
2185
|
+
status: result ? statusOf2(result.status) : "unknown",
|
|
2186
|
+
durationMs: durationMs(result?.duration),
|
|
2187
|
+
...message ? { message: stripAnsi(message) } : {},
|
|
2188
|
+
attachments: mapAttachments(runHookAttachments.get(start.id) ?? [])
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
for (const hook of runHooks) count(hookCounts, hook.status);
|
|
1897
2192
|
const attachmentRows = scenarioRows.flatMap((scenario) => scenario.attachments);
|
|
1898
2193
|
const runAttachments = mapAttachments(attachments.get("") ?? []);
|
|
1899
|
-
const allAttachments = [
|
|
2194
|
+
const allAttachments = [
|
|
2195
|
+
...attachmentRows,
|
|
2196
|
+
...runHooks.flatMap((hook) => hook.attachments),
|
|
2197
|
+
...runAttachments
|
|
2198
|
+
];
|
|
1900
2199
|
return {
|
|
1901
2200
|
features: featureRows,
|
|
1902
2201
|
scenarios: scenarioRows,
|
|
2202
|
+
runHooks,
|
|
1903
2203
|
runAttachments,
|
|
1904
2204
|
counts: {
|
|
1905
2205
|
features: featureRows.length,
|
|
1906
2206
|
scenarios: scenarioCounts,
|
|
1907
2207
|
steps: stepCounts,
|
|
2208
|
+
hooks: hookCounts,
|
|
1908
2209
|
attachments: allAttachments.length,
|
|
1909
2210
|
attachmentBytes: allAttachments.reduce((sum, attachment) => sum + attachment.bytes, 0)
|
|
1910
2211
|
},
|
|
1911
2212
|
durationMs: finiteDuration(
|
|
1912
|
-
scenarioRows.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
2213
|
+
scenarioRows.reduce((sum, scenario) => sum + scenario.durationMs, 0) + runHooks.reduce((sum, hook) => sum + hook.durationMs, 0)
|
|
1913
2214
|
),
|
|
1914
2215
|
...startedAt ? { startedAt } : {},
|
|
1915
2216
|
...finishedAt ? { finishedAt } : {},
|
|
@@ -1919,20 +2220,8 @@ function buildReportModel(envelopes, provenance) {
|
|
|
1919
2220
|
}
|
|
1920
2221
|
|
|
1921
2222
|
// src/summary.ts
|
|
1922
|
-
import {
|
|
1923
|
-
|
|
1924
|
-
TestStepResultStatus as TestStepResultStatus4
|
|
1925
|
-
} from "@cucumber/messages";
|
|
1926
|
-
var SUMMARY_SCHEMA_VERSION = 1;
|
|
1927
|
-
var STATUS_ORDER2 = [
|
|
1928
|
-
TestStepResultStatus4.UNKNOWN,
|
|
1929
|
-
TestStepResultStatus4.PASSED,
|
|
1930
|
-
TestStepResultStatus4.SKIPPED,
|
|
1931
|
-
TestStepResultStatus4.PENDING,
|
|
1932
|
-
TestStepResultStatus4.UNDEFINED,
|
|
1933
|
-
TestStepResultStatus4.AMBIGUOUS,
|
|
1934
|
-
TestStepResultStatus4.FAILED
|
|
1935
|
-
];
|
|
2223
|
+
import { getWorstTestStepResult as getWorstTestStepResult2 } from "@cucumber/messages";
|
|
2224
|
+
var SUMMARY_SCHEMA_VERSION = 2;
|
|
1936
2225
|
var VALID_STATUSES = /* @__PURE__ */ new Set([
|
|
1937
2226
|
"passed",
|
|
1938
2227
|
"failed",
|
|
@@ -2002,9 +2291,6 @@ function scenarioStatus(results) {
|
|
|
2002
2291
|
if (results.length === 0) return "unknown";
|
|
2003
2292
|
return toStatus(getWorstTestStepResult2(results).status);
|
|
2004
2293
|
}
|
|
2005
|
-
function statusOrdinal(status) {
|
|
2006
|
-
return STATUS_ORDER2.indexOf(status.toUpperCase());
|
|
2007
|
-
}
|
|
2008
2294
|
function displayUri(uri) {
|
|
2009
2295
|
const normalized = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
2010
2296
|
if (!/^[a-z]:\//i.test(normalized) && !normalized.startsWith("/")) {
|
|
@@ -2012,8 +2298,11 @@ function displayUri(uri) {
|
|
|
2012
2298
|
}
|
|
2013
2299
|
const marker = normalized.lastIndexOf("/features/");
|
|
2014
2300
|
if (marker >= 0) return normalized.slice(marker + 1);
|
|
2015
|
-
const parts = normalized.split("/").filter(Boolean);
|
|
2016
|
-
|
|
2301
|
+
const parts = normalized.replace(/^[a-z]:/i, "").split("/").filter(Boolean);
|
|
2302
|
+
if (parts.length > 1 && /^(Users|home|Documents and Settings)$/i.test(parts[0] ?? "")) {
|
|
2303
|
+
parts.splice(0, 2);
|
|
2304
|
+
}
|
|
2305
|
+
return parts.slice(-3).join("/") || uri;
|
|
2017
2306
|
}
|
|
2018
2307
|
function featureTree2(document) {
|
|
2019
2308
|
const stepKeywords = /* @__PURE__ */ new Map();
|
|
@@ -2051,11 +2340,14 @@ function summarizeEnvelopes(input) {
|
|
|
2051
2340
|
const testCasesByPickle = /* @__PURE__ */ new Map();
|
|
2052
2341
|
const startedByTestCase = /* @__PURE__ */ new Map();
|
|
2053
2342
|
const hooks = /* @__PURE__ */ new Map();
|
|
2343
|
+
const runHookStarts = /* @__PURE__ */ new Map();
|
|
2344
|
+
const runHookFinishes = /* @__PURE__ */ new Map();
|
|
2054
2345
|
const results = /* @__PURE__ */ new Map();
|
|
2055
2346
|
const attachments = /* @__PURE__ */ new Map();
|
|
2056
2347
|
const attachmentList = [];
|
|
2057
|
-
const finishedIds = /* @__PURE__ */ new Set();
|
|
2058
2348
|
const scenarioFeatures = /* @__PURE__ */ new Map();
|
|
2349
|
+
const suggestions = /* @__PURE__ */ new Map();
|
|
2350
|
+
const stepDefinitions = /* @__PURE__ */ new Map();
|
|
2059
2351
|
const indexFeature = (feature) => {
|
|
2060
2352
|
const visit = (children) => {
|
|
2061
2353
|
for (const child of children) {
|
|
@@ -2084,10 +2376,16 @@ function summarizeEnvelopes(input) {
|
|
|
2084
2376
|
list.push(envelope.testCaseStarted);
|
|
2085
2377
|
startedByTestCase.set(envelope.testCaseStarted.testCaseId, list);
|
|
2086
2378
|
}
|
|
2087
|
-
if (envelope.testCaseFinished) {
|
|
2088
|
-
finishedIds.add(envelope.testCaseFinished.testCaseStartedId);
|
|
2089
|
-
}
|
|
2090
2379
|
if (envelope.hook) hooks.set(envelope.hook.id, envelope.hook);
|
|
2380
|
+
if (envelope.testRunHookStarted) {
|
|
2381
|
+
runHookStarts.set(envelope.testRunHookStarted.id, envelope.testRunHookStarted);
|
|
2382
|
+
}
|
|
2383
|
+
if (envelope.testRunHookFinished) {
|
|
2384
|
+
runHookFinishes.set(
|
|
2385
|
+
envelope.testRunHookFinished.testRunHookStartedId,
|
|
2386
|
+
envelope.testRunHookFinished
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2091
2389
|
if (envelope.testStepFinished) {
|
|
2092
2390
|
const list = results.get(envelope.testStepFinished.testCaseStartedId) ?? [];
|
|
2093
2391
|
list.push(envelope.testStepFinished);
|
|
@@ -2102,6 +2400,28 @@ function summarizeEnvelopes(input) {
|
|
|
2102
2400
|
attachments.set(startedId, list);
|
|
2103
2401
|
}
|
|
2104
2402
|
}
|
|
2403
|
+
if (envelope.suggestion) {
|
|
2404
|
+
const snippets = Array.isArray(envelope.suggestion.snippets) ? envelope.suggestion.snippets : [];
|
|
2405
|
+
const list = snippets.filter((snippet) => typeof snippet?.code === "string").map((snippet) => ({
|
|
2406
|
+
...typeof snippet.language === "string" && snippet.language ? { language: snippet.language } : {},
|
|
2407
|
+
code: snippet.code
|
|
2408
|
+
}));
|
|
2409
|
+
if (list.length > 0) suggestions.set(envelope.suggestion.pickleStepId, list);
|
|
2410
|
+
}
|
|
2411
|
+
if (envelope.stepDefinition) {
|
|
2412
|
+
const pattern = envelope.stepDefinition.pattern;
|
|
2413
|
+
if (typeof pattern?.source === "string") {
|
|
2414
|
+
const reference = envelope.stepDefinition.sourceReference;
|
|
2415
|
+
const uri = typeof reference?.uri === "string" ? reference.uri : "";
|
|
2416
|
+
const line = typeof reference?.location?.line === "number" ? reference.location.line : void 0;
|
|
2417
|
+
const display = displayUri(uri);
|
|
2418
|
+
const source = display ? line ? `${display}:${line}` : display : void 0;
|
|
2419
|
+
stepDefinitions.set(envelope.stepDefinition.id, {
|
|
2420
|
+
pattern: pattern.source,
|
|
2421
|
+
...source ? { source } : {}
|
|
2422
|
+
});
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2105
2425
|
}
|
|
2106
2426
|
const treeCache = /* @__PURE__ */ new Map();
|
|
2107
2427
|
const treeOf = (feature) => {
|
|
@@ -2117,12 +2437,8 @@ function summarizeEnvelopes(input) {
|
|
|
2117
2437
|
const candidates = testCases.flatMap(
|
|
2118
2438
|
(testCase) => startedByTestCase.get(testCase.id) ?? []
|
|
2119
2439
|
);
|
|
2120
|
-
const finishedCandidates = candidates.filter(
|
|
2121
|
-
(candidate) => finishedIds.has(candidate.id)
|
|
2122
|
-
);
|
|
2123
|
-
const pool = finishedCandidates.length ? finishedCandidates : candidates.filter((candidate) => (results.get(candidate.id)?.length ?? 0) > 0);
|
|
2124
2440
|
let latest;
|
|
2125
|
-
for (const candidate of
|
|
2441
|
+
for (const candidate of candidates) {
|
|
2126
2442
|
if (!latest) {
|
|
2127
2443
|
latest = candidate;
|
|
2128
2444
|
continue;
|
|
@@ -2142,7 +2458,8 @@ function summarizeEnvelopes(input) {
|
|
|
2142
2458
|
const testCases = testCasesByPickle.get(pickle.id) ?? [];
|
|
2143
2459
|
const testSteps = testCases.flatMap((testCase) => testCase.testSteps);
|
|
2144
2460
|
const started = latestByPickle.get(pickle.id);
|
|
2145
|
-
|
|
2461
|
+
if (!started) continue;
|
|
2462
|
+
const finished = results.get(started.id) ?? [];
|
|
2146
2463
|
const resultByStep = new Map(
|
|
2147
2464
|
finished.map((entry) => [entry.testStepId, entry.testStepResult])
|
|
2148
2465
|
);
|
|
@@ -2160,36 +2477,49 @@ function summarizeEnvelopes(input) {
|
|
|
2160
2477
|
if (testStep.pickleStepId) {
|
|
2161
2478
|
const pickleStep = pickleSteps.get(testStep.pickleStepId);
|
|
2162
2479
|
const astNodeId = pickleStep?.astNodeIds[0];
|
|
2480
|
+
const status2 = toStatus(result.status);
|
|
2481
|
+
const stepSuggestions = status2 === "undefined" ? suggestions.get(testStep.pickleStepId) ?? [] : [];
|
|
2482
|
+
const definitionIds = status2 === "ambiguous" && Array.isArray(testStep.stepDefinitionIds) ? testStep.stepDefinitionIds : [];
|
|
2483
|
+
const stepMatches = definitionIds.map((id) => stepDefinitions.get(id)).filter(
|
|
2484
|
+
(definition) => Boolean(definition)
|
|
2485
|
+
);
|
|
2163
2486
|
steps.push({
|
|
2164
2487
|
keyword: astNodeId ? (tree.stepKeywords.get(astNodeId) ?? "").trim() : "",
|
|
2165
2488
|
text: pickleStep?.text ?? "",
|
|
2166
|
-
status:
|
|
2489
|
+
status: status2,
|
|
2167
2490
|
durationMs: durationMs2(result.duration),
|
|
2168
|
-
...message ? { message } : {}
|
|
2491
|
+
...message ? { message: stripAnsi(message) } : {},
|
|
2492
|
+
...stepSuggestions.length > 0 ? { suggestions: stepSuggestions } : {},
|
|
2493
|
+
...stepMatches.length > 0 ? { definitions: stepMatches } : {}
|
|
2169
2494
|
});
|
|
2170
2495
|
} else if (testStep.hookId) {
|
|
2171
2496
|
const hook = hooks.get(testStep.hookId);
|
|
2172
2497
|
steps.push({
|
|
2173
2498
|
keyword: "Hook",
|
|
2174
2499
|
text: hook?.type ?? "hook",
|
|
2500
|
+
...hook?.name ? { name: hook.name } : {},
|
|
2175
2501
|
status: toStatus(result.status),
|
|
2176
2502
|
durationMs: durationMs2(result.duration),
|
|
2177
|
-
...message ? { message } : {}
|
|
2503
|
+
...message ? { message: stripAnsi(message) } : {}
|
|
2178
2504
|
});
|
|
2179
2505
|
}
|
|
2180
2506
|
}
|
|
2181
2507
|
const status = scenarioStatus(finished.map((entry) => entry.testStepResult));
|
|
2508
|
+
const executed = finished.length > 0;
|
|
2182
2509
|
const scenarioDuration = steps.reduce((sum, step) => sum + step.durationMs, 0);
|
|
2183
|
-
const scenarioAttachments =
|
|
2510
|
+
const scenarioAttachments = executed ? attachments.get(started.id) ?? [] : [];
|
|
2184
2511
|
for (const attachment of scenarioAttachments) countedAttachments.add(attachment);
|
|
2185
|
-
|
|
2186
|
-
|
|
2512
|
+
if (executed) {
|
|
2513
|
+
countStatus(scenarioCounts, status);
|
|
2514
|
+
for (const step of steps) countStatus(stepCounts, step.status);
|
|
2515
|
+
}
|
|
2187
2516
|
totalDuration += scenarioDuration;
|
|
2188
2517
|
scenarios.push({
|
|
2189
2518
|
name: pickle.name ?? "",
|
|
2190
2519
|
uri: displayUri(pickle.uri ?? ""),
|
|
2191
2520
|
feature: tree.featureName,
|
|
2192
2521
|
status,
|
|
2522
|
+
executed,
|
|
2193
2523
|
durationMs: finiteDuration2(scenarioDuration),
|
|
2194
2524
|
attempt: started?.attempt ?? 0,
|
|
2195
2525
|
tags: (pickle.tags ?? []).map((tag) => tag.name),
|
|
@@ -2200,10 +2530,19 @@ function summarizeEnvelopes(input) {
|
|
|
2200
2530
|
scenarios.sort(
|
|
2201
2531
|
(a, b) => a.uri.localeCompare(b.uri) || a.name.localeCompare(b.name)
|
|
2202
2532
|
);
|
|
2203
|
-
const
|
|
2204
|
-
|
|
2205
|
-
|
|
2533
|
+
const runHookResults = [];
|
|
2534
|
+
for (const start of runHookStarts.values()) {
|
|
2535
|
+
const result = runHookFinishes.get(start.id)?.result;
|
|
2536
|
+
if (result) runHookResults.push(result);
|
|
2537
|
+
}
|
|
2538
|
+
const runHookStatus = scenarioStatus(runHookResults);
|
|
2539
|
+
totalDuration += runHookResults.reduce(
|
|
2540
|
+
(sum, result) => sum + durationMs2(result.duration),
|
|
2541
|
+
0
|
|
2206
2542
|
);
|
|
2543
|
+
const executedScenarios = scenarios.filter((scenario) => scenario.executed);
|
|
2544
|
+
const scenarioOverall = worstExecutedStatus(executedScenarios);
|
|
2545
|
+
const overall = executedScenarios.length === 0 ? runHookStatus === "failed" ? "failed" : "unknown" : statusSeverity(runHookStatus) > statusSeverity(scenarioOverall) ? runHookStatus : scenarioOverall;
|
|
2207
2546
|
const orphanAttachments = attachmentList.filter(
|
|
2208
2547
|
(attachment) => !attachment.testCaseStartedId || countedAttachments.has(attachment)
|
|
2209
2548
|
);
|
|
@@ -2243,7 +2582,7 @@ function isLogoDataUri(value) {
|
|
|
2243
2582
|
|
|
2244
2583
|
// src/render/escape.ts
|
|
2245
2584
|
function escapeHtml(value) {
|
|
2246
|
-
return String(value ?? "").replace(/[&<>"']/g, (character) => {
|
|
2585
|
+
return stripBidiControls(String(value ?? "")).replace(/[&<>"']/g, (character) => {
|
|
2247
2586
|
switch (character) {
|
|
2248
2587
|
case "&":
|
|
2249
2588
|
return "&";
|
|
@@ -2261,6 +2600,271 @@ function escapeHtml(value) {
|
|
|
2261
2600
|
});
|
|
2262
2601
|
}
|
|
2263
2602
|
|
|
2603
|
+
// src/render/ansi.ts
|
|
2604
|
+
function xtermColor(value) {
|
|
2605
|
+
const index = Math.max(16, Math.min(255, Math.floor(value)));
|
|
2606
|
+
if (index < 232) {
|
|
2607
|
+
const offset = index - 16;
|
|
2608
|
+
const component = (step) => (step === 0 ? 0 : 55 + step * 40).toString(16).padStart(2, "0");
|
|
2609
|
+
return `#${component(Math.floor(offset / 36))}${component(
|
|
2610
|
+
Math.floor(offset % 36 / 6)
|
|
2611
|
+
)}${component(offset % 6)}`;
|
|
2612
|
+
}
|
|
2613
|
+
const grey = 8 + (index - 232) * 10;
|
|
2614
|
+
const hex = Math.min(255, grey).toString(16).padStart(2, "0");
|
|
2615
|
+
return `#${hex}${hex}${hex}`;
|
|
2616
|
+
}
|
|
2617
|
+
function rgbColor(red, green, blue) {
|
|
2618
|
+
const channel = (value) => Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
2619
|
+
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
2620
|
+
}
|
|
2621
|
+
function applyIndexedColor(style, foreground, value) {
|
|
2622
|
+
if (value < 16) {
|
|
2623
|
+
if (foreground) {
|
|
2624
|
+
style.fgClass = `ansi-fg-${value}`;
|
|
2625
|
+
delete style.fgColor;
|
|
2626
|
+
} else {
|
|
2627
|
+
style.bgClass = `ansi-bg-${value}`;
|
|
2628
|
+
delete style.bgColor;
|
|
2629
|
+
}
|
|
2630
|
+
return;
|
|
2631
|
+
}
|
|
2632
|
+
const color = xtermColor(value);
|
|
2633
|
+
if (foreground) {
|
|
2634
|
+
style.fgColor = color;
|
|
2635
|
+
delete style.fgClass;
|
|
2636
|
+
} else {
|
|
2637
|
+
style.bgColor = color;
|
|
2638
|
+
delete style.bgClass;
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
function applySgr(style, raw) {
|
|
2642
|
+
const parts = raw === "" ? ["0"] : raw.split(";");
|
|
2643
|
+
for (let index = 0; index < parts.length; index += 1) {
|
|
2644
|
+
const code = parts[index] === "" ? 0 : Number(parts[index]);
|
|
2645
|
+
if (!Number.isFinite(code)) continue;
|
|
2646
|
+
if (code === 0) {
|
|
2647
|
+
delete style.fgClass;
|
|
2648
|
+
delete style.bgClass;
|
|
2649
|
+
delete style.fgColor;
|
|
2650
|
+
delete style.bgColor;
|
|
2651
|
+
delete style.bold;
|
|
2652
|
+
delete style.dim;
|
|
2653
|
+
delete style.italic;
|
|
2654
|
+
delete style.underline;
|
|
2655
|
+
} else if (code === 1) {
|
|
2656
|
+
style.bold = true;
|
|
2657
|
+
} else if (code === 2) {
|
|
2658
|
+
style.dim = true;
|
|
2659
|
+
} else if (code === 3) {
|
|
2660
|
+
style.italic = true;
|
|
2661
|
+
} else if (code === 4) {
|
|
2662
|
+
style.underline = true;
|
|
2663
|
+
} else if (code === 22) {
|
|
2664
|
+
delete style.bold;
|
|
2665
|
+
delete style.dim;
|
|
2666
|
+
} else if (code === 23) {
|
|
2667
|
+
delete style.italic;
|
|
2668
|
+
} else if (code === 24) {
|
|
2669
|
+
delete style.underline;
|
|
2670
|
+
} else if (code >= 30 && code <= 37) {
|
|
2671
|
+
style.fgClass = `ansi-fg-${code - 30}`;
|
|
2672
|
+
delete style.fgColor;
|
|
2673
|
+
} else if (code === 39) {
|
|
2674
|
+
delete style.fgClass;
|
|
2675
|
+
delete style.fgColor;
|
|
2676
|
+
} else if (code >= 40 && code <= 47) {
|
|
2677
|
+
style.bgClass = `ansi-bg-${code - 40}`;
|
|
2678
|
+
delete style.bgColor;
|
|
2679
|
+
} else if (code === 49) {
|
|
2680
|
+
delete style.bgClass;
|
|
2681
|
+
delete style.bgColor;
|
|
2682
|
+
} else if (code >= 90 && code <= 97) {
|
|
2683
|
+
style.fgClass = `ansi-fg-${code - 90 + 8}`;
|
|
2684
|
+
delete style.fgColor;
|
|
2685
|
+
} else if (code >= 100 && code <= 107) {
|
|
2686
|
+
style.bgClass = `ansi-bg-${code - 100 + 8}`;
|
|
2687
|
+
delete style.bgColor;
|
|
2688
|
+
} else if (code === 38 || code === 48) {
|
|
2689
|
+
const mode = Number(parts[index + 1]);
|
|
2690
|
+
const foreground = code === 38;
|
|
2691
|
+
if (mode === 5 && index + 2 < parts.length) {
|
|
2692
|
+
const color = Number(parts[index + 2]);
|
|
2693
|
+
if (Number.isFinite(color)) {
|
|
2694
|
+
applyIndexedColor(style, foreground, color);
|
|
2695
|
+
}
|
|
2696
|
+
index += 2;
|
|
2697
|
+
} else if (mode === 2 && index + 4 < parts.length) {
|
|
2698
|
+
const red = Number(parts[index + 2]);
|
|
2699
|
+
const green = Number(parts[index + 3]);
|
|
2700
|
+
const blue = Number(parts[index + 4]);
|
|
2701
|
+
if (Number.isFinite(red) && Number.isFinite(green) && Number.isFinite(blue)) {
|
|
2702
|
+
const value = rgbColor(red, green, blue);
|
|
2703
|
+
if (foreground) {
|
|
2704
|
+
style.fgColor = value;
|
|
2705
|
+
delete style.fgClass;
|
|
2706
|
+
} else {
|
|
2707
|
+
style.bgColor = value;
|
|
2708
|
+
delete style.bgClass;
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
index += 4;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
function hasStyle(style) {
|
|
2717
|
+
return Boolean(
|
|
2718
|
+
style.fgClass || style.bgClass || style.fgColor || style.bgColor || style.bold || style.dim || style.italic || style.underline
|
|
2719
|
+
);
|
|
2720
|
+
}
|
|
2721
|
+
function spanMarkup(style) {
|
|
2722
|
+
const classes = ["ansi"];
|
|
2723
|
+
if (style.fgClass) classes.push(style.fgClass);
|
|
2724
|
+
if (style.bgClass) classes.push(style.bgClass);
|
|
2725
|
+
if ((style.bgClass || style.bgColor) && !(style.fgClass || style.fgColor)) {
|
|
2726
|
+
classes.push("ansi-bg-only");
|
|
2727
|
+
}
|
|
2728
|
+
if (style.bold) classes.push("ansi-bold");
|
|
2729
|
+
if (style.dim) classes.push("ansi-dim");
|
|
2730
|
+
if (style.italic) classes.push("ansi-italic");
|
|
2731
|
+
if (style.underline) classes.push("ansi-underline");
|
|
2732
|
+
const css = [];
|
|
2733
|
+
if (style.fgColor) {
|
|
2734
|
+
classes.push("ansi-inline-fg");
|
|
2735
|
+
css.push(`--ansi-fg:${style.fgColor}`);
|
|
2736
|
+
}
|
|
2737
|
+
if (style.bgColor) {
|
|
2738
|
+
classes.push("ansi-inline-bg");
|
|
2739
|
+
css.push(`--ansi-bg:${style.bgColor}`);
|
|
2740
|
+
}
|
|
2741
|
+
const attributes = css.length ? ` style="${css.join(";")}"` : "";
|
|
2742
|
+
return `<span class="${classes.join(" ")}"${attributes}>`;
|
|
2743
|
+
}
|
|
2744
|
+
function ansiToHtml(text, colorize) {
|
|
2745
|
+
let output = "";
|
|
2746
|
+
let buffer = "";
|
|
2747
|
+
let style = {};
|
|
2748
|
+
let spanOpen = false;
|
|
2749
|
+
const flush = () => {
|
|
2750
|
+
if (buffer) {
|
|
2751
|
+
output += escapeHtml(buffer);
|
|
2752
|
+
buffer = "";
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
const closeSpan = () => {
|
|
2756
|
+
if (!spanOpen) return;
|
|
2757
|
+
flush();
|
|
2758
|
+
output += "</span>";
|
|
2759
|
+
spanOpen = false;
|
|
2760
|
+
};
|
|
2761
|
+
const openSpan = () => {
|
|
2762
|
+
closeSpan();
|
|
2763
|
+
if (!colorize || !hasStyle(style)) return;
|
|
2764
|
+
output += spanMarkup(style);
|
|
2765
|
+
spanOpen = true;
|
|
2766
|
+
};
|
|
2767
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
2768
|
+
const character = text[index] ?? "";
|
|
2769
|
+
const code = text.charCodeAt(index);
|
|
2770
|
+
if (isEscapeIntroducer(code)) {
|
|
2771
|
+
const scan = scanEscape(text, index);
|
|
2772
|
+
if (scan.sgr !== void 0) {
|
|
2773
|
+
flush();
|
|
2774
|
+
if (colorize) applySgr(style, scan.sgr);
|
|
2775
|
+
openSpan();
|
|
2776
|
+
}
|
|
2777
|
+
index = scan.end - 1;
|
|
2778
|
+
continue;
|
|
2779
|
+
}
|
|
2780
|
+
if (character === "\x07" || code === 127 || code < 32 && character !== "\n" && character !== " " || code >= 128 && code <= 159) {
|
|
2781
|
+
continue;
|
|
2782
|
+
}
|
|
2783
|
+
buffer += character;
|
|
2784
|
+
}
|
|
2785
|
+
closeSpan();
|
|
2786
|
+
flush();
|
|
2787
|
+
return output;
|
|
2788
|
+
}
|
|
2789
|
+
function renderAnsiLog(text) {
|
|
2790
|
+
return ansiToHtml(
|
|
2791
|
+
text,
|
|
2792
|
+
Buffer.byteLength(text, "utf8") <= MAX_TEXT_ATTACHMENT_BYTES
|
|
2793
|
+
);
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
// src/render/client-bundle.ts
|
|
2797
|
+
var CLIENT_SCRIPT = '"use strict";var TolkiraSearch=(()=>{var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var n in e)E(r,n,{get:e[n],enumerable:!0})},q=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of U(e))!R.call(r,s)&&s!==n&&E(r,s,{get:()=>e[s],enumerable:!(t=T(e,s))||t.enumerable});return r};var C=r=>q(E({},"__esModule",{value:!0}),r);var F={};A(F,{SEARCH_OPEN_CAP:()=>$,compileTagExpression:()=>P,evaluateTagExpression:()=>B,isTagExpression:()=>O,parseUrlState:()=>D,rememberHiddenOpen:()=>N,rowsToOpen:()=>L,serializeUrlState:()=>I});var p="operand",c="operator",f={"(":-2,")":-1,or:0,and:1,not:2},w={or:"left",and:"left",not:"right"};function y(r){let e=W(r);if(e.length===0)return new m;let n=[],t=[],s=p;for(e.forEach(i=>{if(_(i))o(s,p),t.push(i),s=p;else if(j(i)){for(o(s,c);t.length>0&&z(h(t))&&(w[i]==="left"&&f[i]<=f[h(t)]||w[i]==="right"&&f[i]<f[h(t)]);)a(t.pop(),n);t.push(i),s=p}else if(i==="(")o(s,p),t.push(i),s=p;else if(i===")"){for(o(s,c);t.length>0&&h(t)!=="(";)a(t.pop(),n);if(t.length===0)throw new Error(`Tag expression "${r}" could not be parsed because of syntax error: Unmatched ).`);h(t)==="("&&t.pop(),s=c}else o(s,p),a(i,n),s=c});t.length>0;){if(h(t)==="(")throw new Error(`Tag expression "${r}" could not be parsed because of syntax error: Unmatched (.`);a(t.pop(),n)}return n.pop();function o(i,u){if(i!==u)throw new Error(`Tag expression "${r}" could not be parsed because of syntax error: Expected ${i}.`)}function a(i,u){if(i==="and"){let x=l(u);u.push(new d(l(u),x))}else if(i==="or"){let x=l(u);u.push(new g(l(u),x))}else i==="not"?u.push(new S(l(u))):u.push(new b(i))}function l(i){if(i.length===0)throw new Error(`Tag expression "${r}" could not be parsed because of syntax error: Expected operand.`);return i.pop()}}function W(r){let e=[],n=!1,t=[];for(let s=0;s<r.length;s++){let o=r.charAt(s);if(n)if(o==="("||o===")"||o==="\\\\"||/\\s/.test(o))t.push(o),n=!1;else throw new Error(`Tag expression "${r}" could not be parsed because of syntax error: Illegal escape before "${o}".`);else o==="\\\\"?n=!0:o==="("||o===")"||/\\s/.test(o)?(t.length>0&&(e.push(t.join("")),t=[]),/\\s/.test(o)||e.push(o)):t.push(o)}return t.length>0&&e.push(t.join("")),e}function _(r){return r==="not"}function j(r){return r==="or"||r==="and"}function z(r){return w[r]!==void 0}function h(r){return r[r.length-1]}var b=class{value;constructor(e){this.value=e}evaluate(e){return e.indexOf(this.value)!==-1}toString(){return this.value.replace(/\\\\/g,"\\\\\\\\").replace(/\\(/g,"\\\\(").replace(/\\)/g,"\\\\)").replace(/\\s/g,"\\\\ ")}},g=class{leftExpr;rightExpr;constructor(e,n){this.leftExpr=e,this.rightExpr=n}evaluate(e){return this.leftExpr.evaluate(e)||this.rightExpr.evaluate(e)}toString(){return`( ${this.leftExpr.toString()} or ${this.rightExpr.toString()} )`}},d=class{leftExpr;rightExpr;constructor(e,n){this.leftExpr=e,this.rightExpr=n}evaluate(e){return this.leftExpr.evaluate(e)&&this.rightExpr.evaluate(e)}toString(){return`( ${this.leftExpr.toString()} and ${this.rightExpr.toString()} )`}},S=class{expr;constructor(e){this.expr=e}evaluate(e){return!this.expr.evaluate(e)}toString(){return this.expr instanceof d||this.expr instanceof g?`not ${this.expr.toString()}`:`not ( ${this.expr.toString()} )`}},m=class{evaluate(e){return!0}toString(){return""}};var $=20;function v(r){return/\\s/.test(r)}function H(r){let e=0;for(;e<r.length;){let n=r[e];if(v(n)){e+=1;continue}if(n==="("||n===")"){e+=1;continue}if(n==="@"){e+=1;let o=e;for(;e<r.length;){let a=r[e];if(a==="\\\\"){e+=2;continue}if(v(a)||a==="("||a===")")break;e+=1}if(e>r.length||e===o)return!1;continue}let t=e;for(;e<r.length;){let o=r[e];if(v(o)||o==="("||o===")")break;e+=1}let s=r.slice(t,e);if(s!=="and"&&s!=="or"&&s!=="not")return!1}return!0}function O(r){let e=r.trim();return!e.includes("@")||!H(e)?!1:e.startsWith("@")||e.startsWith("(")?!0:e.startsWith("not")&&/^(?:\\s|\\(|$)/.test(e.slice(3))}function P(r){if(O(r))try{let e=y(r.trim());return n=>e.evaluate(n)}catch{return}}function B(r,e){return P(r)?.(e)}function D(r,e,n){let t=new URLSearchParams(r),s=new Set(e),o=new Set(n),a=[...new Set(t.getAll("hide"))].filter(i=>s.has(i)),l=t.get("tag")??"";return{query:t.get("query")??"",hidden:a,tag:o.has(l)?l:""}}function I(r,e){let n=new URL(r);e.query?n.searchParams.set("query",e.query):n.searchParams.delete("query"),n.searchParams.delete("hide");for(let t of e.hidden)n.searchParams.append("hide",t);return e.tag?n.searchParams.set("tag",e.tag):n.searchParams.delete("tag"),n.href}function L(r,e=$){if(e<=0)return[];let n=[];for(let t=0;t<r.length&&n.length<e;t+=1){let s=r[t];s?.visible&&!s.open&&n.push(t)}return n}function N(r,e){return r&&!e}return C(F);})();\n\n(function(){var f=Array.prototype.slice.call(document.querySelectorAll("[data-view]")),U=document.getElementById("report-view"),z=document.getElementById("analysis-view");function T(e){!U||!z||(U.hidden=e!=="report",z.hidden=e!=="analysis",f.forEach(function(a){var t=a.getAttribute("data-view")===e;a.setAttribute("aria-selected",t?"true":"false")}),window.scrollTo(0,0))}f.forEach(function(e){e.addEventListener("click",function(){T(e.getAttribute("data-view"))})});var F=document.querySelector(\'[role="tablist"]\');F&&F.addEventListener("keydown",function(e){if(["ArrowLeft","ArrowRight","Home","End"].includes(e.key)){e.preventDefault();var a=f.indexOf(document.activeElement);if(!(a<0)){var t=e.key==="Home"?0:e.key==="End"?f.length-1:(a+(e.key==="ArrowRight"?1:-1)+f.length)%f.length;f[t].focus(),T(f[t].getAttribute("data-view"))}}});var l={query:"",hidden:new Set,tag:""},E=[],L=[],x=new WeakMap,h=Array.prototype.slice.call(document.querySelectorAll("[data-scenario]")),Y=h.concat(Array.prototype.slice.call(document.querySelectorAll(".outlineTitle, .examplesTitle, .ruleTitle, .backgroundTitle"))),G=Array.prototype.slice.call(document.querySelectorAll("[data-feature]")),_=Array.prototype.slice.call(document.querySelectorAll("[data-examples]")).map(function(e){return{group:e,rows:Array.prototype.slice.call(e.querySelectorAll("[data-scenario]"))}}),J=Array.prototype.slice.call(document.querySelectorAll("[data-outline]")).map(function(e){return{group:e,rows:Array.prototype.slice.call(e.querySelectorAll("[data-scenario]"))}}),Q=Array.prototype.slice.call(document.querySelectorAll("[data-rule]")).map(function(e){return{group:e,rows:Array.prototype.slice.call(e.querySelectorAll("[data-scenario]"))}}),D=document.getElementById("tolkira-live"),m=document.getElementById("tolkira-search-note"),q=document.querySelector("[data-triage]"),V=document.querySelector("[data-sources]");function w(){var e=l.query.toLowerCase(),a=l.tag,t=typeof TolkiraSearch<"u"?TolkiraSearch.compileTagExpression(l.query):void 0,r=0;h.forEach(function(n){var o=n.getAttribute("data-status"),c=n.closest("[data-outline]"),y=n.closest("[data-examples]"),S=n.closest("[data-rule]"),b=n.closest("[data-feature]"),A=(c?" "+(c.getAttribute("data-search")||""):"")+(y?" "+(y.getAttribute("data-search")||""):"")+(S?" "+(S.getAttribute("data-search")||""):"")+(b?" "+(b.getAttribute("data-background-search")||""):""),O=((n.getAttribute("data-search")||"")+A).toLowerCase(),R=" "+(n.getAttribute("data-tags")||"")+" ",v=!a||R.indexOf(" "+a+" ")!==-1,ne=!t||t((n.getAttribute("data-tags")||"").split(" ").filter(Boolean)),oe=!!t||!e||O.indexOf(e)!==-1,M=!l.hidden.has(o)&&v&&ne&&oe;M?n.hidden&&x.has(n)&&(n.open=x.get(n),x.delete(n)):(n.hidden||x.set(n,TolkiraSearch.rememberHiddenOpen(n.open,E.indexOf(n)!==-1)),n.open=!1),n.hidden=!M,M&&(r+=1)}),G.forEach(function(n){var o=n.querySelectorAll("[data-scenario]"),c=Array.prototype.some.call(o,function(y){return!y.hidden});n.hidden=!c,c&&(e||l.hidden.size||a)&&(n.open=!0)}),_.forEach(function(n){var o=n.rows.some(function(c){return!c.hidden});n.group.hidden=!o}),J.forEach(function(n){var o=n.rows.some(function(c){return!c.hidden});n.group.hidden=!o}),Q.forEach(function(n){var o=n.rows.some(function(c){return!c.hidden});n.group.hidden=!o}),E.forEach(function(n){n.open=!1}),E=[],L.forEach(function(n){n.open=!1}),L=[];var i=e?TolkiraSearch.rowsToOpen(h.map(function(n){return{visible:!n.hidden,open:n.open}})):[];i.forEach(function(n){var o=h[n];o.open=!0,E.push(o)});var u=i.length;e&&h.forEach(function(n){n.hidden||!n.open||Array.prototype.slice.call(n.querySelectorAll("details.hookGroup")).forEach(function(o){o.open||(o.open=!0,L.push(o))})}),D&&(D.textContent=r+" of "+h.length+" scenarios visible"),m&&(e&&u===20&&r>20?(m.textContent="20 of "+r+" matches expanded. Use Expand all to open the rest.",m.hidden=!1):(m.hidden=!0,m.textContent=""));var s=document.getElementById("empty-results");s&&(s.hidden=r!==0),q&&(q.hidden=!!(e||a||l.hidden.size)),V&&(V.hidden=!!(e||a||l.hidden.size)),$()}function B(){typeof CSS>"u"||!CSS.highlights||CSS.highlights.delete("tolkira-search")}function Z(e){for(var a="",t=0;t<e.length;t++){var r=e.charCodeAt(t),i=e.charAt(t),u=r===92||r===94||r===36||r===46||r===42||r===43||r===63||r===40||r===41||r===91||r===93||r===123||r===125||r===124;a+=u?"\\\\"+i:i}return a}function $(){if(!(typeof CSS>"u"||!CSS.highlights||typeof Highlight>"u")){var e=l.query.trim();if(e.length<2){B();return}try{var a=new RegExp(Z(e),"gi"),t=[];Y.forEach(function(r){if(!(r.hidden||r.closest("[hidden]")||t.length>=200)&&!(r.hasAttribute("data-scenario")&&!r.open))for(var i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null),u;t.length<200&&(u=i.nextNode());){var s=u.nodeValue;if(s){var n=u.parentElement;if(!(n&&(n.tagName==="SCRIPT"||n.tagName==="STYLE"))){a.lastIndex=0;for(var o;t.length<200&&(o=a.exec(s))!==null;){var c=document.createRange();c.setStart(u,o.index),c.setEnd(u,o.index+o[0].length),t.push(c),o[0].length===0&&(a.lastIndex+=1)}}}}}),B(),t.length&&CSS.highlights.set("tolkira-search",new Highlight(...t))}catch{B()}}}var g=document.querySelector("[data-search]"),p=document.querySelector("[data-tag-filter]");function I(){try{var e=TolkiraSearch.serializeUrlState(location.href,{query:l.query,hidden:Array.from(l.hidden),tag:l.tag});typeof history.replaceState=="function"&&history.replaceState(null,"",e)}catch{}}function ee(){var e=Array.prototype.slice.call(document.querySelectorAll("button.filter[data-status]")),a=e.map(function(i){return i.getAttribute("data-status")}),t=p?Array.prototype.map.call(p.options,function(i){return i.value}).filter(Boolean):[],r;try{r=TolkiraSearch.parseUrlState(location.search,a,t)}catch{return}r.query&&(l.query=r.query,g&&(g.value=r.query)),r.hidden.forEach(function(i){l.hidden.add(i)}),e.forEach(function(i){i.setAttribute("aria-pressed",l.hidden.has(i.getAttribute("data-status"))?"false":"true")}),r.tag&&p&&(l.tag=r.tag,p.value=r.tag),(l.query||l.hidden.size||l.tag)&&w()}g&&g.addEventListener("input",function(){l.query=g.value,w(),I()}),p&&p.addEventListener("change",function(){l.tag=p.value,w(),I()}),Array.prototype.slice.call(document.querySelectorAll("button.filter[data-status]")).forEach(function(e){e.addEventListener("click",function(){var a=e.getAttribute("data-status"),t=e.getAttribute("aria-pressed")!=="false";t?(l.hidden.add(a),e.setAttribute("aria-pressed","false")):(l.hidden.delete(a),e.setAttribute("aria-pressed","true")),w(),I()})}),Array.prototype.slice.call(document.querySelectorAll("[data-expand]")).forEach(function(e){e.addEventListener("click",function(){var a=e.getAttribute("data-expand")==="all";G.forEach(function(t){t.open=a}),h.forEach(function(t){t.open=a})})});var k=document.getElementById("tolkira-copy-live");function te(e){var a=document.activeElement,t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",document.body.appendChild(t);var r=!1;try{t.select(),r=document.execCommand("copy")}catch{r=!1}finally{t.remove(),a&&typeof a.focus=="function"&&a.focus()}return r}function re(e,a){var t=!1;function r(u){t||(t=!0,a(u))}function i(){r(te(e))}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{navigator.clipboard.writeText(e).then(function(){r(!0)},i)}catch{i()}else i()}function ae(e){var a=e.closest("[data-scenario]");if(!a)return"";var t=a.closest("[data-feature]"),r=t?t.querySelector("h2"):null,i=a.querySelector(".scenarioName"),u=a.getAttribute("data-scenario-name")||(i?i.textContent:""),s=a.getAttribute("data-example")||"",n=a.getAttribute("data-examples-name")||"",o=a.querySelector(\'.step[data-status="failed"]\'),c=o?null:a.querySelector(\'.hook[data-status="failed"]\'),y=o&&o.querySelector(".kw")?o.querySelector(".kw").textContent.trim():"",S=o?o.querySelector(".stepText"):null,b=S&&S.textContent||"",A=o?o.querySelector(".error"):c?c.querySelector(".error"):null,O=c?c.querySelector(".hookLabel")?c.querySelector(".hookLabel").textContent.trim():"Hook":(y+" "+b.trim()).trim(),R=c?"Hook: ":"Step: ",v=["Feature: "+(r?r.textContent:""),"Scenario: "+u];return s&&v.push("Example: "+s+(n?" ("+n+")":"")),v.push("URI: "+(a.getAttribute("data-uri")||""),R+O),A&&A.textContent.trim()&&v.push(`Error:\n`+A.textContent.trim()),v.join(`\n`)}function W(e,a,t,r,i){var u=null;e.addEventListener("click",function(){e.focus(),re(t(e),function(s){u&&clearTimeout(u),e.textContent=s?"Copied":"Copy failed",k&&(k.textContent=s?r:i),u=setTimeout(function(){e.textContent=a,k&&(k.textContent="")},2e3)})})}Array.prototype.slice.call(document.querySelectorAll("[data-copy-failure]")).forEach(function(e){W(e,"Copy failure",ae,"Failure details copied to clipboard.","Could not copy failure details.")}),Array.prototype.slice.call(document.querySelectorAll("[data-copy-log]")).forEach(function(e){e.hidden=!1,W(e,"Copy log",function(a){var t=a.closest("details"),r=t?t.querySelector("pre"):null;return r?r.textContent:""},"Log copied to clipboard.","Could not copy the log.")});var d=document.getElementById("tolkira-lightbox");if(d){let e=function(){typeof d.close=="function"?d.close():(d.removeAttribute("open"),a())},a=function(){document.documentElement.style.overflow=K,C&&(C.focus(),C=null)};var ie=e,le=a,H=d.querySelector("img"),j=d.querySelector("[data-lightbox-close]"),C=null,K="";Array.prototype.slice.call(document.querySelectorAll(".shotButton")).forEach(function(t){t.addEventListener("click",function(){var r=t.querySelector("img");!r||!H||(H.src=r.src,H.alt=r.alt,C=t,K=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden",typeof d.showModal=="function"?d.showModal():d.setAttribute("open",""))})}),j&&j.addEventListener("click",e),d.addEventListener("click",function(t){t.target===d&&e()}),d.addEventListener("close",a)}function P(){if(location.hash){var e="";try{e=decodeURIComponent(location.hash.slice(1))}catch{return}var a=document.getElementById(e);if(a){for(var t=a;t;)t.tagName==="DETAILS"&&(t.open=!0),t=t.parentElement;var r=a.tagName==="DETAILS"?a.querySelector("summary"):a;if(r)try{r.focus({preventScroll:!0})}catch{r.focus()}a.scrollIntoView()}}}var N=window.matchMedia("(max-width: 560px)");function X(){q&&(q.open=!N.matches)}N.addEventListener&&N.addEventListener("change",X),X(),window.addEventListener("hashchange",P),ee(),T("report"),P()})();\n';
|
|
2798
|
+
|
|
2799
|
+
// src/render/markdown.ts
|
|
2800
|
+
import MarkdownIt from "markdown-it";
|
|
2801
|
+
var markdown = new MarkdownIt({
|
|
2802
|
+
html: false,
|
|
2803
|
+
linkify: false,
|
|
2804
|
+
typographer: false,
|
|
2805
|
+
breaks: true
|
|
2806
|
+
});
|
|
2807
|
+
var SAFE_LINK = /^(?:https?:\/\/|mailto:)/i;
|
|
2808
|
+
var SAFE_IMAGE = /^(?:https?:\/\/|mailto:|data:image\/|\.{0,2}\/)/i;
|
|
2809
|
+
markdown.validateLink = (url) => SAFE_LINK.test(url) || SAFE_IMAGE.test(url);
|
|
2810
|
+
markdown.renderer.rules.link_open = (tokens, index, options, _env, self) => {
|
|
2811
|
+
tokens[index]?.attrSet("rel", "noopener noreferrer nofollow");
|
|
2812
|
+
return self.renderToken(tokens, index, options);
|
|
2813
|
+
};
|
|
2814
|
+
markdown.renderer.rules.image = (tokens, index) => markdown.utils.escapeHtml(String(tokens[index]?.content ?? ""));
|
|
2815
|
+
markdown.core.ruler.push("tolkira_link_policy", (state) => {
|
|
2816
|
+
for (const token of state.tokens) {
|
|
2817
|
+
const children = token.children;
|
|
2818
|
+
if (!children) continue;
|
|
2819
|
+
const stack = [];
|
|
2820
|
+
const suppressed = /* @__PURE__ */ new Set();
|
|
2821
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
2822
|
+
const child = children[index];
|
|
2823
|
+
if (!child) continue;
|
|
2824
|
+
if (child.type === "link_open") {
|
|
2825
|
+
const href = String(child.attrGet("href") ?? "");
|
|
2826
|
+
stack.push({ open: index, safe: SAFE_LINK.test(href), image: false });
|
|
2827
|
+
} else if (child.type === "image" && stack.length > 0) {
|
|
2828
|
+
const link = stack[stack.length - 1];
|
|
2829
|
+
if (link) link.image = true;
|
|
2830
|
+
} else if (child.type === "link_close") {
|
|
2831
|
+
const link = stack.pop();
|
|
2832
|
+
if (link && (!link.safe || link.image)) {
|
|
2833
|
+
suppressed.add(link.open);
|
|
2834
|
+
suppressed.add(index);
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
if (suppressed.size > 0) {
|
|
2839
|
+
token.children = children.filter((_, index) => !suppressed.has(index));
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
});
|
|
2843
|
+
var HEADING_LEVELS = {
|
|
2844
|
+
h1: "h3",
|
|
2845
|
+
h2: "h4",
|
|
2846
|
+
h3: "h4",
|
|
2847
|
+
h4: "h4",
|
|
2848
|
+
h5: "h4",
|
|
2849
|
+
h6: "h4"
|
|
2850
|
+
};
|
|
2851
|
+
for (const type of ["heading_open", "heading_close"]) {
|
|
2852
|
+
const defaultRule = markdown.renderer.rules[type];
|
|
2853
|
+
markdown.renderer.rules[type] = (tokens, index, options, env, self) => {
|
|
2854
|
+
const token = tokens[index];
|
|
2855
|
+
if (token) {
|
|
2856
|
+
token.tag = HEADING_LEVELS[token.tag] ?? token.tag;
|
|
2857
|
+
}
|
|
2858
|
+
return defaultRule ? defaultRule(tokens, index, options, env, self) : self.renderToken(tokens, index, options);
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
markdown.renderer.rules.table_open = () => '<div class="tableWrap" tabindex="0" role="region" aria-label="Description table"><table>';
|
|
2862
|
+
markdown.renderer.rules.table_close = () => "</table></div>";
|
|
2863
|
+
function renderDescription(description) {
|
|
2864
|
+
if (!description || !description.trim()) return "";
|
|
2865
|
+
return `<div class="description">${markdown.render(description)}</div>`;
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2264
2868
|
// src/render/styles.ts
|
|
2265
2869
|
var REPORT_CSS = `:root {
|
|
2266
2870
|
color-scheme: light;
|
|
@@ -2295,6 +2899,22 @@ var REPORT_CSS = `:root {
|
|
|
2295
2899
|
--radius: 10px;
|
|
2296
2900
|
--radius-control: 6px;
|
|
2297
2901
|
--shadow: none;
|
|
2902
|
+
--ansi-fg-0: #24292f;
|
|
2903
|
+
--ansi-fg-1: #b91c1c;
|
|
2904
|
+
--ansi-fg-2: #15803d;
|
|
2905
|
+
--ansi-fg-3: #965c05;
|
|
2906
|
+
--ansi-fg-4: #1d4ed8;
|
|
2907
|
+
--ansi-fg-5: #a21caf;
|
|
2908
|
+
--ansi-fg-6: #0e7490;
|
|
2909
|
+
--ansi-fg-7: #4b5563;
|
|
2910
|
+
--ansi-fg-8: #5b6673;
|
|
2911
|
+
--ansi-fg-9: #d11f1f;
|
|
2912
|
+
--ansi-fg-10: #0f7d38;
|
|
2913
|
+
--ansi-fg-11: #906000;
|
|
2914
|
+
--ansi-fg-12: #2563eb;
|
|
2915
|
+
--ansi-fg-13: #b01ec0;
|
|
2916
|
+
--ansi-fg-14: #0a7697;
|
|
2917
|
+
--ansi-fg-15: #111827;
|
|
2298
2918
|
}
|
|
2299
2919
|
* { box-sizing: border-box; }
|
|
2300
2920
|
html { background: var(--paper); scroll-padding-top: 4.5rem; scrollbar-gutter: stable; }
|
|
@@ -2412,6 +3032,39 @@ img, video { max-width: 100%; height: auto; }
|
|
|
2412
3032
|
.chev { width: 1rem; height: 1rem; justify-self: end; background: currentColor; color: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 1rem no-repeat; transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
2413
3033
|
details[open] > summary .chev { transform: rotate(180deg); }
|
|
2414
3034
|
.rows { border-top: 1px solid var(--line); }
|
|
3035
|
+
.rule { padding: 0.75rem 0 0.25rem; border-top: 1px solid var(--line); }
|
|
3036
|
+
.ruleTitle { margin: 0.25rem 0 0; font-size: 0.9375rem; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
|
|
3037
|
+
.ruleTitle .kw, .backgroundTitle .kw { color: var(--muted); font-weight: 500; }
|
|
3038
|
+
.rule > .tags { margin: 0.5rem 0 0; }
|
|
3039
|
+
.ruleRows { margin-top: 0.25rem; }
|
|
3040
|
+
.background { margin: 0.5rem 0 0; padding: 0.5rem 0.75rem; border-left: 2px solid var(--line); background: var(--surface-2); }
|
|
3041
|
+
.feature > .background { margin: 0.75rem 0 0; }
|
|
3042
|
+
.backgroundTitle { margin: 0; font-size: 0.8125rem; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
|
|
3043
|
+
.background > .description { margin-top: 0.25rem; font-size: 0.8125rem; }
|
|
3044
|
+
.featureShape .featureTags { flex-basis: 100%; margin-top: 0; }
|
|
3045
|
+
.outline { padding: 0.75rem 0 0.25rem; }
|
|
3046
|
+
.outline + .outline { border-top: 1px solid var(--line); }
|
|
3047
|
+
.outlineTitle { margin: 0.25rem 0 0; font-size: 0.9375rem; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
|
|
3048
|
+
.examplesTitle { margin: 0.5rem 0 0.25rem; font-size: 0.875rem; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
|
|
3049
|
+
.outlineTitle .kw, .examplesTitle .kw { color: var(--muted); font-weight: 500; }
|
|
3050
|
+
.outline > .tags, .examples > .tags { margin: 0.5rem 0 0; }
|
|
3051
|
+
.outline > .description, .examples > .description { margin-top: 0.375rem; }
|
|
3052
|
+
.examples { margin: 0.75rem 0 0 0.75rem; padding-left: 0.875rem; border-left: 2px solid var(--line); }
|
|
3053
|
+
.exampleRows { margin-top: 0.25rem; }
|
|
3054
|
+
.exampleRows .scenario { border-top: 1px solid var(--line); }
|
|
3055
|
+
.exampleRows .scenario:last-child { border-bottom: 0; }
|
|
3056
|
+
.exampleNo { color: var(--accent-text); font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500; }
|
|
3057
|
+
.detailLabel { margin: 0.875rem 0 0.375rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
|
|
3058
|
+
.hooks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
|
|
3059
|
+
.hook { display: grid; grid-template-columns: 0.875rem minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.4375rem 0; border-bottom: 1px solid var(--line); font-size: 0.8125rem; }
|
|
3060
|
+
.hook:last-child { border-bottom: 0; }
|
|
3061
|
+
.hookLabel { color: var(--ink-2); font-weight: 500; overflow-wrap: anywhere; }
|
|
3062
|
+
.hookGroup { margin: 0.5rem 0; border: 1px solid var(--line); border-radius: 5px; padding: 0.375rem 0.5625rem; background: var(--surface-2); }
|
|
3063
|
+
.hookGroup > summary { cursor: pointer; color: var(--accent-text); font-size: 0.75rem; }
|
|
3064
|
+
.hookGroup .hooks { margin-top: 0.375rem; }
|
|
3065
|
+
.runHooks { margin: 1.5rem 0; padding: 1rem 1.25rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); }
|
|
3066
|
+
.runHooks h2 { margin: 0 0 0.5rem; font-size: 1.125rem; }
|
|
3067
|
+
.runHooks .hooks { border-top: 1px solid var(--line); }
|
|
2415
3068
|
.scenario { border-bottom: 1px solid var(--line); container-type: inline-size; }
|
|
2416
3069
|
.scenario:last-child { border-bottom: 0; }
|
|
2417
3070
|
.scenarioButton { width: 100%; display: grid; grid-template-columns: minmax(5.5rem, max-content) 6rem minmax(0, 1fr) auto 1.25rem; gap: 0.75rem; align-items: center; padding: 0.75rem 0; border: 0; background: transparent; color: inherit; text-align: left; list-style: none; cursor: pointer; }
|
|
@@ -2426,11 +3079,27 @@ details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
|
2426
3079
|
.thumb { display: block; width: 6rem; height: 3.75rem; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-3); }
|
|
2427
3080
|
.rowRight { color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
2428
3081
|
.detailInline { padding: 0.25rem 0 1.125rem 13rem; background: var(--surface-2); border-top: 1px solid var(--line); }
|
|
2429
|
-
.detailInline h4 { margin: 0.875rem 0 0.375rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
|
|
2430
3082
|
.stepsHead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; }
|
|
2431
3083
|
.copyFailure { min-height: 1.75rem; padding: 0 0.5625rem; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--paper); color: var(--ink-2); font-size: 0.6875rem; }
|
|
2432
3084
|
.copyFailure:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
|
|
2433
|
-
.description { margin: 0.625rem 0 0; color: var(--muted); font-size: 0.875rem; line-height: 1.55;
|
|
3085
|
+
.description { margin: 0.625rem 0 0; color: var(--muted); font-size: 0.875rem; line-height: 1.55; }
|
|
3086
|
+
.description > :first-child { margin-top: 0; }
|
|
3087
|
+
.description > :last-child { margin-bottom: 0; }
|
|
3088
|
+
.description p { margin: 0.5rem 0 0; }
|
|
3089
|
+
.description h3, .description h4 { margin: 0.75rem 0 0.25rem; color: var(--ink); line-height: 1.35; font-weight: 600; }
|
|
3090
|
+
.description h3 { font-size: 1rem; }
|
|
3091
|
+
.description h4 { font-size: 0.9375rem; }
|
|
3092
|
+
.description ul, .description ol { margin: 0.5rem 0 0; padding-left: 1.25rem; }
|
|
3093
|
+
.description li + li { margin-top: 0.125rem; }
|
|
3094
|
+
.description blockquote { margin: 0.5rem 0 0; padding: 0.125rem 0 0.125rem 0.75rem; border-left: 2px solid var(--line-strong); }
|
|
3095
|
+
.description code { padding: 0.05rem 0.25rem; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); font: 0.8125em/1.4 var(--font-mono); }
|
|
3096
|
+
.description pre { margin: 0.5rem 0 0; padding: 0.5rem 0.625rem; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-3); overflow-x: auto; }
|
|
3097
|
+
.description pre code { padding: 0; background: transparent; }
|
|
3098
|
+
.description a { color: var(--accent-text); }
|
|
3099
|
+
.description .tableWrap { margin-top: 0.5rem; }
|
|
3100
|
+
.description table { border-collapse: collapse; background: var(--surface-2); font-size: 0.8125rem; }
|
|
3101
|
+
.description th, .description td { border: 1px solid var(--line); padding: 0.25rem 0.5rem; text-align: left; }
|
|
3102
|
+
.description th { color: var(--muted); font-weight: 600; background: var(--surface-3); }
|
|
2434
3103
|
.steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
|
|
2435
3104
|
.step { display: grid; grid-template-columns: 0.875rem minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.4375rem 0; border-bottom: 1px solid var(--line); font-size: 0.8125rem; }
|
|
2436
3105
|
.step:last-child { border-bottom: 0; }
|
|
@@ -2440,7 +3109,19 @@ details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
|
2440
3109
|
.marker { width: 0.375rem; height: 0.375rem; border-radius: 1px; background: var(--line-strong); }
|
|
2441
3110
|
.marker.pass { background: var(--pass); } .marker.fail { background: var(--fail); } .marker.pending { background: var(--pending); } .marker.undefined { background: var(--undefined); } .marker.ambiguous, .marker.skipped, .marker.unknown { background: var(--muted); }
|
|
2442
3111
|
.step .kw { color: var(--muted); }
|
|
3112
|
+
.step .param { color: var(--accent-text); font-weight: 500; }
|
|
2443
3113
|
.step .dur { color: var(--accent-text); font-family: var(--font-mono); font-size: 0.6875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
3114
|
+
.diagnostic { margin: 0.375rem 0 0.125rem; padding: 0.5rem 0.625rem; border: 1px solid var(--line); border-left: 3px solid var(--undefined); border-radius: 5px; background: var(--undefined-soft); }
|
|
3115
|
+
.diagnostic[data-diagnostic="ambiguous"] { border-left-color: var(--ambiguous); background: var(--surface-3); }
|
|
3116
|
+
.diagnosticLead { margin: 0; color: var(--ink-2); font-size: 0.75rem; }
|
|
3117
|
+
.snippet { margin: 0.375rem 0 0; min-width: 0; }
|
|
3118
|
+
.snippetLang { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 0.625rem; }
|
|
3119
|
+
.snippet pre { margin: 0.125rem 0 0; padding: 0.5rem 0.625rem; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font: 0.6875rem/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
3120
|
+
.snippet code { font: inherit; }
|
|
3121
|
+
.definitions { display: grid; gap: 0.25rem; margin: 0.375rem 0 0; padding: 0; list-style: none; }
|
|
3122
|
+
.definitions li { display: grid; gap: 0.125rem; min-width: 0; padding: 0.375rem 0.5rem; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); }
|
|
3123
|
+
.definitionPattern { font: 0.6875rem/1.5 var(--font-mono); overflow-wrap: anywhere; }
|
|
3124
|
+
.definitionSource { color: var(--muted); font-family: var(--font-mono); font-size: 0.625rem; overflow-wrap: anywhere; }
|
|
2444
3125
|
.error { margin: 0.375rem 0 0.125rem; padding: 0.5rem 0.625rem; border: 1px solid color-mix(in oklab, var(--fail) 24%, var(--line)); border-radius: 5px; background: var(--fail-soft); color: var(--fail); font: 0.6875rem/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
2445
3126
|
.docString { margin: 0.375rem 0 0.125rem; padding: 0.5rem 0.625rem; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-3); color: var(--ink-2); font: 0.6875rem/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
2446
3127
|
.tableWrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
|
|
@@ -2460,6 +3141,25 @@ details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
|
2460
3141
|
.attachmentText { margin: 0.5rem 0; border: 1px solid var(--line); border-radius: 6px; padding: 0.4375rem 0.5625rem; background: var(--surface-2); }
|
|
2461
3142
|
.attachmentText summary { cursor: pointer; color: var(--accent-text); font-size: 0.75rem; }
|
|
2462
3143
|
.attachmentText pre { margin: 0.5rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 0.6875rem/1.45 var(--font-mono); color: var(--ink); }
|
|
3144
|
+
.logTools { display: flex; justify-content: flex-end; margin-top: 0.5rem; }
|
|
3145
|
+
.copyLog { min-height: 1.75rem; padding: 0 0.5625rem; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--paper); color: var(--ink-2); font-size: 0.6875rem; }
|
|
3146
|
+
.copyLog:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
|
|
3147
|
+
.ansi { white-space: pre-wrap; }
|
|
3148
|
+
.ansi-bold { font-weight: 700; }
|
|
3149
|
+
.ansi-dim { opacity: 0.65; }
|
|
3150
|
+
.ansi-italic { font-style: italic; }
|
|
3151
|
+
.ansi-underline { text-decoration: underline; }
|
|
3152
|
+
.ansi-fg-0 { color: var(--ansi-fg-0); } .ansi-fg-1 { color: var(--ansi-fg-1); } .ansi-fg-2 { color: var(--ansi-fg-2); } .ansi-fg-3 { color: var(--ansi-fg-3); }
|
|
3153
|
+
.ansi-fg-4 { color: var(--ansi-fg-4); } .ansi-fg-5 { color: var(--ansi-fg-5); } .ansi-fg-6 { color: var(--ansi-fg-6); } .ansi-fg-7 { color: var(--ansi-fg-7); }
|
|
3154
|
+
.ansi-fg-8 { color: var(--ansi-fg-8); } .ansi-fg-9 { color: var(--ansi-fg-9); } .ansi-fg-10 { color: var(--ansi-fg-10); } .ansi-fg-11 { color: var(--ansi-fg-11); }
|
|
3155
|
+
.ansi-fg-12 { color: var(--ansi-fg-12); } .ansi-fg-13 { color: var(--ansi-fg-13); } .ansi-fg-14 { color: var(--ansi-fg-14); } .ansi-fg-15 { color: var(--ansi-fg-15); }
|
|
3156
|
+
.ansi-bg-0 { background-color: color-mix(in oklab, var(--ansi-fg-0) 26%, var(--paper)); } .ansi-bg-1 { background-color: color-mix(in oklab, var(--ansi-fg-1) 26%, var(--paper)); } .ansi-bg-2 { background-color: color-mix(in oklab, var(--ansi-fg-2) 26%, var(--paper)); } .ansi-bg-3 { background-color: color-mix(in oklab, var(--ansi-fg-3) 26%, var(--paper)); }
|
|
3157
|
+
.ansi-bg-4 { background-color: color-mix(in oklab, var(--ansi-fg-4) 26%, var(--paper)); } .ansi-bg-5 { background-color: color-mix(in oklab, var(--ansi-fg-5) 26%, var(--paper)); } .ansi-bg-6 { background-color: color-mix(in oklab, var(--ansi-fg-6) 26%, var(--paper)); } .ansi-bg-7 { background-color: color-mix(in oklab, var(--ansi-fg-7) 26%, var(--paper)); }
|
|
3158
|
+
.ansi-bg-8 { background-color: color-mix(in oklab, var(--ansi-fg-8) 26%, var(--paper)); } .ansi-bg-9 { background-color: color-mix(in oklab, var(--ansi-fg-9) 26%, var(--paper)); } .ansi-bg-10 { background-color: color-mix(in oklab, var(--ansi-fg-10) 26%, var(--paper)); } .ansi-bg-11 { background-color: color-mix(in oklab, var(--ansi-fg-11) 26%, var(--paper)); }
|
|
3159
|
+
.ansi-bg-12 { background-color: color-mix(in oklab, var(--ansi-fg-12) 26%, var(--paper)); } .ansi-bg-13 { background-color: color-mix(in oklab, var(--ansi-fg-13) 26%, var(--paper)); } .ansi-bg-14 { background-color: color-mix(in oklab, var(--ansi-fg-14) 26%, var(--paper)); } .ansi-bg-15 { background-color: color-mix(in oklab, var(--ansi-fg-15) 26%, var(--paper)); }
|
|
3160
|
+
.ansi-bg-only { color: var(--ink); }
|
|
3161
|
+
.ansi-inline-fg { color: color-mix(in oklab, var(--ansi-fg) 30%, var(--ink)); }
|
|
3162
|
+
.ansi-inline-bg { background-color: color-mix(in oklab, var(--ansi-bg) 26%, var(--paper)); }
|
|
2463
3163
|
.fileLink { display: inline-block; margin: 0.3125rem 0; color: var(--accent-text); font-size: 0.75rem; }
|
|
2464
3164
|
.meta span, .path, .description, .step, .featureSource, .featureUri, .fileLink, .attachment figcaption, .attachmentText summary, .detailMeta span { overflow-wrap: anywhere; }
|
|
2465
3165
|
.detailMeta { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.75rem; color: var(--muted); font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
|
|
@@ -2524,6 +3224,7 @@ details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
|
2524
3224
|
.thumb { width: 2.5rem; height: 1.875rem; }
|
|
2525
3225
|
.statusText { min-width: 3.125rem; }
|
|
2526
3226
|
.filter { min-height: 1.75rem; }
|
|
3227
|
+
.examples { margin-left: 0; padding-left: 0.625rem; }
|
|
2527
3228
|
.matrixHint { display: block; margin: 0 0 0.5rem; font-size: 0.75rem; }
|
|
2528
3229
|
.triageBox > summary { display: flex; flex-wrap: wrap; padding: 0.875rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
|
|
2529
3230
|
.triageBox .triage { margin: 0.5rem 0 0; }
|
|
@@ -2532,6 +3233,7 @@ details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
|
2532
3233
|
}
|
|
2533
3234
|
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
|
|
2534
3235
|
@container (max-width: 16rem) {
|
|
3236
|
+
.thumb { display: none; }
|
|
2535
3237
|
.runHead h1 { font-size: 1.3rem; }
|
|
2536
3238
|
.feature > summary { grid-template-columns: auto 1fr auto; grid-template-areas: "status . chev" "title title title" "shape shape shape"; gap: 0.5rem; }
|
|
2537
3239
|
.feature > summary .statusCell { grid-area: status; }
|
|
@@ -2582,6 +3284,22 @@ details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
|
2582
3284
|
--skipped-soft: oklch(21% 0.009 60);
|
|
2583
3285
|
--unknown: oklch(71% 0.012 85);
|
|
2584
3286
|
--unknown-soft: oklch(21% 0.009 60);
|
|
3287
|
+
--ansi-fg-0: #9ca3af;
|
|
3288
|
+
--ansi-fg-1: #f87171;
|
|
3289
|
+
--ansi-fg-2: #86efac;
|
|
3290
|
+
--ansi-fg-3: #fde047;
|
|
3291
|
+
--ansi-fg-4: #93c5fd;
|
|
3292
|
+
--ansi-fg-5: #f0abfc;
|
|
3293
|
+
--ansi-fg-6: #67e8f9;
|
|
3294
|
+
--ansi-fg-7: #e5e7eb;
|
|
3295
|
+
--ansi-fg-8: #9ca3af;
|
|
3296
|
+
--ansi-fg-9: #fca5a5;
|
|
3297
|
+
--ansi-fg-10: #4ade80;
|
|
3298
|
+
--ansi-fg-11: #facc15;
|
|
3299
|
+
--ansi-fg-12: #60a5fa;
|
|
3300
|
+
--ansi-fg-13: #e879f9;
|
|
3301
|
+
--ansi-fg-14: #22d3ee;
|
|
3302
|
+
--ansi-fg-15: #ffffff;
|
|
2585
3303
|
}
|
|
2586
3304
|
}
|
|
2587
3305
|
`;
|
|
@@ -2631,6 +3349,8 @@ var TRIAGE_FEATURE_LIMIT = 20;
|
|
|
2631
3349
|
var TRIAGE_SCENARIO_LIMIT = 3;
|
|
2632
3350
|
var SOURCE_LIMIT = 6;
|
|
2633
3351
|
var SEARCH_MESSAGE_LIMIT = 2e3;
|
|
3352
|
+
var UNDEFINED_LEAD = "No step definition found.";
|
|
3353
|
+
var AMBIGUOUS_LEAD = "Multiple matching step definitions found:";
|
|
2634
3354
|
function compareStatus(a, b) {
|
|
2635
3355
|
const passed = Number(a === "passed") - Number(b === "passed");
|
|
2636
3356
|
return passed !== 0 ? passed : statusSeverity(b) - statusSeverity(a);
|
|
@@ -2654,74 +3374,88 @@ function countStatuses(scenarios) {
|
|
|
2654
3374
|
}
|
|
2655
3375
|
return counts;
|
|
2656
3376
|
}
|
|
3377
|
+
function executedOnly(scenarios) {
|
|
3378
|
+
return scenarios.filter((scenario) => scenario.executed);
|
|
3379
|
+
}
|
|
2657
3380
|
function barWidth(count2, total) {
|
|
2658
3381
|
return total === 0 ? 0 : Math.round(count2 / total * 1e3) / 10;
|
|
2659
3382
|
}
|
|
2660
3383
|
function attentionCounts(scenarios) {
|
|
2661
3384
|
const counts = /* @__PURE__ */ new Map();
|
|
2662
3385
|
for (const scenario of scenarios) {
|
|
2663
|
-
if (scenario.status === "passed") continue;
|
|
3386
|
+
if (!scenario.executed || scenario.status === "passed") continue;
|
|
2664
3387
|
counts.set(scenario.status, (counts.get(scenario.status) ?? 0) + 1);
|
|
2665
3388
|
}
|
|
2666
3389
|
return [...counts.entries()].sort((a, b) => statusSeverity(b[0]) - statusSeverity(a[0])).map(([status, count2]) => `${count2} ${status}`).join(", ");
|
|
2667
3390
|
}
|
|
2668
3391
|
function featureBar(scenarios) {
|
|
2669
|
-
const
|
|
3392
|
+
const executed = executedOnly(scenarios);
|
|
3393
|
+
const total = executed.length;
|
|
2670
3394
|
if (total === 0) return "";
|
|
2671
|
-
const counts = countStatuses(
|
|
3395
|
+
const counts = countStatuses(executed);
|
|
2672
3396
|
const segments = ALL_STATUSES.filter((status) => counts[status]).map(
|
|
2673
3397
|
(status) => `<i class="${statusClass(status)}" style="width:${barWidth(counts[status] ?? 0, total)}%"></i>`
|
|
2674
3398
|
).join("");
|
|
2675
3399
|
return `<span class="bar" aria-hidden="true">${segments}</span>`;
|
|
2676
3400
|
}
|
|
2677
3401
|
function featureShape(feature, scenarios) {
|
|
2678
|
-
const
|
|
3402
|
+
const executed = executedOnly(scenarios);
|
|
3403
|
+
const passed = executed.filter(
|
|
2679
3404
|
(scenario) => scenario.status === "passed"
|
|
2680
3405
|
).length;
|
|
2681
|
-
const attention = attentionCounts(
|
|
2682
|
-
const counts = `${passed} of ${
|
|
3406
|
+
const attention = attentionCounts(executed);
|
|
3407
|
+
const counts = `${passed} of ${executed.length} passed${attention ? ` \xB7 ${attention}` : ""}`;
|
|
2683
3408
|
const source = feature.sourceFile ? `<span class="featureSource">from ${escapeHtml(feature.sourceFile)}</span>` : "";
|
|
2684
|
-
return `<span class="featureShape"><span class="featureCounts">${counts}</span>${featureBar(scenarios)}${source}<span class="featureUri">${escapeHtml(displayUri(feature.uri))}</span
|
|
3409
|
+
return `<span class="featureShape"><span class="featureCounts">${counts}</span>${featureBar(scenarios)}${source}<span class="featureUri">${escapeHtml(displayUri(feature.uri))}</span>${tagsMarkup(feature.tags, "featureTags")}</span>`;
|
|
2685
3410
|
}
|
|
2686
3411
|
function renderTriageRow({
|
|
2687
3412
|
feature,
|
|
2688
3413
|
scenarios,
|
|
2689
3414
|
index
|
|
2690
3415
|
}) {
|
|
2691
|
-
const failing = scenarios.filter(
|
|
3416
|
+
const failing = executedOnly(scenarios).filter(
|
|
2692
3417
|
(scenario) => scenario.status !== "passed"
|
|
2693
3418
|
);
|
|
2694
3419
|
const links = failing.slice(0, TRIAGE_SCENARIO_LIMIT).map((scenario) => {
|
|
2695
3420
|
const scenarioIndex = scenarios.indexOf(scenario) + 1;
|
|
2696
|
-
return `<li><a class="triageScenario" href="#scenario-${index + 1}-${scenarioIndex}"><span class="triageStatus ${statusClass(scenario.status)}">${statusLabel(scenario.status)}</span><span>${escapeHtml(scenario
|
|
3421
|
+
return `<li><a class="triageScenario" href="#scenario-${index + 1}-${scenarioIndex}"><span class="triageStatus ${statusClass(scenario.status)}">${statusLabel(scenario.status)}</span><span>${escapeHtml(scenarioLabel(scenario))}</span></a></li>`;
|
|
2697
3422
|
}).join("");
|
|
2698
3423
|
const more = failing.length > TRIAGE_SCENARIO_LIMIT ? `<li class="triageMore">+${failing.length - TRIAGE_SCENARIO_LIMIT} more in the report</li>` : "";
|
|
2699
|
-
const failed =
|
|
3424
|
+
const failed = failing.find((scenario) => scenario.status === "failed");
|
|
2700
3425
|
const failedStep = failed?.steps.find(
|
|
2701
3426
|
(step) => step.status === "failed" && step.message
|
|
2702
3427
|
);
|
|
2703
|
-
const
|
|
3428
|
+
const failedHook = failed?.hooks.find(
|
|
3429
|
+
(hook) => hook.status === "failed" && hook.message
|
|
3430
|
+
);
|
|
3431
|
+
const reasonSource = failedStep?.message ? `${failedStep.keyword ? `${failedStep.keyword} ` : ""}${failedStep.text}` : failedHook?.message ? hookLabel2(failedHook) : "";
|
|
3432
|
+
const reasonMessage = failedStep?.message ?? failedHook?.message ?? "";
|
|
3433
|
+
const reason = reasonSource ? `${reasonSource} \u2014 ${reasonMessage.split(/\r?\n/)[0].trim().slice(0, 120)}${reasonMessage.split(/\r?\n/)[0].trim().length > 120 ? "\u2026" : ""}` : "";
|
|
2704
3434
|
return `<li class="triageItem"><a class="triageFeature" href="#feature-${index + 1}" title="${escapeHtml(displayUri(feature.uri))}"><span class="triageStatus ${statusClass(feature.status)}">${statusLabel(feature.status)}</span><span>${escapeHtml(feature.name)}</span></a><p class="triageCounts">${attentionCounts(scenarios)}</p><ul class="triageScenarios">${links}${more}</ul>${reason ? `<p class="triageReason"><span class="triageReasonLabel">First failure:</span> ${escapeHtml(reason)}</p>` : ""}</li>`;
|
|
2705
3435
|
}
|
|
2706
3436
|
function renderTriage(features) {
|
|
2707
3437
|
const attention = features.map((entry, index) => ({ ...entry, index })).filter(
|
|
2708
|
-
({ scenarios }) => scenarios.some(
|
|
3438
|
+
({ scenarios }) => scenarios.some(
|
|
3439
|
+
(scenario) => scenario.executed && scenario.status !== "passed"
|
|
3440
|
+
)
|
|
2709
3441
|
);
|
|
2710
3442
|
if (attention.length === 0) return "";
|
|
2711
3443
|
const shown = attention.slice(0, 5);
|
|
2712
3444
|
const rest = attention.slice(5, TRIAGE_FEATURE_LIMIT);
|
|
2713
3445
|
const total = features.reduce(
|
|
2714
|
-
(sum, entry) => sum + entry.scenarios.length,
|
|
3446
|
+
(sum, entry) => sum + executedOnly(entry.scenarios).length,
|
|
2715
3447
|
0
|
|
2716
3448
|
);
|
|
2717
3449
|
const need = attention.reduce(
|
|
2718
|
-
(sum, entry) => sum + entry.scenarios.filter(
|
|
3450
|
+
(sum, entry) => sum + entry.scenarios.filter(
|
|
3451
|
+
(scenario) => scenario.executed && scenario.status !== "passed"
|
|
3452
|
+
).length,
|
|
2719
3453
|
0
|
|
2720
3454
|
);
|
|
2721
3455
|
const rows = shown.map(renderTriageRow).join("");
|
|
2722
3456
|
const restBlock = rest.length ? `<details class="triageRest"><summary>Show ${rest.length} more feature${rest.length === 1 ? "" : "s"}</summary><ol class="triageList">${rest.map(renderTriageRow).join("")}</ol></details>` : "";
|
|
2723
3457
|
const remainder = attention.length > TRIAGE_FEATURE_LIMIT ? `<p class="triageMore">${attention.length - TRIAGE_FEATURE_LIMIT} more feature${attention.length - TRIAGE_FEATURE_LIMIT === 1 ? "" : "s"} below.</p>` : "";
|
|
2724
|
-
const lead = `${need} of ${total} scenario${total === 1 ? "" : "s"} ${
|
|
3458
|
+
const lead = `${need} of ${total} scenario${total === 1 ? "" : "s"} ${total === 1 ? "needs" : "need"} attention.`;
|
|
2725
3459
|
return `<details class="triageBox" data-triage open><summary class="triageSummary"><span class="triageTitle">Needs attention</span><span class="triageSummaryLead">${lead}</span><span class="chev" aria-hidden="true"></span></summary><nav class="triage" aria-label="Needs attention"><h2 id="triage-heading">Needs attention</h2><p class="triageLead">${lead}</p><ol class="triageList">${rows}</ol>${restBlock}${remainder}</nav></details>`;
|
|
2726
3460
|
}
|
|
2727
3461
|
function renderSourceStrip(model) {
|
|
@@ -2735,13 +3469,18 @@ function renderSourceStrip(model) {
|
|
|
2735
3469
|
groups.set(file, group);
|
|
2736
3470
|
});
|
|
2737
3471
|
if (groups.size < 2) return "";
|
|
2738
|
-
const entries = [...groups.entries()].map(([file, group]) =>
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
3472
|
+
const entries = [...groups.entries()].map(([file, group]) => {
|
|
3473
|
+
const scenarios = executedOnly(
|
|
3474
|
+
group.features.flatMap((feature) => feature.scenarios)
|
|
3475
|
+
);
|
|
3476
|
+
return {
|
|
3477
|
+
file,
|
|
3478
|
+
features: group.features.length,
|
|
3479
|
+
scenarios,
|
|
3480
|
+
status: worstExecutedStatus(scenarios),
|
|
3481
|
+
order: group.order
|
|
3482
|
+
};
|
|
3483
|
+
});
|
|
2745
3484
|
entries.sort((a, b) => {
|
|
2746
3485
|
const status = compareStatus(a.status, b.status);
|
|
2747
3486
|
return status !== 0 ? status : a.order - b.order;
|
|
@@ -2769,6 +3508,179 @@ function countPills(model) {
|
|
|
2769
3508
|
(status) => `<span class="${statusClass(status)}"><b>${counts[status]}</b> ${status}</span>`
|
|
2770
3509
|
).join("")}</div>`;
|
|
2771
3510
|
}
|
|
3511
|
+
function safeHttpUrl(value) {
|
|
3512
|
+
const trimmed = stripBidiControls(value ?? "").trim();
|
|
3513
|
+
if (!trimmed) return void 0;
|
|
3514
|
+
try {
|
|
3515
|
+
const url = new URL(trimmed);
|
|
3516
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url.href : void 0;
|
|
3517
|
+
} catch {
|
|
3518
|
+
return void 0;
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
function githubRepoPath(url) {
|
|
3522
|
+
if (url.hostname.toLowerCase() !== "github.com") return void 0;
|
|
3523
|
+
const path5 = url.pathname.replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
3524
|
+
return /^\/[^/]+\/[^/]+$/.test(path5) ? path5 : void 0;
|
|
3525
|
+
}
|
|
3526
|
+
function githubBaseUrl(remote) {
|
|
3527
|
+
const value = stripBidiControls(remote ?? "").trim();
|
|
3528
|
+
if (!value) return void 0;
|
|
3529
|
+
const direct = safeHttpUrl(value);
|
|
3530
|
+
if (direct) {
|
|
3531
|
+
const url = new URL(direct);
|
|
3532
|
+
const path5 = githubRepoPath(url);
|
|
3533
|
+
return path5 ? `${url.origin}${path5}` : void 0;
|
|
3534
|
+
}
|
|
3535
|
+
const scp = /^(?:[^@\s/:]+@)?github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(
|
|
3536
|
+
value
|
|
3537
|
+
);
|
|
3538
|
+
if (scp) return `https://github.com/${scp[1]}/${scp[2]}`;
|
|
3539
|
+
if (!/^(?:ssh|git\+ssh):\/\//i.test(value)) return void 0;
|
|
3540
|
+
try {
|
|
3541
|
+
const path5 = githubRepoPath(new URL(value));
|
|
3542
|
+
return path5 ? `https://github.com${path5}` : void 0;
|
|
3543
|
+
} catch {
|
|
3544
|
+
return void 0;
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
function shortRevision(revision) {
|
|
3548
|
+
return stripBidiControls(revision).slice(0, 7);
|
|
3549
|
+
}
|
|
3550
|
+
function githubCommitUrl(ci) {
|
|
3551
|
+
if (!ci?.remote || !ci.revision) return void 0;
|
|
3552
|
+
const base = githubBaseUrl(ci.remote);
|
|
3553
|
+
if (!base) return void 0;
|
|
3554
|
+
return `${base}/commit/${encodeURIComponent(stripBidiControls(ci.revision))}`;
|
|
3555
|
+
}
|
|
3556
|
+
function revisionMarkup(ci) {
|
|
3557
|
+
if (!ci?.revision) return "";
|
|
3558
|
+
const short = escapeHtml(shortRevision(ci.revision));
|
|
3559
|
+
const commit = githubCommitUrl(ci);
|
|
3560
|
+
if (!commit) return short;
|
|
3561
|
+
return `<a href="${escapeHtml(commit)}" title="${escapeHtml(ci.revision)}" rel="noopener noreferrer">${short}</a>`;
|
|
3562
|
+
}
|
|
3563
|
+
function ciNameMarkup(ci) {
|
|
3564
|
+
const href = safeHttpUrl(ci?.url);
|
|
3565
|
+
const label = ci?.name || href;
|
|
3566
|
+
if (!label) return "";
|
|
3567
|
+
return href ? `<a href="${escapeHtml(href)}" rel="noopener noreferrer">${escapeHtml(label)}</a>` : escapeHtml(label);
|
|
3568
|
+
}
|
|
3569
|
+
function ciHeaderMarkup(ci) {
|
|
3570
|
+
if (!ci) return "";
|
|
3571
|
+
const name = ciNameMarkup(ci);
|
|
3572
|
+
const rows = [
|
|
3573
|
+
name ? `<span class="ci"><b>CI</b> ${name}</span>` : "",
|
|
3574
|
+
ci.revision ? `<span><b>Revision</b> ${revisionMarkup(ci)}</span>` : "",
|
|
3575
|
+
ci.branch ? `<span><b>Branch</b> <span>${escapeHtml(ci.branch)}</span></span>` : "",
|
|
3576
|
+
ci.tag ? `<span><b>Tag</b> <span>${escapeHtml(ci.tag)}</span></span>` : ""
|
|
3577
|
+
].filter(Boolean);
|
|
3578
|
+
return rows.join("");
|
|
3579
|
+
}
|
|
3580
|
+
function ciDetailRows(ci) {
|
|
3581
|
+
if (!ci) return "";
|
|
3582
|
+
const name = ciNameMarkup(ci);
|
|
3583
|
+
return [
|
|
3584
|
+
name ? `<dt>CI</dt><dd>${name}</dd>` : "",
|
|
3585
|
+
ci.revision ? `<dt>Revision</dt><dd>${revisionMarkup(ci)}</dd>` : "",
|
|
3586
|
+
ci.branch ? `<dt>Branch</dt><dd>${escapeHtml(ci.branch)}</dd>` : "",
|
|
3587
|
+
ci.tag ? `<dt>Tag</dt><dd>${escapeHtml(ci.tag)}</dd>` : ""
|
|
3588
|
+
].join("");
|
|
3589
|
+
}
|
|
3590
|
+
function prettyJson(text) {
|
|
3591
|
+
try {
|
|
3592
|
+
JSON.parse(text);
|
|
3593
|
+
} catch {
|
|
3594
|
+
return void 0;
|
|
3595
|
+
}
|
|
3596
|
+
const out = [];
|
|
3597
|
+
const stack = [];
|
|
3598
|
+
let inString = false;
|
|
3599
|
+
let escaped = false;
|
|
3600
|
+
const openItem = () => {
|
|
3601
|
+
const top = stack[stack.length - 1];
|
|
3602
|
+
if (top && !top.hasItems) {
|
|
3603
|
+
out.push("\n", " ".repeat(stack.length));
|
|
3604
|
+
top.hasItems = true;
|
|
3605
|
+
}
|
|
3606
|
+
};
|
|
3607
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
3608
|
+
const character = text[index];
|
|
3609
|
+
if (inString) {
|
|
3610
|
+
out.push(character);
|
|
3611
|
+
if (escaped) escaped = false;
|
|
3612
|
+
else if (character === "\\") escaped = true;
|
|
3613
|
+
else if (character === '"') inString = false;
|
|
3614
|
+
continue;
|
|
3615
|
+
}
|
|
3616
|
+
if (character === '"') {
|
|
3617
|
+
openItem();
|
|
3618
|
+
out.push(character);
|
|
3619
|
+
inString = true;
|
|
3620
|
+
continue;
|
|
3621
|
+
}
|
|
3622
|
+
if (character === "{" || character === "[") {
|
|
3623
|
+
openItem();
|
|
3624
|
+
out.push(character);
|
|
3625
|
+
stack.push({ opener: character, hasItems: false });
|
|
3626
|
+
continue;
|
|
3627
|
+
}
|
|
3628
|
+
if (character === "}" || character === "]") {
|
|
3629
|
+
const frame = stack.pop();
|
|
3630
|
+
if (!frame) return void 0;
|
|
3631
|
+
if (frame.opener === "{" && character !== "}" || frame.opener === "[" && character !== "]") {
|
|
3632
|
+
return void 0;
|
|
3633
|
+
}
|
|
3634
|
+
if (frame.hasItems) out.push("\n", " ".repeat(stack.length));
|
|
3635
|
+
out.push(character);
|
|
3636
|
+
continue;
|
|
3637
|
+
}
|
|
3638
|
+
if (character === ",") {
|
|
3639
|
+
out.push(",", "\n", " ".repeat(stack.length));
|
|
3640
|
+
continue;
|
|
3641
|
+
}
|
|
3642
|
+
if (character === ":") {
|
|
3643
|
+
out.push(": ");
|
|
3644
|
+
continue;
|
|
3645
|
+
}
|
|
3646
|
+
if (character === " " || character === "\n" || character === "\r" || character === " ") {
|
|
3647
|
+
continue;
|
|
3648
|
+
}
|
|
3649
|
+
let end = index;
|
|
3650
|
+
while (end < text.length && !/[\s,\]}:]/.test(text[end])) {
|
|
3651
|
+
end += 1;
|
|
3652
|
+
}
|
|
3653
|
+
openItem();
|
|
3654
|
+
out.push(text.slice(index, end));
|
|
3655
|
+
index = end - 1;
|
|
3656
|
+
}
|
|
3657
|
+
return stack.length === 0 && !inString ? out.join("") : void 0;
|
|
3658
|
+
}
|
|
3659
|
+
function jsonBody(text) {
|
|
3660
|
+
return prettyJson(text) ?? text;
|
|
3661
|
+
}
|
|
3662
|
+
function uriListBody(text) {
|
|
3663
|
+
return text.split(/\r?\n/).map((line) => {
|
|
3664
|
+
const label = line.trim();
|
|
3665
|
+
const href = safeHttpUrl(label);
|
|
3666
|
+
return href ? `<a href="${escapeHtml(href)}" rel="noopener noreferrer">${escapeHtml(label)}</a>` : escapeHtml(line);
|
|
3667
|
+
}).join("\n");
|
|
3668
|
+
}
|
|
3669
|
+
function textAttachmentBody(attachment) {
|
|
3670
|
+
const text = attachment.text ?? "";
|
|
3671
|
+
const mediaType = normalizedMediaType(attachment.mediaType);
|
|
3672
|
+
if (mediaType.startsWith("application/json")) {
|
|
3673
|
+
const body = Buffer.byteLength(text, "utf8") > MAX_TEXT_ATTACHMENT_BYTES ? text : jsonBody(text);
|
|
3674
|
+
return `<pre>${escapeHtml(body)}</pre>`;
|
|
3675
|
+
}
|
|
3676
|
+
if (mediaType === "text/uri-list") {
|
|
3677
|
+
return `<pre>${uriListBody(text)}</pre>`;
|
|
3678
|
+
}
|
|
3679
|
+
if (mediaType === "text/x.cucumber.log+plain") {
|
|
3680
|
+
return `<div class="logTools"><button class="copyLog" type="button" data-copy-log aria-label="Copy log ${escapeHtml(attachment.fileName)}" hidden>Copy log</button></div><pre class="ansiLog">${renderAnsiLog(text)}</pre>`;
|
|
3681
|
+
}
|
|
3682
|
+
return `<pre>${escapeHtml(text)}</pre>`;
|
|
3683
|
+
}
|
|
2772
3684
|
function renderAttachment(attachment, context) {
|
|
2773
3685
|
const name = escapeHtml(attachment.fileName);
|
|
2774
3686
|
const media = escapeHtml(attachment.mediaType);
|
|
@@ -2783,7 +3695,7 @@ function renderAttachment(attachment, context) {
|
|
|
2783
3695
|
return `<figure class="attachment"><audio controls src="${escapeHtml(attachment.dataUri)}"></audio><figcaption>${name} (${media})</figcaption></figure>`;
|
|
2784
3696
|
}
|
|
2785
3697
|
if (attachment.kind === "text" && attachment.text !== void 0) {
|
|
2786
|
-
return `<details class="attachmentText"><summary>${name} (${media})</summary
|
|
3698
|
+
return `<details class="attachmentText"><summary>${name} (${media})</summary>${textAttachmentBody(attachment)}</details>`;
|
|
2787
3699
|
}
|
|
2788
3700
|
if (attachment.dataUri) {
|
|
2789
3701
|
return `<a class="fileLink" href="${escapeHtml(attachment.dataUri)}" download="${name}">${name} (${media}, ${attachment.bytes} bytes)</a>`;
|
|
@@ -2795,7 +3707,50 @@ function scenarioTags(model) {
|
|
|
2795
3707
|
(a, b) => a.localeCompare(b)
|
|
2796
3708
|
);
|
|
2797
3709
|
}
|
|
3710
|
+
function renderDiagnostic(step) {
|
|
3711
|
+
if (step.status === "undefined") {
|
|
3712
|
+
const suggestions = step.suggestions ?? [];
|
|
3713
|
+
const lead = suggestions.length ? `${UNDEFINED_LEAD} Implement with the snippet(s) below:` : UNDEFINED_LEAD;
|
|
3714
|
+
const snippets = suggestions.map((suggestion) => {
|
|
3715
|
+
const language = suggestion.language ? `<span class="snippetLang">${escapeHtml(suggestion.language)}</span>` : "";
|
|
3716
|
+
return `<div class="snippet">${language}<pre><code>${escapeHtml(suggestion.code)}</code></pre></div>`;
|
|
3717
|
+
}).join("");
|
|
3718
|
+
return `<div class="diagnostic" data-diagnostic="undefined"><p class="diagnosticLead">${lead}</p>${snippets}</div>`;
|
|
3719
|
+
}
|
|
3720
|
+
if (step.status === "ambiguous") {
|
|
3721
|
+
const definitions = step.definitions ?? [];
|
|
3722
|
+
const items = definitions.map(
|
|
3723
|
+
(definition) => `<li><code class="definitionPattern">${escapeHtml(definition.pattern)}</code>${definition.source ? `<span class="definitionSource">${escapeHtml(displayUri(definition.source))}</span>` : ""}</li>`
|
|
3724
|
+
).join("");
|
|
3725
|
+
const list = items ? `<ul class="definitions">${items}</ul>` : "";
|
|
3726
|
+
return `<div class="diagnostic" data-diagnostic="ambiguous"><p class="diagnosticLead">${AMBIGUOUS_LEAD}</p>${list}</div>`;
|
|
3727
|
+
}
|
|
3728
|
+
return "";
|
|
3729
|
+
}
|
|
3730
|
+
function renderStepText(step) {
|
|
3731
|
+
const parameters = step.parameters;
|
|
3732
|
+
if (!parameters?.length) return escapeHtml(step.text);
|
|
3733
|
+
let cursor = 0;
|
|
3734
|
+
for (const parameter of parameters) {
|
|
3735
|
+
const end = parameter.start + parameter.value.length;
|
|
3736
|
+
if (!Number.isInteger(parameter.start) || parameter.start < cursor || !parameter.value.length || end > step.text.length || step.text.slice(parameter.start, end) !== parameter.value) {
|
|
3737
|
+
return escapeHtml(step.text);
|
|
3738
|
+
}
|
|
3739
|
+
cursor = end;
|
|
3740
|
+
}
|
|
3741
|
+
cursor = 0;
|
|
3742
|
+
let html = "";
|
|
3743
|
+
for (const parameter of parameters) {
|
|
3744
|
+
const end = parameter.start + parameter.value.length;
|
|
3745
|
+
const matched = step.text.slice(parameter.start, end);
|
|
3746
|
+
html += escapeHtml(step.text.slice(cursor, parameter.start));
|
|
3747
|
+
html += `<span class="param" data-parameter-type="${escapeHtml(parameter.type)}">${escapeHtml(matched)}</span>`;
|
|
3748
|
+
cursor = end;
|
|
3749
|
+
}
|
|
3750
|
+
return html + escapeHtml(step.text.slice(cursor));
|
|
3751
|
+
}
|
|
2798
3752
|
function renderStep(step, scenarioName) {
|
|
3753
|
+
const diagnostic = renderDiagnostic(step);
|
|
2799
3754
|
const docString = step.docString ? `<pre class="docString">${escapeHtml(step.docString)}</pre>` : "";
|
|
2800
3755
|
const table = step.dataTable ? `<div class="tableWrap" tabindex="0" role="region" aria-label="Data table for: ${escapeHtml(step.text)}"><table class="dataTable"><tbody>${step.dataTable.map(
|
|
2801
3756
|
(row, index) => `<tr>${row.map(
|
|
@@ -2805,37 +3760,258 @@ function renderStep(step, scenarioName) {
|
|
|
2805
3760
|
const error = step.message ? `<pre class="error">${escapeHtml(step.message)}</pre>` : "";
|
|
2806
3761
|
const context = `${scenarioName}: ${step.keyword.trim()} ${step.text}`;
|
|
2807
3762
|
const attachments = step.attachments.map((attachment) => renderAttachment(attachment, context)).join("");
|
|
2808
|
-
return `<li class="step"${step.status === "failed" ? ' data-status="failed"' : ""}><span class="stepMarker ${statusClass(step.status)}"><span aria-hidden="true">${STEP_GLYPHS[step.status]}</span><span class="sr">${statusLabel(step.status)}</span></span><div><span class="kw">${escapeHtml(step.keyword)}</span>
|
|
3763
|
+
return `<li class="step"${step.status === "failed" ? ' data-status="failed"' : ""}><span class="stepMarker ${statusClass(step.status)}"><span aria-hidden="true">${STEP_GLYPHS[step.status]}</span><span class="sr">${statusLabel(step.status)}</span></span><div><span class="kw">${escapeHtml(step.keyword)}</span> <span class="stepText">${renderStepText(step)}</span>${diagnostic}${error}${docString}${table}${attachments}</div><span class="dur">${durationLabel(step.durationMs)}</span></li>`;
|
|
3764
|
+
}
|
|
3765
|
+
function hookLabel2(hook, bareName = false) {
|
|
3766
|
+
if (hook.name) return bareName ? hook.name : `${hook.type}: ${hook.name}`;
|
|
3767
|
+
return hook.type;
|
|
3768
|
+
}
|
|
3769
|
+
function renderHook(hook, scenarioName, bareName = false) {
|
|
3770
|
+
const error = hook.message ? `<pre class="error">${escapeHtml(hook.message)}</pre>` : "";
|
|
3771
|
+
const label = hookLabel2(hook, bareName);
|
|
3772
|
+
const attachments = hook.attachments.map((attachment) => renderAttachment(attachment, `${scenarioName}: ${label}`)).join("");
|
|
3773
|
+
return `<li class="hook" data-status="${hook.status}"><span class="stepMarker ${statusClass(hook.status)}"><span aria-hidden="true">${STEP_GLYPHS[hook.status]}</span><span class="sr">${statusLabel(hook.status)}</span></span><div><span class="hookLabel">${escapeHtml(label)}</span>${error}${attachments}</div><span class="dur">${durationLabel(hook.durationMs)}</span></li>`;
|
|
3774
|
+
}
|
|
3775
|
+
function renderRunHooks(model) {
|
|
3776
|
+
if (model.runHooks.length === 0) return "";
|
|
3777
|
+
return `<section class="runHooks" data-run-hooks aria-labelledby="run-hooks-heading"><h2 id="run-hooks-heading">Hooks</h2><ul class="hooks">${model.runHooks.map((hook) => renderHook(hook, "Run", true)).join("")}</ul></section>`;
|
|
3778
|
+
}
|
|
3779
|
+
function scenarioLabel(scenario) {
|
|
3780
|
+
const outline = scenario.outline;
|
|
3781
|
+
if (!outline) return scenario.name;
|
|
3782
|
+
const number = `#${outline.examplesIndex + 1}.${outline.exampleIndex + 1}`;
|
|
3783
|
+
const examples = outline.examplesName ? `${outline.examplesName} ` : "";
|
|
3784
|
+
return `${examples}${number} \xB7 ${scenario.name}`.trim();
|
|
3785
|
+
}
|
|
3786
|
+
function tagsMarkup(tags, extraClass = "") {
|
|
3787
|
+
const className = extraClass ? `tags ${extraClass}` : "tags";
|
|
3788
|
+
return tags.length ? `<span class="${className}">${tags.map((tag) => `<span class="tag">${escapeHtml(tag)}</span>`).join("")}</span>` : "";
|
|
3789
|
+
}
|
|
3790
|
+
function backgroundText(background) {
|
|
3791
|
+
return [background.name, background.description].join(" ");
|
|
3792
|
+
}
|
|
3793
|
+
function backgroundMarkup(backgrounds) {
|
|
3794
|
+
return backgrounds.filter((background) => background.name || background.description).map((background) => {
|
|
3795
|
+
const name = background.name ? ` ${escapeHtml(background.name)}` : "";
|
|
3796
|
+
const description = renderDescription(background.description);
|
|
3797
|
+
return `<section class="background" data-background><h3 class="backgroundTitle"><span class="kw">${escapeHtml(background.keyword)}:</span>${name}</h3>${description}</section>`;
|
|
3798
|
+
}).join("");
|
|
3799
|
+
}
|
|
3800
|
+
function ruleSearchText(rule) {
|
|
3801
|
+
return [
|
|
3802
|
+
rule.name,
|
|
3803
|
+
rule.description,
|
|
3804
|
+
...rule.tags,
|
|
3805
|
+
...rule.backgrounds.map(backgroundText)
|
|
3806
|
+
].join(" ");
|
|
2809
3807
|
}
|
|
2810
3808
|
function scenarioText(scenario) {
|
|
3809
|
+
const outline = scenario.outline;
|
|
3810
|
+
const example = outline ? `#${outline.examplesIndex + 1}.${outline.exampleIndex + 1}` : "";
|
|
2811
3811
|
return [
|
|
2812
3812
|
scenario.name,
|
|
2813
3813
|
scenario.featureName,
|
|
2814
3814
|
displayUri(scenario.uri),
|
|
2815
|
-
scenario.keyword,
|
|
2816
|
-
scenario.description,
|
|
3815
|
+
outline ? outline.keyword : scenario.keyword,
|
|
3816
|
+
...outline ? [outline.name, outline.examplesKeyword, outline.examplesName, example] : [scenario.description],
|
|
2817
3817
|
scenario.tags.join(" "),
|
|
2818
|
-
scenario.
|
|
3818
|
+
scenario.hooks.map(
|
|
3819
|
+
(hook) => `${hook.type} ${hook.name ?? ""} ${(hook.message ?? "").slice(0, SEARCH_MESSAGE_LIMIT)}`
|
|
3820
|
+
).join(" "),
|
|
3821
|
+
scenario.steps.map((step) => {
|
|
3822
|
+
const diagnostic = step.status === "undefined" || step.status === "ambiguous" ? [
|
|
3823
|
+
step.status === "undefined" ? UNDEFINED_LEAD : AMBIGUOUS_LEAD,
|
|
3824
|
+
...(step.suggestions ?? []).flatMap((suggestion) => [
|
|
3825
|
+
suggestion.language ?? "",
|
|
3826
|
+
suggestion.code.slice(0, SEARCH_MESSAGE_LIMIT)
|
|
3827
|
+
]),
|
|
3828
|
+
...(step.definitions ?? []).flatMap((definition) => [
|
|
3829
|
+
definition.pattern.slice(0, SEARCH_MESSAGE_LIMIT),
|
|
3830
|
+
displayUri(definition.source ?? "").slice(
|
|
3831
|
+
0,
|
|
3832
|
+
SEARCH_MESSAGE_LIMIT
|
|
3833
|
+
)
|
|
3834
|
+
])
|
|
3835
|
+
].join(" ") : "";
|
|
3836
|
+
return `${step.keyword} ${step.text} ${(step.message ?? "").slice(0, SEARCH_MESSAGE_LIMIT)} ${diagnostic}`;
|
|
3837
|
+
}).join(" ")
|
|
2819
3838
|
].join(" ");
|
|
2820
3839
|
}
|
|
2821
|
-
function renderScenario(scenario, featureIndex, scenarioIndex) {
|
|
3840
|
+
function renderScenario(scenario, featureIndex, scenarioIndex, grouped = false, inRule = false) {
|
|
3841
|
+
const outline = scenario.outline;
|
|
3842
|
+
const example = grouped && outline ? `#${outline.examplesIndex + 1}.${outline.exampleIndex + 1}` : "";
|
|
3843
|
+
const heading = grouped ? "h5" : inRule ? "h4" : "h3";
|
|
2822
3844
|
const image = scenario.attachments.find(
|
|
2823
3845
|
(attachment) => attachment.kind === "image" && attachment.dataUri
|
|
2824
3846
|
);
|
|
2825
|
-
const open = scenario.status
|
|
2826
|
-
const
|
|
2827
|
-
|
|
2828
|
-
|
|
3847
|
+
const open = scenario.executed && (scenario.status !== "passed" || !grouped && Boolean(image));
|
|
3848
|
+
const passedHooks = scenario.hooks.filter(
|
|
3849
|
+
(hook) => hook.status === "passed"
|
|
3850
|
+
);
|
|
3851
|
+
const inlineItems = [
|
|
3852
|
+
...scenario.steps.map((step) => ({
|
|
3853
|
+
order: step.order,
|
|
3854
|
+
html: renderStep(step, scenario.name)
|
|
3855
|
+
})),
|
|
3856
|
+
...scenario.hooks.filter((hook) => hook.status !== "passed").map((hook) => ({ order: hook.order, html: renderHook(hook, scenario.name) }))
|
|
3857
|
+
].sort((a, b) => a.order - b.order).map((item) => item.html).join("");
|
|
3858
|
+
const passedHooksGroup = passedHooks.length ? `<details class="hookGroup"><summary>${passedHooks.length} hook${passedHooks.length === 1 ? "" : "s"}</summary><ul class="hooks" aria-label="Passed hooks">${passedHooks.map((hook) => renderHook(hook, scenario.name)).join("")}</ul></details>` : "";
|
|
3859
|
+
const description = grouped ? "" : renderDescription(scenario.description);
|
|
3860
|
+
const screenReaderLabel = grouped && outline ? `<span class="sr">${escapeHtml(`${scenario.name}, Scenario Outline ${outline.name}${outline.examplesName ? `, Examples ${outline.examplesName}` : ""}, example ${example}`)}</span>` : "";
|
|
3861
|
+
const visibleName = grouped ? `<span class="exampleNo" aria-hidden="true">${escapeHtml(example)}</span>${screenReaderLabel}` : escapeHtml(scenario.name);
|
|
3862
|
+
const rowTags = grouped ? "" : tagsMarkup(scenario.ownTags);
|
|
3863
|
+
const extraAttachments = scenario.extraAttachments.length ? `<div role="group" aria-label="Attachments"><p class="detailLabel">Attachments</p>${scenario.extraAttachments.map((attachment) => renderAttachment(attachment, scenario.name)).join("")}</div>` : "";
|
|
2829
3864
|
const copyFailure = scenario.status === "failed" ? '<button class="copyFailure" type="button" data-copy-failure>Copy failure</button>' : "";
|
|
2830
|
-
|
|
3865
|
+
const exampleData = grouped ? ` data-example="${escapeHtml(example)}" data-examples-name="${escapeHtml(outline?.examplesName ?? "")}"` : "";
|
|
3866
|
+
const scenarioMeta = grouped && outline ? `<span>Scenario: ${escapeHtml(scenario.name)}</span>` : "";
|
|
3867
|
+
const statusCell = scenario.executed ? `<span class="statusCell"><span class="statusText ${statusClass(scenario.status)}">${statusLabel(scenario.status)}</span></span>` : '<span class="statusCell"><span class="sr">Not executed</span></span>';
|
|
3868
|
+
const statusData = scenario.executed ? ` data-status="${scenario.status}"` : "";
|
|
3869
|
+
return `<details class="scenario" id="scenario-${featureIndex + 1}-${scenarioIndex + 1}" data-scenario${statusData} data-uri="${escapeHtml(displayUri(scenario.uri))}" data-scenario-name="${escapeHtml(scenario.name)}"${exampleData} data-tags="${escapeHtml(scenario.tags.join(" "))}" data-search="${escapeHtml(scenarioText(scenario))}" ${open ? "open" : ""}><summary class="scenarioButton">${statusCell}<span class="thumbCell">${image ? `<img class="thumb" src="${escapeHtml(image.dataUri ?? "")}" alt="" loading="lazy">` : ""}</span><span class="scenarioMain"><${heading} class="scenarioName">${visibleName}</${heading}><span class="scenarioSub">${scenario.steps.length} step${scenario.steps.length === 1 ? "" : "s"}${scenario.hooks.length ? ` \xB7 ${scenario.hooks.length} hook${scenario.hooks.length === 1 ? "" : "s"}` : ""}${rowTags ? ` ${rowTags}` : ""}</span></span><span class="rowRight">${durationLabel(scenario.durationMs)}${scenario.attachments.length ? `<br>${scenario.attachments.length} attachment${scenario.attachments.length === 1 ? "" : "s"}` : ""}</span><span class="chev" aria-hidden="true"></span></summary><div class="detailInline">${description}<div class="stepsHead"><p class="detailLabel">Steps</p>${copyFailure}</div><ol class="steps" aria-label="Steps and hooks">${inlineItems}</ol>${passedHooksGroup}${extraAttachments}<div class="detailMeta">${scenarioMeta}<span>Feature: ${escapeHtml(scenario.featureName)}</span><span>Attempt: ${scenario.attempt + 1}</span>${scenario.startedAt ? `<span>Started: ${dateLabel(scenario.startedAt)}</span>` : ""}${scenario.ruleName ? `<span>Rule: ${escapeHtml(scenario.ruleName)}</span>` : ""}</div></div></details>`;
|
|
3870
|
+
}
|
|
3871
|
+
function renderExamples(outline, rows, featureIndex, idIndex) {
|
|
3872
|
+
const description = renderDescription(outline.examplesDescription);
|
|
3873
|
+
const title = outline.examplesName ? `<span class="kw">${escapeHtml(outline.examplesKeyword)}:</span> ${escapeHtml(outline.examplesName)}` : `<span class="kw">${escapeHtml(outline.examplesKeyword)}:</span>`;
|
|
3874
|
+
return `<section class="examples" data-examples data-search="${escapeHtml(outline.examplesDescription)}">${tagsMarkup(outline.examplesTags)}<h4 class="examplesTitle">${title}</h4>${description}<div class="exampleRows">${rows.map(
|
|
3875
|
+
(scenario) => renderScenario(
|
|
3876
|
+
scenario,
|
|
3877
|
+
featureIndex,
|
|
3878
|
+
idIndex.get(scenario.id) ?? 0,
|
|
3879
|
+
true
|
|
3880
|
+
)
|
|
3881
|
+
).join("")}</div></section>`;
|
|
3882
|
+
}
|
|
3883
|
+
function renderOutline(outline, rows, featureIndex, idIndex) {
|
|
3884
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
3885
|
+
for (const row of rows) {
|
|
3886
|
+
if (!row.outline) continue;
|
|
3887
|
+
const block = blocks.get(row.outline.examplesId) ?? {
|
|
3888
|
+
outline: row.outline,
|
|
3889
|
+
rows: []
|
|
3890
|
+
};
|
|
3891
|
+
block.rows.push(row);
|
|
3892
|
+
blocks.set(row.outline.examplesId, block);
|
|
3893
|
+
}
|
|
3894
|
+
const exampleBlocks = [...blocks.values()].sort((a, b) => a.outline.examplesIndex - b.outline.examplesIndex).map(
|
|
3895
|
+
(block) => renderExamples(block.outline, block.rows, featureIndex, idIndex)
|
|
3896
|
+
).join("");
|
|
3897
|
+
const description = renderDescription(outline.description);
|
|
3898
|
+
return `<section class="outline" data-outline data-search="${escapeHtml(outline.description)}">${tagsMarkup(outline.tags)}<h3 class="outlineTitle"><span class="kw">${escapeHtml(outline.keyword)}:</span> ${escapeHtml(outline.name)}</h3>${description}${exampleBlocks}</section>`;
|
|
3899
|
+
}
|
|
3900
|
+
function renderFeatureItem(item, featureIndex, idIndex, inRule) {
|
|
3901
|
+
if (item.kind === "outline" && item.outline && item.rows) {
|
|
3902
|
+
return renderOutline(item.outline, item.rows, featureIndex, idIndex);
|
|
3903
|
+
}
|
|
3904
|
+
if (item.scenario) {
|
|
3905
|
+
return renderScenario(
|
|
3906
|
+
item.scenario,
|
|
3907
|
+
featureIndex,
|
|
3908
|
+
idIndex.get(item.scenario.id) ?? 0,
|
|
3909
|
+
false,
|
|
3910
|
+
inRule
|
|
3911
|
+
);
|
|
3912
|
+
}
|
|
3913
|
+
return "";
|
|
3914
|
+
}
|
|
3915
|
+
function renderRuleBlock(block, featureIndex, idIndex) {
|
|
3916
|
+
const rule = block.rule;
|
|
3917
|
+
const name = rule.name ? ` ${escapeHtml(rule.name)}` : "";
|
|
3918
|
+
const description = renderDescription(rule.description);
|
|
3919
|
+
return `<section class="rule" data-rule data-search="${escapeHtml(ruleSearchText(rule))}"><h3 class="ruleTitle"><span class="kw">${escapeHtml(rule.keyword)}:</span>${name}</h3>${tagsMarkup(rule.tags, "ruleTags")}${description}${backgroundMarkup(rule.backgrounds)}<div class="ruleRows">${block.items.map((item) => renderFeatureItem(item, featureIndex, idIndex, true)).join("")}</div></section>`;
|
|
2831
3920
|
}
|
|
2832
3921
|
function renderFeature({ feature, scenarios }, featureIndex) {
|
|
2833
|
-
const
|
|
2834
|
-
|
|
3922
|
+
const executed = executedOnly(scenarios);
|
|
3923
|
+
const open = executed.length === 0 || executed.some(
|
|
3924
|
+
(scenario) => scenario.status !== "passed" || scenario.attachments.some((attachment) => attachment.kind === "image")
|
|
3925
|
+
);
|
|
3926
|
+
const description = renderDescription(feature.description);
|
|
3927
|
+
const idIndex = new Map(scenarios.map((scenario, index) => [scenario.id, index]));
|
|
3928
|
+
const inputIndex = new Map(
|
|
3929
|
+
feature.scenarios.map((scenario, index) => [scenario.id, index])
|
|
2835
3930
|
);
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
|
|
3931
|
+
const groups = /* @__PURE__ */ new Map();
|
|
3932
|
+
const items = [];
|
|
3933
|
+
for (const scenario of feature.scenarios) {
|
|
3934
|
+
if (scenario.outline) {
|
|
3935
|
+
const group = groups.get(scenario.outline.id) ?? {
|
|
3936
|
+
outline: scenario.outline,
|
|
3937
|
+
rows: [],
|
|
3938
|
+
order: inputIndex.get(scenario.id) ?? 0,
|
|
3939
|
+
...scenario.rule ? { ruleId: scenario.rule.id } : {}
|
|
3940
|
+
};
|
|
3941
|
+
group.rows.push(scenario);
|
|
3942
|
+
groups.set(scenario.outline.id, group);
|
|
3943
|
+
} else {
|
|
3944
|
+
items.push({
|
|
3945
|
+
kind: "scenario",
|
|
3946
|
+
status: scenario.status,
|
|
3947
|
+
order: inputIndex.get(scenario.id) ?? 0,
|
|
3948
|
+
...scenario.rule ? { ruleId: scenario.rule.id } : {},
|
|
3949
|
+
scenario
|
|
3950
|
+
});
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
for (const group of groups.values()) {
|
|
3954
|
+
group.rows.sort((a, b) => {
|
|
3955
|
+
const outlineA = a.outline;
|
|
3956
|
+
const outlineB = b.outline;
|
|
3957
|
+
if (!outlineA || !outlineB) return 0;
|
|
3958
|
+
return outlineA.examplesIndex - outlineB.examplesIndex || outlineA.exampleIndex - outlineB.exampleIndex;
|
|
3959
|
+
});
|
|
3960
|
+
items.push({
|
|
3961
|
+
kind: "outline",
|
|
3962
|
+
status: worstExecutedStatus(group.rows),
|
|
3963
|
+
order: group.order,
|
|
3964
|
+
...group.ruleId ? { ruleId: group.ruleId } : {},
|
|
3965
|
+
outline: group.outline,
|
|
3966
|
+
rows: group.rows
|
|
3967
|
+
});
|
|
3968
|
+
}
|
|
3969
|
+
items.sort((a, b) => {
|
|
3970
|
+
const status = compareStatus(a.status, b.status);
|
|
3971
|
+
return status !== 0 ? status : a.order - b.order;
|
|
3972
|
+
});
|
|
3973
|
+
const featureItems = [];
|
|
3974
|
+
const ruleBlocks = /* @__PURE__ */ new Map();
|
|
3975
|
+
for (const item of items) {
|
|
3976
|
+
const rule = item.scenario?.rule ?? item.rows?.[0]?.rule;
|
|
3977
|
+
if (!item.ruleId || !rule) {
|
|
3978
|
+
featureItems.push(item);
|
|
3979
|
+
continue;
|
|
3980
|
+
}
|
|
3981
|
+
const block = ruleBlocks.get(item.ruleId) ?? {
|
|
3982
|
+
rule,
|
|
3983
|
+
items: [],
|
|
3984
|
+
order: item.order
|
|
3985
|
+
};
|
|
3986
|
+
block.items.push(item);
|
|
3987
|
+
block.order = Math.min(block.order, item.order);
|
|
3988
|
+
ruleBlocks.set(item.ruleId, block);
|
|
3989
|
+
}
|
|
3990
|
+
const topItems = [
|
|
3991
|
+
...featureItems,
|
|
3992
|
+
...[...ruleBlocks.values()].map(
|
|
3993
|
+
(block) => ({
|
|
3994
|
+
kind: "rule",
|
|
3995
|
+
status: worstExecutedStatus(
|
|
3996
|
+
block.items.flatMap(
|
|
3997
|
+
(item) => item.scenario ? [item.scenario] : item.rows ?? []
|
|
3998
|
+
)
|
|
3999
|
+
),
|
|
4000
|
+
order: block.order,
|
|
4001
|
+
rule: block.rule,
|
|
4002
|
+
items: block.items
|
|
4003
|
+
})
|
|
4004
|
+
)
|
|
4005
|
+
];
|
|
4006
|
+
topItems.sort((a, b) => {
|
|
4007
|
+
const status = compareStatus(a.status, b.status);
|
|
4008
|
+
return status !== 0 ? status : a.order - b.order;
|
|
4009
|
+
});
|
|
4010
|
+
const backgroundSearch = escapeHtml(
|
|
4011
|
+
feature.backgrounds.map(backgroundText).join(" ")
|
|
4012
|
+
);
|
|
4013
|
+
return `<details class="feature ${feature.status === "failed" ? "has-fail" : "has-pass"}" id="feature-${featureIndex + 1}" data-feature data-background-search="${backgroundSearch}" ${open ? "open" : ""}><summary><span class="statusCell"><span class="statusText ${statusClass(feature.status)}">${statusLabel(feature.status)}</span></span><h2>${escapeHtml(feature.name)}</h2><span class="chev" aria-hidden="true"></span>${featureShape(feature, scenarios)}</summary>${description}${backgroundMarkup(feature.backgrounds)}<div class="rows">${topItems.map(
|
|
4014
|
+
(item) => item.kind === "rule" ? renderRuleBlock(item, featureIndex, idIndex) : renderFeatureItem(item, featureIndex, idIndex, false)
|
|
2839
4015
|
).join("")}</div></details>`;
|
|
2840
4016
|
}
|
|
2841
4017
|
function matrixStatuses(model) {
|
|
@@ -2847,12 +4023,13 @@ function renderFeatureMatrix(model) {
|
|
|
2847
4023
|
const statuses = matrixStatuses(model);
|
|
2848
4024
|
const head = `<tr><th>Feature</th><th>Total</th>${statuses.map((status) => `<th>${statusLabel(status)}</th>`).join("")}<th>Duration</th></tr>`;
|
|
2849
4025
|
const rows = model.features.map((feature) => {
|
|
2850
|
-
const
|
|
4026
|
+
const executed = executedOnly(feature.scenarios);
|
|
4027
|
+
const counts = countStatuses(executed);
|
|
2851
4028
|
const cells = statuses.map((status) => {
|
|
2852
4029
|
const count2 = counts[status] ?? 0;
|
|
2853
4030
|
return `<td class="num${count2 === 0 ? " zero" : ""}">${count2}</td>`;
|
|
2854
4031
|
}).join("");
|
|
2855
|
-
return `<tr><th scope="row"><span class="matrixName">${escapeHtml(feature.name)}</span><span class="matrixUri">${escapeHtml(displayUri(feature.uri))}</span></th><td class="num">${
|
|
4032
|
+
return `<tr><th scope="row"><span class="matrixName">${escapeHtml(feature.name)}</span><span class="matrixUri">${escapeHtml(displayUri(feature.uri))}</span></th><td class="num">${executed.length}</td>${cells}<td class="num">${durationLabel(feature.durationMs)}</td></tr>`;
|
|
2856
4033
|
}).join("");
|
|
2857
4034
|
return `<table class="featureTable"><thead>${head}</thead><tbody>${rows}</tbody></table>`;
|
|
2858
4035
|
}
|
|
@@ -2866,16 +4043,18 @@ function renderReportView(model, options) {
|
|
|
2866
4043
|
const passed = model.counts.scenarios.passed;
|
|
2867
4044
|
const percent = total === 0 ? 0 : Math.round(passed / total * 1e3) / 10;
|
|
2868
4045
|
const meta = metadataLine(options.metadata);
|
|
4046
|
+
const ci = ciHeaderMarkup(model.environment?.ci);
|
|
2869
4047
|
const date = dateLabel(model.startedAt);
|
|
2870
4048
|
const ordered = orderFeatures(model.features);
|
|
2871
4049
|
const features = ordered.map((feature, index) => renderFeature(feature, index)).join("");
|
|
2872
4050
|
const triage = renderTriage(ordered);
|
|
2873
4051
|
const sources = renderSourceStrip(model);
|
|
4052
|
+
const runHooks = renderRunHooks(model);
|
|
2874
4053
|
const tags = scenarioTags(model);
|
|
2875
4054
|
const tagFilter = tags.length ? `<label class="tagFilter"><span>Tag</span><select data-tag-filter><option value="">All tags</option>${tags.map((tag) => `<option value="${escapeHtml(tag)}">${escapeHtml(tag)}</option>`).join("")}</select></label>` : "";
|
|
2876
|
-
return `<div class="tabPanel" id="report-view" role="tabpanel" aria-labelledby="view-report" tabindex="0"><main class="shell"><header class="runHead"><div><p class="path">${escapeHtml(model.source)} / ${escapeHtml(options.title)}</p><h1>${escapeHtml(options.title)}</h1><p class="meta">${date ? `<span>${date}</span>` : ""}<span>${model.counts.features} feature${model.counts.features === 1 ? "" : "s"}</span><span>${model.counts.scenarios.total} scenarios</span><span>${durationLabel(model.durationMs)}</span><span>${escapeHtml(model.source)}</span>${meta}</p></div><div class="health"><div class="healthTop"><strong>${percent}%</strong><span>${passed}
|
|
4055
|
+
return `<div class="tabPanel" id="report-view" role="tabpanel" aria-labelledby="view-report" tabindex="0"><main class="shell"><header class="runHead"><div><p class="path">${escapeHtml(model.source)} / ${escapeHtml(options.title)}</p><h1>${escapeHtml(options.title)}</h1><p class="meta">${date ? `<span>${date}</span>` : ""}<span>${model.counts.features} feature${model.counts.features === 1 ? "" : "s"}</span><span>${model.counts.scenarios.total} executed scenario${model.counts.scenarios.total === 1 ? "" : "s"}</span><span>${durationLabel(model.durationMs)}</span><span>${escapeHtml(model.source)}</span>${ci}${meta}</p></div><div class="health"><div class="healthTop"><strong>${percent}%</strong><span aria-hidden="true">${passed} / ${total}</span><span class="sr">${passed} / ${total} passed</span></div>${statusBar(model)}${countPills(model)}</div></header><div class="toolbar"><label class="search"><span aria-hidden="true">\u2315</span><input data-search type="search" placeholder="Search scenario, feature or tag" aria-label="Search scenarios"></label>${tagFilter}<div class="filters">${displayStatuses(model).map(
|
|
2877
4056
|
(status) => `<button class="filter" type="button" data-status="${status}" aria-pressed="true">${statusLabel(status)} <b>${model.counts.scenarios[status]}</b></button>`
|
|
2878
|
-
).join("")}</div><div class="expand"><button type="button" data-expand="all">Expand all</button><button type="button" data-expand="none">Collapse all</button></div></div><p class="live sr" id="tolkira-live" role="status" aria-live="polite" data-total="${total}"></p><p class="
|
|
4057
|
+
).join("")}</div><div class="expand"><button type="button" data-expand="all">Expand all</button><button type="button" data-expand="none">Collapse all</button></div></div><p class="live sr" id="tolkira-live" role="status" aria-live="polite" data-total="${total}"></p><p class="searchNote" id="tolkira-search-note" hidden></p>${triage}${sources}<div id="feature-list">${features || `<div class="empty">No scenarios in this report.</div>`}</div>${runHooks}<div class="empty" id="empty-results" hidden>No scenarios match the current search or filters.</div><p class="foot">Generated by Tolkira. Single file. No network requests. Screenshots are embedded.</p></main></div>`;
|
|
2879
4058
|
}
|
|
2880
4059
|
function renderAnalysisView(model, options, summary) {
|
|
2881
4060
|
const counts = model.counts.scenarios;
|
|
@@ -2893,316 +4072,14 @@ function renderAnalysisView(model, options, summary) {
|
|
|
2893
4072
|
model.environment?.runtime ? `<dt>Runtime</dt><dd>${escapeHtml(model.environment.runtime)}</dd>` : "",
|
|
2894
4073
|
model.environment?.os ? `<dt>OS</dt><dd>${escapeHtml(model.environment.os)}</dd>` : "",
|
|
2895
4074
|
model.environment?.cpu ? `<dt>CPU</dt><dd>${escapeHtml(model.environment.cpu)}</dd>` : "",
|
|
2896
|
-
model.environment?.protocol ? `<dt>Protocol</dt><dd>${escapeHtml(model.environment.protocol)}</dd>` : ""
|
|
4075
|
+
model.environment?.protocol ? `<dt>Protocol</dt><dd>${escapeHtml(model.environment.protocol)}</dd>` : "",
|
|
4076
|
+
ciDetailRows(model.environment?.ci)
|
|
2897
4077
|
].join("");
|
|
2898
|
-
const runRows = `<dt>Duration</dt><dd>${durationLabel(model.durationMs)}</dd><dt>Features</dt><dd>${model.counts.features}</dd><dt>Scenarios</dt><dd>${counts.total}</dd><dt>Steps</dt><dd>${model.counts.steps.total}</dd><dt>Attachments</dt><dd>${model.counts.attachments}</dd><dt>Attachment size</dt><dd>${model.counts.attachmentBytes} bytes</dd><dt>Source</dt><dd>${escapeHtml(model.source)}</dd>`;
|
|
2899
|
-
return `<div class="tabPanel" id="analysis-view" role="tabpanel" aria-labelledby="view-analysis" tabindex="0" hidden><main class="shell analysis"><header class="runHead"><div><p class="path">${escapeHtml(model.source)} / details</p><h1>Run details</h1><p class="meta">${dateLabel(model.startedAt) ? `<span>${dateLabel(model.startedAt)}</span>` : ""}<span>${escapeHtml(model.source)}</span></p></div><div class="health"><div class="healthTop"><strong>${counts.total === 0 ? 0 : Math.round(counts.passed / counts.total * 1e3) / 10}%</strong><span>${counts.passed}
|
|
4078
|
+
const runRows = `<dt>Duration</dt><dd>${durationLabel(model.durationMs)}</dd><dt>Features</dt><dd>${model.counts.features}</dd><dt>Scenarios</dt><dd>${counts.total}</dd><dt>Steps (excl. hooks)</dt><dd>${model.counts.steps.total}</dd><dt>Hooks</dt><dd>${model.counts.hooks.total}</dd><dt>Attachments</dt><dd>${model.counts.attachments}</dd><dt>Attachment size</dt><dd>${model.counts.attachmentBytes} bytes</dd><dt>Source</dt><dd>${escapeHtml(model.source)}</dd>`;
|
|
4079
|
+
return `<div class="tabPanel" id="analysis-view" role="tabpanel" aria-labelledby="view-analysis" tabindex="0" hidden><main class="shell analysis"><header class="runHead"><div><p class="path">${escapeHtml(model.source)} / details</p><h1>Run details</h1><p class="meta">${dateLabel(model.startedAt) ? `<span>${dateLabel(model.startedAt)}</span>` : ""}<span>${escapeHtml(model.source)}</span></p></div><div class="health"><div class="healthTop"><strong>${counts.total === 0 ? 0 : Math.round(counts.passed / counts.total * 1e3) / 10}%</strong><span>${counts.passed} / ${counts.total} passed</span></div>${statusBar(model)}${countPills(model)}</div></header><div class="analysisGrid"><section class="panel"><h2>Features</h2><p>Where the run spent its scenarios and steps.</p><p class="matrixHint">Executed scenarios only. Scroll for all status columns.</p><div class="tableWrap" tabindex="0" role="region" aria-label="Feature status matrix">${renderFeatureMatrix(model)}</div></section><section class="panel"><h2>Status distribution</h2><p>Executed scenarios only.</p><div class="legend">${displayStatuses(model).map(
|
|
2900
4080
|
(status) => `<div class="legendRow ${statusClass(status)}"><span class="marker ${statusClass(status)}"></span><span>${statusLabel(status)}</span><b>${counts[status]}</b></div>`
|
|
2901
|
-
).join("")}</div><h2 class="subhead">Run</h2><dl class="metaList">${runRows}</dl>${environmentRows ? `<h2 class="subhead">Cucumber environment</h2><dl class="metaList">${environmentRows}</dl>` : ""}${customRows ? `<h2 class="subhead">Custom metadata</h2><dl class="metaList">${customRows}</dl>` : ""}</section></div>${model.runAttachments.length ? `<section class="panel" style="margin-top:16px"><h2>Run attachments</h2>${model.runAttachments.map((attachment) => renderAttachment(attachment, "Run attachments")).join("")}</section>` : ""}<section class="panel" style="margin-top:16px"><h2>Agent summary</h2><p>The same run as stable JSON for CI tools and agents.</p><pre class="json" tabindex="0" aria-label="Agent summary JSON">${escapeHtml(JSON.stringify(preview))}</pre></section><p class="foot">Full summary: <code>tolkira ... --json</code></p></main></div>`;
|
|
2902
|
-
}
|
|
2903
|
-
var SCRIPT = `<script>
|
|
2904
|
-
(function () {
|
|
2905
|
-
var views = Array.prototype.slice.call(document.querySelectorAll('[data-view]'));
|
|
2906
|
-
var report = document.getElementById('report-view');
|
|
2907
|
-
var analysis = document.getElementById('analysis-view');
|
|
2908
|
-
function showView(name) {
|
|
2909
|
-
if (!report || !analysis) return;
|
|
2910
|
-
report.hidden = name !== 'report';
|
|
2911
|
-
analysis.hidden = name !== 'analysis';
|
|
2912
|
-
views.forEach(function (button) {
|
|
2913
|
-
var active = button.getAttribute('data-view') === name;
|
|
2914
|
-
button.setAttribute('aria-selected', active ? 'true' : 'false');
|
|
2915
|
-
});
|
|
2916
|
-
window.scrollTo(0, 0);
|
|
2917
|
-
}
|
|
2918
|
-
views.forEach(function (button) {
|
|
2919
|
-
button.addEventListener('click', function () { showView(button.getAttribute('data-view')); });
|
|
2920
|
-
});
|
|
2921
|
-
var tablist = document.querySelector('[role="tablist"]');
|
|
2922
|
-
if (tablist) tablist.addEventListener('keydown', function (event) {
|
|
2923
|
-
if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
|
|
2924
|
-
event.preventDefault();
|
|
2925
|
-
var index = views.indexOf(document.activeElement);
|
|
2926
|
-
if (index < 0) return;
|
|
2927
|
-
var next = event.key === 'Home' ? 0 : event.key === 'End' ? views.length - 1 : (index + (event.key === 'ArrowRight' ? 1 : -1) + views.length) % views.length;
|
|
2928
|
-
views[next].focus();
|
|
2929
|
-
showView(views[next].getAttribute('data-view'));
|
|
2930
|
-
});
|
|
2931
|
-
var state = { query: '', hidden: new Set(), tag: '' };
|
|
2932
|
-
var searchOpened = [];
|
|
2933
|
-
var scenarios = Array.prototype.slice.call(document.querySelectorAll('[data-scenario]'));
|
|
2934
|
-
var features = Array.prototype.slice.call(document.querySelectorAll('[data-feature]'));
|
|
2935
|
-
var live = document.getElementById('tolkira-live');
|
|
2936
|
-
var searchNote = document.getElementById('tolkira-search-note');
|
|
2937
|
-
var triage = document.querySelector('[data-triage]');
|
|
2938
|
-
var sources = document.querySelector('[data-sources]');
|
|
2939
|
-
function apply() {
|
|
2940
|
-
var query = state.query.toLowerCase();
|
|
2941
|
-
var tag = state.tag;
|
|
2942
|
-
var visible = 0;
|
|
2943
|
-
scenarios.forEach(function (scenario) {
|
|
2944
|
-
var status = scenario.getAttribute('data-status');
|
|
2945
|
-
var text = (scenario.getAttribute('data-search') || '').toLowerCase();
|
|
2946
|
-
var tags = ' ' + (scenario.getAttribute('data-tags') || '') + ' ';
|
|
2947
|
-
var tagMatch = !tag || tags.indexOf(' ' + tag + ' ') !== -1;
|
|
2948
|
-
var match = !state.hidden.has(status) && tagMatch && (!query || text.indexOf(query) !== -1);
|
|
2949
|
-
scenario.hidden = !match;
|
|
2950
|
-
if (match) visible += 1;
|
|
2951
|
-
});
|
|
2952
|
-
features.forEach(function (feature) {
|
|
2953
|
-
var children = feature.querySelectorAll('[data-scenario]');
|
|
2954
|
-
var any = Array.prototype.some.call(children, function (child) { return !child.hidden; });
|
|
2955
|
-
feature.hidden = !any;
|
|
2956
|
-
if (any && (query || state.hidden.size || tag)) feature.open = true;
|
|
2957
|
-
});
|
|
2958
|
-
searchOpened.forEach(function (scenario) { scenario.open = false; });
|
|
2959
|
-
searchOpened = [];
|
|
2960
|
-
if (query) {
|
|
2961
|
-
var opened = 0;
|
|
2962
|
-
scenarios.forEach(function (scenario) {
|
|
2963
|
-
if (!scenario.hidden && opened < 20) {
|
|
2964
|
-
if (!scenario.open) searchOpened.push(scenario);
|
|
2965
|
-
scenario.open = true;
|
|
2966
|
-
opened += 1;
|
|
2967
|
-
}
|
|
2968
|
-
});
|
|
2969
|
-
}
|
|
2970
|
-
if (live) live.textContent = visible + ' of ' + scenarios.length + ' scenarios visible';
|
|
2971
|
-
if (searchNote) {
|
|
2972
|
-
if (query && visible > 20) {
|
|
2973
|
-
searchNote.textContent = '20 of ' + visible + ' matches expanded. Use Expand all to open the rest.';
|
|
2974
|
-
searchNote.hidden = false;
|
|
2975
|
-
} else {
|
|
2976
|
-
searchNote.hidden = true;
|
|
2977
|
-
searchNote.textContent = '';
|
|
2978
|
-
}
|
|
2979
|
-
}
|
|
2980
|
-
var empty = document.getElementById('empty-results');
|
|
2981
|
-
if (empty) empty.hidden = visible !== 0;
|
|
2982
|
-
if (triage) triage.hidden = Boolean(query || tag || state.hidden.size);
|
|
2983
|
-
if (sources) sources.hidden = Boolean(query || tag || state.hidden.size);
|
|
2984
|
-
highlightSearch();
|
|
2985
|
-
}
|
|
2986
|
-
function clearHighlights() {
|
|
2987
|
-
if (typeof CSS === 'undefined' || !CSS.highlights) return;
|
|
2988
|
-
CSS.highlights.delete('tolkira-search');
|
|
2989
|
-
}
|
|
2990
|
-
function escapeRegex(value) {
|
|
2991
|
-
var out = '';
|
|
2992
|
-
for (var i = 0; i < value.length; i++) {
|
|
2993
|
-
var code = value.charCodeAt(i);
|
|
2994
|
-
var ch = value.charAt(i);
|
|
2995
|
-
var special = code === 92 || code === 94 || code === 36 || code === 46 || code === 42 || code === 43 || code === 63 || code === 40 || code === 41 || code === 91 || code === 93 || code === 123 || code === 125 || code === 124;
|
|
2996
|
-
out += special ? String.fromCharCode(92) + ch : ch;
|
|
2997
|
-
}
|
|
2998
|
-
return out;
|
|
2999
|
-
}
|
|
3000
|
-
function highlightSearch() {
|
|
3001
|
-
if (typeof CSS === 'undefined' || !CSS.highlights || typeof Highlight === 'undefined') return;
|
|
3002
|
-
var needle = state.query.trim();
|
|
3003
|
-
if (needle.length < 2) { clearHighlights(); return; }
|
|
3004
|
-
try {
|
|
3005
|
-
var pattern = new RegExp(escapeRegex(needle), 'gi');
|
|
3006
|
-
var ranges = [];
|
|
3007
|
-
scenarios.forEach(function (scenario) {
|
|
3008
|
-
if (scenario.hidden || !scenario.open || ranges.length >= 200) return;
|
|
3009
|
-
var walker = document.createTreeWalker(scenario, NodeFilter.SHOW_TEXT, null);
|
|
3010
|
-
var node;
|
|
3011
|
-
while (ranges.length < 200 && (node = walker.nextNode())) {
|
|
3012
|
-
var value = node.nodeValue;
|
|
3013
|
-
if (!value) continue;
|
|
3014
|
-
var parent = node.parentElement;
|
|
3015
|
-
if (parent && (parent.tagName === 'SCRIPT' || parent.tagName === 'STYLE')) continue;
|
|
3016
|
-
pattern.lastIndex = 0;
|
|
3017
|
-
var match;
|
|
3018
|
-
while (ranges.length < 200 && (match = pattern.exec(value)) !== null) {
|
|
3019
|
-
var range = document.createRange();
|
|
3020
|
-
range.setStart(node, match.index);
|
|
3021
|
-
range.setEnd(node, match.index + match[0].length);
|
|
3022
|
-
ranges.push(range);
|
|
3023
|
-
if (match[0].length === 0) pattern.lastIndex += 1;
|
|
3024
|
-
}
|
|
3025
|
-
}
|
|
3026
|
-
});
|
|
3027
|
-
clearHighlights();
|
|
3028
|
-
if (ranges.length) CSS.highlights.set('tolkira-search', new Highlight(...ranges));
|
|
3029
|
-
} catch (error) {
|
|
3030
|
-
clearHighlights();
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
var search = document.querySelector('[data-search]');
|
|
3034
|
-
if (search) search.addEventListener('input', function () {
|
|
3035
|
-
state.query = search.value;
|
|
3036
|
-
apply();
|
|
3037
|
-
});
|
|
3038
|
-
var tagFilter = document.querySelector('[data-tag-filter]');
|
|
3039
|
-
if (tagFilter) tagFilter.addEventListener('change', function () {
|
|
3040
|
-
state.tag = tagFilter.value;
|
|
3041
|
-
apply();
|
|
3042
|
-
});
|
|
3043
|
-
Array.prototype.slice.call(document.querySelectorAll('button.filter[data-status]')).forEach(function (button) {
|
|
3044
|
-
button.addEventListener('click', function () {
|
|
3045
|
-
var status = button.getAttribute('data-status');
|
|
3046
|
-
var active = button.getAttribute('aria-pressed') !== 'false';
|
|
3047
|
-
if (active) { state.hidden.add(status); button.setAttribute('aria-pressed', 'false'); }
|
|
3048
|
-
else { state.hidden.delete(status); button.setAttribute('aria-pressed', 'true'); }
|
|
3049
|
-
apply();
|
|
3050
|
-
});
|
|
3051
|
-
});
|
|
3052
|
-
Array.prototype.slice.call(document.querySelectorAll('[data-expand]')).forEach(function (button) {
|
|
3053
|
-
button.addEventListener('click', function () {
|
|
3054
|
-
var open = button.getAttribute('data-expand') === 'all';
|
|
3055
|
-
features.forEach(function (feature) { feature.open = open; });
|
|
3056
|
-
scenarios.forEach(function (scenario) { scenario.open = open; });
|
|
3057
|
-
});
|
|
3058
|
-
});
|
|
3059
|
-
var copyLive = document.getElementById('tolkira-copy-live');
|
|
3060
|
-
function legacyCopy(text) {
|
|
3061
|
-
var active = document.activeElement;
|
|
3062
|
-
var field = document.createElement('textarea');
|
|
3063
|
-
field.value = text;
|
|
3064
|
-
field.setAttribute('readonly', '');
|
|
3065
|
-
field.style.position = 'fixed';
|
|
3066
|
-
field.style.top = '-1000px';
|
|
3067
|
-
document.body.appendChild(field);
|
|
3068
|
-
var ok = false;
|
|
3069
|
-
try {
|
|
3070
|
-
field.select();
|
|
3071
|
-
ok = document.execCommand('copy');
|
|
3072
|
-
} catch (error) {
|
|
3073
|
-
ok = false;
|
|
3074
|
-
} finally {
|
|
3075
|
-
field.remove();
|
|
3076
|
-
if (active && typeof active.focus === 'function') active.focus();
|
|
3077
|
-
}
|
|
3078
|
-
return ok;
|
|
3079
|
-
}
|
|
3080
|
-
function writeClipboard(text, done) {
|
|
3081
|
-
var settled = false;
|
|
3082
|
-
function finish(ok) {
|
|
3083
|
-
if (settled) return;
|
|
3084
|
-
settled = true;
|
|
3085
|
-
done(ok);
|
|
3086
|
-
}
|
|
3087
|
-
function fallback() {
|
|
3088
|
-
finish(legacyCopy(text));
|
|
3089
|
-
}
|
|
3090
|
-
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
3091
|
-
try {
|
|
3092
|
-
navigator.clipboard.writeText(text).then(function () { finish(true); }, fallback);
|
|
3093
|
-
} catch (error) {
|
|
3094
|
-
fallback();
|
|
3095
|
-
}
|
|
3096
|
-
} else {
|
|
3097
|
-
fallback();
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3100
|
-
function failureText(button) {
|
|
3101
|
-
var scenario = button.closest('[data-scenario]');
|
|
3102
|
-
if (!scenario) return '';
|
|
3103
|
-
var feature = scenario.closest('[data-feature]');
|
|
3104
|
-
var featureTitle = feature ? feature.querySelector('h2') : null;
|
|
3105
|
-
var scenarioTitle = scenario.querySelector('.scenarioName');
|
|
3106
|
-
var step = scenario.querySelector('.step[data-status="failed"]');
|
|
3107
|
-
var keyword = step && step.querySelector('.kw') ? step.querySelector('.kw').textContent.trim() : '';
|
|
3108
|
-
var body = step ? step.querySelector('div') : null;
|
|
3109
|
-
var text = '';
|
|
3110
|
-
if (body) {
|
|
3111
|
-
Array.prototype.forEach.call(body.childNodes, function (node) {
|
|
3112
|
-
if (node.nodeType === 3) text += node.nodeValue;
|
|
3113
|
-
});
|
|
3114
|
-
}
|
|
3115
|
-
var error = step ? step.querySelector('.error') : null;
|
|
3116
|
-
var stepLabel = keyword === 'Hook' ? text.trim() : (keyword + ' ' + text.trim()).trim();
|
|
3117
|
-
var lines = [
|
|
3118
|
-
'Feature: ' + (featureTitle ? featureTitle.textContent : ''),
|
|
3119
|
-
'Scenario: ' + (scenarioTitle ? scenarioTitle.textContent : ''),
|
|
3120
|
-
'URI: ' + (scenario.getAttribute('data-uri') || ''),
|
|
3121
|
-
'Step: ' + stepLabel
|
|
3122
|
-
];
|
|
3123
|
-
if (error && error.textContent.trim()) {
|
|
3124
|
-
lines.push('Error:\\n' + error.textContent.trim());
|
|
3125
|
-
}
|
|
3126
|
-
return lines.join('\\n');
|
|
3127
|
-
}
|
|
3128
|
-
Array.prototype.slice.call(document.querySelectorAll('[data-copy-failure]')).forEach(function (button) {
|
|
3129
|
-
var labelTimer = null;
|
|
3130
|
-
button.addEventListener('click', function () {
|
|
3131
|
-
button.focus();
|
|
3132
|
-
writeClipboard(failureText(button), function (ok) {
|
|
3133
|
-
if (labelTimer) clearTimeout(labelTimer);
|
|
3134
|
-
button.textContent = ok ? 'Copied' : 'Copy failed';
|
|
3135
|
-
if (copyLive) {
|
|
3136
|
-
copyLive.textContent = ok
|
|
3137
|
-
? 'Failure details copied to clipboard.'
|
|
3138
|
-
: 'Could not copy failure details.';
|
|
3139
|
-
}
|
|
3140
|
-
labelTimer = setTimeout(function () {
|
|
3141
|
-
button.textContent = 'Copy failure';
|
|
3142
|
-
if (copyLive) copyLive.textContent = '';
|
|
3143
|
-
}, 2000);
|
|
3144
|
-
});
|
|
3145
|
-
});
|
|
3146
|
-
});
|
|
3147
|
-
var lightbox = document.getElementById('tolkira-lightbox');
|
|
3148
|
-
if (lightbox) {
|
|
3149
|
-
var lightboxImage = lightbox.querySelector('img');
|
|
3150
|
-
var closeLightbox = lightbox.querySelector('[data-lightbox-close]');
|
|
3151
|
-
var lightboxTrigger = null;
|
|
3152
|
-
var previousOverflow = '';
|
|
3153
|
-
function closeDialog() {
|
|
3154
|
-
if (typeof lightbox.close === 'function') lightbox.close();
|
|
3155
|
-
else { lightbox.removeAttribute('open'); restoreLightbox(); }
|
|
3156
|
-
}
|
|
3157
|
-
function restoreLightbox() {
|
|
3158
|
-
document.documentElement.style.overflow = previousOverflow;
|
|
3159
|
-
if (lightboxTrigger) { lightboxTrigger.focus(); lightboxTrigger = null; }
|
|
3160
|
-
}
|
|
3161
|
-
Array.prototype.slice.call(document.querySelectorAll('.shotButton')).forEach(function (button) {
|
|
3162
|
-
button.addEventListener('click', function () {
|
|
3163
|
-
var image = button.querySelector('img');
|
|
3164
|
-
if (!image || !lightboxImage) return;
|
|
3165
|
-
lightboxImage.src = image.src;
|
|
3166
|
-
lightboxImage.alt = image.alt;
|
|
3167
|
-
lightboxTrigger = button;
|
|
3168
|
-
previousOverflow = document.documentElement.style.overflow;
|
|
3169
|
-
document.documentElement.style.overflow = 'hidden';
|
|
3170
|
-
if (typeof lightbox.showModal === 'function') lightbox.showModal();
|
|
3171
|
-
else lightbox.setAttribute('open', '');
|
|
3172
|
-
});
|
|
3173
|
-
});
|
|
3174
|
-
if (closeLightbox) closeLightbox.addEventListener('click', closeDialog);
|
|
3175
|
-
lightbox.addEventListener('click', function (event) { if (event.target === lightbox) closeDialog(); });
|
|
3176
|
-
lightbox.addEventListener('close', restoreLightbox);
|
|
3177
|
-
}
|
|
3178
|
-
function revealHash() {
|
|
3179
|
-
if (!location.hash) return;
|
|
3180
|
-
var id = '';
|
|
3181
|
-
try { id = decodeURIComponent(location.hash.slice(1)); } catch (error) { return; }
|
|
3182
|
-
var target = document.getElementById(id);
|
|
3183
|
-
if (!target) return;
|
|
3184
|
-
var node = target;
|
|
3185
|
-
while (node) {
|
|
3186
|
-
if (node.tagName === 'DETAILS') node.open = true;
|
|
3187
|
-
node = node.parentElement;
|
|
3188
|
-
}
|
|
3189
|
-
var focusTarget = target.tagName === 'DETAILS' ? target.querySelector('summary') : target;
|
|
3190
|
-
if (focusTarget) {
|
|
3191
|
-
try { focusTarget.focus({ preventScroll: true }); } catch (error) { focusTarget.focus(); }
|
|
3192
|
-
}
|
|
3193
|
-
target.scrollIntoView();
|
|
3194
|
-
}
|
|
3195
|
-
var compact = window.matchMedia('(max-width: 560px)');
|
|
3196
|
-
function syncCompact() {
|
|
3197
|
-
if (triage) triage.open = !compact.matches;
|
|
3198
|
-
}
|
|
3199
|
-
if (compact.addEventListener) compact.addEventListener('change', syncCompact);
|
|
3200
|
-
syncCompact();
|
|
3201
|
-
window.addEventListener('hashchange', revealHash);
|
|
3202
|
-
showView('report');
|
|
3203
|
-
revealHash();
|
|
3204
|
-
})();
|
|
3205
|
-
</script>`;
|
|
4081
|
+
).join("")}</div><h2 class="subhead">Run</h2><dl class="metaList">${runRows}</dl>${environmentRows ? `<h2 class="subhead">Cucumber environment</h2><dl class="metaList">${environmentRows}</dl>` : ""}${customRows ? `<h2 class="subhead">Custom metadata</h2><dl class="metaList">${customRows}</dl>` : ""}</section></div>${model.runAttachments.length ? `<section class="panel" style="margin-top:16px"><h2>Run attachments</h2>${model.runAttachments.map((attachment) => renderAttachment(attachment, "Run attachments")).join("")}</section>` : ""}<section class="panel" style="margin-top:16px"><h2>Agent summary</h2><p>The same run as stable JSON for CI tools and agents. Its step counts include hook entries; the HTML counts above exclude them.</p><pre class="json" tabindex="0" aria-label="Agent summary JSON">${escapeHtml(JSON.stringify(preview))}</pre></section><p class="foot">Full summary: <code>tolkira ... --json</code></p></main></div>`;
|
|
4082
|
+
}
|
|
3206
4083
|
function inlineScriptHashes(html) {
|
|
3207
4084
|
const hashes = /* @__PURE__ */ new Set();
|
|
3208
4085
|
for (const match of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)) {
|
|
@@ -3222,7 +4099,8 @@ async function renderHtml(envelopes, options) {
|
|
|
3222
4099
|
const summary = options.summary ?? summarizeEnvelopes(safeEnvelopes);
|
|
3223
4100
|
const logo = isLogoDataUri(options.logo) ? `<img class="logo" src="${escapeHtml(options.logo)}" alt="">` : "";
|
|
3224
4101
|
const accent = isValidAccent(options.accent) ? `<style>:root{--accent:${options.accent}}</style>` : "";
|
|
3225
|
-
const
|
|
4102
|
+
const clientScript = `<script>${CLIENT_SCRIPT.replace(/<\/script/gi, "<\\/script")}</script>`;
|
|
4103
|
+
const body = `<header class="topbar"><div class="topbarInner"><div class="brand">${logo}tol<span>kira</span></div><div class="views" role="tablist" aria-label="Report view"><button class="view" id="view-report" type="button" role="tab" data-view="report" aria-selected="true" aria-controls="report-view">Report</button><button class="view" id="view-analysis" type="button" role="tab" data-view="analysis" aria-selected="false" aria-controls="analysis-view">Details</button></div></div></header><p class="sr" id="tolkira-copy-live" aria-live="polite"></p>${renderReportView(model, options)}${renderAnalysisView(model, options, summary)}<dialog class="lightbox" id="tolkira-lightbox" aria-label="Full-size attachment"><button class="lightboxClose" type="button" data-lightbox-close>Close</button><img alt=""></dialog>${clientScript}`;
|
|
3226
4104
|
const hashes = inlineScriptHashes(body);
|
|
3227
4105
|
return `<!doctype html>
|
|
3228
4106
|
<html lang="en">
|
|
@@ -3238,17 +4116,14 @@ ${csp(hashes)}
|
|
|
3238
4116
|
}
|
|
3239
4117
|
|
|
3240
4118
|
// src/index.ts
|
|
3241
|
-
var version = "0.
|
|
4119
|
+
var version = "0.3.0";
|
|
3242
4120
|
async function generateReport(inputs, options = {}) {
|
|
3243
4121
|
const groups = await loadInputs(inputs);
|
|
3244
4122
|
const envelopes = groups.flatMap((group) => group.envelopes);
|
|
3245
4123
|
const summary = summarizeEnvelopes(envelopes);
|
|
3246
4124
|
return {
|
|
3247
4125
|
html: await renderHtml(envelopes, {
|
|
3248
|
-
|
|
3249
|
-
metadata: options.metadata,
|
|
3250
|
-
logo: options.logo,
|
|
3251
|
-
accent: options.accent,
|
|
4126
|
+
...renderOptions(options),
|
|
3252
4127
|
summary,
|
|
3253
4128
|
provenance: groups.length > 1 ? provenanceFor(groups) : void 0
|
|
3254
4129
|
}),
|
|
@@ -3258,8 +4133,31 @@ async function generateReport(inputs, options = {}) {
|
|
|
3258
4133
|
|
|
3259
4134
|
// src/output.ts
|
|
3260
4135
|
import { randomUUID } from "node:crypto";
|
|
3261
|
-
import {
|
|
4136
|
+
import { realpathSync } from "node:fs";
|
|
4137
|
+
import { mkdir, rename, rm, stat as stat2, writeFile } from "node:fs/promises";
|
|
3262
4138
|
import path3 from "node:path";
|
|
4139
|
+
async function outputOverwritesInput(inputs, output, logo) {
|
|
4140
|
+
const outputPath = path3.resolve(output);
|
|
4141
|
+
const outputInfo = await stat2(outputPath).catch(() => void 0);
|
|
4142
|
+
if (!outputInfo?.isFile()) return false;
|
|
4143
|
+
const outputReal = realpathSync(outputPath);
|
|
4144
|
+
if (logo) {
|
|
4145
|
+
const logoInfo = await stat2(logo).catch(() => void 0);
|
|
4146
|
+
if (logoInfo?.isFile() && realpathSync(logo) === outputReal) return true;
|
|
4147
|
+
}
|
|
4148
|
+
for (const input of inputs) {
|
|
4149
|
+
const inputInfo = await stat2(input).catch(() => void 0);
|
|
4150
|
+
if (!inputInfo) continue;
|
|
4151
|
+
if (inputInfo.isFile() && realpathSync(input) === outputReal) return true;
|
|
4152
|
+
if (inputInfo.isDirectory()) {
|
|
4153
|
+
const directory = realpathSync(input);
|
|
4154
|
+
for (const file of await collectReportFiles(directory)) {
|
|
4155
|
+
if (realpathSync(file) === outputReal) return true;
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
return false;
|
|
4160
|
+
}
|
|
3263
4161
|
async function writeAtomic(output, content) {
|
|
3264
4162
|
const directory = path3.dirname(output);
|
|
3265
4163
|
await mkdir(directory, { recursive: true });
|
|
@@ -3356,7 +4254,7 @@ async function readLogo(file) {
|
|
|
3356
4254
|
`Unsupported logo type "${extension}". Use PNG, JPEG, GIF, WebP or SVG.`
|
|
3357
4255
|
);
|
|
3358
4256
|
}
|
|
3359
|
-
const info = await
|
|
4257
|
+
const info = await stat3(file);
|
|
3360
4258
|
if (info.size > MAX_LOGO_BYTES) {
|
|
3361
4259
|
throw new Error("Logo is larger than 2 MB.");
|
|
3362
4260
|
}
|
|
@@ -3387,28 +4285,6 @@ async function readLogo(file) {
|
|
|
3387
4285
|
}
|
|
3388
4286
|
return `data:${mime};base64,${data.toString("base64")}`;
|
|
3389
4287
|
}
|
|
3390
|
-
async function outputOverwritesInput(inputs, output, logo) {
|
|
3391
|
-
const outputPath = path4.resolve(output);
|
|
3392
|
-
const outputInfo = await stat2(outputPath).catch(() => void 0);
|
|
3393
|
-
if (!outputInfo?.isFile()) return false;
|
|
3394
|
-
const outputReal = realpathSync(outputPath);
|
|
3395
|
-
if (logo) {
|
|
3396
|
-
const logoInfo = await stat2(logo).catch(() => void 0);
|
|
3397
|
-
if (logoInfo?.isFile() && realpathSync(logo) === outputReal) return true;
|
|
3398
|
-
}
|
|
3399
|
-
for (const input of inputs) {
|
|
3400
|
-
const inputInfo = await stat2(input).catch(() => void 0);
|
|
3401
|
-
if (!inputInfo) continue;
|
|
3402
|
-
if (inputInfo.isFile() && realpathSync(input) === outputReal) return true;
|
|
3403
|
-
if (inputInfo.isDirectory()) {
|
|
3404
|
-
const directory = realpathSync(input);
|
|
3405
|
-
for (const file of await collectReportFiles(directory)) {
|
|
3406
|
-
if (realpathSync(file) === outputReal) return true;
|
|
3407
|
-
}
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
return false;
|
|
3411
|
-
}
|
|
3412
4288
|
async function runCli(argv, io = {
|
|
3413
4289
|
stdout: (text) => process.stdout.write(text),
|
|
3414
4290
|
stderr: (text) => process.stderr.write(text)
|
|
@@ -3520,7 +4396,7 @@ function isMainModule() {
|
|
|
3520
4396
|
const entry = process.argv[1];
|
|
3521
4397
|
if (!entry) return false;
|
|
3522
4398
|
try {
|
|
3523
|
-
return
|
|
4399
|
+
return realpathSync2(fileURLToPath(import.meta.url)) === realpathSync2(entry);
|
|
3524
4400
|
} catch {
|
|
3525
4401
|
return false;
|
|
3526
4402
|
}
|