tolkira 0.1.2 → 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/DESIGN.md +12 -7
- package/GLOSSARY.md +108 -0
- package/README.md +222 -20
- package/SECURITY.md +3 -0
- package/dist/cli.js +1860 -555
- 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 +1829 -549
- package/dist/index.js.map +4 -4
- package/dist/input/background.d.ts +4 -0
- package/dist/input/junit.d.ts +3 -1
- package/dist/input/load.d.ts +13 -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/escape.d.ts +1 -1
- package/dist/render/html.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 +87 -3
- package/dist/report/status.d.ts +12 -0
- package/dist/stream.d.ts +15 -0
- package/dist/summary.d.ts +15 -2
- package/dist/text.d.ts +15 -0
- package/docs/AGENT-INTERFACE.md +158 -21
- package/docs/COMPATIBILITY.md +59 -5
- 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 +31 -8
package/dist/index.js
CHANGED
|
@@ -7,9 +7,19 @@ import path2 from "node:path";
|
|
|
7
7
|
import {
|
|
8
8
|
AttachmentContentEncoding,
|
|
9
9
|
HookType,
|
|
10
|
-
TestStepResultStatus
|
|
11
|
-
version as messagesVersion
|
|
10
|
+
TestStepResultStatus
|
|
12
11
|
} from "@cucumber/messages";
|
|
12
|
+
|
|
13
|
+
// src/input/background.ts
|
|
14
|
+
var synthetic = /* @__PURE__ */ new WeakSet();
|
|
15
|
+
function markSyntheticBackground(background) {
|
|
16
|
+
synthetic.add(background);
|
|
17
|
+
}
|
|
18
|
+
function isSyntheticBackground(background) {
|
|
19
|
+
return synthetic.has(background);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/input/legacy.ts
|
|
13
23
|
function isRecord(value) {
|
|
14
24
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
15
25
|
}
|
|
@@ -143,13 +153,13 @@ function createIdFactory(prefix) {
|
|
|
143
153
|
}
|
|
144
154
|
function normalizeUri(uri, index) {
|
|
145
155
|
if (!uri) return `features/legacy-${index}.feature`;
|
|
146
|
-
const slashed = uri.replace(/\\/g, "/");
|
|
156
|
+
const slashed = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
147
157
|
const normalized = slashed.replace(/^\.\//, "");
|
|
148
158
|
if (/^[a-z]:\//i.test(normalized) || slashed.startsWith("/")) {
|
|
149
159
|
const marker = slashed.lastIndexOf("/features/");
|
|
150
160
|
if (marker >= 0) return slashed.slice(marker + 1);
|
|
151
161
|
const parts = slashed.split("/").filter(Boolean);
|
|
152
|
-
return parts.
|
|
162
|
+
return parts[parts.length - 1] ?? `features/legacy-${index}.feature`;
|
|
153
163
|
}
|
|
154
164
|
return normalized || `features/legacy-${index}.feature`;
|
|
155
165
|
}
|
|
@@ -330,26 +340,10 @@ function resultOf(legacyStep, scale = 1) {
|
|
|
330
340
|
}
|
|
331
341
|
return result;
|
|
332
342
|
}
|
|
333
|
-
var MIME_EXTENSIONS = {
|
|
334
|
-
"application/json": "json",
|
|
335
|
-
"application/octet-stream": "bin",
|
|
336
|
-
"image/gif": "gif",
|
|
337
|
-
"image/jpeg": "jpg",
|
|
338
|
-
"image/png": "png",
|
|
339
|
-
"image/svg+xml": "svg",
|
|
340
|
-
"text/html": "html",
|
|
341
|
-
"text/plain": "txt",
|
|
342
|
-
"video/mp4": "mp4",
|
|
343
|
-
"video/webm": "webm"
|
|
344
|
-
};
|
|
345
343
|
function isLikelyBase64(value) {
|
|
346
344
|
const compact = value.replace(/\s/g, "");
|
|
347
345
|
return compact.length > 0 && compact.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(compact);
|
|
348
346
|
}
|
|
349
|
-
function attachmentFileName(mediaType, index) {
|
|
350
|
-
const extension = MIME_EXTENSIONS[mediaType.toLowerCase()] ?? mediaType.split("/")[1]?.split(";")[0]?.trim() ?? "bin";
|
|
351
|
-
return `attachment-${index + 1}.${extension}`;
|
|
352
|
-
}
|
|
353
347
|
function parseLegacyJson(content, source, options = {}) {
|
|
354
348
|
let parsed;
|
|
355
349
|
try {
|
|
@@ -371,13 +365,12 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
371
365
|
const runId = nextId("run");
|
|
372
366
|
const envelopes = [];
|
|
373
367
|
const statuses = [];
|
|
374
|
-
let attachmentCounter = 0;
|
|
375
368
|
const meta = {
|
|
376
|
-
protocolVersion:
|
|
369
|
+
protocolVersion: "",
|
|
377
370
|
implementation: { name: "tolkira-legacy-json" },
|
|
378
|
-
runtime: { name: "
|
|
379
|
-
os: { name:
|
|
380
|
-
cpu: { name:
|
|
371
|
+
runtime: { name: "" },
|
|
372
|
+
os: { name: "" },
|
|
373
|
+
cpu: { name: "" }
|
|
381
374
|
};
|
|
382
375
|
envelopes.push({ meta });
|
|
383
376
|
envelopes.push({ testRunStarted: { id: runId, timestamp: timestamp(startedAt) } });
|
|
@@ -416,14 +409,18 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
416
409
|
description: normalizeText(backgroundElement.description),
|
|
417
410
|
steps: backgroundNodes
|
|
418
411
|
};
|
|
412
|
+
markSyntheticBackground(background);
|
|
419
413
|
featureChildren.push({ background });
|
|
420
414
|
}
|
|
421
415
|
const scenarios = (legacyFeature.elements ?? []).filter(
|
|
422
416
|
(element) => !isBackgroundElement(element)
|
|
423
417
|
);
|
|
418
|
+
const featureTagNames = new Set(featureTags.map((tag) => tag.name));
|
|
424
419
|
for (const [scenarioIndex, element] of scenarios.entries()) {
|
|
425
420
|
const scenarioId = nextId("scenario");
|
|
426
|
-
const scenarioTags2 = mapTags(element.tags, nextId)
|
|
421
|
+
const scenarioTags2 = mapTags(element.tags, nextId).filter(
|
|
422
|
+
(tag) => !featureTagNames.has(tag.name)
|
|
423
|
+
);
|
|
427
424
|
const scenarioSteps = (element.steps ?? []).filter((step) => !isHook(step));
|
|
428
425
|
const stepNodes = scenarioSteps.map((step) => mapStep(step, nextId));
|
|
429
426
|
const backgroundInline = backgroundSteps.length > 0 && backgroundSteps.every(
|
|
@@ -568,7 +565,6 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
568
565
|
body: embedding.data,
|
|
569
566
|
contentEncoding: isLikelyBase64(embedding.data) ? AttachmentContentEncoding.BASE64 : AttachmentContentEncoding.IDENTITY,
|
|
570
567
|
mediaType,
|
|
571
|
-
fileName: attachmentFileName(mediaType, attachmentCounter++),
|
|
572
568
|
testCaseStartedId,
|
|
573
569
|
testStepId: plan.testStep.id,
|
|
574
570
|
timestamp: finishedAt
|
|
@@ -589,7 +585,7 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
589
585
|
envelopes.push({
|
|
590
586
|
gherkinDocument: { uri, feature: featureNode, comments: [] }
|
|
591
587
|
});
|
|
592
|
-
envelopes.push(
|
|
588
|
+
for (const envelope of scenarioEnvelopes) envelopes.push(envelope);
|
|
593
589
|
}
|
|
594
590
|
const success = !statuses.some(
|
|
595
591
|
(status) => status === TestStepResultStatus.FAILED || status === TestStepResultStatus.AMBIGUOUS || status === TestStepResultStatus.UNDEFINED
|
|
@@ -679,12 +675,12 @@ function secondsToNanoseconds(value) {
|
|
|
679
675
|
function isXmlChar(code) {
|
|
680
676
|
return code === 9 || code === 10 || code === 13 || code >= 32 && code <= 55295 || code >= 57344 && code <= 65533 || code >= 65536 && code <= 1114111;
|
|
681
677
|
}
|
|
682
|
-
function checkEntityReferences(fragment, source
|
|
678
|
+
function checkEntityReferences(fragment, source) {
|
|
683
679
|
const entityPattern = /&([^;]{1,32});/g;
|
|
684
680
|
let match;
|
|
685
681
|
while ((match = entityPattern.exec(fragment)) !== null) {
|
|
686
682
|
const entity = match[1];
|
|
687
|
-
if (entity === "amp" || entity === "lt" || entity === "gt" || entity === "quot" || entity === "apos"
|
|
683
|
+
if (entity === "amp" || entity === "lt" || entity === "gt" || entity === "quot" || entity === "apos") {
|
|
688
684
|
continue;
|
|
689
685
|
}
|
|
690
686
|
let code;
|
|
@@ -700,8 +696,7 @@ function checkEntityReferences(fragment, source, allowedNames) {
|
|
|
700
696
|
}
|
|
701
697
|
}
|
|
702
698
|
}
|
|
703
|
-
function
|
|
704
|
-
const allowedNames = /* @__PURE__ */ new Set();
|
|
699
|
+
function assertSafeMarkup(content, source) {
|
|
705
700
|
const scanTag = (start) => {
|
|
706
701
|
let index2 = start + 1;
|
|
707
702
|
let quote = "";
|
|
@@ -710,11 +705,7 @@ function assertValidEntities(content, source) {
|
|
|
710
705
|
const char = content[index2];
|
|
711
706
|
if (quote) {
|
|
712
707
|
if (char === quote) {
|
|
713
|
-
checkEntityReferences(
|
|
714
|
-
content.slice(valueStart, index2),
|
|
715
|
-
source,
|
|
716
|
-
allowedNames
|
|
717
|
-
);
|
|
708
|
+
checkEntityReferences(content.slice(valueStart, index2), source);
|
|
718
709
|
quote = "";
|
|
719
710
|
}
|
|
720
711
|
} else if (char === '"' || char === "'") {
|
|
@@ -727,47 +718,15 @@ function assertValidEntities(content, source) {
|
|
|
727
718
|
}
|
|
728
719
|
return index2;
|
|
729
720
|
};
|
|
730
|
-
const scanDoctype = (start) => {
|
|
731
|
-
let index2 = start + "<!DOCTYPE".length;
|
|
732
|
-
let quote = "";
|
|
733
|
-
let depth = 0;
|
|
734
|
-
while (index2 < content.length) {
|
|
735
|
-
const char = content[index2];
|
|
736
|
-
if (quote) {
|
|
737
|
-
if (char === quote) quote = "";
|
|
738
|
-
} else if (char === '"' || char === "'") {
|
|
739
|
-
quote = char;
|
|
740
|
-
} else if (char === "[") {
|
|
741
|
-
depth += 1;
|
|
742
|
-
} else if (char === "]") {
|
|
743
|
-
depth -= 1;
|
|
744
|
-
} else if (char === ">" && depth <= 0) {
|
|
745
|
-
const doctype = content.slice(start, index2 + 1);
|
|
746
|
-
for (const entity of doctype.matchAll(
|
|
747
|
-
/<!ENTITY\s+([A-Za-z_:][\w.:-]*)/g
|
|
748
|
-
)) {
|
|
749
|
-
const name = entity[1];
|
|
750
|
-
if (name) allowedNames.add(name);
|
|
751
|
-
}
|
|
752
|
-
return index2 + 1;
|
|
753
|
-
}
|
|
754
|
-
index2 += 1;
|
|
755
|
-
}
|
|
756
|
-
return index2;
|
|
757
|
-
};
|
|
758
721
|
let index = 0;
|
|
759
722
|
while (index < content.length) {
|
|
760
723
|
const start = content.indexOf("<", index);
|
|
761
724
|
if (start === -1) {
|
|
762
|
-
checkEntityReferences(content.slice(index), source
|
|
725
|
+
checkEntityReferences(content.slice(index), source);
|
|
763
726
|
return;
|
|
764
727
|
}
|
|
765
728
|
if (start > index) {
|
|
766
|
-
checkEntityReferences(
|
|
767
|
-
content.slice(index, start),
|
|
768
|
-
source,
|
|
769
|
-
allowedNames
|
|
770
|
-
);
|
|
729
|
+
checkEntityReferences(content.slice(index, start), source);
|
|
771
730
|
}
|
|
772
731
|
if (content.startsWith("<!--", start)) {
|
|
773
732
|
const end = content.indexOf("-->", start + 4);
|
|
@@ -778,9 +737,15 @@ function assertValidEntities(content, source) {
|
|
|
778
737
|
} else if (content.startsWith("<?", start)) {
|
|
779
738
|
const end = content.indexOf("?>", start + 2);
|
|
780
739
|
index = end === -1 ? content.length : end + 2;
|
|
781
|
-
} else if (content.startsWith("<!DOCTYPE", start)) {
|
|
782
|
-
index = scanDoctype(start);
|
|
783
740
|
} else if (content.startsWith("<!", start)) {
|
|
741
|
+
const declaration = /^<!(DOCTYPE|ENTITY)\b/i.exec(
|
|
742
|
+
content.slice(start, start + 10)
|
|
743
|
+
);
|
|
744
|
+
if (declaration) {
|
|
745
|
+
throw new Error(
|
|
746
|
+
`Invalid JUnit XML in ${source}: <!${declaration[1].toUpperCase()}> declarations are not supported.`
|
|
747
|
+
);
|
|
748
|
+
}
|
|
784
749
|
const end = content.indexOf(">", start + 2);
|
|
785
750
|
index = end === -1 ? content.length : end + 1;
|
|
786
751
|
} else {
|
|
@@ -833,6 +798,7 @@ function elementFromTestcase(testcase, index) {
|
|
|
833
798
|
const skipped = asArray(testcase.skipped).length > 0;
|
|
834
799
|
const status = hasFailure ? "failed" : skipped ? "skipped" : "passed";
|
|
835
800
|
const name = stringOf(testcase.name) || stringOf(testcase.classname) || `Test ${index + 1}`;
|
|
801
|
+
const description = stringOf(testcase.description);
|
|
836
802
|
const result = {
|
|
837
803
|
status,
|
|
838
804
|
duration: secondsToNanoseconds(testcase.time)
|
|
@@ -861,6 +827,7 @@ function elementFromTestcase(testcase, index) {
|
|
|
861
827
|
type: "scenario",
|
|
862
828
|
keyword: "Scenario",
|
|
863
829
|
name,
|
|
830
|
+
description,
|
|
864
831
|
line: 1,
|
|
865
832
|
tags: [],
|
|
866
833
|
steps: [step]
|
|
@@ -872,6 +839,7 @@ function featureFromSuite(suite, source, index) {
|
|
|
872
839
|
return {
|
|
873
840
|
keyword: "Feature",
|
|
874
841
|
name,
|
|
842
|
+
description: stringOf(suite.description),
|
|
875
843
|
uri: source,
|
|
876
844
|
line: 1,
|
|
877
845
|
tags: [],
|
|
@@ -884,9 +852,9 @@ function looksLikeJUnit(content) {
|
|
|
884
852
|
const trimmed = content.replace(/^\uFEFF/, "").trimStart();
|
|
885
853
|
return trimmed.startsWith("<") && /<testsuites?\b/i.test(trimmed);
|
|
886
854
|
}
|
|
887
|
-
async function parseJUnitXml(content, source) {
|
|
855
|
+
async function parseJUnitXml(content, source, options = {}) {
|
|
888
856
|
const { XMLParser, XMLValidator } = await import("fast-xml-parser");
|
|
889
|
-
|
|
857
|
+
assertSafeMarkup(content, source);
|
|
890
858
|
const validation = XMLValidator.validate(content);
|
|
891
859
|
if (validation !== true) {
|
|
892
860
|
const line = Number.isFinite(validation.err.line) ? validation.err.line : 1;
|
|
@@ -921,7 +889,9 @@ async function parseJUnitXml(content, source) {
|
|
|
921
889
|
const legacy = suites.map(
|
|
922
890
|
(suite, index) => featureFromSuite(suite, source, index)
|
|
923
891
|
);
|
|
924
|
-
const envelopes = parseLegacyValue(legacy, source, {
|
|
892
|
+
const envelopes = parseLegacyValue(legacy, source, {
|
|
893
|
+
idPrefix: options.idPrefix ?? "junit"
|
|
894
|
+
});
|
|
925
895
|
for (const envelope of envelopes) {
|
|
926
896
|
if (envelope.meta) {
|
|
927
897
|
envelope.meta.implementation = { name: "JUnit XML", version: "" };
|
|
@@ -1147,6 +1117,14 @@ function parseMessages(content, source) {
|
|
|
1147
1117
|
// src/input/load.ts
|
|
1148
1118
|
var MESSAGES_EXTENSIONS = /* @__PURE__ */ new Set([".jsonl", ".ndjson"]);
|
|
1149
1119
|
var MAX_TOTAL_INPUT_BYTES = 100 * 1024 * 1024;
|
|
1120
|
+
function addInputBytes(totalBytes, size) {
|
|
1121
|
+
if (totalBytes + size > MAX_TOTAL_INPUT_BYTES) {
|
|
1122
|
+
throw new Error(
|
|
1123
|
+
"Inputs exceed 100 MB in total. Split the report or use external attachments."
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
return totalBytes + size;
|
|
1127
|
+
}
|
|
1150
1128
|
function isObject3(value) {
|
|
1151
1129
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1152
1130
|
}
|
|
@@ -1165,7 +1143,7 @@ function sniffLegacy(content) {
|
|
|
1165
1143
|
}
|
|
1166
1144
|
}
|
|
1167
1145
|
function looksLikeMessages(content) {
|
|
1168
|
-
const firstLine = content.split(/\r?\n
|
|
1146
|
+
const firstLine = content.replace(/^\uFEFF/, "").split(/\r?\n/, 20).map((line) => line.trim()).find(Boolean);
|
|
1169
1147
|
if (!firstLine) return false;
|
|
1170
1148
|
try {
|
|
1171
1149
|
return isEnvelopeLike(JSON.parse(firstLine));
|
|
@@ -1189,7 +1167,23 @@ async function canonicalPath(file) {
|
|
|
1189
1167
|
return path2.resolve(file);
|
|
1190
1168
|
}
|
|
1191
1169
|
}
|
|
1192
|
-
|
|
1170
|
+
function collectGherkinIds(value) {
|
|
1171
|
+
const ids = [];
|
|
1172
|
+
const visit = (node) => {
|
|
1173
|
+
if (Array.isArray(node)) {
|
|
1174
|
+
for (const child of node) visit(child);
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (!node || typeof node !== "object") return;
|
|
1178
|
+
for (const [key, child] of Object.entries(node)) {
|
|
1179
|
+
if (key === "id" && typeof child === "string") ids.push(child);
|
|
1180
|
+
else visit(child);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
visit(value);
|
|
1184
|
+
return ids;
|
|
1185
|
+
}
|
|
1186
|
+
async function loadInputs(inputs) {
|
|
1193
1187
|
const requested = Array.isArray(inputs) ? inputs : [inputs];
|
|
1194
1188
|
if (requested.length === 0) {
|
|
1195
1189
|
throw new Error("No input files provided.");
|
|
@@ -1220,58 +1214,128 @@ async function loadEnvelopes(inputs) {
|
|
|
1220
1214
|
const ordered = [...files.values()].sort(
|
|
1221
1215
|
(a, b) => a.file.localeCompare(b.file)
|
|
1222
1216
|
);
|
|
1223
|
-
const
|
|
1217
|
+
const groups = [];
|
|
1224
1218
|
const seenContent = /* @__PURE__ */ new Set();
|
|
1225
1219
|
let totalBytes = 0;
|
|
1226
1220
|
for (const [index, input] of ordered.entries()) {
|
|
1227
1221
|
const info = await stat(input.file);
|
|
1228
|
-
|
|
1229
|
-
throw new Error(
|
|
1230
|
-
"Inputs exceed 100 MB in total. Split the report or use external attachments."
|
|
1231
|
-
);
|
|
1232
|
-
}
|
|
1222
|
+
const nextTotal = addInputBytes(totalBytes, info.size);
|
|
1233
1223
|
const content = await readFile(input.file, "utf8");
|
|
1234
1224
|
const hash = createHash("sha256").update(content).digest("hex");
|
|
1235
1225
|
if (seenContent.has(hash)) continue;
|
|
1236
1226
|
seenContent.add(hash);
|
|
1237
|
-
totalBytes
|
|
1227
|
+
totalBytes = nextTotal;
|
|
1238
1228
|
const extension = path2.extname(input.file).toLowerCase();
|
|
1239
1229
|
const legacy = sniffLegacy(content);
|
|
1230
|
+
let parsed = [];
|
|
1240
1231
|
if (legacy?.kind === "legacy") {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
);
|
|
1246
|
-
continue;
|
|
1247
|
-
}
|
|
1248
|
-
if (legacy?.kind === "malformed") {
|
|
1232
|
+
parsed = parseLegacyValue(legacy.parsed, input.file, {
|
|
1233
|
+
idPrefix: `legacy-${index}`
|
|
1234
|
+
});
|
|
1235
|
+
} else if (legacy?.kind === "malformed") {
|
|
1249
1236
|
parseLegacyJson(content, input.file, { idPrefix: `legacy-${index}` });
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1237
|
+
} else if (looksLikeJUnit(content)) {
|
|
1238
|
+
parsed = await parseJUnitXml(content, input.file, {
|
|
1239
|
+
idPrefix: `junit-${index}`
|
|
1240
|
+
});
|
|
1241
|
+
} else if (looksLikeMessages(content)) {
|
|
1242
|
+
parsed = parseMessages(content, input.file);
|
|
1243
|
+
} else if (input.explicit && extension === ".xml") {
|
|
1244
|
+
await parseJUnitXml(content, input.file, { idPrefix: `junit-${index}` });
|
|
1245
|
+
} else {
|
|
1246
|
+
if (input.explicit && MESSAGES_EXTENSIONS.has(extension) && content.trim().length === 0) {
|
|
1247
|
+
throw new Error(`Input is empty: ${input.file}`);
|
|
1248
|
+
}
|
|
1249
|
+
if (input.explicit) {
|
|
1250
|
+
invalidJson(content, input.file);
|
|
1251
|
+
}
|
|
1252
|
+
if (MESSAGES_EXTENSIONS.has(extension)) {
|
|
1253
|
+
parseMessages(content, input.file);
|
|
1254
|
+
}
|
|
1255
1255
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1256
|
+
groups.push({ file: input.file, envelopes: parsed });
|
|
1257
|
+
}
|
|
1258
|
+
if (groups.every((group) => group.envelopes.length === 0)) {
|
|
1259
|
+
throw new Error("No supported report files found.");
|
|
1260
|
+
}
|
|
1261
|
+
const seenIds = /* @__PURE__ */ new Map();
|
|
1262
|
+
for (const group of groups) {
|
|
1263
|
+
const file = path2.basename(group.file);
|
|
1264
|
+
for (const envelope of group.envelopes) {
|
|
1265
|
+
const ids = [
|
|
1266
|
+
["pickle", envelope.pickle?.id],
|
|
1267
|
+
["testCase", envelope.testCase?.id],
|
|
1268
|
+
["testCaseStarted", envelope.testCaseStarted?.id],
|
|
1269
|
+
["hook", envelope.hook?.id]
|
|
1270
|
+
];
|
|
1271
|
+
for (const step of envelope.testCase?.testSteps ?? []) {
|
|
1272
|
+
ids.push(["testStep", step.id]);
|
|
1273
|
+
}
|
|
1274
|
+
for (const id of collectGherkinIds(envelope.gherkinDocument)) {
|
|
1275
|
+
ids.push(["gherkin", id]);
|
|
1276
|
+
}
|
|
1277
|
+
for (const [kind, id] of ids) {
|
|
1278
|
+
if (!id) continue;
|
|
1279
|
+
const key = `${kind}:${id}`;
|
|
1280
|
+
const previous = seenIds.get(key);
|
|
1281
|
+
if (previous) {
|
|
1282
|
+
throw new Error(
|
|
1283
|
+
`Duplicate Cucumber Messages ${kind} id in ${previous} and ${file}. Merge the streams before splitting or use unique ids.`
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
seenIds.set(key, file);
|
|
1287
|
+
}
|
|
1259
1288
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1289
|
+
}
|
|
1290
|
+
return groups;
|
|
1291
|
+
}
|
|
1292
|
+
async function loadEnvelopes(inputs) {
|
|
1293
|
+
return (await loadInputs(inputs)).flatMap((group) => group.envelopes);
|
|
1294
|
+
}
|
|
1295
|
+
function provenanceFor(groups) {
|
|
1296
|
+
const names = /* @__PURE__ */ new Map();
|
|
1297
|
+
for (const group of groups) {
|
|
1298
|
+
if (!group.envelopes.some(
|
|
1299
|
+
(envelope) => envelope.gherkinDocument || envelope.pickle
|
|
1300
|
+
)) {
|
|
1262
1301
|
continue;
|
|
1263
1302
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1303
|
+
const name = path2.basename(group.file);
|
|
1304
|
+
const set = names.get(name) ?? /* @__PURE__ */ new Set();
|
|
1305
|
+
set.add(group.file);
|
|
1306
|
+
names.set(name, set);
|
|
1307
|
+
}
|
|
1308
|
+
const ambiguous = new Set(
|
|
1309
|
+
[...names.entries()].filter(([, files]) => files.size > 1).map(([name]) => name)
|
|
1310
|
+
);
|
|
1311
|
+
const uriFiles = /* @__PURE__ */ new Map();
|
|
1312
|
+
for (const group of groups) {
|
|
1313
|
+
const name = path2.basename(group.file);
|
|
1314
|
+
if (ambiguous.has(name)) continue;
|
|
1315
|
+
for (const envelope of group.envelopes) {
|
|
1316
|
+
for (const uri of [envelope.gherkinDocument?.uri, envelope.pickle?.uri]) {
|
|
1317
|
+
if (!uri) continue;
|
|
1318
|
+
const set = uriFiles.get(uri) ?? /* @__PURE__ */ new Set();
|
|
1319
|
+
set.add(name);
|
|
1320
|
+
uriFiles.set(uri, set);
|
|
1321
|
+
}
|
|
1269
1322
|
}
|
|
1270
1323
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1324
|
+
const provenance = /* @__PURE__ */ new Map();
|
|
1325
|
+
for (const [uri, files] of uriFiles) {
|
|
1326
|
+
if (files.size === 1) provenance.set(uri, [...files][0]);
|
|
1273
1327
|
}
|
|
1274
|
-
return
|
|
1328
|
+
return provenance;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
// src/options.ts
|
|
1332
|
+
function renderOptions(options) {
|
|
1333
|
+
return {
|
|
1334
|
+
title: options.title ?? "Tolkira report",
|
|
1335
|
+
metadata: options.metadata,
|
|
1336
|
+
logo: options.logo,
|
|
1337
|
+
accent: options.accent
|
|
1338
|
+
};
|
|
1275
1339
|
}
|
|
1276
1340
|
|
|
1277
1341
|
// src/render/html.ts
|
|
@@ -1280,13 +1344,12 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
1280
1344
|
// src/input/sanitize.ts
|
|
1281
1345
|
var REMOTE_MARKDOWN_IMAGE = /!\[([^\]]*)\]\(\s*(?:https?:)?\/\/[^)\s]+(?:\s+["'][^"']*["'])?\s*\)/gi;
|
|
1282
1346
|
var REMOTE_ANGLE_IMAGE = /!\[([^\]]*)\]\(\s*<(?:https?:)?\/\/[^>]+>\s*\)/gi;
|
|
1283
|
-
var REMOTE_REFERENCE_DEFINITION = /^\s*\[[^\]]+\]:\s*(?:https?:)?\/\/\S+.*$/gim;
|
|
1284
1347
|
var RAW_IMAGE_TAG = /<img\b[^>]*>/gi;
|
|
1285
1348
|
var MAX_ATTACHMENT_BYTES = 50 * 1024 * 1024;
|
|
1286
1349
|
var MAX_TOTAL_ATTACHMENT_BYTES = 100 * 1024 * 1024;
|
|
1287
1350
|
function stripRemoteImages(value) {
|
|
1288
1351
|
if (typeof value !== "string") return "";
|
|
1289
|
-
return value.replace(REMOTE_ANGLE_IMAGE, "$1").replace(REMOTE_MARKDOWN_IMAGE, "$1
|
|
1352
|
+
return value.replace(REMOTE_ANGLE_IMAGE, "![$1]()").replace(REMOTE_MARKDOWN_IMAGE, "![$1]()").replace(RAW_IMAGE_TAG, "");
|
|
1290
1353
|
}
|
|
1291
1354
|
function base64Bytes(value) {
|
|
1292
1355
|
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
@@ -1355,11 +1418,35 @@ function sanitizeEnvelopes(envelopes) {
|
|
|
1355
1418
|
return envelopes;
|
|
1356
1419
|
}
|
|
1357
1420
|
|
|
1421
|
+
// src/report/attachment.ts
|
|
1422
|
+
var MAX_TEXT_ATTACHMENT_BYTES = 262144;
|
|
1423
|
+
var MEDIA_EXTENSIONS = {
|
|
1424
|
+
"application/json": "json",
|
|
1425
|
+
"application/octet-stream": "bin",
|
|
1426
|
+
"image/gif": "gif",
|
|
1427
|
+
"image/jpeg": "jpg",
|
|
1428
|
+
"image/png": "png",
|
|
1429
|
+
"image/svg+xml": "svg",
|
|
1430
|
+
"image/webp": "webp",
|
|
1431
|
+
"text/csv": "csv",
|
|
1432
|
+
"text/html": "html",
|
|
1433
|
+
"text/plain": "txt",
|
|
1434
|
+
"text/uri-list": "txt",
|
|
1435
|
+
"text/x.cucumber.log+plain": "log",
|
|
1436
|
+
"video/mp4": "mp4",
|
|
1437
|
+
"video/webm": "webm"
|
|
1438
|
+
};
|
|
1439
|
+
function normalizedMediaType(mediaType) {
|
|
1440
|
+
return mediaType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
1441
|
+
}
|
|
1442
|
+
var SAFE_MEDIA_TYPES = new Set(Object.keys(MEDIA_EXTENSIONS));
|
|
1443
|
+
function safeMediaType(mediaType) {
|
|
1444
|
+
const base = normalizedMediaType(mediaType || "");
|
|
1445
|
+
return SAFE_MEDIA_TYPES.has(base) ? base : "application/octet-stream";
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1358
1448
|
// src/report/model.ts
|
|
1359
|
-
import {
|
|
1360
|
-
getWorstTestStepResult,
|
|
1361
|
-
TestStepResultStatus as TestStepResultStatus3
|
|
1362
|
-
} from "@cucumber/messages";
|
|
1449
|
+
import { getWorstTestStepResult } from "@cucumber/messages";
|
|
1363
1450
|
|
|
1364
1451
|
// src/result-message.ts
|
|
1365
1452
|
function stepResultMessage(result) {
|
|
@@ -1372,7 +1459,89 @@ ${message}`;
|
|
|
1372
1459
|
return message || exception || void 0;
|
|
1373
1460
|
}
|
|
1374
1461
|
|
|
1375
|
-
// src/
|
|
1462
|
+
// src/text.ts
|
|
1463
|
+
var BIDI_CONTROLS = /[\u202A-\u202E\u2066-\u2069]/g;
|
|
1464
|
+
var ANSI_CONTROLS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/;
|
|
1465
|
+
var STRING_INTRODUCERS = /* @__PURE__ */ new Set([144, 152, 157, 158, 159]);
|
|
1466
|
+
function stripBidiControls(value) {
|
|
1467
|
+
return value.replace(BIDI_CONTROLS, "");
|
|
1468
|
+
}
|
|
1469
|
+
function csiEnd(text, start) {
|
|
1470
|
+
let index = start + 1;
|
|
1471
|
+
while (index < text.length && text.charCodeAt(index) >= 48 && text.charCodeAt(index) <= 63) {
|
|
1472
|
+
index += 1;
|
|
1473
|
+
}
|
|
1474
|
+
while (index < text.length && text.charCodeAt(index) >= 32 && text.charCodeAt(index) <= 47) {
|
|
1475
|
+
index += 1;
|
|
1476
|
+
}
|
|
1477
|
+
return index < text.length ? index + 1 : index;
|
|
1478
|
+
}
|
|
1479
|
+
function stringEnd(text, start, allowBel) {
|
|
1480
|
+
let end = start;
|
|
1481
|
+
while (end < text.length) {
|
|
1482
|
+
if (allowBel && text[end] === "\x07") return end + 1;
|
|
1483
|
+
if (text[end] === "\x9C") return end + 1;
|
|
1484
|
+
if (text[end] === "\x1B" && text[end + 1] === "\\") return end + 2;
|
|
1485
|
+
end += 1;
|
|
1486
|
+
}
|
|
1487
|
+
return void 0;
|
|
1488
|
+
}
|
|
1489
|
+
function isEscapeIntroducer(code) {
|
|
1490
|
+
return code === 27 || code === 155 || STRING_INTRODUCERS.has(code);
|
|
1491
|
+
}
|
|
1492
|
+
function scanEscape(text, start) {
|
|
1493
|
+
const first = text.charCodeAt(start);
|
|
1494
|
+
if (first === 155) {
|
|
1495
|
+
const end2 = csiEnd(text, start);
|
|
1496
|
+
const final = end2 > start + 1 ? text[end2 - 1] : "";
|
|
1497
|
+
return final === "m" ? { end: end2, sgr: text.slice(start + 1, end2 - 1) } : { end: end2 };
|
|
1498
|
+
}
|
|
1499
|
+
if (STRING_INTRODUCERS.has(first)) {
|
|
1500
|
+
return {
|
|
1501
|
+
end: stringEnd(text, start + 1, first === 157) ?? start + 1
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
let index = start + 1;
|
|
1505
|
+
if (index >= text.length) return { end: index };
|
|
1506
|
+
const introducer = text[index];
|
|
1507
|
+
if (introducer === "[") {
|
|
1508
|
+
const end2 = csiEnd(text, index);
|
|
1509
|
+
const final = end2 > index + 1 ? text[end2 - 1] : "";
|
|
1510
|
+
return final === "m" ? { end: end2, sgr: text.slice(index + 1, end2 - 1) } : { end: end2 };
|
|
1511
|
+
}
|
|
1512
|
+
if (introducer === "]" || introducer === "P" || introducer === "_" || introducer === "^" || introducer === "X") {
|
|
1513
|
+
return { end: stringEnd(text, index + 1, introducer === "]") ?? text.length };
|
|
1514
|
+
}
|
|
1515
|
+
let end = index;
|
|
1516
|
+
while (end < text.length && text.charCodeAt(end) >= 32 && text.charCodeAt(end) <= 47) {
|
|
1517
|
+
end += 1;
|
|
1518
|
+
}
|
|
1519
|
+
if (end < text.length && text.charCodeAt(end) >= 48 && text.charCodeAt(end) <= 126) {
|
|
1520
|
+
end += 1;
|
|
1521
|
+
}
|
|
1522
|
+
return { end };
|
|
1523
|
+
}
|
|
1524
|
+
function isControl(code) {
|
|
1525
|
+
return code === 127 || code >= 128 && code <= 159 || code < 32 && code !== 9 && code !== 10;
|
|
1526
|
+
}
|
|
1527
|
+
function stripAnsi(text) {
|
|
1528
|
+
if (!ANSI_CONTROLS.test(text)) return text;
|
|
1529
|
+
let output = "";
|
|
1530
|
+
let chunkStart = 0;
|
|
1531
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
1532
|
+
const code = text.charCodeAt(index);
|
|
1533
|
+
const escape = isEscapeIntroducer(code);
|
|
1534
|
+
if (escape || isControl(code)) {
|
|
1535
|
+
if (index > chunkStart) output += text.slice(chunkStart, index);
|
|
1536
|
+
if (escape) index = scanEscape(text, index).end - 1;
|
|
1537
|
+
chunkStart = index + 1;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return output + text.slice(chunkStart);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// src/report/status.ts
|
|
1544
|
+
import { TestStepResultStatus as TestStepResultStatus3 } from "@cucumber/messages";
|
|
1376
1545
|
var STATUS_ORDER = [
|
|
1377
1546
|
TestStepResultStatus3.UNKNOWN,
|
|
1378
1547
|
TestStepResultStatus3.PASSED,
|
|
@@ -1382,6 +1551,25 @@ var STATUS_ORDER = [
|
|
|
1382
1551
|
TestStepResultStatus3.AMBIGUOUS,
|
|
1383
1552
|
TestStepResultStatus3.FAILED
|
|
1384
1553
|
];
|
|
1554
|
+
function statusSeverity(status) {
|
|
1555
|
+
return STATUS_ORDER.indexOf(status.toUpperCase());
|
|
1556
|
+
}
|
|
1557
|
+
function worstExecutedStatus(scenarios) {
|
|
1558
|
+
const executed = scenarios.filter((scenario) => scenario.executed);
|
|
1559
|
+
if (executed.length === 0) return "unknown";
|
|
1560
|
+
let worst = "unknown";
|
|
1561
|
+
let hasNonPassed = false;
|
|
1562
|
+
for (const scenario of executed) {
|
|
1563
|
+
if (scenario.status === "passed") continue;
|
|
1564
|
+
hasNonPassed = true;
|
|
1565
|
+
if (statusSeverity(scenario.status) > statusSeverity(worst)) {
|
|
1566
|
+
worst = scenario.status;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
return hasNonPassed ? worst : "passed";
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// src/report/model.ts
|
|
1385
1573
|
var VALID_STATUS = /* @__PURE__ */ new Set([
|
|
1386
1574
|
"passed",
|
|
1387
1575
|
"failed",
|
|
@@ -1399,12 +1587,22 @@ function durationMs(duration2) {
|
|
|
1399
1587
|
if (!duration2) return 0;
|
|
1400
1588
|
const seconds = Number.isFinite(duration2.seconds) ? duration2.seconds : 0;
|
|
1401
1589
|
const nanos = Number.isFinite(duration2.nanos) ? duration2.nanos : 0;
|
|
1402
|
-
|
|
1590
|
+
const milliseconds = seconds * 1e3 + nanos / 1e6;
|
|
1591
|
+
if (!Number.isFinite(milliseconds) || milliseconds <= 0) return 0;
|
|
1592
|
+
const rounded = Math.round(milliseconds * 1e3) / 1e3;
|
|
1593
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1594
|
+
}
|
|
1595
|
+
function finiteDuration(value) {
|
|
1596
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
1597
|
+
const rounded = Math.round(value * 1e3) / 1e3;
|
|
1598
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1403
1599
|
}
|
|
1404
1600
|
function timestampIso(timestamp2) {
|
|
1405
1601
|
if (!timestamp2) return void 0;
|
|
1406
1602
|
const milliseconds = timestamp2.seconds * 1e3 + timestamp2.nanos / 1e6;
|
|
1407
|
-
|
|
1603
|
+
if (!Number.isFinite(milliseconds)) return void 0;
|
|
1604
|
+
const date = new Date(milliseconds);
|
|
1605
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
1408
1606
|
}
|
|
1409
1607
|
function normalizeText2(value) {
|
|
1410
1608
|
return (value ?? "").replace(/\r\n/g, "\n");
|
|
@@ -1414,60 +1612,67 @@ function productLabel(product) {
|
|
|
1414
1612
|
const label = [product.name, product.version].filter(Boolean).join(" ");
|
|
1415
1613
|
return label || void 0;
|
|
1416
1614
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
function
|
|
1422
|
-
|
|
1615
|
+
function nonEmpty(value) {
|
|
1616
|
+
const trimmed = stripBidiControls(value ?? "").trim();
|
|
1617
|
+
return trimmed ? trimmed : void 0;
|
|
1618
|
+
}
|
|
1619
|
+
function ciFromMeta(ci) {
|
|
1620
|
+
if (!ci) return void 0;
|
|
1621
|
+
const git = ci.git;
|
|
1622
|
+
const name = nonEmpty(ci.name);
|
|
1623
|
+
const url = nonEmpty(ci.url);
|
|
1624
|
+
const remote = nonEmpty(git?.remote);
|
|
1625
|
+
const revision = nonEmpty(git?.revision);
|
|
1626
|
+
const branch = nonEmpty(git?.branch);
|
|
1627
|
+
const tag = nonEmpty(git?.tag);
|
|
1628
|
+
const result = {
|
|
1629
|
+
...name ? { name } : {},
|
|
1630
|
+
...url ? { url } : {},
|
|
1631
|
+
...remote ? { remote } : {},
|
|
1632
|
+
...revision ? { revision } : {},
|
|
1633
|
+
...branch ? { branch } : {},
|
|
1634
|
+
...tag ? { tag } : {}
|
|
1635
|
+
};
|
|
1636
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
1423
1637
|
}
|
|
1424
1638
|
function hookLabel(type) {
|
|
1425
1639
|
switch (type) {
|
|
1426
1640
|
case "BEFORE_TEST_CASE":
|
|
1427
|
-
return "Before
|
|
1641
|
+
return "Before";
|
|
1428
1642
|
case "AFTER_TEST_CASE":
|
|
1429
|
-
return "After
|
|
1643
|
+
return "After";
|
|
1430
1644
|
case "BEFORE_TEST_STEP":
|
|
1431
|
-
return "
|
|
1645
|
+
return "BeforeStep";
|
|
1432
1646
|
case "AFTER_TEST_STEP":
|
|
1433
|
-
return "
|
|
1647
|
+
return "AfterStep";
|
|
1434
1648
|
case "BEFORE_TEST_RUN":
|
|
1435
|
-
return "
|
|
1649
|
+
return "BeforeAll";
|
|
1436
1650
|
case "AFTER_TEST_RUN":
|
|
1437
|
-
return "
|
|
1651
|
+
return "AfterAll";
|
|
1438
1652
|
default:
|
|
1439
1653
|
return "Hook";
|
|
1440
1654
|
}
|
|
1441
1655
|
}
|
|
1442
|
-
function
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
"image/gif": "gif",
|
|
1447
|
-
"image/jpeg": "jpg",
|
|
1448
|
-
"image/png": "png",
|
|
1449
|
-
"image/svg+xml": "svg",
|
|
1450
|
-
"text/html": "html",
|
|
1451
|
-
"text/plain": "txt",
|
|
1452
|
-
"video/mp4": "mp4",
|
|
1453
|
-
"video/webm": "webm"
|
|
1454
|
-
};
|
|
1455
|
-
return map[mediaType.toLowerCase()] ?? mediaType.split("/")[1]?.split(";")[0] ?? "bin";
|
|
1656
|
+
function attachmentFileName(fileName, mediaType) {
|
|
1657
|
+
if (fileName) return fileName;
|
|
1658
|
+
const extension = MEDIA_EXTENSIONS[normalizedMediaType(mediaType)];
|
|
1659
|
+
return extension ? `attachment.${extension}` : "attachment";
|
|
1456
1660
|
}
|
|
1457
1661
|
function attachmentKind(mediaType) {
|
|
1458
|
-
|
|
1459
|
-
if (
|
|
1460
|
-
if (
|
|
1461
|
-
if (
|
|
1662
|
+
const base = normalizedMediaType(mediaType);
|
|
1663
|
+
if (base.startsWith("image/")) return "image";
|
|
1664
|
+
if (base.startsWith("video/")) return "video";
|
|
1665
|
+
if (base.startsWith("audio/")) return "audio";
|
|
1666
|
+
if (base.startsWith("text/") || base.includes("json")) {
|
|
1462
1667
|
return "text";
|
|
1463
1668
|
}
|
|
1464
1669
|
return "binary";
|
|
1465
1670
|
}
|
|
1466
|
-
function toAttachment(attachment
|
|
1671
|
+
function toAttachment(attachment) {
|
|
1467
1672
|
const body = attachment.body ?? "";
|
|
1468
|
-
const mediaType = attachment.mediaType || "application/octet-stream";
|
|
1673
|
+
const mediaType = safeMediaType(attachment.mediaType || "application/octet-stream");
|
|
1469
1674
|
const kind = attachmentKind(mediaType);
|
|
1470
|
-
const fileName = attachment.fileName
|
|
1675
|
+
const fileName = attachmentFileName(attachment.fileName, mediaType);
|
|
1471
1676
|
const isBase64 = attachment.contentEncoding === "BASE64";
|
|
1472
1677
|
const bytes = isBase64 ? Math.max(0, Math.floor(body.length * 3 / 4) - (body.endsWith("==") ? 2 : body.endsWith("=") ? 1 : 0)) : Buffer.byteLength(body, "utf8");
|
|
1473
1678
|
if (kind === "image" || kind === "video" || kind === "audio") {
|
|
@@ -1528,33 +1733,96 @@ function count(counts, status) {
|
|
|
1528
1733
|
counts.total += 1;
|
|
1529
1734
|
counts[status] += 1;
|
|
1530
1735
|
}
|
|
1736
|
+
function backgroundRow(background) {
|
|
1737
|
+
if (isSyntheticBackground(background)) return void 0;
|
|
1738
|
+
return {
|
|
1739
|
+
id: background.id,
|
|
1740
|
+
keyword: background.keyword || "Background",
|
|
1741
|
+
name: background.name ?? "",
|
|
1742
|
+
description: normalizeText2(background.description)
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
function backgroundsOf(children) {
|
|
1746
|
+
const rows = [];
|
|
1747
|
+
for (const child of children ?? []) {
|
|
1748
|
+
if (!child.background) continue;
|
|
1749
|
+
const row = backgroundRow(child.background);
|
|
1750
|
+
if (row) rows.push(row);
|
|
1751
|
+
}
|
|
1752
|
+
return rows;
|
|
1753
|
+
}
|
|
1754
|
+
function ruleMetadata(rule) {
|
|
1755
|
+
return {
|
|
1756
|
+
id: rule.id,
|
|
1757
|
+
keyword: rule.keyword || "Rule",
|
|
1758
|
+
name: rule.name ?? "",
|
|
1759
|
+
description: normalizeText2(rule.description),
|
|
1760
|
+
tags: (rule.tags ?? []).map((tag) => tag.name),
|
|
1761
|
+
backgrounds: backgroundsOf(rule.children ?? [])
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1531
1764
|
function featureTree(document) {
|
|
1532
1765
|
const map = /* @__PURE__ */ new Map();
|
|
1533
1766
|
if (!document) return map;
|
|
1534
|
-
const visit = (children,
|
|
1767
|
+
const visit = (children, rule) => {
|
|
1535
1768
|
for (const child of children) {
|
|
1536
|
-
if (child.scenario)
|
|
1537
|
-
|
|
1769
|
+
if (child.scenario) {
|
|
1770
|
+
map.set(child.scenario.id, { scenario: child.scenario, ...rule ? { rule } : {} });
|
|
1771
|
+
}
|
|
1772
|
+
if ("rule" in child && child.rule) {
|
|
1773
|
+
visit(child.rule.children ?? [], ruleMetadata(child.rule));
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
};
|
|
1777
|
+
visit(document.children ?? []);
|
|
1778
|
+
return map;
|
|
1779
|
+
}
|
|
1780
|
+
function exampleRowTree(document, uri) {
|
|
1781
|
+
const map = /* @__PURE__ */ new Map();
|
|
1782
|
+
if (!document) return map;
|
|
1783
|
+
const visit = (children) => {
|
|
1784
|
+
for (const child of children) {
|
|
1785
|
+
if (child.scenario) {
|
|
1786
|
+
const scenario = child.scenario;
|
|
1787
|
+
(scenario.examples ?? []).forEach((examples, examplesIndex) => {
|
|
1788
|
+
(examples.tableBody ?? []).forEach((row, exampleIndex) => {
|
|
1789
|
+
map.set(row.id, {
|
|
1790
|
+
uri,
|
|
1791
|
+
scenario,
|
|
1792
|
+
examples,
|
|
1793
|
+
examplesIndex,
|
|
1794
|
+
exampleIndex
|
|
1795
|
+
});
|
|
1796
|
+
});
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
if ("rule" in child && child.rule) visit(child.rule.children ?? []);
|
|
1538
1800
|
}
|
|
1539
1801
|
};
|
|
1540
1802
|
visit(document.children ?? []);
|
|
1541
1803
|
return map;
|
|
1542
1804
|
}
|
|
1543
|
-
function buildReportModel(envelopes) {
|
|
1805
|
+
function buildReportModel(envelopes, provenance) {
|
|
1544
1806
|
const features = /* @__PURE__ */ new Map();
|
|
1807
|
+
const featureUris = /* @__PURE__ */ new Map();
|
|
1808
|
+
const featureSeen = /* @__PURE__ */ new Set();
|
|
1545
1809
|
const featureOrder = [];
|
|
1546
1810
|
const scenarioTree = /* @__PURE__ */ new Map();
|
|
1811
|
+
const outlineRows = /* @__PURE__ */ new Map();
|
|
1547
1812
|
const featureByScenarioId = /* @__PURE__ */ new Map();
|
|
1548
1813
|
const stepById = /* @__PURE__ */ new Map();
|
|
1549
1814
|
const pickles = /* @__PURE__ */ new Map();
|
|
1550
1815
|
const testCases = /* @__PURE__ */ new Map();
|
|
1551
1816
|
const started = /* @__PURE__ */ new Map();
|
|
1552
1817
|
const hooks = /* @__PURE__ */ new Map();
|
|
1818
|
+
const runHookStarts = /* @__PURE__ */ new Map();
|
|
1819
|
+
const runHookFinishes = /* @__PURE__ */ new Map();
|
|
1553
1820
|
const results = /* @__PURE__ */ new Map();
|
|
1554
1821
|
const attachments = /* @__PURE__ */ new Map();
|
|
1555
|
-
const
|
|
1822
|
+
const runHookAttachments = /* @__PURE__ */ new Map();
|
|
1823
|
+
const suggestions = /* @__PURE__ */ new Map();
|
|
1824
|
+
const stepDefinitions = /* @__PURE__ */ new Map();
|
|
1556
1825
|
const attachmentCache = /* @__PURE__ */ new Map();
|
|
1557
|
-
let attachmentIndex = 0;
|
|
1558
1826
|
let startedAt;
|
|
1559
1827
|
let finishedAt;
|
|
1560
1828
|
let source = "Cucumber";
|
|
@@ -1562,7 +1830,7 @@ function buildReportModel(envelopes) {
|
|
|
1562
1830
|
const mapAttachments = (list) => list.map((attachment) => {
|
|
1563
1831
|
const cached = attachmentCache.get(attachment);
|
|
1564
1832
|
if (cached) return cached;
|
|
1565
|
-
const mapped = toAttachment(attachment
|
|
1833
|
+
const mapped = toAttachment(attachment);
|
|
1566
1834
|
attachmentCache.set(attachment, mapped);
|
|
1567
1835
|
return mapped;
|
|
1568
1836
|
});
|
|
@@ -1570,12 +1838,14 @@ function buildReportModel(envelopes) {
|
|
|
1570
1838
|
if (envelope.meta) {
|
|
1571
1839
|
const { implementation, runtime, os, cpu, protocolVersion } = envelope.meta;
|
|
1572
1840
|
source = productLabel(implementation) ?? "Cucumber";
|
|
1841
|
+
const ci = environment?.ci ?? ciFromMeta(envelope.meta.ci);
|
|
1573
1842
|
const next = {
|
|
1574
1843
|
...implementation && productLabel(implementation) ? { producer: productLabel(implementation) } : {},
|
|
1575
1844
|
...runtime && productLabel(runtime) ? { runtime: productLabel(runtime) } : {},
|
|
1576
1845
|
...os && productLabel(os) ? { os: productLabel(os) } : {},
|
|
1577
1846
|
...cpu && productLabel(cpu) ? { cpu: productLabel(cpu) } : {},
|
|
1578
|
-
...protocolVersion ? { protocol: protocolVersion } : {}
|
|
1847
|
+
...protocolVersion ? { protocol: protocolVersion } : {},
|
|
1848
|
+
...ci ? { ci } : {}
|
|
1579
1849
|
};
|
|
1580
1850
|
if (Object.keys(next).length > 0) environment = next;
|
|
1581
1851
|
}
|
|
@@ -1589,14 +1859,21 @@ function buildReportModel(envelopes) {
|
|
|
1589
1859
|
}
|
|
1590
1860
|
if (envelope.gherkinDocument?.feature) {
|
|
1591
1861
|
const feature = envelope.gherkinDocument.feature;
|
|
1592
|
-
|
|
1593
|
-
|
|
1862
|
+
const uri = envelope.gherkinDocument.uri;
|
|
1863
|
+
const key = uri ?? feature.name;
|
|
1864
|
+
if (!features.has(key)) features.set(key, feature);
|
|
1865
|
+
if (!featureSeen.has(feature)) {
|
|
1866
|
+
featureSeen.add(feature);
|
|
1867
|
+
if (uri) featureUris.set(feature, uri);
|
|
1594
1868
|
featureOrder.push(feature);
|
|
1595
1869
|
}
|
|
1596
1870
|
for (const [id, value] of featureTree(feature)) {
|
|
1597
1871
|
scenarioTree.set(id, value);
|
|
1598
1872
|
featureByScenarioId.set(id, feature);
|
|
1599
1873
|
}
|
|
1874
|
+
for (const [id, value] of exampleRowTree(feature, uri ?? "")) {
|
|
1875
|
+
outlineRows.set(id, value);
|
|
1876
|
+
}
|
|
1600
1877
|
const collectSteps = (children) => {
|
|
1601
1878
|
for (const child of children) {
|
|
1602
1879
|
if (child.background) {
|
|
@@ -1613,17 +1890,49 @@ function buildReportModel(envelopes) {
|
|
|
1613
1890
|
if (envelope.pickle) pickles.set(envelope.pickle.id, envelope.pickle);
|
|
1614
1891
|
if (envelope.testCase) testCases.set(envelope.testCase.id, envelope.testCase);
|
|
1615
1892
|
if (envelope.testCaseStarted) started.set(envelope.testCaseStarted.id, envelope.testCaseStarted);
|
|
1616
|
-
if (envelope.testCaseFinished) finishedStarted.add(envelope.testCaseFinished.testCaseStartedId);
|
|
1617
1893
|
if (envelope.hook) hooks.set(envelope.hook.id, envelope.hook);
|
|
1894
|
+
if (envelope.testRunHookStarted) {
|
|
1895
|
+
runHookStarts.set(envelope.testRunHookStarted.id, envelope.testRunHookStarted);
|
|
1896
|
+
}
|
|
1897
|
+
if (envelope.testRunHookFinished) {
|
|
1898
|
+
runHookFinishes.set(
|
|
1899
|
+
envelope.testRunHookFinished.testRunHookStartedId,
|
|
1900
|
+
envelope.testRunHookFinished
|
|
1901
|
+
);
|
|
1902
|
+
}
|
|
1618
1903
|
if (envelope.testStepFinished) {
|
|
1619
1904
|
const list = results.get(envelope.testStepFinished.testCaseStartedId) ?? [];
|
|
1620
1905
|
list.push(envelope.testStepFinished);
|
|
1621
1906
|
results.set(envelope.testStepFinished.testCaseStartedId, list);
|
|
1622
1907
|
}
|
|
1623
1908
|
if (envelope.attachment) {
|
|
1624
|
-
const
|
|
1909
|
+
const key = envelope.attachment.testRunHookStartedId;
|
|
1910
|
+
const target = key ? runHookAttachments : attachments;
|
|
1911
|
+
const id = key ?? envelope.attachment.testCaseStartedId ?? "";
|
|
1912
|
+
const list = target.get(id) ?? [];
|
|
1625
1913
|
list.push(envelope.attachment);
|
|
1626
|
-
|
|
1914
|
+
target.set(id, list);
|
|
1915
|
+
}
|
|
1916
|
+
if (envelope.suggestion) {
|
|
1917
|
+
const snippets = Array.isArray(envelope.suggestion.snippets) ? envelope.suggestion.snippets : [];
|
|
1918
|
+
const list = snippets.filter((snippet) => typeof snippet?.code === "string").map((snippet) => ({
|
|
1919
|
+
...typeof snippet.language === "string" && snippet.language ? { language: snippet.language } : {},
|
|
1920
|
+
code: snippet.code
|
|
1921
|
+
}));
|
|
1922
|
+
if (list.length > 0) suggestions.set(envelope.suggestion.pickleStepId, list);
|
|
1923
|
+
}
|
|
1924
|
+
if (envelope.stepDefinition) {
|
|
1925
|
+
const pattern = envelope.stepDefinition.pattern;
|
|
1926
|
+
if (typeof pattern?.source === "string") {
|
|
1927
|
+
const reference = envelope.stepDefinition.sourceReference;
|
|
1928
|
+
const uri = typeof reference?.uri === "string" ? reference.uri : "";
|
|
1929
|
+
const line = typeof reference?.location?.line === "number" ? reference.location.line : void 0;
|
|
1930
|
+
const source2 = uri ? line ? `${uri}:${line}` : uri : void 0;
|
|
1931
|
+
stepDefinitions.set(envelope.stepDefinition.id, {
|
|
1932
|
+
pattern: pattern.source,
|
|
1933
|
+
...source2 ? { source: source2 } : {}
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1627
1936
|
}
|
|
1628
1937
|
}
|
|
1629
1938
|
const testCasesByPickle = /* @__PURE__ */ new Map();
|
|
@@ -1641,34 +1950,39 @@ function buildReportModel(envelopes) {
|
|
|
1641
1950
|
const scenarioRows = [];
|
|
1642
1951
|
const scenarioCounts = emptyStatusCounts();
|
|
1643
1952
|
const stepCounts = emptyStatusCounts();
|
|
1953
|
+
const hookCounts = emptyStatusCounts();
|
|
1644
1954
|
const featureScenarios = /* @__PURE__ */ new Map();
|
|
1645
1955
|
for (const pickle of pickles.values()) {
|
|
1646
1956
|
const testCasesForPickle = testCasesByPickle.get(pickle.id) ?? [];
|
|
1647
1957
|
const candidates = testCasesForPickle.flatMap(
|
|
1648
1958
|
(testCase2) => startedByTestCase.get(testCase2.id) ?? []
|
|
1649
1959
|
);
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
1655
|
-
if (candidate.attempt < current.attempt) return current;
|
|
1656
|
-
const cSeconds = candidate.timestamp?.seconds ?? 0;
|
|
1960
|
+
const latest = candidates.reduce((current, candidate2) => {
|
|
1961
|
+
if (!current) return candidate2;
|
|
1962
|
+
if (candidate2.attempt > current.attempt) return candidate2;
|
|
1963
|
+
if (candidate2.attempt < current.attempt) return current;
|
|
1964
|
+
const cSeconds = candidate2.timestamp?.seconds ?? 0;
|
|
1657
1965
|
const currentSeconds = current.timestamp?.seconds ?? 0;
|
|
1658
|
-
if (cSeconds !== currentSeconds) return cSeconds > currentSeconds ?
|
|
1659
|
-
const cNanos =
|
|
1966
|
+
if (cSeconds !== currentSeconds) return cSeconds > currentSeconds ? candidate2 : current;
|
|
1967
|
+
const cNanos = candidate2.timestamp?.nanos ?? 0;
|
|
1660
1968
|
const currentNanos = current.timestamp?.nanos ?? 0;
|
|
1661
|
-
return cNanos > currentNanos ?
|
|
1969
|
+
return cNanos > currentNanos ? candidate2 : current;
|
|
1662
1970
|
}, void 0);
|
|
1663
1971
|
if (!latest) continue;
|
|
1664
1972
|
const testCase = testCases.get(latest.testCaseId);
|
|
1665
1973
|
if (!testCase) continue;
|
|
1666
1974
|
const pickleSteps = new Map(pickle.steps.map((step) => [step.id, step]));
|
|
1667
|
-
const
|
|
1975
|
+
const rawResults = (results.get(latest.id) ?? []).map(
|
|
1976
|
+
(entry) => entry.testStepResult
|
|
1977
|
+
);
|
|
1978
|
+
const executed = rawResults.length > 0;
|
|
1979
|
+
const startedAttachments = executed ? attachments.get(latest.id) ?? [] : [];
|
|
1668
1980
|
const resultsByStep = new Map(
|
|
1669
1981
|
(results.get(latest.id) ?? []).map((entry) => [entry.testStepId, entry.testStepResult])
|
|
1670
1982
|
);
|
|
1671
1983
|
const stepRows = [];
|
|
1984
|
+
const hookRows = [];
|
|
1985
|
+
let testStepOrder = 0;
|
|
1672
1986
|
for (const testStep of testCase.testSteps) {
|
|
1673
1987
|
const result = resultsByStep.get(testStep.id);
|
|
1674
1988
|
if (!result) continue;
|
|
@@ -1680,8 +1994,30 @@ function buildReportModel(envelopes) {
|
|
|
1680
1994
|
startedAttachments.filter((attachment) => attachment.testStepId === testStep.id)
|
|
1681
1995
|
);
|
|
1682
1996
|
const message = stepResultMessage(result);
|
|
1997
|
+
const stepSuggestions = suggestions.get(testStep.pickleStepId) ?? [];
|
|
1998
|
+
const definitionIds = Array.isArray(testStep.stepDefinitionIds) ? testStep.stepDefinitionIds : [];
|
|
1999
|
+
const stepMatches = definitionIds.map((id) => stepDefinitions.get(id)).filter(
|
|
2000
|
+
(definition) => Boolean(definition)
|
|
2001
|
+
);
|
|
2002
|
+
const matchLists = testStep.stepMatchArgumentsLists ?? [];
|
|
2003
|
+
const parameters = [];
|
|
2004
|
+
if (matchLists.length === 1) {
|
|
2005
|
+
for (const argument of matchLists[0]?.stepMatchArguments ?? []) {
|
|
2006
|
+
const start = argument.group?.start;
|
|
2007
|
+
const value = argument.group?.value;
|
|
2008
|
+
if (typeof start !== "number" || !Number.isFinite(start) || typeof value !== "string" || value.length === 0) {
|
|
2009
|
+
continue;
|
|
2010
|
+
}
|
|
2011
|
+
parameters.push({
|
|
2012
|
+
start,
|
|
2013
|
+
value,
|
|
2014
|
+
type: argument.parameterTypeName || "anonymous"
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
1683
2018
|
stepRows.push({
|
|
1684
2019
|
id: testStep.id,
|
|
2020
|
+
order: testStepOrder++,
|
|
1685
2021
|
keyword: data.keyword,
|
|
1686
2022
|
text: pickleStep?.text ?? "",
|
|
1687
2023
|
status: statusOf2(result.status),
|
|
@@ -1689,36 +2025,66 @@ function buildReportModel(envelopes) {
|
|
|
1689
2025
|
...message ? { message: stripAnsi(message) } : {},
|
|
1690
2026
|
...data.docString ? { docString: data.docString } : {},
|
|
1691
2027
|
...data.dataTable ? { dataTable: data.dataTable } : {},
|
|
2028
|
+
...stepSuggestions.length > 0 ? { suggestions: stepSuggestions } : {},
|
|
2029
|
+
...stepMatches.length > 0 ? { definitions: stepMatches } : {},
|
|
2030
|
+
...parameters.length > 0 ? { parameters } : {},
|
|
1692
2031
|
attachments: stepAttachments2
|
|
1693
2032
|
});
|
|
1694
2033
|
} else if (testStep.hookId) {
|
|
1695
2034
|
const hook = hooks.get(testStep.hookId);
|
|
1696
|
-
const
|
|
2035
|
+
const hookAttachments2 = mapAttachments(
|
|
1697
2036
|
startedAttachments.filter((attachment) => attachment.testStepId === testStep.id)
|
|
1698
2037
|
);
|
|
1699
2038
|
const message = stepResultMessage(result);
|
|
1700
|
-
|
|
2039
|
+
hookRows.push({
|
|
1701
2040
|
id: testStep.id,
|
|
1702
|
-
|
|
1703
|
-
|
|
2041
|
+
order: testStepOrder++,
|
|
2042
|
+
type: hookLabel(hook?.type),
|
|
2043
|
+
...hook?.name ? { name: hook.name } : {},
|
|
1704
2044
|
status: statusOf2(result.status),
|
|
1705
2045
|
durationMs: durationMs(result.duration),
|
|
1706
2046
|
...message ? { message: stripAnsi(message) } : {},
|
|
1707
|
-
attachments:
|
|
1708
|
-
hook: hook?.type
|
|
2047
|
+
attachments: hookAttachments2
|
|
1709
2048
|
});
|
|
1710
2049
|
}
|
|
1711
2050
|
}
|
|
1712
|
-
const
|
|
1713
|
-
const
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
2051
|
+
const status = executed ? statusOf2(getWorstTestStepResult(rawResults).status) : "unknown";
|
|
2052
|
+
const duration2 = [...stepRows, ...hookRows].reduce(
|
|
2053
|
+
(sum, entry) => sum + entry.durationMs,
|
|
2054
|
+
0
|
|
2055
|
+
);
|
|
2056
|
+
const astIds = pickle.astNodeIds ?? [];
|
|
2057
|
+
const candidate = astIds.length ? outlineRows.get(astIds.at(-1) ?? "") : void 0;
|
|
2058
|
+
const outlineExample = candidate && astIds.includes(candidate.scenario.id) && (!candidate.uri || !pickle.uri || candidate.uri === pickle.uri) ? candidate : void 0;
|
|
2059
|
+
const scenarioId = outlineExample?.scenario.id ?? astIds[0] ?? "";
|
|
2060
|
+
const tree = outlineExample ?? scenarioTree.get(scenarioId);
|
|
2061
|
+
const astEntry = outlineExample ? scenarioTree.get(outlineExample.scenario.id) : scenarioTree.get(scenarioId);
|
|
2062
|
+
const rule = astEntry?.rule;
|
|
2063
|
+
const feature = featureByScenarioId.get(scenarioId) ?? features.get(pickle.uri);
|
|
1717
2064
|
const stepAttachments = stepRows.flatMap((step) => step.attachments);
|
|
2065
|
+
const hookAttachments = hookRows.flatMap((hook) => hook.attachments);
|
|
1718
2066
|
const extraAttachments = mapAttachments(
|
|
1719
2067
|
startedAttachments.filter((attachment) => !attachment.testStepId)
|
|
1720
2068
|
);
|
|
1721
|
-
const scenarioAttachments = [
|
|
2069
|
+
const scenarioAttachments = [
|
|
2070
|
+
...stepAttachments,
|
|
2071
|
+
...hookAttachments,
|
|
2072
|
+
...extraAttachments
|
|
2073
|
+
];
|
|
2074
|
+
const outline = outlineExample ? {
|
|
2075
|
+
id: outlineExample.scenario.id,
|
|
2076
|
+
keyword: outlineExample.scenario.keyword,
|
|
2077
|
+
name: outlineExample.scenario.name,
|
|
2078
|
+
description: normalizeText2(outlineExample.scenario.description),
|
|
2079
|
+
tags: (outlineExample.scenario.tags ?? []).map((tag) => tag.name),
|
|
2080
|
+
examplesId: outlineExample.examples.id,
|
|
2081
|
+
examplesKeyword: outlineExample.examples.keyword,
|
|
2082
|
+
examplesName: outlineExample.examples.name,
|
|
2083
|
+
examplesDescription: normalizeText2(outlineExample.examples.description),
|
|
2084
|
+
examplesTags: (outlineExample.examples.tags ?? []).map((tag) => tag.name),
|
|
2085
|
+
examplesIndex: outlineExample.examplesIndex,
|
|
2086
|
+
exampleIndex: outlineExample.exampleIndex
|
|
2087
|
+
} : void 0;
|
|
1722
2088
|
const row = {
|
|
1723
2089
|
id: pickle.id,
|
|
1724
2090
|
name: pickle.name,
|
|
@@ -1726,19 +2092,27 @@ function buildReportModel(envelopes) {
|
|
|
1726
2092
|
description: normalizeText2(tree?.scenario.description),
|
|
1727
2093
|
uri: pickle.uri,
|
|
1728
2094
|
featureName: feature?.name ?? pickle.uri,
|
|
1729
|
-
...
|
|
2095
|
+
...rule ? { rule } : {},
|
|
2096
|
+
...rule?.name ? { ruleName: rule.name } : {},
|
|
1730
2097
|
status,
|
|
1731
|
-
|
|
1732
|
-
|
|
2098
|
+
executed,
|
|
2099
|
+
durationMs: finiteDuration(duration2),
|
|
2100
|
+
attempt: Number.isFinite(latest.attempt) ? latest.attempt : 0,
|
|
1733
2101
|
...timestampIso(latest.timestamp) ? { startedAt: timestampIso(latest.timestamp) } : {},
|
|
1734
|
-
tags: pickle.tags.map((tag) => tag.name),
|
|
2102
|
+
ownTags: outlineExample ? (outlineExample.examples.tags ?? []).map((tag) => tag.name) : tree ? (tree.scenario.tags ?? []).map((tag) => tag.name) : (pickle.tags ?? []).map((tag) => tag.name),
|
|
2103
|
+
tags: (pickle.tags ?? []).map((tag) => tag.name),
|
|
2104
|
+
...outline ? { outline } : {},
|
|
1735
2105
|
steps: stepRows,
|
|
2106
|
+
hooks: hookRows,
|
|
1736
2107
|
attachments: scenarioAttachments,
|
|
1737
2108
|
extraAttachments
|
|
1738
2109
|
};
|
|
1739
2110
|
scenarioRows.push(row);
|
|
1740
|
-
|
|
1741
|
-
|
|
2111
|
+
if (executed) {
|
|
2112
|
+
count(scenarioCounts, status);
|
|
2113
|
+
for (const step of stepRows) count(stepCounts, step.status);
|
|
2114
|
+
for (const hook of hookRows) count(hookCounts, hook.status);
|
|
2115
|
+
}
|
|
1742
2116
|
if (feature) {
|
|
1743
2117
|
const list = featureScenarios.get(feature) ?? [];
|
|
1744
2118
|
list.push(row);
|
|
@@ -1746,44 +2120,89 @@ function buildReportModel(envelopes) {
|
|
|
1746
2120
|
}
|
|
1747
2121
|
}
|
|
1748
2122
|
const featureRows = [];
|
|
2123
|
+
const inInputOrder = new Set(featureOrder);
|
|
1749
2124
|
const orderedFeatures = [
|
|
1750
2125
|
...featureOrder,
|
|
1751
|
-
...[...featureScenarios.keys()].filter(
|
|
2126
|
+
...[...featureScenarios.keys()].filter(
|
|
2127
|
+
(feature) => !inInputOrder.has(feature)
|
|
2128
|
+
)
|
|
1752
2129
|
];
|
|
1753
2130
|
for (const feature of orderedFeatures) {
|
|
1754
2131
|
const scenarios = featureScenarios.get(feature) ?? [];
|
|
1755
2132
|
if (scenarios.length === 0) continue;
|
|
1756
|
-
const status = scenarios
|
|
1757
|
-
|
|
1758
|
-
|
|
2133
|
+
const status = worstExecutedStatus(scenarios);
|
|
2134
|
+
const featureUri = featureUris.get(feature) ?? scenarios[0]?.uri ?? "";
|
|
2135
|
+
const sourceFiles = /* @__PURE__ */ new Set([
|
|
2136
|
+
...scenarios.map((scenario) => provenance?.get(scenario.uri)),
|
|
2137
|
+
provenance?.get(featureUri)
|
|
2138
|
+
]);
|
|
2139
|
+
const sourceFile = sourceFiles.size === 1 && !sourceFiles.has(void 0) ? [...sourceFiles][0] : void 0;
|
|
1759
2140
|
featureRows.push({
|
|
1760
2141
|
id: `feature-${featureRows.length + 1}`,
|
|
1761
2142
|
name: feature.name,
|
|
1762
2143
|
keyword: feature.keyword,
|
|
1763
2144
|
uri: scenarios[0]?.uri ?? "",
|
|
1764
2145
|
description: normalizeText2(feature.description),
|
|
1765
|
-
tags: feature.tags.map((tag) => tag.name),
|
|
2146
|
+
tags: (feature.tags ?? []).map((tag) => tag.name),
|
|
2147
|
+
backgrounds: backgroundsOf(feature.children ?? []),
|
|
1766
2148
|
status,
|
|
1767
|
-
durationMs:
|
|
2149
|
+
durationMs: finiteDuration(
|
|
2150
|
+
scenarios.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
2151
|
+
),
|
|
1768
2152
|
scenarios,
|
|
1769
|
-
attachments: scenarios.reduce((sum, scenario) => sum + scenario.attachments.length, 0)
|
|
2153
|
+
attachments: scenarios.reduce((sum, scenario) => sum + scenario.attachments.length, 0),
|
|
2154
|
+
...sourceFile ? { sourceFile } : {}
|
|
1770
2155
|
});
|
|
1771
2156
|
}
|
|
2157
|
+
if (featureRows.some((feature) => !feature.sourceFile)) {
|
|
2158
|
+
for (const feature of featureRows) delete feature.sourceFile;
|
|
2159
|
+
}
|
|
2160
|
+
const runHooks = [];
|
|
2161
|
+
const orderedRunHooks = [...runHookStarts.values()].map((start, index) => ({ start, index })).sort((a, b) => {
|
|
2162
|
+
const seconds = (a.start.timestamp?.seconds ?? 0) - (b.start.timestamp?.seconds ?? 0);
|
|
2163
|
+
if (seconds !== 0) return seconds;
|
|
2164
|
+
const nanos = (a.start.timestamp?.nanos ?? 0) - (b.start.timestamp?.nanos ?? 0);
|
|
2165
|
+
return nanos !== 0 ? nanos : a.index - b.index;
|
|
2166
|
+
});
|
|
2167
|
+
for (const { start } of orderedRunHooks) {
|
|
2168
|
+
const finish = runHookFinishes.get(start.id);
|
|
2169
|
+
const hook = hooks.get(start.hookId);
|
|
2170
|
+
const result = finish?.result;
|
|
2171
|
+
const message = result ? stepResultMessage(result) : "";
|
|
2172
|
+
runHooks.push({
|
|
2173
|
+
id: start.id,
|
|
2174
|
+
type: hookLabel(hook?.type),
|
|
2175
|
+
...hook?.name ? { name: hook.name } : {},
|
|
2176
|
+
status: result ? statusOf2(result.status) : "unknown",
|
|
2177
|
+
durationMs: durationMs(result?.duration),
|
|
2178
|
+
...message ? { message: stripAnsi(message) } : {},
|
|
2179
|
+
attachments: mapAttachments(runHookAttachments.get(start.id) ?? [])
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
for (const hook of runHooks) count(hookCounts, hook.status);
|
|
1772
2183
|
const attachmentRows = scenarioRows.flatMap((scenario) => scenario.attachments);
|
|
1773
2184
|
const runAttachments = mapAttachments(attachments.get("") ?? []);
|
|
1774
|
-
const allAttachments = [
|
|
2185
|
+
const allAttachments = [
|
|
2186
|
+
...attachmentRows,
|
|
2187
|
+
...runHooks.flatMap((hook) => hook.attachments),
|
|
2188
|
+
...runAttachments
|
|
2189
|
+
];
|
|
1775
2190
|
return {
|
|
1776
2191
|
features: featureRows,
|
|
1777
2192
|
scenarios: scenarioRows,
|
|
2193
|
+
runHooks,
|
|
1778
2194
|
runAttachments,
|
|
1779
2195
|
counts: {
|
|
1780
2196
|
features: featureRows.length,
|
|
1781
2197
|
scenarios: scenarioCounts,
|
|
1782
2198
|
steps: stepCounts,
|
|
2199
|
+
hooks: hookCounts,
|
|
1783
2200
|
attachments: allAttachments.length,
|
|
1784
2201
|
attachmentBytes: allAttachments.reduce((sum, attachment) => sum + attachment.bytes, 0)
|
|
1785
2202
|
},
|
|
1786
|
-
durationMs:
|
|
2203
|
+
durationMs: finiteDuration(
|
|
2204
|
+
scenarioRows.reduce((sum, scenario) => sum + scenario.durationMs, 0) + runHooks.reduce((sum, hook) => sum + hook.durationMs, 0)
|
|
2205
|
+
),
|
|
1787
2206
|
...startedAt ? { startedAt } : {},
|
|
1788
2207
|
...finishedAt ? { finishedAt } : {},
|
|
1789
2208
|
source,
|
|
@@ -1792,20 +2211,8 @@ function buildReportModel(envelopes) {
|
|
|
1792
2211
|
}
|
|
1793
2212
|
|
|
1794
2213
|
// src/summary.ts
|
|
1795
|
-
import {
|
|
1796
|
-
|
|
1797
|
-
TestStepResultStatus as TestStepResultStatus4
|
|
1798
|
-
} from "@cucumber/messages";
|
|
1799
|
-
var SUMMARY_SCHEMA_VERSION = 1;
|
|
1800
|
-
var STATUS_ORDER2 = [
|
|
1801
|
-
TestStepResultStatus4.UNKNOWN,
|
|
1802
|
-
TestStepResultStatus4.PASSED,
|
|
1803
|
-
TestStepResultStatus4.SKIPPED,
|
|
1804
|
-
TestStepResultStatus4.PENDING,
|
|
1805
|
-
TestStepResultStatus4.UNDEFINED,
|
|
1806
|
-
TestStepResultStatus4.AMBIGUOUS,
|
|
1807
|
-
TestStepResultStatus4.FAILED
|
|
1808
|
-
];
|
|
2214
|
+
import { getWorstTestStepResult as getWorstTestStepResult2 } from "@cucumber/messages";
|
|
2215
|
+
var SUMMARY_SCHEMA_VERSION = 2;
|
|
1809
2216
|
var VALID_STATUSES = /* @__PURE__ */ new Set([
|
|
1810
2217
|
"passed",
|
|
1811
2218
|
"failed",
|
|
@@ -1861,23 +2268,32 @@ function durationMs2(duration2) {
|
|
|
1861
2268
|
if (!duration2) return 0;
|
|
1862
2269
|
const seconds = Number.isFinite(duration2.seconds) ? duration2.seconds : 0;
|
|
1863
2270
|
const nanos = Number.isFinite(duration2.nanos) ? duration2.nanos : 0;
|
|
1864
|
-
|
|
2271
|
+
const milliseconds = seconds * 1e3 + nanos / 1e6;
|
|
2272
|
+
if (!Number.isFinite(milliseconds) || milliseconds <= 0) return 0;
|
|
2273
|
+
const rounded = Math.round(milliseconds * 1e3) / 1e3;
|
|
2274
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
2275
|
+
}
|
|
2276
|
+
function finiteDuration2(value) {
|
|
2277
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
2278
|
+
const rounded = Math.round(value * 1e3) / 1e3;
|
|
2279
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1865
2280
|
}
|
|
1866
2281
|
function scenarioStatus(results) {
|
|
1867
2282
|
if (results.length === 0) return "unknown";
|
|
1868
2283
|
return toStatus(getWorstTestStepResult2(results).status);
|
|
1869
2284
|
}
|
|
1870
|
-
function statusOrdinal(status) {
|
|
1871
|
-
return STATUS_ORDER2.indexOf(status.toUpperCase());
|
|
1872
|
-
}
|
|
1873
2285
|
function displayUri(uri) {
|
|
1874
|
-
const normalized = uri.replace(/\\/g, "/");
|
|
2286
|
+
const normalized = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
1875
2287
|
if (!/^[a-z]:\//i.test(normalized) && !normalized.startsWith("/")) {
|
|
1876
2288
|
return normalized;
|
|
1877
2289
|
}
|
|
1878
2290
|
const marker = normalized.lastIndexOf("/features/");
|
|
1879
2291
|
if (marker >= 0) return normalized.slice(marker + 1);
|
|
1880
|
-
|
|
2292
|
+
const parts = normalized.replace(/^[a-z]:/i, "").split("/").filter(Boolean);
|
|
2293
|
+
if (parts.length > 1 && /^(Users|home|Documents and Settings)$/i.test(parts[0] ?? "")) {
|
|
2294
|
+
parts.splice(0, 2);
|
|
2295
|
+
}
|
|
2296
|
+
return parts.slice(-3).join("/") || uri;
|
|
1881
2297
|
}
|
|
1882
2298
|
function featureTree2(document) {
|
|
1883
2299
|
const stepKeywords = /* @__PURE__ */ new Map();
|
|
@@ -1915,11 +2331,14 @@ function summarizeEnvelopes(input) {
|
|
|
1915
2331
|
const testCasesByPickle = /* @__PURE__ */ new Map();
|
|
1916
2332
|
const startedByTestCase = /* @__PURE__ */ new Map();
|
|
1917
2333
|
const hooks = /* @__PURE__ */ new Map();
|
|
2334
|
+
const runHookStarts = /* @__PURE__ */ new Map();
|
|
2335
|
+
const runHookFinishes = /* @__PURE__ */ new Map();
|
|
1918
2336
|
const results = /* @__PURE__ */ new Map();
|
|
1919
2337
|
const attachments = /* @__PURE__ */ new Map();
|
|
1920
2338
|
const attachmentList = [];
|
|
1921
|
-
const finishedIds = /* @__PURE__ */ new Set();
|
|
1922
2339
|
const scenarioFeatures = /* @__PURE__ */ new Map();
|
|
2340
|
+
const suggestions = /* @__PURE__ */ new Map();
|
|
2341
|
+
const stepDefinitions = /* @__PURE__ */ new Map();
|
|
1923
2342
|
const indexFeature = (feature) => {
|
|
1924
2343
|
const visit = (children) => {
|
|
1925
2344
|
for (const child of children) {
|
|
@@ -1948,10 +2367,16 @@ function summarizeEnvelopes(input) {
|
|
|
1948
2367
|
list.push(envelope.testCaseStarted);
|
|
1949
2368
|
startedByTestCase.set(envelope.testCaseStarted.testCaseId, list);
|
|
1950
2369
|
}
|
|
1951
|
-
if (envelope.testCaseFinished) {
|
|
1952
|
-
finishedIds.add(envelope.testCaseFinished.testCaseStartedId);
|
|
1953
|
-
}
|
|
1954
2370
|
if (envelope.hook) hooks.set(envelope.hook.id, envelope.hook);
|
|
2371
|
+
if (envelope.testRunHookStarted) {
|
|
2372
|
+
runHookStarts.set(envelope.testRunHookStarted.id, envelope.testRunHookStarted);
|
|
2373
|
+
}
|
|
2374
|
+
if (envelope.testRunHookFinished) {
|
|
2375
|
+
runHookFinishes.set(
|
|
2376
|
+
envelope.testRunHookFinished.testRunHookStartedId,
|
|
2377
|
+
envelope.testRunHookFinished
|
|
2378
|
+
);
|
|
2379
|
+
}
|
|
1955
2380
|
if (envelope.testStepFinished) {
|
|
1956
2381
|
const list = results.get(envelope.testStepFinished.testCaseStartedId) ?? [];
|
|
1957
2382
|
list.push(envelope.testStepFinished);
|
|
@@ -1966,6 +2391,28 @@ function summarizeEnvelopes(input) {
|
|
|
1966
2391
|
attachments.set(startedId, list);
|
|
1967
2392
|
}
|
|
1968
2393
|
}
|
|
2394
|
+
if (envelope.suggestion) {
|
|
2395
|
+
const snippets = Array.isArray(envelope.suggestion.snippets) ? envelope.suggestion.snippets : [];
|
|
2396
|
+
const list = snippets.filter((snippet) => typeof snippet?.code === "string").map((snippet) => ({
|
|
2397
|
+
...typeof snippet.language === "string" && snippet.language ? { language: snippet.language } : {},
|
|
2398
|
+
code: snippet.code
|
|
2399
|
+
}));
|
|
2400
|
+
if (list.length > 0) suggestions.set(envelope.suggestion.pickleStepId, list);
|
|
2401
|
+
}
|
|
2402
|
+
if (envelope.stepDefinition) {
|
|
2403
|
+
const pattern = envelope.stepDefinition.pattern;
|
|
2404
|
+
if (typeof pattern?.source === "string") {
|
|
2405
|
+
const reference = envelope.stepDefinition.sourceReference;
|
|
2406
|
+
const uri = typeof reference?.uri === "string" ? reference.uri : "";
|
|
2407
|
+
const line = typeof reference?.location?.line === "number" ? reference.location.line : void 0;
|
|
2408
|
+
const display = displayUri(uri);
|
|
2409
|
+
const source = display ? line ? `${display}:${line}` : display : void 0;
|
|
2410
|
+
stepDefinitions.set(envelope.stepDefinition.id, {
|
|
2411
|
+
pattern: pattern.source,
|
|
2412
|
+
...source ? { source } : {}
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
1969
2416
|
}
|
|
1970
2417
|
const treeCache = /* @__PURE__ */ new Map();
|
|
1971
2418
|
const treeOf = (feature) => {
|
|
@@ -1981,12 +2428,8 @@ function summarizeEnvelopes(input) {
|
|
|
1981
2428
|
const candidates = testCases.flatMap(
|
|
1982
2429
|
(testCase) => startedByTestCase.get(testCase.id) ?? []
|
|
1983
2430
|
);
|
|
1984
|
-
const finishedCandidates = candidates.filter(
|
|
1985
|
-
(candidate) => finishedIds.has(candidate.id)
|
|
1986
|
-
);
|
|
1987
|
-
const pool = finishedCandidates.length ? finishedCandidates : candidates.filter((candidate) => (results.get(candidate.id)?.length ?? 0) > 0);
|
|
1988
2431
|
let latest;
|
|
1989
|
-
for (const candidate of
|
|
2432
|
+
for (const candidate of candidates) {
|
|
1990
2433
|
if (!latest) {
|
|
1991
2434
|
latest = candidate;
|
|
1992
2435
|
continue;
|
|
@@ -2006,7 +2449,8 @@ function summarizeEnvelopes(input) {
|
|
|
2006
2449
|
const testCases = testCasesByPickle.get(pickle.id) ?? [];
|
|
2007
2450
|
const testSteps = testCases.flatMap((testCase) => testCase.testSteps);
|
|
2008
2451
|
const started = latestByPickle.get(pickle.id);
|
|
2009
|
-
|
|
2452
|
+
if (!started) continue;
|
|
2453
|
+
const finished = results.get(started.id) ?? [];
|
|
2010
2454
|
const resultByStep = new Map(
|
|
2011
2455
|
finished.map((entry) => [entry.testStepId, entry.testStepResult])
|
|
2012
2456
|
);
|
|
@@ -2024,37 +2468,50 @@ function summarizeEnvelopes(input) {
|
|
|
2024
2468
|
if (testStep.pickleStepId) {
|
|
2025
2469
|
const pickleStep = pickleSteps.get(testStep.pickleStepId);
|
|
2026
2470
|
const astNodeId = pickleStep?.astNodeIds[0];
|
|
2471
|
+
const status2 = toStatus(result.status);
|
|
2472
|
+
const stepSuggestions = status2 === "undefined" ? suggestions.get(testStep.pickleStepId) ?? [] : [];
|
|
2473
|
+
const definitionIds = status2 === "ambiguous" && Array.isArray(testStep.stepDefinitionIds) ? testStep.stepDefinitionIds : [];
|
|
2474
|
+
const stepMatches = definitionIds.map((id) => stepDefinitions.get(id)).filter(
|
|
2475
|
+
(definition) => Boolean(definition)
|
|
2476
|
+
);
|
|
2027
2477
|
steps.push({
|
|
2028
2478
|
keyword: astNodeId ? (tree.stepKeywords.get(astNodeId) ?? "").trim() : "",
|
|
2029
2479
|
text: pickleStep?.text ?? "",
|
|
2030
|
-
status:
|
|
2480
|
+
status: status2,
|
|
2031
2481
|
durationMs: durationMs2(result.duration),
|
|
2032
|
-
...message ? { message } : {}
|
|
2482
|
+
...message ? { message: stripAnsi(message) } : {},
|
|
2483
|
+
...stepSuggestions.length > 0 ? { suggestions: stepSuggestions } : {},
|
|
2484
|
+
...stepMatches.length > 0 ? { definitions: stepMatches } : {}
|
|
2033
2485
|
});
|
|
2034
2486
|
} else if (testStep.hookId) {
|
|
2035
2487
|
const hook = hooks.get(testStep.hookId);
|
|
2036
2488
|
steps.push({
|
|
2037
2489
|
keyword: "Hook",
|
|
2038
2490
|
text: hook?.type ?? "hook",
|
|
2491
|
+
...hook?.name ? { name: hook.name } : {},
|
|
2039
2492
|
status: toStatus(result.status),
|
|
2040
2493
|
durationMs: durationMs2(result.duration),
|
|
2041
|
-
...message ? { message } : {}
|
|
2494
|
+
...message ? { message: stripAnsi(message) } : {}
|
|
2042
2495
|
});
|
|
2043
2496
|
}
|
|
2044
2497
|
}
|
|
2045
2498
|
const status = scenarioStatus(finished.map((entry) => entry.testStepResult));
|
|
2499
|
+
const executed = finished.length > 0;
|
|
2046
2500
|
const scenarioDuration = steps.reduce((sum, step) => sum + step.durationMs, 0);
|
|
2047
|
-
const scenarioAttachments =
|
|
2501
|
+
const scenarioAttachments = executed ? attachments.get(started.id) ?? [] : [];
|
|
2048
2502
|
for (const attachment of scenarioAttachments) countedAttachments.add(attachment);
|
|
2049
|
-
|
|
2050
|
-
|
|
2503
|
+
if (executed) {
|
|
2504
|
+
countStatus(scenarioCounts, status);
|
|
2505
|
+
for (const step of steps) countStatus(stepCounts, step.status);
|
|
2506
|
+
}
|
|
2051
2507
|
totalDuration += scenarioDuration;
|
|
2052
2508
|
scenarios.push({
|
|
2053
2509
|
name: pickle.name ?? "",
|
|
2054
2510
|
uri: displayUri(pickle.uri ?? ""),
|
|
2055
2511
|
feature: tree.featureName,
|
|
2056
2512
|
status,
|
|
2057
|
-
|
|
2513
|
+
executed,
|
|
2514
|
+
durationMs: finiteDuration2(scenarioDuration),
|
|
2058
2515
|
attempt: started?.attempt ?? 0,
|
|
2059
2516
|
tags: (pickle.tags ?? []).map((tag) => tag.name),
|
|
2060
2517
|
attachments: scenarioAttachments.length,
|
|
@@ -2064,17 +2521,26 @@ function summarizeEnvelopes(input) {
|
|
|
2064
2521
|
scenarios.sort(
|
|
2065
2522
|
(a, b) => a.uri.localeCompare(b.uri) || a.name.localeCompare(b.name)
|
|
2066
2523
|
);
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
|
|
2524
|
+
const runHookResults = [];
|
|
2525
|
+
for (const start of runHookStarts.values()) {
|
|
2526
|
+
const result = runHookFinishes.get(start.id)?.result;
|
|
2527
|
+
if (result) runHookResults.push(result);
|
|
2528
|
+
}
|
|
2529
|
+
const runHookStatus = scenarioStatus(runHookResults);
|
|
2530
|
+
totalDuration += runHookResults.reduce(
|
|
2531
|
+
(sum, result) => sum + durationMs2(result.duration),
|
|
2532
|
+
0
|
|
2070
2533
|
);
|
|
2534
|
+
const executedScenarios = scenarios.filter((scenario) => scenario.executed);
|
|
2535
|
+
const scenarioOverall = worstExecutedStatus(executedScenarios);
|
|
2536
|
+
const overall = executedScenarios.length === 0 ? runHookStatus === "failed" ? "failed" : "unknown" : statusSeverity(runHookStatus) > statusSeverity(scenarioOverall) ? runHookStatus : scenarioOverall;
|
|
2071
2537
|
const orphanAttachments = attachmentList.filter(
|
|
2072
2538
|
(attachment) => !attachment.testCaseStartedId || countedAttachments.has(attachment)
|
|
2073
2539
|
);
|
|
2074
2540
|
return {
|
|
2075
2541
|
schemaVersion: SUMMARY_SCHEMA_VERSION,
|
|
2076
2542
|
status: overall,
|
|
2077
|
-
durationMs:
|
|
2543
|
+
durationMs: finiteDuration2(totalDuration),
|
|
2078
2544
|
counts: {
|
|
2079
2545
|
features: featureSet.size,
|
|
2080
2546
|
scenarios: scenarioCounts,
|
|
@@ -2107,7 +2573,7 @@ function isLogoDataUri(value) {
|
|
|
2107
2573
|
|
|
2108
2574
|
// src/render/escape.ts
|
|
2109
2575
|
function escapeHtml(value) {
|
|
2110
|
-
return value.replace(/[&<>"']/g, (character) => {
|
|
2576
|
+
return stripBidiControls(String(value ?? "")).replace(/[&<>"']/g, (character) => {
|
|
2111
2577
|
switch (character) {
|
|
2112
2578
|
case "&":
|
|
2113
2579
|
return "&";
|
|
@@ -2125,6 +2591,271 @@ function escapeHtml(value) {
|
|
|
2125
2591
|
});
|
|
2126
2592
|
}
|
|
2127
2593
|
|
|
2594
|
+
// src/render/ansi.ts
|
|
2595
|
+
function xtermColor(value) {
|
|
2596
|
+
const index = Math.max(16, Math.min(255, Math.floor(value)));
|
|
2597
|
+
if (index < 232) {
|
|
2598
|
+
const offset = index - 16;
|
|
2599
|
+
const component = (step) => (step === 0 ? 0 : 55 + step * 40).toString(16).padStart(2, "0");
|
|
2600
|
+
return `#${component(Math.floor(offset / 36))}${component(
|
|
2601
|
+
Math.floor(offset % 36 / 6)
|
|
2602
|
+
)}${component(offset % 6)}`;
|
|
2603
|
+
}
|
|
2604
|
+
const grey = 8 + (index - 232) * 10;
|
|
2605
|
+
const hex = Math.min(255, grey).toString(16).padStart(2, "0");
|
|
2606
|
+
return `#${hex}${hex}${hex}`;
|
|
2607
|
+
}
|
|
2608
|
+
function rgbColor(red, green, blue) {
|
|
2609
|
+
const channel = (value) => Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
2610
|
+
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
2611
|
+
}
|
|
2612
|
+
function applyIndexedColor(style, foreground, value) {
|
|
2613
|
+
if (value < 16) {
|
|
2614
|
+
if (foreground) {
|
|
2615
|
+
style.fgClass = `ansi-fg-${value}`;
|
|
2616
|
+
delete style.fgColor;
|
|
2617
|
+
} else {
|
|
2618
|
+
style.bgClass = `ansi-bg-${value}`;
|
|
2619
|
+
delete style.bgColor;
|
|
2620
|
+
}
|
|
2621
|
+
return;
|
|
2622
|
+
}
|
|
2623
|
+
const color = xtermColor(value);
|
|
2624
|
+
if (foreground) {
|
|
2625
|
+
style.fgColor = color;
|
|
2626
|
+
delete style.fgClass;
|
|
2627
|
+
} else {
|
|
2628
|
+
style.bgColor = color;
|
|
2629
|
+
delete style.bgClass;
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
function applySgr(style, raw) {
|
|
2633
|
+
const parts = raw === "" ? ["0"] : raw.split(";");
|
|
2634
|
+
for (let index = 0; index < parts.length; index += 1) {
|
|
2635
|
+
const code = parts[index] === "" ? 0 : Number(parts[index]);
|
|
2636
|
+
if (!Number.isFinite(code)) continue;
|
|
2637
|
+
if (code === 0) {
|
|
2638
|
+
delete style.fgClass;
|
|
2639
|
+
delete style.bgClass;
|
|
2640
|
+
delete style.fgColor;
|
|
2641
|
+
delete style.bgColor;
|
|
2642
|
+
delete style.bold;
|
|
2643
|
+
delete style.dim;
|
|
2644
|
+
delete style.italic;
|
|
2645
|
+
delete style.underline;
|
|
2646
|
+
} else if (code === 1) {
|
|
2647
|
+
style.bold = true;
|
|
2648
|
+
} else if (code === 2) {
|
|
2649
|
+
style.dim = true;
|
|
2650
|
+
} else if (code === 3) {
|
|
2651
|
+
style.italic = true;
|
|
2652
|
+
} else if (code === 4) {
|
|
2653
|
+
style.underline = true;
|
|
2654
|
+
} else if (code === 22) {
|
|
2655
|
+
delete style.bold;
|
|
2656
|
+
delete style.dim;
|
|
2657
|
+
} else if (code === 23) {
|
|
2658
|
+
delete style.italic;
|
|
2659
|
+
} else if (code === 24) {
|
|
2660
|
+
delete style.underline;
|
|
2661
|
+
} else if (code >= 30 && code <= 37) {
|
|
2662
|
+
style.fgClass = `ansi-fg-${code - 30}`;
|
|
2663
|
+
delete style.fgColor;
|
|
2664
|
+
} else if (code === 39) {
|
|
2665
|
+
delete style.fgClass;
|
|
2666
|
+
delete style.fgColor;
|
|
2667
|
+
} else if (code >= 40 && code <= 47) {
|
|
2668
|
+
style.bgClass = `ansi-bg-${code - 40}`;
|
|
2669
|
+
delete style.bgColor;
|
|
2670
|
+
} else if (code === 49) {
|
|
2671
|
+
delete style.bgClass;
|
|
2672
|
+
delete style.bgColor;
|
|
2673
|
+
} else if (code >= 90 && code <= 97) {
|
|
2674
|
+
style.fgClass = `ansi-fg-${code - 90 + 8}`;
|
|
2675
|
+
delete style.fgColor;
|
|
2676
|
+
} else if (code >= 100 && code <= 107) {
|
|
2677
|
+
style.bgClass = `ansi-bg-${code - 100 + 8}`;
|
|
2678
|
+
delete style.bgColor;
|
|
2679
|
+
} else if (code === 38 || code === 48) {
|
|
2680
|
+
const mode = Number(parts[index + 1]);
|
|
2681
|
+
const foreground = code === 38;
|
|
2682
|
+
if (mode === 5 && index + 2 < parts.length) {
|
|
2683
|
+
const color = Number(parts[index + 2]);
|
|
2684
|
+
if (Number.isFinite(color)) {
|
|
2685
|
+
applyIndexedColor(style, foreground, color);
|
|
2686
|
+
}
|
|
2687
|
+
index += 2;
|
|
2688
|
+
} else if (mode === 2 && index + 4 < parts.length) {
|
|
2689
|
+
const red = Number(parts[index + 2]);
|
|
2690
|
+
const green = Number(parts[index + 3]);
|
|
2691
|
+
const blue = Number(parts[index + 4]);
|
|
2692
|
+
if (Number.isFinite(red) && Number.isFinite(green) && Number.isFinite(blue)) {
|
|
2693
|
+
const value = rgbColor(red, green, blue);
|
|
2694
|
+
if (foreground) {
|
|
2695
|
+
style.fgColor = value;
|
|
2696
|
+
delete style.fgClass;
|
|
2697
|
+
} else {
|
|
2698
|
+
style.bgColor = value;
|
|
2699
|
+
delete style.bgClass;
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
index += 4;
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
function hasStyle(style) {
|
|
2708
|
+
return Boolean(
|
|
2709
|
+
style.fgClass || style.bgClass || style.fgColor || style.bgColor || style.bold || style.dim || style.italic || style.underline
|
|
2710
|
+
);
|
|
2711
|
+
}
|
|
2712
|
+
function spanMarkup(style) {
|
|
2713
|
+
const classes = ["ansi"];
|
|
2714
|
+
if (style.fgClass) classes.push(style.fgClass);
|
|
2715
|
+
if (style.bgClass) classes.push(style.bgClass);
|
|
2716
|
+
if ((style.bgClass || style.bgColor) && !(style.fgClass || style.fgColor)) {
|
|
2717
|
+
classes.push("ansi-bg-only");
|
|
2718
|
+
}
|
|
2719
|
+
if (style.bold) classes.push("ansi-bold");
|
|
2720
|
+
if (style.dim) classes.push("ansi-dim");
|
|
2721
|
+
if (style.italic) classes.push("ansi-italic");
|
|
2722
|
+
if (style.underline) classes.push("ansi-underline");
|
|
2723
|
+
const css = [];
|
|
2724
|
+
if (style.fgColor) {
|
|
2725
|
+
classes.push("ansi-inline-fg");
|
|
2726
|
+
css.push(`--ansi-fg:${style.fgColor}`);
|
|
2727
|
+
}
|
|
2728
|
+
if (style.bgColor) {
|
|
2729
|
+
classes.push("ansi-inline-bg");
|
|
2730
|
+
css.push(`--ansi-bg:${style.bgColor}`);
|
|
2731
|
+
}
|
|
2732
|
+
const attributes = css.length ? ` style="${css.join(";")}"` : "";
|
|
2733
|
+
return `<span class="${classes.join(" ")}"${attributes}>`;
|
|
2734
|
+
}
|
|
2735
|
+
function ansiToHtml(text, colorize) {
|
|
2736
|
+
let output = "";
|
|
2737
|
+
let buffer = "";
|
|
2738
|
+
let style = {};
|
|
2739
|
+
let spanOpen = false;
|
|
2740
|
+
const flush = () => {
|
|
2741
|
+
if (buffer) {
|
|
2742
|
+
output += escapeHtml(buffer);
|
|
2743
|
+
buffer = "";
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
const closeSpan = () => {
|
|
2747
|
+
if (!spanOpen) return;
|
|
2748
|
+
flush();
|
|
2749
|
+
output += "</span>";
|
|
2750
|
+
spanOpen = false;
|
|
2751
|
+
};
|
|
2752
|
+
const openSpan = () => {
|
|
2753
|
+
closeSpan();
|
|
2754
|
+
if (!colorize || !hasStyle(style)) return;
|
|
2755
|
+
output += spanMarkup(style);
|
|
2756
|
+
spanOpen = true;
|
|
2757
|
+
};
|
|
2758
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
2759
|
+
const character = text[index] ?? "";
|
|
2760
|
+
const code = text.charCodeAt(index);
|
|
2761
|
+
if (isEscapeIntroducer(code)) {
|
|
2762
|
+
const scan = scanEscape(text, index);
|
|
2763
|
+
if (scan.sgr !== void 0) {
|
|
2764
|
+
flush();
|
|
2765
|
+
if (colorize) applySgr(style, scan.sgr);
|
|
2766
|
+
openSpan();
|
|
2767
|
+
}
|
|
2768
|
+
index = scan.end - 1;
|
|
2769
|
+
continue;
|
|
2770
|
+
}
|
|
2771
|
+
if (character === "\x07" || code === 127 || code < 32 && character !== "\n" && character !== " " || code >= 128 && code <= 159) {
|
|
2772
|
+
continue;
|
|
2773
|
+
}
|
|
2774
|
+
buffer += character;
|
|
2775
|
+
}
|
|
2776
|
+
closeSpan();
|
|
2777
|
+
flush();
|
|
2778
|
+
return output;
|
|
2779
|
+
}
|
|
2780
|
+
function renderAnsiLog(text) {
|
|
2781
|
+
return ansiToHtml(
|
|
2782
|
+
text,
|
|
2783
|
+
Buffer.byteLength(text, "utf8") <= MAX_TEXT_ATTACHMENT_BYTES
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
// src/render/client-bundle.ts
|
|
2788
|
+
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';
|
|
2789
|
+
|
|
2790
|
+
// src/render/markdown.ts
|
|
2791
|
+
import MarkdownIt from "markdown-it";
|
|
2792
|
+
var markdown = new MarkdownIt({
|
|
2793
|
+
html: false,
|
|
2794
|
+
linkify: false,
|
|
2795
|
+
typographer: false,
|
|
2796
|
+
breaks: true
|
|
2797
|
+
});
|
|
2798
|
+
var SAFE_LINK = /^(?:https?:\/\/|mailto:)/i;
|
|
2799
|
+
var SAFE_IMAGE = /^(?:https?:\/\/|mailto:|data:image\/|\.{0,2}\/)/i;
|
|
2800
|
+
markdown.validateLink = (url) => SAFE_LINK.test(url) || SAFE_IMAGE.test(url);
|
|
2801
|
+
markdown.renderer.rules.link_open = (tokens, index, options, _env, self) => {
|
|
2802
|
+
tokens[index]?.attrSet("rel", "noopener noreferrer nofollow");
|
|
2803
|
+
return self.renderToken(tokens, index, options);
|
|
2804
|
+
};
|
|
2805
|
+
markdown.renderer.rules.image = (tokens, index) => markdown.utils.escapeHtml(String(tokens[index]?.content ?? ""));
|
|
2806
|
+
markdown.core.ruler.push("tolkira_link_policy", (state) => {
|
|
2807
|
+
for (const token of state.tokens) {
|
|
2808
|
+
const children = token.children;
|
|
2809
|
+
if (!children) continue;
|
|
2810
|
+
const stack = [];
|
|
2811
|
+
const suppressed = /* @__PURE__ */ new Set();
|
|
2812
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
2813
|
+
const child = children[index];
|
|
2814
|
+
if (!child) continue;
|
|
2815
|
+
if (child.type === "link_open") {
|
|
2816
|
+
const href = String(child.attrGet("href") ?? "");
|
|
2817
|
+
stack.push({ open: index, safe: SAFE_LINK.test(href), image: false });
|
|
2818
|
+
} else if (child.type === "image" && stack.length > 0) {
|
|
2819
|
+
const link = stack[stack.length - 1];
|
|
2820
|
+
if (link) link.image = true;
|
|
2821
|
+
} else if (child.type === "link_close") {
|
|
2822
|
+
const link = stack.pop();
|
|
2823
|
+
if (link && (!link.safe || link.image)) {
|
|
2824
|
+
suppressed.add(link.open);
|
|
2825
|
+
suppressed.add(index);
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
if (suppressed.size > 0) {
|
|
2830
|
+
token.children = children.filter((_, index) => !suppressed.has(index));
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
});
|
|
2834
|
+
var HEADING_LEVELS = {
|
|
2835
|
+
h1: "h3",
|
|
2836
|
+
h2: "h4",
|
|
2837
|
+
h3: "h4",
|
|
2838
|
+
h4: "h4",
|
|
2839
|
+
h5: "h4",
|
|
2840
|
+
h6: "h4"
|
|
2841
|
+
};
|
|
2842
|
+
for (const type of ["heading_open", "heading_close"]) {
|
|
2843
|
+
const defaultRule = markdown.renderer.rules[type];
|
|
2844
|
+
markdown.renderer.rules[type] = (tokens, index, options, env, self) => {
|
|
2845
|
+
const token = tokens[index];
|
|
2846
|
+
if (token) {
|
|
2847
|
+
token.tag = HEADING_LEVELS[token.tag] ?? token.tag;
|
|
2848
|
+
}
|
|
2849
|
+
return defaultRule ? defaultRule(tokens, index, options, env, self) : self.renderToken(tokens, index, options);
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
markdown.renderer.rules.table_open = () => '<div class="tableWrap" tabindex="0" role="region" aria-label="Description table"><table>';
|
|
2853
|
+
markdown.renderer.rules.table_close = () => "</table></div>";
|
|
2854
|
+
function renderDescription(description) {
|
|
2855
|
+
if (!description || !description.trim()) return "";
|
|
2856
|
+
return `<div class="description">${markdown.render(description)}</div>`;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2128
2859
|
// src/render/styles.ts
|
|
2129
2860
|
var REPORT_CSS = `:root {
|
|
2130
2861
|
color-scheme: light;
|
|
@@ -2159,6 +2890,22 @@ var REPORT_CSS = `:root {
|
|
|
2159
2890
|
--radius: 10px;
|
|
2160
2891
|
--radius-control: 6px;
|
|
2161
2892
|
--shadow: none;
|
|
2893
|
+
--ansi-fg-0: #24292f;
|
|
2894
|
+
--ansi-fg-1: #b91c1c;
|
|
2895
|
+
--ansi-fg-2: #15803d;
|
|
2896
|
+
--ansi-fg-3: #965c05;
|
|
2897
|
+
--ansi-fg-4: #1d4ed8;
|
|
2898
|
+
--ansi-fg-5: #a21caf;
|
|
2899
|
+
--ansi-fg-6: #0e7490;
|
|
2900
|
+
--ansi-fg-7: #4b5563;
|
|
2901
|
+
--ansi-fg-8: #5b6673;
|
|
2902
|
+
--ansi-fg-9: #d11f1f;
|
|
2903
|
+
--ansi-fg-10: #0f7d38;
|
|
2904
|
+
--ansi-fg-11: #906000;
|
|
2905
|
+
--ansi-fg-12: #2563eb;
|
|
2906
|
+
--ansi-fg-13: #b01ec0;
|
|
2907
|
+
--ansi-fg-14: #0a7697;
|
|
2908
|
+
--ansi-fg-15: #111827;
|
|
2162
2909
|
}
|
|
2163
2910
|
* { box-sizing: border-box; }
|
|
2164
2911
|
html { background: var(--paper); scroll-padding-top: 4.5rem; scrollbar-gutter: stable; }
|
|
@@ -2217,13 +2964,56 @@ img, video { max-width: 100%; height: auto; }
|
|
|
2217
2964
|
.expand { display: flex; gap: 0.25rem; margin-left: auto; }
|
|
2218
2965
|
.expand button { min-height: 1.875rem; padding: 0 0.5rem; border: 0; background: transparent; color: var(--muted); font-size: 0.75rem; text-decoration: underline; text-underline-offset: 0.16em; }
|
|
2219
2966
|
.live { margin: 0.625rem 0 0; color: var(--muted); font-size: 0.75rem; }
|
|
2967
|
+
.searchNote { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.75rem; }
|
|
2968
|
+
.triageBox { margin: 1.25rem 0 1.5rem; }
|
|
2969
|
+
.triageBox > summary { display: none; }
|
|
2970
|
+
.triageSummary { align-items: baseline; gap: 0.25rem 0.5rem; }
|
|
2971
|
+
.triageSummary .triageTitle { font-weight: 600; }
|
|
2972
|
+
.triageSummaryLead { color: var(--muted); font-size: 0.8125rem; }
|
|
2973
|
+
.triageSummary .chev { margin-left: auto; }
|
|
2974
|
+
.triageBox .triage { margin: 0; }
|
|
2975
|
+
.triage { margin: 1.25rem 0 1.5rem; padding: 1.125rem 1.25rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); }
|
|
2976
|
+
.triage h2 { margin: 0; font-size: 1.125rem; line-height: 1.3; }
|
|
2977
|
+
.triageLead { margin: 0.25rem 0 0.875rem; color: var(--muted); font-size: 0.8125rem; }
|
|
2978
|
+
.triageList { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.875rem; }
|
|
2979
|
+
.triageItem { display: grid; gap: 0.25rem; min-width: 0; padding-top: 0.875rem; border-top: 1px solid var(--line); }
|
|
2980
|
+
.triageItem:first-child { padding-top: 0; border-top: 0; }
|
|
2981
|
+
.triageFeature { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0.375rem 0.5rem; min-width: 0; min-height: 1.5rem; padding-block: 0.125rem; color: var(--ink); font-size: 0.875rem; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
|
|
2982
|
+
.triageFeature:hover { text-decoration: underline; text-underline-offset: 0.16em; }
|
|
2983
|
+
.triageCounts { margin: 0; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
2984
|
+
.triageScenarios { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.875rem; margin: 0.125rem 0 0; padding: 0; list-style: none; }
|
|
2985
|
+
.triageScenarios a { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: baseline; gap: 0 0.375rem; min-width: 0; min-height: 1.5rem; padding-block: 0.125rem; color: var(--ink-2); font-size: 0.8125rem; text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--line-strong) 70%, transparent); text-underline-offset: 0.16em; overflow-wrap: anywhere; }
|
|
2986
|
+
.triageScenarios a:hover { color: var(--ink); text-decoration-color: currentColor; }
|
|
2987
|
+
.triageStatus { flex: none; font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.01em; }
|
|
2988
|
+
.triageStatus.pass { color: var(--pass); } .triageStatus.fail { color: var(--fail); } .triageStatus.pending { color: var(--pending); } .triageStatus.undefined { color: var(--undefined); } .triageStatus.ambiguous, .triageStatus.skipped, .triageStatus.unknown { color: var(--muted); }
|
|
2989
|
+
.triageMore { color: var(--muted); font-size: 0.75rem; }
|
|
2990
|
+
.triageReason { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
|
|
2991
|
+
.triageReasonLabel { color: var(--ink-2); font-weight: 500; }
|
|
2992
|
+
.triageRest { margin-top: 0.75rem; }
|
|
2993
|
+
.triageRest > summary { min-height: 1.5rem; padding-block: 0.125rem; color: var(--accent-text); font-size: 0.8125rem; cursor: pointer; }
|
|
2994
|
+
.triageRest .triageList { margin-top: 0.75rem; }
|
|
2995
|
+
.sources { margin: 0 0 1.5rem; }
|
|
2996
|
+
.sources h2 { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
|
|
2997
|
+
.sourceList { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
|
|
2998
|
+
.sourceItem { min-width: 0; padding: 0.75rem 0.875rem; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-2); }
|
|
2999
|
+
.sourceHead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.5rem; }
|
|
3000
|
+
.sourceName { color: var(--ink); font-size: 0.8125rem; font-weight: 600; overflow-wrap: anywhere; }
|
|
3001
|
+
.sourceCounts { margin: 0.25rem 0 0.5rem; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
3002
|
+
.sourceItem .bar { margin: 0; height: 0.25rem; }
|
|
2220
3003
|
.feature { border-bottom: 1px solid var(--line-strong); background: transparent; container-type: inline-size; }
|
|
2221
|
-
.feature > summary { display: grid; grid-template-columns: minmax(5.5rem, max-content) minmax(0, 1fr)
|
|
3004
|
+
.feature > summary { display: grid; grid-template-columns: minmax(5.5rem, max-content) minmax(0, 1fr) 1.25rem; gap: 0.25rem 0.75rem; align-items: start; padding: 1rem 0; list-style: none; cursor: pointer; }
|
|
3005
|
+
.feature > summary .statusCell { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
|
|
3006
|
+
.feature > summary h2 { grid-column: 2; grid-row: 1; }
|
|
3007
|
+
.feature > summary .chev { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
|
|
3008
|
+
.featureShape { grid-column: 2; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; min-width: 0; }
|
|
3009
|
+
.featureCounts { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
3010
|
+
.featureShape .bar { flex: 1 1 6rem; max-width: 16rem; margin: 0; height: 0.25rem; }
|
|
3011
|
+
.featureSource { color: var(--muted); font-size: 0.6875rem; }
|
|
3012
|
+
.featureUri { color: var(--muted); font-size: 0.6875rem; overflow-wrap: anywhere; }
|
|
2222
3013
|
.feature > summary::-webkit-details-marker, .scenarioButton::-webkit-details-marker { display: none; }
|
|
2223
3014
|
.feature > summary:focus-visible, .scenarioButton:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
2224
3015
|
.feature > summary:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--paper)); }
|
|
2225
3016
|
.feature h2 { margin: 0; min-width: 0; font-size: 1rem; line-height: 1.3; font-weight: 600; overflow-wrap: break-word; }
|
|
2226
|
-
.feature .fmeta { color: var(--muted); font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; }
|
|
2227
3017
|
.statusCell { display: flex; align-items: center; }
|
|
2228
3018
|
.statusText { display: inline-flex; align-items: center; justify-content: center; min-width: 3.875rem; min-height: 1.375rem; padding: 0 0.4375rem; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-3); color: var(--muted); font-size: 0.6875rem; font-weight: 500; }
|
|
2229
3019
|
.statusText.pass { color: var(--pass); border-color: color-mix(in oklab, var(--pass) 32%, var(--line)); background: var(--pass-soft); }
|
|
@@ -2233,11 +3023,44 @@ img, video { max-width: 100%; height: auto; }
|
|
|
2233
3023
|
.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); }
|
|
2234
3024
|
details[open] > summary .chev { transform: rotate(180deg); }
|
|
2235
3025
|
.rows { border-top: 1px solid var(--line); }
|
|
3026
|
+
.rule { padding: 0.75rem 0 0.25rem; border-top: 1px solid var(--line); }
|
|
3027
|
+
.ruleTitle { margin: 0.25rem 0 0; font-size: 0.9375rem; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
|
|
3028
|
+
.ruleTitle .kw, .backgroundTitle .kw { color: var(--muted); font-weight: 500; }
|
|
3029
|
+
.rule > .tags { margin: 0.5rem 0 0; }
|
|
3030
|
+
.ruleRows { margin-top: 0.25rem; }
|
|
3031
|
+
.background { margin: 0.5rem 0 0; padding: 0.5rem 0.75rem; border-left: 2px solid var(--line); background: var(--surface-2); }
|
|
3032
|
+
.feature > .background { margin: 0.75rem 0 0; }
|
|
3033
|
+
.backgroundTitle { margin: 0; font-size: 0.8125rem; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
|
|
3034
|
+
.background > .description { margin-top: 0.25rem; font-size: 0.8125rem; }
|
|
3035
|
+
.featureShape .featureTags { flex-basis: 100%; margin-top: 0; }
|
|
3036
|
+
.outline { padding: 0.75rem 0 0.25rem; }
|
|
3037
|
+
.outline + .outline { border-top: 1px solid var(--line); }
|
|
3038
|
+
.outlineTitle { margin: 0.25rem 0 0; font-size: 0.9375rem; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
|
|
3039
|
+
.examplesTitle { margin: 0.5rem 0 0.25rem; font-size: 0.875rem; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
|
|
3040
|
+
.outlineTitle .kw, .examplesTitle .kw { color: var(--muted); font-weight: 500; }
|
|
3041
|
+
.outline > .tags, .examples > .tags { margin: 0.5rem 0 0; }
|
|
3042
|
+
.outline > .description, .examples > .description { margin-top: 0.375rem; }
|
|
3043
|
+
.examples { margin: 0.75rem 0 0 0.75rem; padding-left: 0.875rem; border-left: 2px solid var(--line); }
|
|
3044
|
+
.exampleRows { margin-top: 0.25rem; }
|
|
3045
|
+
.exampleRows .scenario { border-top: 1px solid var(--line); }
|
|
3046
|
+
.exampleRows .scenario:last-child { border-bottom: 0; }
|
|
3047
|
+
.exampleNo { color: var(--accent-text); font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500; }
|
|
3048
|
+
.detailLabel { margin: 0.875rem 0 0.375rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
|
|
3049
|
+
.hooks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
|
|
3050
|
+
.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; }
|
|
3051
|
+
.hook:last-child { border-bottom: 0; }
|
|
3052
|
+
.hookLabel { color: var(--ink-2); font-weight: 500; overflow-wrap: anywhere; }
|
|
3053
|
+
.hookGroup { margin: 0.5rem 0; border: 1px solid var(--line); border-radius: 5px; padding: 0.375rem 0.5625rem; background: var(--surface-2); }
|
|
3054
|
+
.hookGroup > summary { cursor: pointer; color: var(--accent-text); font-size: 0.75rem; }
|
|
3055
|
+
.hookGroup .hooks { margin-top: 0.375rem; }
|
|
3056
|
+
.runHooks { margin: 1.5rem 0; padding: 1rem 1.25rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); }
|
|
3057
|
+
.runHooks h2 { margin: 0 0 0.5rem; font-size: 1.125rem; }
|
|
3058
|
+
.runHooks .hooks { border-top: 1px solid var(--line); }
|
|
2236
3059
|
.scenario { border-bottom: 1px solid var(--line); container-type: inline-size; }
|
|
2237
3060
|
.scenario:last-child { border-bottom: 0; }
|
|
2238
3061
|
.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; }
|
|
2239
3062
|
.scenarioButton:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--paper)); }
|
|
2240
|
-
details[open] > summary.scenarioButton { background: var(--
|
|
3063
|
+
details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
2241
3064
|
.scenarioMain { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
|
|
2242
3065
|
.scenarioName { margin: 0; font-size: 0.875rem; line-height: 1.4; font-weight: 500; overflow-wrap: break-word; }
|
|
2243
3066
|
.scenarioSub { display: block; color: var(--muted); font-size: 0.75rem; }
|
|
@@ -2247,11 +3070,27 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2247
3070
|
.thumb { display: block; width: 6rem; height: 3.75rem; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-3); }
|
|
2248
3071
|
.rowRight { color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
2249
3072
|
.detailInline { padding: 0.25rem 0 1.125rem 13rem; background: var(--surface-2); border-top: 1px solid var(--line); }
|
|
2250
|
-
.detailInline h4 { margin: 0.875rem 0 0.375rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
|
|
2251
3073
|
.stepsHead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; }
|
|
2252
3074
|
.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; }
|
|
2253
3075
|
.copyFailure:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
|
|
2254
|
-
.description { margin: 0.625rem 0 0; color: var(--muted); font-size: 0.875rem; line-height: 1.55;
|
|
3076
|
+
.description { margin: 0.625rem 0 0; color: var(--muted); font-size: 0.875rem; line-height: 1.55; }
|
|
3077
|
+
.description > :first-child { margin-top: 0; }
|
|
3078
|
+
.description > :last-child { margin-bottom: 0; }
|
|
3079
|
+
.description p { margin: 0.5rem 0 0; }
|
|
3080
|
+
.description h3, .description h4 { margin: 0.75rem 0 0.25rem; color: var(--ink); line-height: 1.35; font-weight: 600; }
|
|
3081
|
+
.description h3 { font-size: 1rem; }
|
|
3082
|
+
.description h4 { font-size: 0.9375rem; }
|
|
3083
|
+
.description ul, .description ol { margin: 0.5rem 0 0; padding-left: 1.25rem; }
|
|
3084
|
+
.description li + li { margin-top: 0.125rem; }
|
|
3085
|
+
.description blockquote { margin: 0.5rem 0 0; padding: 0.125rem 0 0.125rem 0.75rem; border-left: 2px solid var(--line-strong); }
|
|
3086
|
+
.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); }
|
|
3087
|
+
.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; }
|
|
3088
|
+
.description pre code { padding: 0; background: transparent; }
|
|
3089
|
+
.description a { color: var(--accent-text); }
|
|
3090
|
+
.description .tableWrap { margin-top: 0.5rem; }
|
|
3091
|
+
.description table { border-collapse: collapse; background: var(--surface-2); font-size: 0.8125rem; }
|
|
3092
|
+
.description th, .description td { border: 1px solid var(--line); padding: 0.25rem 0.5rem; text-align: left; }
|
|
3093
|
+
.description th { color: var(--muted); font-weight: 600; background: var(--surface-3); }
|
|
2255
3094
|
.steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
|
|
2256
3095
|
.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; }
|
|
2257
3096
|
.step:last-child { border-bottom: 0; }
|
|
@@ -2261,7 +3100,19 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2261
3100
|
.marker { width: 0.375rem; height: 0.375rem; border-radius: 1px; background: var(--line-strong); }
|
|
2262
3101
|
.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); }
|
|
2263
3102
|
.step .kw { color: var(--muted); }
|
|
3103
|
+
.step .param { color: var(--accent-text); font-weight: 500; }
|
|
2264
3104
|
.step .dur { color: var(--accent-text); font-family: var(--font-mono); font-size: 0.6875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
3105
|
+
.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); }
|
|
3106
|
+
.diagnostic[data-diagnostic="ambiguous"] { border-left-color: var(--ambiguous); background: var(--surface-3); }
|
|
3107
|
+
.diagnosticLead { margin: 0; color: var(--ink-2); font-size: 0.75rem; }
|
|
3108
|
+
.snippet { margin: 0.375rem 0 0; min-width: 0; }
|
|
3109
|
+
.snippetLang { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 0.625rem; }
|
|
3110
|
+
.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; }
|
|
3111
|
+
.snippet code { font: inherit; }
|
|
3112
|
+
.definitions { display: grid; gap: 0.25rem; margin: 0.375rem 0 0; padding: 0; list-style: none; }
|
|
3113
|
+
.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); }
|
|
3114
|
+
.definitionPattern { font: 0.6875rem/1.5 var(--font-mono); overflow-wrap: anywhere; }
|
|
3115
|
+
.definitionSource { color: var(--muted); font-family: var(--font-mono); font-size: 0.625rem; overflow-wrap: anywhere; }
|
|
2265
3116
|
.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; }
|
|
2266
3117
|
.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; }
|
|
2267
3118
|
.tableWrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
|
|
@@ -2281,8 +3132,27 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2281
3132
|
.attachmentText { margin: 0.5rem 0; border: 1px solid var(--line); border-radius: 6px; padding: 0.4375rem 0.5625rem; background: var(--surface-2); }
|
|
2282
3133
|
.attachmentText summary { cursor: pointer; color: var(--accent-text); font-size: 0.75rem; }
|
|
2283
3134
|
.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); }
|
|
3135
|
+
.logTools { display: flex; justify-content: flex-end; margin-top: 0.5rem; }
|
|
3136
|
+
.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; }
|
|
3137
|
+
.copyLog:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
|
|
3138
|
+
.ansi { white-space: pre-wrap; }
|
|
3139
|
+
.ansi-bold { font-weight: 700; }
|
|
3140
|
+
.ansi-dim { opacity: 0.65; }
|
|
3141
|
+
.ansi-italic { font-style: italic; }
|
|
3142
|
+
.ansi-underline { text-decoration: underline; }
|
|
3143
|
+
.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); }
|
|
3144
|
+
.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); }
|
|
3145
|
+
.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); }
|
|
3146
|
+
.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); }
|
|
3147
|
+
.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)); }
|
|
3148
|
+
.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)); }
|
|
3149
|
+
.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)); }
|
|
3150
|
+
.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)); }
|
|
3151
|
+
.ansi-bg-only { color: var(--ink); }
|
|
3152
|
+
.ansi-inline-fg { color: color-mix(in oklab, var(--ansi-fg) 30%, var(--ink)); }
|
|
3153
|
+
.ansi-inline-bg { background-color: color-mix(in oklab, var(--ansi-bg) 26%, var(--paper)); }
|
|
2284
3154
|
.fileLink { display: inline-block; margin: 0.3125rem 0; color: var(--accent-text); font-size: 0.75rem; }
|
|
2285
|
-
.meta span, .
|
|
3155
|
+
.meta span, .path, .description, .step, .featureSource, .featureUri, .fileLink, .attachment figcaption, .attachmentText summary, .detailMeta span { overflow-wrap: anywhere; }
|
|
2286
3156
|
.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; }
|
|
2287
3157
|
.empty { margin: 1.5rem 0; padding: 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface-2); color: var(--muted); font-size: 0.875rem; }
|
|
2288
3158
|
.foot { margin-top: 1.75rem; color: var(--muted); font-size: 0.75rem; }
|
|
@@ -2293,12 +3163,19 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2293
3163
|
.panel h2 { margin: 0 0 0.375rem; font-size: 1.125rem; }
|
|
2294
3164
|
.panel h2.subhead { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
|
|
2295
3165
|
.panel p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.8125rem; }
|
|
2296
|
-
.featureTable { width: 100%; min-width:
|
|
3166
|
+
.featureTable { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.8125rem; }
|
|
2297
3167
|
.featureTable th { text-align: left; color: var(--muted); font-size: 0.6875rem; font-weight: 500; padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--line-strong); }
|
|
3168
|
+
.featureTable th:not(:first-child) { text-align: right; }
|
|
3169
|
+
.featureTable th[scope="row"] { width: 38%; color: var(--ink); font-size: 0.8125rem; font-weight: 400; overflow-wrap: anywhere; }
|
|
3170
|
+
.featureTable .matrixName { display: block; }
|
|
3171
|
+
.featureTable .matrixUri { display: block; color: var(--muted); font-size: 0.6875rem; overflow-wrap: anywhere; }
|
|
3172
|
+
.featureTable th:first-child, .featureTable td:first-child { width: 38%; overflow-wrap: anywhere; }
|
|
2298
3173
|
.featureTable td { padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--line); }
|
|
2299
3174
|
.featureTable td:last-child, .featureTable th:last-child { text-align: right; }
|
|
2300
3175
|
.featureTable tr:last-child td { border-bottom: 0; }
|
|
2301
3176
|
.featureTable .num { text-align: right; font-family: var(--font-mono); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
3177
|
+
.featureTable .zero { color: var(--muted); }
|
|
3178
|
+
.matrixHint { display: none; }
|
|
2302
3179
|
.legend { display: grid; gap: 0.375rem; margin-top: 0.625rem; }
|
|
2303
3180
|
.legendRow { display: grid; grid-template-columns: 0.625rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; font-size: 0.8125rem; border-radius: 5px; padding: 0.375rem 0.5rem; background: var(--surface-3); }
|
|
2304
3181
|
.legendRow.pass { background: var(--pass-soft); } .legendRow.fail { background: var(--fail-soft); } .legendRow.pending { background: var(--pending-soft); } .legendRow.undefined { background: var(--undefined-soft); } .legendRow.ambiguous, .legendRow.skipped, .legendRow.unknown { background: var(--surface-3); }
|
|
@@ -2315,7 +3192,7 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2315
3192
|
.runHead { grid-template-columns: 1fr; gap: 1.25rem; }
|
|
2316
3193
|
.health { border-left: 0; border-top: 1px solid var(--line-strong); padding: 1rem 0 0; }
|
|
2317
3194
|
.feature > summary { grid-template-columns: 4.75rem minmax(0, 1fr) 1.25rem; }
|
|
2318
|
-
.
|
|
3195
|
+
.featureUri { display: none; }
|
|
2319
3196
|
.scenarioButton { grid-template-columns: minmax(3.5rem, max-content) 2.75rem minmax(0, 1fr) 1.125rem; grid-template-areas: "status thumb title chev" "status thumb meta chev"; gap: 0.25rem 0.5rem; align-items: start; }
|
|
2320
3197
|
.scenarioButton .statusCell { grid-area: status; align-self: start; }
|
|
2321
3198
|
.scenarioButton .thumbCell { grid-area: thumb; align-self: start; }
|
|
@@ -2338,14 +3215,23 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2338
3215
|
.thumb { width: 2.5rem; height: 1.875rem; }
|
|
2339
3216
|
.statusText { min-width: 3.125rem; }
|
|
2340
3217
|
.filter { min-height: 1.75rem; }
|
|
3218
|
+
.examples { margin-left: 0; padding-left: 0.625rem; }
|
|
3219
|
+
.matrixHint { display: block; margin: 0 0 0.5rem; font-size: 0.75rem; }
|
|
3220
|
+
.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; }
|
|
3221
|
+
.triageBox .triage { margin: 0.5rem 0 0; }
|
|
3222
|
+
.triageBox .triage h2, .triageBox .triage .triageLead { display: none; }
|
|
3223
|
+
.sources { display: none; }
|
|
2341
3224
|
}
|
|
2342
3225
|
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
|
|
2343
3226
|
@container (max-width: 16rem) {
|
|
3227
|
+
.thumb { display: none; }
|
|
2344
3228
|
.runHead h1 { font-size: 1.3rem; }
|
|
2345
|
-
.feature > summary { grid-template-columns: auto 1fr auto; grid-template-areas: "status . chev" "title title title"; gap: 0.5rem; }
|
|
3229
|
+
.feature > summary { grid-template-columns: auto 1fr auto; grid-template-areas: "status . chev" "title title title" "shape shape shape"; gap: 0.5rem; }
|
|
2346
3230
|
.feature > summary .statusCell { grid-area: status; }
|
|
2347
3231
|
.feature > summary h2 { grid-area: title; }
|
|
2348
3232
|
.feature > summary .chev { grid-area: chev; }
|
|
3233
|
+
.featureShape { grid-area: shape; }
|
|
3234
|
+
.triageScenarios a { grid-template-columns: minmax(0, 1fr); gap: 0.125rem; }
|
|
2349
3235
|
.scenarioButton { grid-template-columns: auto auto 1fr auto; grid-template-areas: "status thumb . chev" "title title title title" "meta meta meta meta"; gap: 0.5rem; }
|
|
2350
3236
|
.scenarioButton .statusCell { grid-area: status; }
|
|
2351
3237
|
.scenarioButton .thumbCell { grid-area: thumb; }
|
|
@@ -2389,6 +3275,22 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2389
3275
|
--skipped-soft: oklch(21% 0.009 60);
|
|
2390
3276
|
--unknown: oklch(71% 0.012 85);
|
|
2391
3277
|
--unknown-soft: oklch(21% 0.009 60);
|
|
3278
|
+
--ansi-fg-0: #9ca3af;
|
|
3279
|
+
--ansi-fg-1: #f87171;
|
|
3280
|
+
--ansi-fg-2: #86efac;
|
|
3281
|
+
--ansi-fg-3: #fde047;
|
|
3282
|
+
--ansi-fg-4: #93c5fd;
|
|
3283
|
+
--ansi-fg-5: #f0abfc;
|
|
3284
|
+
--ansi-fg-6: #67e8f9;
|
|
3285
|
+
--ansi-fg-7: #e5e7eb;
|
|
3286
|
+
--ansi-fg-8: #9ca3af;
|
|
3287
|
+
--ansi-fg-9: #fca5a5;
|
|
3288
|
+
--ansi-fg-10: #4ade80;
|
|
3289
|
+
--ansi-fg-11: #facc15;
|
|
3290
|
+
--ansi-fg-12: #60a5fa;
|
|
3291
|
+
--ansi-fg-13: #e879f9;
|
|
3292
|
+
--ansi-fg-14: #22d3ee;
|
|
3293
|
+
--ansi-fg-15: #ffffff;
|
|
2392
3294
|
}
|
|
2393
3295
|
}
|
|
2394
3296
|
`;
|
|
@@ -2410,6 +3312,7 @@ var STEP_GLYPHS = {
|
|
|
2410
3312
|
unknown: "\xB7"
|
|
2411
3313
|
};
|
|
2412
3314
|
function durationLabel(milliseconds) {
|
|
3315
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) return "0 ms";
|
|
2413
3316
|
if (milliseconds < 1e3) return `${Math.round(milliseconds * 100) / 100} ms`;
|
|
2414
3317
|
return `${(milliseconds / 1e3).toFixed(2)} s`;
|
|
2415
3318
|
}
|
|
@@ -2433,11 +3336,161 @@ function displayStatuses(model) {
|
|
|
2433
3336
|
(status) => model.counts.scenarios[status] > 0
|
|
2434
3337
|
);
|
|
2435
3338
|
}
|
|
3339
|
+
var TRIAGE_FEATURE_LIMIT = 20;
|
|
3340
|
+
var TRIAGE_SCENARIO_LIMIT = 3;
|
|
3341
|
+
var SOURCE_LIMIT = 6;
|
|
3342
|
+
var SEARCH_MESSAGE_LIMIT = 2e3;
|
|
3343
|
+
var UNDEFINED_LEAD = "No step definition found.";
|
|
3344
|
+
var AMBIGUOUS_LEAD = "Multiple matching step definitions found:";
|
|
3345
|
+
function compareStatus(a, b) {
|
|
3346
|
+
const passed = Number(a === "passed") - Number(b === "passed");
|
|
3347
|
+
return passed !== 0 ? passed : statusSeverity(b) - statusSeverity(a);
|
|
3348
|
+
}
|
|
3349
|
+
function bySeverity(items) {
|
|
3350
|
+
return items.map((item, index) => ({ item, index })).sort((a, b) => {
|
|
3351
|
+
const status = compareStatus(a.item.status, b.item.status);
|
|
3352
|
+
return status !== 0 ? status : a.index - b.index;
|
|
3353
|
+
}).map(({ item }) => item);
|
|
3354
|
+
}
|
|
3355
|
+
function orderFeatures(features) {
|
|
3356
|
+
return bySeverity(features).map((feature) => ({
|
|
3357
|
+
feature,
|
|
3358
|
+
scenarios: bySeverity(feature.scenarios)
|
|
3359
|
+
}));
|
|
3360
|
+
}
|
|
3361
|
+
function countStatuses(scenarios) {
|
|
3362
|
+
const counts = {};
|
|
3363
|
+
for (const scenario of scenarios) {
|
|
3364
|
+
counts[scenario.status] = (counts[scenario.status] ?? 0) + 1;
|
|
3365
|
+
}
|
|
3366
|
+
return counts;
|
|
3367
|
+
}
|
|
3368
|
+
function executedOnly(scenarios) {
|
|
3369
|
+
return scenarios.filter((scenario) => scenario.executed);
|
|
3370
|
+
}
|
|
3371
|
+
function barWidth(count2, total) {
|
|
3372
|
+
return total === 0 ? 0 : Math.round(count2 / total * 1e3) / 10;
|
|
3373
|
+
}
|
|
3374
|
+
function attentionCounts(scenarios) {
|
|
3375
|
+
const counts = /* @__PURE__ */ new Map();
|
|
3376
|
+
for (const scenario of scenarios) {
|
|
3377
|
+
if (!scenario.executed || scenario.status === "passed") continue;
|
|
3378
|
+
counts.set(scenario.status, (counts.get(scenario.status) ?? 0) + 1);
|
|
3379
|
+
}
|
|
3380
|
+
return [...counts.entries()].sort((a, b) => statusSeverity(b[0]) - statusSeverity(a[0])).map(([status, count2]) => `${count2} ${status}`).join(", ");
|
|
3381
|
+
}
|
|
3382
|
+
function featureBar(scenarios) {
|
|
3383
|
+
const executed = executedOnly(scenarios);
|
|
3384
|
+
const total = executed.length;
|
|
3385
|
+
if (total === 0) return "";
|
|
3386
|
+
const counts = countStatuses(executed);
|
|
3387
|
+
const segments = ALL_STATUSES.filter((status) => counts[status]).map(
|
|
3388
|
+
(status) => `<i class="${statusClass(status)}" style="width:${barWidth(counts[status] ?? 0, total)}%"></i>`
|
|
3389
|
+
).join("");
|
|
3390
|
+
return `<span class="bar" aria-hidden="true">${segments}</span>`;
|
|
3391
|
+
}
|
|
3392
|
+
function featureShape(feature, scenarios) {
|
|
3393
|
+
const executed = executedOnly(scenarios);
|
|
3394
|
+
const passed = executed.filter(
|
|
3395
|
+
(scenario) => scenario.status === "passed"
|
|
3396
|
+
).length;
|
|
3397
|
+
const attention = attentionCounts(executed);
|
|
3398
|
+
const counts = `${passed} of ${executed.length} passed${attention ? ` \xB7 ${attention}` : ""}`;
|
|
3399
|
+
const source = feature.sourceFile ? `<span class="featureSource">from ${escapeHtml(feature.sourceFile)}</span>` : "";
|
|
3400
|
+
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>`;
|
|
3401
|
+
}
|
|
3402
|
+
function renderTriageRow({
|
|
3403
|
+
feature,
|
|
3404
|
+
scenarios,
|
|
3405
|
+
index
|
|
3406
|
+
}) {
|
|
3407
|
+
const failing = executedOnly(scenarios).filter(
|
|
3408
|
+
(scenario) => scenario.status !== "passed"
|
|
3409
|
+
);
|
|
3410
|
+
const links = failing.slice(0, TRIAGE_SCENARIO_LIMIT).map((scenario) => {
|
|
3411
|
+
const scenarioIndex = scenarios.indexOf(scenario) + 1;
|
|
3412
|
+
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>`;
|
|
3413
|
+
}).join("");
|
|
3414
|
+
const more = failing.length > TRIAGE_SCENARIO_LIMIT ? `<li class="triageMore">+${failing.length - TRIAGE_SCENARIO_LIMIT} more in the report</li>` : "";
|
|
3415
|
+
const failed = failing.find((scenario) => scenario.status === "failed");
|
|
3416
|
+
const failedStep = failed?.steps.find(
|
|
3417
|
+
(step) => step.status === "failed" && step.message
|
|
3418
|
+
);
|
|
3419
|
+
const failedHook = failed?.hooks.find(
|
|
3420
|
+
(hook) => hook.status === "failed" && hook.message
|
|
3421
|
+
);
|
|
3422
|
+
const reasonSource = failedStep?.message ? `${failedStep.keyword ? `${failedStep.keyword} ` : ""}${failedStep.text}` : failedHook?.message ? hookLabel2(failedHook) : "";
|
|
3423
|
+
const reasonMessage = failedStep?.message ?? failedHook?.message ?? "";
|
|
3424
|
+
const reason = reasonSource ? `${reasonSource} \u2014 ${reasonMessage.split(/\r?\n/)[0].trim().slice(0, 120)}${reasonMessage.split(/\r?\n/)[0].trim().length > 120 ? "\u2026" : ""}` : "";
|
|
3425
|
+
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>`;
|
|
3426
|
+
}
|
|
3427
|
+
function renderTriage(features) {
|
|
3428
|
+
const attention = features.map((entry, index) => ({ ...entry, index })).filter(
|
|
3429
|
+
({ scenarios }) => scenarios.some(
|
|
3430
|
+
(scenario) => scenario.executed && scenario.status !== "passed"
|
|
3431
|
+
)
|
|
3432
|
+
);
|
|
3433
|
+
if (attention.length === 0) return "";
|
|
3434
|
+
const shown = attention.slice(0, 5);
|
|
3435
|
+
const rest = attention.slice(5, TRIAGE_FEATURE_LIMIT);
|
|
3436
|
+
const total = features.reduce(
|
|
3437
|
+
(sum, entry) => sum + executedOnly(entry.scenarios).length,
|
|
3438
|
+
0
|
|
3439
|
+
);
|
|
3440
|
+
const need = attention.reduce(
|
|
3441
|
+
(sum, entry) => sum + entry.scenarios.filter(
|
|
3442
|
+
(scenario) => scenario.executed && scenario.status !== "passed"
|
|
3443
|
+
).length,
|
|
3444
|
+
0
|
|
3445
|
+
);
|
|
3446
|
+
const rows = shown.map(renderTriageRow).join("");
|
|
3447
|
+
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>` : "";
|
|
3448
|
+
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>` : "";
|
|
3449
|
+
const lead = `${need} of ${total} scenario${total === 1 ? "" : "s"} ${total === 1 ? "needs" : "need"} attention.`;
|
|
3450
|
+
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>`;
|
|
3451
|
+
}
|
|
3452
|
+
function renderSourceStrip(model) {
|
|
3453
|
+
if (model.features.some((feature) => !feature.sourceFile)) return "";
|
|
3454
|
+
const groups = /* @__PURE__ */ new Map();
|
|
3455
|
+
model.features.forEach((feature, index) => {
|
|
3456
|
+
const file = feature.sourceFile;
|
|
3457
|
+
if (!file) return;
|
|
3458
|
+
const group = groups.get(file) ?? { features: [], order: index };
|
|
3459
|
+
group.features.push(feature);
|
|
3460
|
+
groups.set(file, group);
|
|
3461
|
+
});
|
|
3462
|
+
if (groups.size < 2) return "";
|
|
3463
|
+
const entries = [...groups.entries()].map(([file, group]) => {
|
|
3464
|
+
const scenarios = executedOnly(
|
|
3465
|
+
group.features.flatMap((feature) => feature.scenarios)
|
|
3466
|
+
);
|
|
3467
|
+
return {
|
|
3468
|
+
file,
|
|
3469
|
+
features: group.features.length,
|
|
3470
|
+
scenarios,
|
|
3471
|
+
status: worstExecutedStatus(scenarios),
|
|
3472
|
+
order: group.order
|
|
3473
|
+
};
|
|
3474
|
+
});
|
|
3475
|
+
entries.sort((a, b) => {
|
|
3476
|
+
const status = compareStatus(a.status, b.status);
|
|
3477
|
+
return status !== 0 ? status : a.order - b.order;
|
|
3478
|
+
});
|
|
3479
|
+
const shown = entries.slice(0, SOURCE_LIMIT);
|
|
3480
|
+
const remainder = entries.length - shown.length;
|
|
3481
|
+
const items = shown.map((entry) => {
|
|
3482
|
+
const attention = attentionCounts(entry.scenarios);
|
|
3483
|
+
const counts = `${entry.features} feature${entry.features === 1 ? "" : "s"} \xB7 ${entry.scenarios.length} scenario${entry.scenarios.length === 1 ? "" : "s"}${attention ? ` \xB7 ${attention}` : ""}`;
|
|
3484
|
+
return `<li class="sourceItem"><div class="sourceHead"><span class="triageStatus ${statusClass(entry.status)}">${statusLabel(entry.status)}</span><span class="sourceName">${escapeHtml(entry.file)}</span></div><p class="sourceCounts">${counts}</p>${featureBar(entry.scenarios)}</li>`;
|
|
3485
|
+
}).join("");
|
|
3486
|
+
const more = remainder > 0 ? `<p class="triageMore">${remainder} more input${remainder === 1 ? "" : "s"}</p>` : "";
|
|
3487
|
+
return `<section class="sources" aria-labelledby="sources-heading" data-sources><h2 id="sources-heading">Sources</h2><ul class="sourceList">${items}</ul>${more}</section>`;
|
|
3488
|
+
}
|
|
2436
3489
|
function statusBar(model) {
|
|
2437
3490
|
const total = model.counts.scenarios.total;
|
|
2438
3491
|
if (total === 0) return "";
|
|
2439
3492
|
return `<div class="bar" aria-hidden="true">${displayStatuses(model).map(
|
|
2440
|
-
(status) => `<i class="${statusClass(status)}" style="width:${model.counts.scenarios[status]
|
|
3493
|
+
(status) => `<i class="${statusClass(status)}" style="width:${barWidth(model.counts.scenarios[status], total)}%"></i>`
|
|
2441
3494
|
).join("")}</div>`;
|
|
2442
3495
|
}
|
|
2443
3496
|
function countPills(model) {
|
|
@@ -2446,6 +3499,179 @@ function countPills(model) {
|
|
|
2446
3499
|
(status) => `<span class="${statusClass(status)}"><b>${counts[status]}</b> ${status}</span>`
|
|
2447
3500
|
).join("")}</div>`;
|
|
2448
3501
|
}
|
|
3502
|
+
function safeHttpUrl(value) {
|
|
3503
|
+
const trimmed = stripBidiControls(value ?? "").trim();
|
|
3504
|
+
if (!trimmed) return void 0;
|
|
3505
|
+
try {
|
|
3506
|
+
const url = new URL(trimmed);
|
|
3507
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url.href : void 0;
|
|
3508
|
+
} catch {
|
|
3509
|
+
return void 0;
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
function githubRepoPath(url) {
|
|
3513
|
+
if (url.hostname.toLowerCase() !== "github.com") return void 0;
|
|
3514
|
+
const path3 = url.pathname.replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
3515
|
+
return /^\/[^/]+\/[^/]+$/.test(path3) ? path3 : void 0;
|
|
3516
|
+
}
|
|
3517
|
+
function githubBaseUrl(remote) {
|
|
3518
|
+
const value = stripBidiControls(remote ?? "").trim();
|
|
3519
|
+
if (!value) return void 0;
|
|
3520
|
+
const direct = safeHttpUrl(value);
|
|
3521
|
+
if (direct) {
|
|
3522
|
+
const url = new URL(direct);
|
|
3523
|
+
const path3 = githubRepoPath(url);
|
|
3524
|
+
return path3 ? `${url.origin}${path3}` : void 0;
|
|
3525
|
+
}
|
|
3526
|
+
const scp = /^(?:[^@\s/:]+@)?github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(
|
|
3527
|
+
value
|
|
3528
|
+
);
|
|
3529
|
+
if (scp) return `https://github.com/${scp[1]}/${scp[2]}`;
|
|
3530
|
+
if (!/^(?:ssh|git\+ssh):\/\//i.test(value)) return void 0;
|
|
3531
|
+
try {
|
|
3532
|
+
const path3 = githubRepoPath(new URL(value));
|
|
3533
|
+
return path3 ? `https://github.com${path3}` : void 0;
|
|
3534
|
+
} catch {
|
|
3535
|
+
return void 0;
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
function shortRevision(revision) {
|
|
3539
|
+
return stripBidiControls(revision).slice(0, 7);
|
|
3540
|
+
}
|
|
3541
|
+
function githubCommitUrl(ci) {
|
|
3542
|
+
if (!ci?.remote || !ci.revision) return void 0;
|
|
3543
|
+
const base = githubBaseUrl(ci.remote);
|
|
3544
|
+
if (!base) return void 0;
|
|
3545
|
+
return `${base}/commit/${encodeURIComponent(stripBidiControls(ci.revision))}`;
|
|
3546
|
+
}
|
|
3547
|
+
function revisionMarkup(ci) {
|
|
3548
|
+
if (!ci?.revision) return "";
|
|
3549
|
+
const short = escapeHtml(shortRevision(ci.revision));
|
|
3550
|
+
const commit = githubCommitUrl(ci);
|
|
3551
|
+
if (!commit) return short;
|
|
3552
|
+
return `<a href="${escapeHtml(commit)}" title="${escapeHtml(ci.revision)}" rel="noopener noreferrer">${short}</a>`;
|
|
3553
|
+
}
|
|
3554
|
+
function ciNameMarkup(ci) {
|
|
3555
|
+
const href = safeHttpUrl(ci?.url);
|
|
3556
|
+
const label = ci?.name || href;
|
|
3557
|
+
if (!label) return "";
|
|
3558
|
+
return href ? `<a href="${escapeHtml(href)}" rel="noopener noreferrer">${escapeHtml(label)}</a>` : escapeHtml(label);
|
|
3559
|
+
}
|
|
3560
|
+
function ciHeaderMarkup(ci) {
|
|
3561
|
+
if (!ci) return "";
|
|
3562
|
+
const name = ciNameMarkup(ci);
|
|
3563
|
+
const rows = [
|
|
3564
|
+
name ? `<span class="ci"><b>CI</b> ${name}</span>` : "",
|
|
3565
|
+
ci.revision ? `<span><b>Revision</b> ${revisionMarkup(ci)}</span>` : "",
|
|
3566
|
+
ci.branch ? `<span><b>Branch</b> <span>${escapeHtml(ci.branch)}</span></span>` : "",
|
|
3567
|
+
ci.tag ? `<span><b>Tag</b> <span>${escapeHtml(ci.tag)}</span></span>` : ""
|
|
3568
|
+
].filter(Boolean);
|
|
3569
|
+
return rows.join("");
|
|
3570
|
+
}
|
|
3571
|
+
function ciDetailRows(ci) {
|
|
3572
|
+
if (!ci) return "";
|
|
3573
|
+
const name = ciNameMarkup(ci);
|
|
3574
|
+
return [
|
|
3575
|
+
name ? `<dt>CI</dt><dd>${name}</dd>` : "",
|
|
3576
|
+
ci.revision ? `<dt>Revision</dt><dd>${revisionMarkup(ci)}</dd>` : "",
|
|
3577
|
+
ci.branch ? `<dt>Branch</dt><dd>${escapeHtml(ci.branch)}</dd>` : "",
|
|
3578
|
+
ci.tag ? `<dt>Tag</dt><dd>${escapeHtml(ci.tag)}</dd>` : ""
|
|
3579
|
+
].join("");
|
|
3580
|
+
}
|
|
3581
|
+
function prettyJson(text) {
|
|
3582
|
+
try {
|
|
3583
|
+
JSON.parse(text);
|
|
3584
|
+
} catch {
|
|
3585
|
+
return void 0;
|
|
3586
|
+
}
|
|
3587
|
+
const out = [];
|
|
3588
|
+
const stack = [];
|
|
3589
|
+
let inString = false;
|
|
3590
|
+
let escaped = false;
|
|
3591
|
+
const openItem = () => {
|
|
3592
|
+
const top = stack[stack.length - 1];
|
|
3593
|
+
if (top && !top.hasItems) {
|
|
3594
|
+
out.push("\n", " ".repeat(stack.length));
|
|
3595
|
+
top.hasItems = true;
|
|
3596
|
+
}
|
|
3597
|
+
};
|
|
3598
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
3599
|
+
const character = text[index];
|
|
3600
|
+
if (inString) {
|
|
3601
|
+
out.push(character);
|
|
3602
|
+
if (escaped) escaped = false;
|
|
3603
|
+
else if (character === "\\") escaped = true;
|
|
3604
|
+
else if (character === '"') inString = false;
|
|
3605
|
+
continue;
|
|
3606
|
+
}
|
|
3607
|
+
if (character === '"') {
|
|
3608
|
+
openItem();
|
|
3609
|
+
out.push(character);
|
|
3610
|
+
inString = true;
|
|
3611
|
+
continue;
|
|
3612
|
+
}
|
|
3613
|
+
if (character === "{" || character === "[") {
|
|
3614
|
+
openItem();
|
|
3615
|
+
out.push(character);
|
|
3616
|
+
stack.push({ opener: character, hasItems: false });
|
|
3617
|
+
continue;
|
|
3618
|
+
}
|
|
3619
|
+
if (character === "}" || character === "]") {
|
|
3620
|
+
const frame = stack.pop();
|
|
3621
|
+
if (!frame) return void 0;
|
|
3622
|
+
if (frame.opener === "{" && character !== "}" || frame.opener === "[" && character !== "]") {
|
|
3623
|
+
return void 0;
|
|
3624
|
+
}
|
|
3625
|
+
if (frame.hasItems) out.push("\n", " ".repeat(stack.length));
|
|
3626
|
+
out.push(character);
|
|
3627
|
+
continue;
|
|
3628
|
+
}
|
|
3629
|
+
if (character === ",") {
|
|
3630
|
+
out.push(",", "\n", " ".repeat(stack.length));
|
|
3631
|
+
continue;
|
|
3632
|
+
}
|
|
3633
|
+
if (character === ":") {
|
|
3634
|
+
out.push(": ");
|
|
3635
|
+
continue;
|
|
3636
|
+
}
|
|
3637
|
+
if (character === " " || character === "\n" || character === "\r" || character === " ") {
|
|
3638
|
+
continue;
|
|
3639
|
+
}
|
|
3640
|
+
let end = index;
|
|
3641
|
+
while (end < text.length && !/[\s,\]}:]/.test(text[end])) {
|
|
3642
|
+
end += 1;
|
|
3643
|
+
}
|
|
3644
|
+
openItem();
|
|
3645
|
+
out.push(text.slice(index, end));
|
|
3646
|
+
index = end - 1;
|
|
3647
|
+
}
|
|
3648
|
+
return stack.length === 0 && !inString ? out.join("") : void 0;
|
|
3649
|
+
}
|
|
3650
|
+
function jsonBody(text) {
|
|
3651
|
+
return prettyJson(text) ?? text;
|
|
3652
|
+
}
|
|
3653
|
+
function uriListBody(text) {
|
|
3654
|
+
return text.split(/\r?\n/).map((line) => {
|
|
3655
|
+
const label = line.trim();
|
|
3656
|
+
const href = safeHttpUrl(label);
|
|
3657
|
+
return href ? `<a href="${escapeHtml(href)}" rel="noopener noreferrer">${escapeHtml(label)}</a>` : escapeHtml(line);
|
|
3658
|
+
}).join("\n");
|
|
3659
|
+
}
|
|
3660
|
+
function textAttachmentBody(attachment) {
|
|
3661
|
+
const text = attachment.text ?? "";
|
|
3662
|
+
const mediaType = normalizedMediaType(attachment.mediaType);
|
|
3663
|
+
if (mediaType.startsWith("application/json")) {
|
|
3664
|
+
const body = Buffer.byteLength(text, "utf8") > MAX_TEXT_ATTACHMENT_BYTES ? text : jsonBody(text);
|
|
3665
|
+
return `<pre>${escapeHtml(body)}</pre>`;
|
|
3666
|
+
}
|
|
3667
|
+
if (mediaType === "text/uri-list") {
|
|
3668
|
+
return `<pre>${uriListBody(text)}</pre>`;
|
|
3669
|
+
}
|
|
3670
|
+
if (mediaType === "text/x.cucumber.log+plain") {
|
|
3671
|
+
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>`;
|
|
3672
|
+
}
|
|
3673
|
+
return `<pre>${escapeHtml(text)}</pre>`;
|
|
3674
|
+
}
|
|
2449
3675
|
function renderAttachment(attachment, context) {
|
|
2450
3676
|
const name = escapeHtml(attachment.fileName);
|
|
2451
3677
|
const media = escapeHtml(attachment.mediaType);
|
|
@@ -2460,7 +3686,7 @@ function renderAttachment(attachment, context) {
|
|
|
2460
3686
|
return `<figure class="attachment"><audio controls src="${escapeHtml(attachment.dataUri)}"></audio><figcaption>${name} (${media})</figcaption></figure>`;
|
|
2461
3687
|
}
|
|
2462
3688
|
if (attachment.kind === "text" && attachment.text !== void 0) {
|
|
2463
|
-
return `<details class="attachmentText"><summary>${name} (${media})</summary
|
|
3689
|
+
return `<details class="attachmentText"><summary>${name} (${media})</summary>${textAttachmentBody(attachment)}</details>`;
|
|
2464
3690
|
}
|
|
2465
3691
|
if (attachment.dataUri) {
|
|
2466
3692
|
return `<a class="fileLink" href="${escapeHtml(attachment.dataUri)}" download="${name}">${name} (${media}, ${attachment.bytes} bytes)</a>`;
|
|
@@ -2472,7 +3698,50 @@ function scenarioTags(model) {
|
|
|
2472
3698
|
(a, b) => a.localeCompare(b)
|
|
2473
3699
|
);
|
|
2474
3700
|
}
|
|
3701
|
+
function renderDiagnostic(step) {
|
|
3702
|
+
if (step.status === "undefined") {
|
|
3703
|
+
const suggestions = step.suggestions ?? [];
|
|
3704
|
+
const lead = suggestions.length ? `${UNDEFINED_LEAD} Implement with the snippet(s) below:` : UNDEFINED_LEAD;
|
|
3705
|
+
const snippets = suggestions.map((suggestion) => {
|
|
3706
|
+
const language = suggestion.language ? `<span class="snippetLang">${escapeHtml(suggestion.language)}</span>` : "";
|
|
3707
|
+
return `<div class="snippet">${language}<pre><code>${escapeHtml(suggestion.code)}</code></pre></div>`;
|
|
3708
|
+
}).join("");
|
|
3709
|
+
return `<div class="diagnostic" data-diagnostic="undefined"><p class="diagnosticLead">${lead}</p>${snippets}</div>`;
|
|
3710
|
+
}
|
|
3711
|
+
if (step.status === "ambiguous") {
|
|
3712
|
+
const definitions = step.definitions ?? [];
|
|
3713
|
+
const items = definitions.map(
|
|
3714
|
+
(definition) => `<li><code class="definitionPattern">${escapeHtml(definition.pattern)}</code>${definition.source ? `<span class="definitionSource">${escapeHtml(displayUri(definition.source))}</span>` : ""}</li>`
|
|
3715
|
+
).join("");
|
|
3716
|
+
const list = items ? `<ul class="definitions">${items}</ul>` : "";
|
|
3717
|
+
return `<div class="diagnostic" data-diagnostic="ambiguous"><p class="diagnosticLead">${AMBIGUOUS_LEAD}</p>${list}</div>`;
|
|
3718
|
+
}
|
|
3719
|
+
return "";
|
|
3720
|
+
}
|
|
3721
|
+
function renderStepText(step) {
|
|
3722
|
+
const parameters = step.parameters;
|
|
3723
|
+
if (!parameters?.length) return escapeHtml(step.text);
|
|
3724
|
+
let cursor = 0;
|
|
3725
|
+
for (const parameter of parameters) {
|
|
3726
|
+
const end = parameter.start + parameter.value.length;
|
|
3727
|
+
if (!Number.isInteger(parameter.start) || parameter.start < cursor || !parameter.value.length || end > step.text.length || step.text.slice(parameter.start, end) !== parameter.value) {
|
|
3728
|
+
return escapeHtml(step.text);
|
|
3729
|
+
}
|
|
3730
|
+
cursor = end;
|
|
3731
|
+
}
|
|
3732
|
+
cursor = 0;
|
|
3733
|
+
let html = "";
|
|
3734
|
+
for (const parameter of parameters) {
|
|
3735
|
+
const end = parameter.start + parameter.value.length;
|
|
3736
|
+
const matched = step.text.slice(parameter.start, end);
|
|
3737
|
+
html += escapeHtml(step.text.slice(cursor, parameter.start));
|
|
3738
|
+
html += `<span class="param" data-parameter-type="${escapeHtml(parameter.type)}">${escapeHtml(matched)}</span>`;
|
|
3739
|
+
cursor = end;
|
|
3740
|
+
}
|
|
3741
|
+
return html + escapeHtml(step.text.slice(cursor));
|
|
3742
|
+
}
|
|
2475
3743
|
function renderStep(step, scenarioName) {
|
|
3744
|
+
const diagnostic = renderDiagnostic(step);
|
|
2476
3745
|
const docString = step.docString ? `<pre class="docString">${escapeHtml(step.docString)}</pre>` : "";
|
|
2477
3746
|
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(
|
|
2478
3747
|
(row, index) => `<tr>${row.map(
|
|
@@ -2482,37 +3751,278 @@ function renderStep(step, scenarioName) {
|
|
|
2482
3751
|
const error = step.message ? `<pre class="error">${escapeHtml(step.message)}</pre>` : "";
|
|
2483
3752
|
const context = `${scenarioName}: ${step.keyword.trim()} ${step.text}`;
|
|
2484
3753
|
const attachments = step.attachments.map((attachment) => renderAttachment(attachment, context)).join("");
|
|
2485
|
-
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>
|
|
3754
|
+
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>`;
|
|
3755
|
+
}
|
|
3756
|
+
function hookLabel2(hook, bareName = false) {
|
|
3757
|
+
if (hook.name) return bareName ? hook.name : `${hook.type}: ${hook.name}`;
|
|
3758
|
+
return hook.type;
|
|
3759
|
+
}
|
|
3760
|
+
function renderHook(hook, scenarioName, bareName = false) {
|
|
3761
|
+
const error = hook.message ? `<pre class="error">${escapeHtml(hook.message)}</pre>` : "";
|
|
3762
|
+
const label = hookLabel2(hook, bareName);
|
|
3763
|
+
const attachments = hook.attachments.map((attachment) => renderAttachment(attachment, `${scenarioName}: ${label}`)).join("");
|
|
3764
|
+
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>`;
|
|
3765
|
+
}
|
|
3766
|
+
function renderRunHooks(model) {
|
|
3767
|
+
if (model.runHooks.length === 0) return "";
|
|
3768
|
+
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>`;
|
|
3769
|
+
}
|
|
3770
|
+
function scenarioLabel(scenario) {
|
|
3771
|
+
const outline = scenario.outline;
|
|
3772
|
+
if (!outline) return scenario.name;
|
|
3773
|
+
const number = `#${outline.examplesIndex + 1}.${outline.exampleIndex + 1}`;
|
|
3774
|
+
const examples = outline.examplesName ? `${outline.examplesName} ` : "";
|
|
3775
|
+
return `${examples}${number} \xB7 ${scenario.name}`.trim();
|
|
3776
|
+
}
|
|
3777
|
+
function tagsMarkup(tags, extraClass = "") {
|
|
3778
|
+
const className = extraClass ? `tags ${extraClass}` : "tags";
|
|
3779
|
+
return tags.length ? `<span class="${className}">${tags.map((tag) => `<span class="tag">${escapeHtml(tag)}</span>`).join("")}</span>` : "";
|
|
3780
|
+
}
|
|
3781
|
+
function backgroundText(background) {
|
|
3782
|
+
return [background.name, background.description].join(" ");
|
|
3783
|
+
}
|
|
3784
|
+
function backgroundMarkup(backgrounds) {
|
|
3785
|
+
return backgrounds.filter((background) => background.name || background.description).map((background) => {
|
|
3786
|
+
const name = background.name ? ` ${escapeHtml(background.name)}` : "";
|
|
3787
|
+
const description = renderDescription(background.description);
|
|
3788
|
+
return `<section class="background" data-background><h3 class="backgroundTitle"><span class="kw">${escapeHtml(background.keyword)}:</span>${name}</h3>${description}</section>`;
|
|
3789
|
+
}).join("");
|
|
3790
|
+
}
|
|
3791
|
+
function ruleSearchText(rule) {
|
|
3792
|
+
return [
|
|
3793
|
+
rule.name,
|
|
3794
|
+
rule.description,
|
|
3795
|
+
...rule.tags,
|
|
3796
|
+
...rule.backgrounds.map(backgroundText)
|
|
3797
|
+
].join(" ");
|
|
2486
3798
|
}
|
|
2487
3799
|
function scenarioText(scenario) {
|
|
3800
|
+
const outline = scenario.outline;
|
|
3801
|
+
const example = outline ? `#${outline.examplesIndex + 1}.${outline.exampleIndex + 1}` : "";
|
|
2488
3802
|
return [
|
|
2489
3803
|
scenario.name,
|
|
2490
3804
|
scenario.featureName,
|
|
2491
|
-
scenario.uri,
|
|
2492
|
-
scenario.keyword,
|
|
2493
|
-
scenario.description,
|
|
3805
|
+
displayUri(scenario.uri),
|
|
3806
|
+
outline ? outline.keyword : scenario.keyword,
|
|
3807
|
+
...outline ? [outline.name, outline.examplesKeyword, outline.examplesName, example] : [scenario.description],
|
|
2494
3808
|
scenario.tags.join(" "),
|
|
2495
|
-
scenario.
|
|
3809
|
+
scenario.hooks.map(
|
|
3810
|
+
(hook) => `${hook.type} ${hook.name ?? ""} ${(hook.message ?? "").slice(0, SEARCH_MESSAGE_LIMIT)}`
|
|
3811
|
+
).join(" "),
|
|
3812
|
+
scenario.steps.map((step) => {
|
|
3813
|
+
const diagnostic = step.status === "undefined" || step.status === "ambiguous" ? [
|
|
3814
|
+
step.status === "undefined" ? UNDEFINED_LEAD : AMBIGUOUS_LEAD,
|
|
3815
|
+
...(step.suggestions ?? []).flatMap((suggestion) => [
|
|
3816
|
+
suggestion.language ?? "",
|
|
3817
|
+
suggestion.code.slice(0, SEARCH_MESSAGE_LIMIT)
|
|
3818
|
+
]),
|
|
3819
|
+
...(step.definitions ?? []).flatMap((definition) => [
|
|
3820
|
+
definition.pattern.slice(0, SEARCH_MESSAGE_LIMIT),
|
|
3821
|
+
displayUri(definition.source ?? "").slice(
|
|
3822
|
+
0,
|
|
3823
|
+
SEARCH_MESSAGE_LIMIT
|
|
3824
|
+
)
|
|
3825
|
+
])
|
|
3826
|
+
].join(" ") : "";
|
|
3827
|
+
return `${step.keyword} ${step.text} ${(step.message ?? "").slice(0, SEARCH_MESSAGE_LIMIT)} ${diagnostic}`;
|
|
3828
|
+
}).join(" ")
|
|
2496
3829
|
].join(" ");
|
|
2497
3830
|
}
|
|
2498
|
-
function renderScenario(scenario) {
|
|
3831
|
+
function renderScenario(scenario, featureIndex, scenarioIndex, grouped = false, inRule = false) {
|
|
3832
|
+
const outline = scenario.outline;
|
|
3833
|
+
const example = grouped && outline ? `#${outline.examplesIndex + 1}.${outline.exampleIndex + 1}` : "";
|
|
3834
|
+
const heading = grouped ? "h5" : inRule ? "h4" : "h3";
|
|
2499
3835
|
const image = scenario.attachments.find(
|
|
2500
3836
|
(attachment) => attachment.kind === "image" && attachment.dataUri
|
|
2501
3837
|
);
|
|
2502
|
-
const open = scenario.status
|
|
2503
|
-
const
|
|
2504
|
-
|
|
2505
|
-
|
|
3838
|
+
const open = scenario.executed && (scenario.status !== "passed" || !grouped && Boolean(image));
|
|
3839
|
+
const passedHooks = scenario.hooks.filter(
|
|
3840
|
+
(hook) => hook.status === "passed"
|
|
3841
|
+
);
|
|
3842
|
+
const inlineItems = [
|
|
3843
|
+
...scenario.steps.map((step) => ({
|
|
3844
|
+
order: step.order,
|
|
3845
|
+
html: renderStep(step, scenario.name)
|
|
3846
|
+
})),
|
|
3847
|
+
...scenario.hooks.filter((hook) => hook.status !== "passed").map((hook) => ({ order: hook.order, html: renderHook(hook, scenario.name) }))
|
|
3848
|
+
].sort((a, b) => a.order - b.order).map((item) => item.html).join("");
|
|
3849
|
+
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>` : "";
|
|
3850
|
+
const description = grouped ? "" : renderDescription(scenario.description);
|
|
3851
|
+
const screenReaderLabel = grouped && outline ? `<span class="sr">${escapeHtml(`${scenario.name}, Scenario Outline ${outline.name}${outline.examplesName ? `, Examples ${outline.examplesName}` : ""}, example ${example}`)}</span>` : "";
|
|
3852
|
+
const visibleName = grouped ? `<span class="exampleNo" aria-hidden="true">${escapeHtml(example)}</span>${screenReaderLabel}` : escapeHtml(scenario.name);
|
|
3853
|
+
const rowTags = grouped ? "" : tagsMarkup(scenario.ownTags);
|
|
3854
|
+
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>` : "";
|
|
2506
3855
|
const copyFailure = scenario.status === "failed" ? '<button class="copyFailure" type="button" data-copy-failure>Copy failure</button>' : "";
|
|
2507
|
-
|
|
3856
|
+
const exampleData = grouped ? ` data-example="${escapeHtml(example)}" data-examples-name="${escapeHtml(outline?.examplesName ?? "")}"` : "";
|
|
3857
|
+
const scenarioMeta = grouped && outline ? `<span>Scenario: ${escapeHtml(scenario.name)}</span>` : "";
|
|
3858
|
+
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>';
|
|
3859
|
+
const statusData = scenario.executed ? ` data-status="${scenario.status}"` : "";
|
|
3860
|
+
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>`;
|
|
3861
|
+
}
|
|
3862
|
+
function renderExamples(outline, rows, featureIndex, idIndex) {
|
|
3863
|
+
const description = renderDescription(outline.examplesDescription);
|
|
3864
|
+
const title = outline.examplesName ? `<span class="kw">${escapeHtml(outline.examplesKeyword)}:</span> ${escapeHtml(outline.examplesName)}` : `<span class="kw">${escapeHtml(outline.examplesKeyword)}:</span>`;
|
|
3865
|
+
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(
|
|
3866
|
+
(scenario) => renderScenario(
|
|
3867
|
+
scenario,
|
|
3868
|
+
featureIndex,
|
|
3869
|
+
idIndex.get(scenario.id) ?? 0,
|
|
3870
|
+
true
|
|
3871
|
+
)
|
|
3872
|
+
).join("")}</div></section>`;
|
|
3873
|
+
}
|
|
3874
|
+
function renderOutline(outline, rows, featureIndex, idIndex) {
|
|
3875
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
3876
|
+
for (const row of rows) {
|
|
3877
|
+
if (!row.outline) continue;
|
|
3878
|
+
const block = blocks.get(row.outline.examplesId) ?? {
|
|
3879
|
+
outline: row.outline,
|
|
3880
|
+
rows: []
|
|
3881
|
+
};
|
|
3882
|
+
block.rows.push(row);
|
|
3883
|
+
blocks.set(row.outline.examplesId, block);
|
|
3884
|
+
}
|
|
3885
|
+
const exampleBlocks = [...blocks.values()].sort((a, b) => a.outline.examplesIndex - b.outline.examplesIndex).map(
|
|
3886
|
+
(block) => renderExamples(block.outline, block.rows, featureIndex, idIndex)
|
|
3887
|
+
).join("");
|
|
3888
|
+
const description = renderDescription(outline.description);
|
|
3889
|
+
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>`;
|
|
3890
|
+
}
|
|
3891
|
+
function renderFeatureItem(item, featureIndex, idIndex, inRule) {
|
|
3892
|
+
if (item.kind === "outline" && item.outline && item.rows) {
|
|
3893
|
+
return renderOutline(item.outline, item.rows, featureIndex, idIndex);
|
|
3894
|
+
}
|
|
3895
|
+
if (item.scenario) {
|
|
3896
|
+
return renderScenario(
|
|
3897
|
+
item.scenario,
|
|
3898
|
+
featureIndex,
|
|
3899
|
+
idIndex.get(item.scenario.id) ?? 0,
|
|
3900
|
+
false,
|
|
3901
|
+
inRule
|
|
3902
|
+
);
|
|
3903
|
+
}
|
|
3904
|
+
return "";
|
|
3905
|
+
}
|
|
3906
|
+
function renderRuleBlock(block, featureIndex, idIndex) {
|
|
3907
|
+
const rule = block.rule;
|
|
3908
|
+
const name = rule.name ? ` ${escapeHtml(rule.name)}` : "";
|
|
3909
|
+
const description = renderDescription(rule.description);
|
|
3910
|
+
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>`;
|
|
3911
|
+
}
|
|
3912
|
+
function renderFeature({ feature, scenarios }, featureIndex) {
|
|
3913
|
+
const executed = executedOnly(scenarios);
|
|
3914
|
+
const open = executed.length === 0 || executed.some(
|
|
3915
|
+
(scenario) => scenario.status !== "passed" || scenario.attachments.some((attachment) => attachment.kind === "image")
|
|
3916
|
+
);
|
|
3917
|
+
const description = renderDescription(feature.description);
|
|
3918
|
+
const idIndex = new Map(scenarios.map((scenario, index) => [scenario.id, index]));
|
|
3919
|
+
const inputIndex = new Map(
|
|
3920
|
+
feature.scenarios.map((scenario, index) => [scenario.id, index])
|
|
3921
|
+
);
|
|
3922
|
+
const groups = /* @__PURE__ */ new Map();
|
|
3923
|
+
const items = [];
|
|
3924
|
+
for (const scenario of feature.scenarios) {
|
|
3925
|
+
if (scenario.outline) {
|
|
3926
|
+
const group = groups.get(scenario.outline.id) ?? {
|
|
3927
|
+
outline: scenario.outline,
|
|
3928
|
+
rows: [],
|
|
3929
|
+
order: inputIndex.get(scenario.id) ?? 0,
|
|
3930
|
+
...scenario.rule ? { ruleId: scenario.rule.id } : {}
|
|
3931
|
+
};
|
|
3932
|
+
group.rows.push(scenario);
|
|
3933
|
+
groups.set(scenario.outline.id, group);
|
|
3934
|
+
} else {
|
|
3935
|
+
items.push({
|
|
3936
|
+
kind: "scenario",
|
|
3937
|
+
status: scenario.status,
|
|
3938
|
+
order: inputIndex.get(scenario.id) ?? 0,
|
|
3939
|
+
...scenario.rule ? { ruleId: scenario.rule.id } : {},
|
|
3940
|
+
scenario
|
|
3941
|
+
});
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
for (const group of groups.values()) {
|
|
3945
|
+
group.rows.sort((a, b) => {
|
|
3946
|
+
const outlineA = a.outline;
|
|
3947
|
+
const outlineB = b.outline;
|
|
3948
|
+
if (!outlineA || !outlineB) return 0;
|
|
3949
|
+
return outlineA.examplesIndex - outlineB.examplesIndex || outlineA.exampleIndex - outlineB.exampleIndex;
|
|
3950
|
+
});
|
|
3951
|
+
items.push({
|
|
3952
|
+
kind: "outline",
|
|
3953
|
+
status: worstExecutedStatus(group.rows),
|
|
3954
|
+
order: group.order,
|
|
3955
|
+
...group.ruleId ? { ruleId: group.ruleId } : {},
|
|
3956
|
+
outline: group.outline,
|
|
3957
|
+
rows: group.rows
|
|
3958
|
+
});
|
|
3959
|
+
}
|
|
3960
|
+
items.sort((a, b) => {
|
|
3961
|
+
const status = compareStatus(a.status, b.status);
|
|
3962
|
+
return status !== 0 ? status : a.order - b.order;
|
|
3963
|
+
});
|
|
3964
|
+
const featureItems = [];
|
|
3965
|
+
const ruleBlocks = /* @__PURE__ */ new Map();
|
|
3966
|
+
for (const item of items) {
|
|
3967
|
+
const rule = item.scenario?.rule ?? item.rows?.[0]?.rule;
|
|
3968
|
+
if (!item.ruleId || !rule) {
|
|
3969
|
+
featureItems.push(item);
|
|
3970
|
+
continue;
|
|
3971
|
+
}
|
|
3972
|
+
const block = ruleBlocks.get(item.ruleId) ?? {
|
|
3973
|
+
rule,
|
|
3974
|
+
items: [],
|
|
3975
|
+
order: item.order
|
|
3976
|
+
};
|
|
3977
|
+
block.items.push(item);
|
|
3978
|
+
block.order = Math.min(block.order, item.order);
|
|
3979
|
+
ruleBlocks.set(item.ruleId, block);
|
|
3980
|
+
}
|
|
3981
|
+
const topItems = [
|
|
3982
|
+
...featureItems,
|
|
3983
|
+
...[...ruleBlocks.values()].map(
|
|
3984
|
+
(block) => ({
|
|
3985
|
+
kind: "rule",
|
|
3986
|
+
status: worstExecutedStatus(
|
|
3987
|
+
block.items.flatMap(
|
|
3988
|
+
(item) => item.scenario ? [item.scenario] : item.rows ?? []
|
|
3989
|
+
)
|
|
3990
|
+
),
|
|
3991
|
+
order: block.order,
|
|
3992
|
+
rule: block.rule,
|
|
3993
|
+
items: block.items
|
|
3994
|
+
})
|
|
3995
|
+
)
|
|
3996
|
+
];
|
|
3997
|
+
topItems.sort((a, b) => {
|
|
3998
|
+
const status = compareStatus(a.status, b.status);
|
|
3999
|
+
return status !== 0 ? status : a.order - b.order;
|
|
4000
|
+
});
|
|
4001
|
+
const backgroundSearch = escapeHtml(
|
|
4002
|
+
feature.backgrounds.map(backgroundText).join(" ")
|
|
4003
|
+
);
|
|
4004
|
+
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(
|
|
4005
|
+
(item) => item.kind === "rule" ? renderRuleBlock(item, featureIndex, idIndex) : renderFeatureItem(item, featureIndex, idIndex, false)
|
|
4006
|
+
).join("")}</div></details>`;
|
|
2508
4007
|
}
|
|
2509
|
-
function
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
(scenario) => scenario.attachments.some((attachment) => attachment.kind === "image")
|
|
4008
|
+
function matrixStatuses(model) {
|
|
4009
|
+
return ALL_STATUSES.filter((status) => model.counts.scenarios[status] > 0).sort(
|
|
4010
|
+
compareStatus
|
|
2513
4011
|
);
|
|
2514
|
-
|
|
2515
|
-
|
|
4012
|
+
}
|
|
4013
|
+
function renderFeatureMatrix(model) {
|
|
4014
|
+
const statuses = matrixStatuses(model);
|
|
4015
|
+
const head = `<tr><th>Feature</th><th>Total</th>${statuses.map((status) => `<th>${statusLabel(status)}</th>`).join("")}<th>Duration</th></tr>`;
|
|
4016
|
+
const rows = model.features.map((feature) => {
|
|
4017
|
+
const executed = executedOnly(feature.scenarios);
|
|
4018
|
+
const counts = countStatuses(executed);
|
|
4019
|
+
const cells = statuses.map((status) => {
|
|
4020
|
+
const count2 = counts[status] ?? 0;
|
|
4021
|
+
return `<td class="num${count2 === 0 ? " zero" : ""}">${count2}</td>`;
|
|
4022
|
+
}).join("");
|
|
4023
|
+
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>`;
|
|
4024
|
+
}).join("");
|
|
4025
|
+
return `<table class="featureTable"><thead>${head}</thead><tbody>${rows}</tbody></table>`;
|
|
2516
4026
|
}
|
|
2517
4027
|
function metadataLine(metadata) {
|
|
2518
4028
|
return Object.entries(metadata ?? {}).filter(([key, value]) => key.length > 0 && value.length > 0).map(
|
|
@@ -2524,13 +4034,18 @@ function renderReportView(model, options) {
|
|
|
2524
4034
|
const passed = model.counts.scenarios.passed;
|
|
2525
4035
|
const percent = total === 0 ? 0 : Math.round(passed / total * 1e3) / 10;
|
|
2526
4036
|
const meta = metadataLine(options.metadata);
|
|
4037
|
+
const ci = ciHeaderMarkup(model.environment?.ci);
|
|
2527
4038
|
const date = dateLabel(model.startedAt);
|
|
2528
|
-
const
|
|
4039
|
+
const ordered = orderFeatures(model.features);
|
|
4040
|
+
const features = ordered.map((feature, index) => renderFeature(feature, index)).join("");
|
|
4041
|
+
const triage = renderTriage(ordered);
|
|
4042
|
+
const sources = renderSourceStrip(model);
|
|
4043
|
+
const runHooks = renderRunHooks(model);
|
|
2529
4044
|
const tags = scenarioTags(model);
|
|
2530
4045
|
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>` : "";
|
|
2531
|
-
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>${escapeHtml(model.source)}</span>${meta}</p></div><div class="health"><div class="healthTop"><strong>${percent}%</strong><span>${passed}
|
|
4046
|
+
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(
|
|
2532
4047
|
(status) => `<button class="filter" type="button" data-status="${status}" aria-pressed="true">${statusLabel(status)} <b>${model.counts.scenarios[status]}</b></button>`
|
|
2533
|
-
).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="
|
|
4048
|
+
).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>`;
|
|
2534
4049
|
}
|
|
2535
4050
|
function renderAnalysisView(model, options, summary) {
|
|
2536
4051
|
const counts = model.counts.scenarios;
|
|
@@ -2548,271 +4063,14 @@ function renderAnalysisView(model, options, summary) {
|
|
|
2548
4063
|
model.environment?.runtime ? `<dt>Runtime</dt><dd>${escapeHtml(model.environment.runtime)}</dd>` : "",
|
|
2549
4064
|
model.environment?.os ? `<dt>OS</dt><dd>${escapeHtml(model.environment.os)}</dd>` : "",
|
|
2550
4065
|
model.environment?.cpu ? `<dt>CPU</dt><dd>${escapeHtml(model.environment.cpu)}</dd>` : "",
|
|
2551
|
-
model.environment?.protocol ? `<dt>Protocol</dt><dd>${escapeHtml(model.environment.protocol)}</dd>` : ""
|
|
4066
|
+
model.environment?.protocol ? `<dt>Protocol</dt><dd>${escapeHtml(model.environment.protocol)}</dd>` : "",
|
|
4067
|
+
ciDetailRows(model.environment?.ci)
|
|
2552
4068
|
].join("");
|
|
2553
|
-
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>`;
|
|
2554
|
-
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}
|
|
2555
|
-
(feature) => `<tr><td>${escapeHtml(feature.name)}</td><td class="num">${feature.scenarios.length}</td><td class="num">${feature.scenarios.filter((scenario) => scenario.status === "passed").length}</td><td class="num">${feature.scenarios.filter((scenario) => scenario.status === "failed").length}</td><td class="num">${durationLabel(feature.durationMs)}</td></tr>`
|
|
2556
|
-
).join("")}</tbody></table></div></section><section class="panel"><h2>Status distribution</h2><p>All scenarios in the run.</p><div class="legend">${displayStatuses(model).map(
|
|
4069
|
+
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>`;
|
|
4070
|
+
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(
|
|
2557
4071
|
(status) => `<div class="legendRow ${statusClass(status)}"><span class="marker ${statusClass(status)}"></span><span>${statusLabel(status)}</span><b>${counts[status]}</b></div>`
|
|
2558
|
-
).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>`;
|
|
2559
|
-
}
|
|
2560
|
-
var SCRIPT = `<script>
|
|
2561
|
-
(function () {
|
|
2562
|
-
var views = Array.prototype.slice.call(document.querySelectorAll('[data-view]'));
|
|
2563
|
-
var report = document.getElementById('report-view');
|
|
2564
|
-
var analysis = document.getElementById('analysis-view');
|
|
2565
|
-
function showView(name) {
|
|
2566
|
-
if (!report || !analysis) return;
|
|
2567
|
-
report.hidden = name !== 'report';
|
|
2568
|
-
analysis.hidden = name !== 'analysis';
|
|
2569
|
-
views.forEach(function (button) {
|
|
2570
|
-
var active = button.getAttribute('data-view') === name;
|
|
2571
|
-
button.setAttribute('aria-selected', active ? 'true' : 'false');
|
|
2572
|
-
});
|
|
2573
|
-
window.scrollTo(0, 0);
|
|
2574
|
-
}
|
|
2575
|
-
views.forEach(function (button) {
|
|
2576
|
-
button.addEventListener('click', function () { showView(button.getAttribute('data-view')); });
|
|
2577
|
-
});
|
|
2578
|
-
var tablist = document.querySelector('[role="tablist"]');
|
|
2579
|
-
if (tablist) tablist.addEventListener('keydown', function (event) {
|
|
2580
|
-
if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
|
|
2581
|
-
event.preventDefault();
|
|
2582
|
-
var index = views.indexOf(document.activeElement);
|
|
2583
|
-
if (index < 0) return;
|
|
2584
|
-
var next = event.key === 'Home' ? 0 : event.key === 'End' ? views.length - 1 : (index + (event.key === 'ArrowRight' ? 1 : -1) + views.length) % views.length;
|
|
2585
|
-
views[next].focus();
|
|
2586
|
-
showView(views[next].getAttribute('data-view'));
|
|
2587
|
-
});
|
|
2588
|
-
var state = { query: '', hidden: new Set(), tag: '' };
|
|
2589
|
-
var scenarios = Array.prototype.slice.call(document.querySelectorAll('[data-scenario]'));
|
|
2590
|
-
var features = Array.prototype.slice.call(document.querySelectorAll('[data-feature]'));
|
|
2591
|
-
var live = document.getElementById('tolkira-live');
|
|
2592
|
-
function apply() {
|
|
2593
|
-
var query = state.query.toLowerCase();
|
|
2594
|
-
var tag = state.tag;
|
|
2595
|
-
var visible = 0;
|
|
2596
|
-
scenarios.forEach(function (scenario) {
|
|
2597
|
-
var status = scenario.getAttribute('data-status');
|
|
2598
|
-
var text = (scenario.getAttribute('data-search') || '').toLowerCase();
|
|
2599
|
-
var tags = ' ' + (scenario.getAttribute('data-tags') || '') + ' ';
|
|
2600
|
-
var tagMatch = !tag || tags.indexOf(' ' + tag + ' ') !== -1;
|
|
2601
|
-
var match = !state.hidden.has(status) && tagMatch && (!query || text.indexOf(query) !== -1);
|
|
2602
|
-
scenario.hidden = !match;
|
|
2603
|
-
if (match) visible += 1;
|
|
2604
|
-
});
|
|
2605
|
-
features.forEach(function (feature) {
|
|
2606
|
-
var children = feature.querySelectorAll('[data-scenario]');
|
|
2607
|
-
var any = Array.prototype.some.call(children, function (child) { return !child.hidden; });
|
|
2608
|
-
feature.hidden = !any;
|
|
2609
|
-
if (any && (query || state.hidden.size || tag)) feature.open = true;
|
|
2610
|
-
});
|
|
2611
|
-
if (query) {
|
|
2612
|
-
scenarios.forEach(function (scenario) {
|
|
2613
|
-
if (!scenario.hidden) scenario.open = true;
|
|
2614
|
-
});
|
|
2615
|
-
}
|
|
2616
|
-
if (live) live.textContent = visible + ' of ' + scenarios.length + ' scenarios visible';
|
|
2617
|
-
var empty = document.getElementById('empty-results');
|
|
2618
|
-
if (empty) empty.hidden = visible !== 0;
|
|
2619
|
-
highlightSearch();
|
|
2620
|
-
}
|
|
2621
|
-
function clearHighlights() {
|
|
2622
|
-
if (typeof CSS === 'undefined' || !CSS.highlights) return;
|
|
2623
|
-
CSS.highlights.delete('tolkira-search');
|
|
2624
|
-
}
|
|
2625
|
-
function escapeRegex(value) {
|
|
2626
|
-
var out = '';
|
|
2627
|
-
for (var i = 0; i < value.length; i++) {
|
|
2628
|
-
var code = value.charCodeAt(i);
|
|
2629
|
-
var ch = value.charAt(i);
|
|
2630
|
-
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;
|
|
2631
|
-
out += special ? String.fromCharCode(92) + ch : ch;
|
|
2632
|
-
}
|
|
2633
|
-
return out;
|
|
2634
|
-
}
|
|
2635
|
-
function highlightSearch() {
|
|
2636
|
-
if (typeof CSS === 'undefined' || !CSS.highlights || typeof Highlight === 'undefined') return;
|
|
2637
|
-
var needle = state.query.trim();
|
|
2638
|
-
if (needle.length < 2) { clearHighlights(); return; }
|
|
2639
|
-
try {
|
|
2640
|
-
var pattern = new RegExp(escapeRegex(needle), 'gi');
|
|
2641
|
-
var ranges = [];
|
|
2642
|
-
scenarios.forEach(function (scenario) {
|
|
2643
|
-
if (scenario.hidden || !scenario.open || ranges.length >= 200) return;
|
|
2644
|
-
var walker = document.createTreeWalker(scenario, NodeFilter.SHOW_TEXT, null);
|
|
2645
|
-
var node;
|
|
2646
|
-
while (ranges.length < 200 && (node = walker.nextNode())) {
|
|
2647
|
-
var value = node.nodeValue;
|
|
2648
|
-
if (!value) continue;
|
|
2649
|
-
var parent = node.parentElement;
|
|
2650
|
-
if (parent && (parent.tagName === 'SCRIPT' || parent.tagName === 'STYLE')) continue;
|
|
2651
|
-
pattern.lastIndex = 0;
|
|
2652
|
-
var match;
|
|
2653
|
-
while (ranges.length < 200 && (match = pattern.exec(value)) !== null) {
|
|
2654
|
-
var range = document.createRange();
|
|
2655
|
-
range.setStart(node, match.index);
|
|
2656
|
-
range.setEnd(node, match.index + match[0].length);
|
|
2657
|
-
ranges.push(range);
|
|
2658
|
-
if (match[0].length === 0) pattern.lastIndex += 1;
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
});
|
|
2662
|
-
clearHighlights();
|
|
2663
|
-
if (ranges.length) CSS.highlights.set('tolkira-search', new Highlight(...ranges));
|
|
2664
|
-
} catch (error) {
|
|
2665
|
-
clearHighlights();
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
var search = document.querySelector('[data-search]');
|
|
2669
|
-
if (search) search.addEventListener('input', function () {
|
|
2670
|
-
state.query = search.value;
|
|
2671
|
-
apply();
|
|
2672
|
-
});
|
|
2673
|
-
var tagFilter = document.querySelector('[data-tag-filter]');
|
|
2674
|
-
if (tagFilter) tagFilter.addEventListener('change', function () {
|
|
2675
|
-
state.tag = tagFilter.value;
|
|
2676
|
-
apply();
|
|
2677
|
-
});
|
|
2678
|
-
Array.prototype.slice.call(document.querySelectorAll('button.filter[data-status]')).forEach(function (button) {
|
|
2679
|
-
button.addEventListener('click', function () {
|
|
2680
|
-
var status = button.getAttribute('data-status');
|
|
2681
|
-
var active = button.getAttribute('aria-pressed') !== 'false';
|
|
2682
|
-
if (active) { state.hidden.add(status); button.setAttribute('aria-pressed', 'false'); }
|
|
2683
|
-
else { state.hidden.delete(status); button.setAttribute('aria-pressed', 'true'); }
|
|
2684
|
-
apply();
|
|
2685
|
-
});
|
|
2686
|
-
});
|
|
2687
|
-
Array.prototype.slice.call(document.querySelectorAll('[data-expand]')).forEach(function (button) {
|
|
2688
|
-
button.addEventListener('click', function () {
|
|
2689
|
-
var open = button.getAttribute('data-expand') === 'all';
|
|
2690
|
-
features.forEach(function (feature) { feature.open = open; });
|
|
2691
|
-
scenarios.forEach(function (scenario) { scenario.open = open; });
|
|
2692
|
-
});
|
|
2693
|
-
});
|
|
2694
|
-
var copyLive = document.getElementById('tolkira-copy-live');
|
|
2695
|
-
function legacyCopy(text) {
|
|
2696
|
-
var active = document.activeElement;
|
|
2697
|
-
var field = document.createElement('textarea');
|
|
2698
|
-
field.value = text;
|
|
2699
|
-
field.setAttribute('readonly', '');
|
|
2700
|
-
field.style.position = 'fixed';
|
|
2701
|
-
field.style.top = '-1000px';
|
|
2702
|
-
document.body.appendChild(field);
|
|
2703
|
-
var ok = false;
|
|
2704
|
-
try {
|
|
2705
|
-
field.select();
|
|
2706
|
-
ok = document.execCommand('copy');
|
|
2707
|
-
} catch (error) {
|
|
2708
|
-
ok = false;
|
|
2709
|
-
} finally {
|
|
2710
|
-
field.remove();
|
|
2711
|
-
if (active && typeof active.focus === 'function') active.focus();
|
|
2712
|
-
}
|
|
2713
|
-
return ok;
|
|
2714
|
-
}
|
|
2715
|
-
function writeClipboard(text, done) {
|
|
2716
|
-
var settled = false;
|
|
2717
|
-
function finish(ok) {
|
|
2718
|
-
if (settled) return;
|
|
2719
|
-
settled = true;
|
|
2720
|
-
done(ok);
|
|
2721
|
-
}
|
|
2722
|
-
function fallback() {
|
|
2723
|
-
finish(legacyCopy(text));
|
|
2724
|
-
}
|
|
2725
|
-
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
2726
|
-
try {
|
|
2727
|
-
navigator.clipboard.writeText(text).then(function () { finish(true); }, fallback);
|
|
2728
|
-
} catch (error) {
|
|
2729
|
-
fallback();
|
|
2730
|
-
}
|
|
2731
|
-
} else {
|
|
2732
|
-
fallback();
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
|
-
function failureText(button) {
|
|
2736
|
-
var scenario = button.closest('[data-scenario]');
|
|
2737
|
-
if (!scenario) return '';
|
|
2738
|
-
var feature = scenario.closest('[data-feature]');
|
|
2739
|
-
var featureTitle = feature ? feature.querySelector('h2') : null;
|
|
2740
|
-
var scenarioTitle = scenario.querySelector('.scenarioName');
|
|
2741
|
-
var step = scenario.querySelector('.step[data-status="failed"]');
|
|
2742
|
-
var keyword = step && step.querySelector('.kw') ? step.querySelector('.kw').textContent.trim() : '';
|
|
2743
|
-
var body = step ? step.querySelector('div') : null;
|
|
2744
|
-
var text = '';
|
|
2745
|
-
if (body) {
|
|
2746
|
-
Array.prototype.forEach.call(body.childNodes, function (node) {
|
|
2747
|
-
if (node.nodeType === 3) text += node.nodeValue;
|
|
2748
|
-
});
|
|
2749
|
-
}
|
|
2750
|
-
var error = step ? step.querySelector('.error') : null;
|
|
2751
|
-
var stepLabel = keyword === 'Hook' ? text.trim() : (keyword + ' ' + text.trim()).trim();
|
|
2752
|
-
var lines = [
|
|
2753
|
-
'Feature: ' + (featureTitle ? featureTitle.textContent : ''),
|
|
2754
|
-
'Scenario: ' + (scenarioTitle ? scenarioTitle.textContent : ''),
|
|
2755
|
-
'URI: ' + (scenario.getAttribute('data-uri') || ''),
|
|
2756
|
-
'Step: ' + stepLabel
|
|
2757
|
-
];
|
|
2758
|
-
if (error && error.textContent.trim()) {
|
|
2759
|
-
lines.push('Error:\\n' + error.textContent.trim());
|
|
2760
|
-
}
|
|
2761
|
-
return lines.join('\\n');
|
|
2762
|
-
}
|
|
2763
|
-
Array.prototype.slice.call(document.querySelectorAll('[data-copy-failure]')).forEach(function (button) {
|
|
2764
|
-
var labelTimer = null;
|
|
2765
|
-
button.addEventListener('click', function () {
|
|
2766
|
-
button.focus();
|
|
2767
|
-
writeClipboard(failureText(button), function (ok) {
|
|
2768
|
-
if (labelTimer) clearTimeout(labelTimer);
|
|
2769
|
-
button.textContent = ok ? 'Copied' : 'Copy failed';
|
|
2770
|
-
if (copyLive) {
|
|
2771
|
-
copyLive.textContent = ok
|
|
2772
|
-
? 'Failure details copied to clipboard.'
|
|
2773
|
-
: 'Could not copy failure details.';
|
|
2774
|
-
}
|
|
2775
|
-
labelTimer = setTimeout(function () {
|
|
2776
|
-
button.textContent = 'Copy failure';
|
|
2777
|
-
if (copyLive) copyLive.textContent = '';
|
|
2778
|
-
}, 2000);
|
|
2779
|
-
});
|
|
2780
|
-
});
|
|
2781
|
-
});
|
|
2782
|
-
var lightbox = document.getElementById('tolkira-lightbox');
|
|
2783
|
-
if (lightbox) {
|
|
2784
|
-
var lightboxImage = lightbox.querySelector('img');
|
|
2785
|
-
var closeLightbox = lightbox.querySelector('[data-lightbox-close]');
|
|
2786
|
-
var lightboxTrigger = null;
|
|
2787
|
-
var previousOverflow = '';
|
|
2788
|
-
function closeDialog() {
|
|
2789
|
-
if (typeof lightbox.close === 'function') lightbox.close();
|
|
2790
|
-
else { lightbox.removeAttribute('open'); restoreLightbox(); }
|
|
2791
|
-
}
|
|
2792
|
-
function restoreLightbox() {
|
|
2793
|
-
document.documentElement.style.overflow = previousOverflow;
|
|
2794
|
-
if (lightboxTrigger) { lightboxTrigger.focus(); lightboxTrigger = null; }
|
|
2795
|
-
}
|
|
2796
|
-
Array.prototype.slice.call(document.querySelectorAll('.shotButton')).forEach(function (button) {
|
|
2797
|
-
button.addEventListener('click', function () {
|
|
2798
|
-
var image = button.querySelector('img');
|
|
2799
|
-
if (!image || !lightboxImage) return;
|
|
2800
|
-
lightboxImage.src = image.src;
|
|
2801
|
-
lightboxImage.alt = image.alt;
|
|
2802
|
-
lightboxTrigger = button;
|
|
2803
|
-
previousOverflow = document.documentElement.style.overflow;
|
|
2804
|
-
document.documentElement.style.overflow = 'hidden';
|
|
2805
|
-
if (typeof lightbox.showModal === 'function') lightbox.showModal();
|
|
2806
|
-
else lightbox.setAttribute('open', '');
|
|
2807
|
-
});
|
|
2808
|
-
});
|
|
2809
|
-
if (closeLightbox) closeLightbox.addEventListener('click', closeDialog);
|
|
2810
|
-
lightbox.addEventListener('click', function (event) { if (event.target === lightbox) closeDialog(); });
|
|
2811
|
-
lightbox.addEventListener('close', restoreLightbox);
|
|
2812
|
-
}
|
|
2813
|
-
showView('report');
|
|
2814
|
-
})();
|
|
2815
|
-
</script>`;
|
|
4072
|
+
).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>`;
|
|
4073
|
+
}
|
|
2816
4074
|
function inlineScriptHashes(html) {
|
|
2817
4075
|
const hashes = /* @__PURE__ */ new Set();
|
|
2818
4076
|
for (const match of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)) {
|
|
@@ -2828,11 +4086,12 @@ function csp(hashes) {
|
|
|
2828
4086
|
}
|
|
2829
4087
|
async function renderHtml(envelopes, options) {
|
|
2830
4088
|
const safeEnvelopes = sanitizeEnvelopes(envelopes);
|
|
2831
|
-
const model = buildReportModel(safeEnvelopes);
|
|
4089
|
+
const model = buildReportModel(safeEnvelopes, options.provenance);
|
|
2832
4090
|
const summary = options.summary ?? summarizeEnvelopes(safeEnvelopes);
|
|
2833
4091
|
const logo = isLogoDataUri(options.logo) ? `<img class="logo" src="${escapeHtml(options.logo)}" alt="">` : "";
|
|
2834
4092
|
const accent = isValidAccent(options.accent) ? `<style>:root{--accent:${options.accent}}</style>` : "";
|
|
2835
|
-
const
|
|
4093
|
+
const clientScript = `<script>${CLIENT_SCRIPT.replace(/<\/script/gi, "<\\/script")}</script>`;
|
|
4094
|
+
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}`;
|
|
2836
4095
|
const hashes = inlineScriptHashes(body);
|
|
2837
4096
|
return `<!doctype html>
|
|
2838
4097
|
<html lang="en">
|
|
@@ -2847,19 +4106,39 @@ ${csp(hashes)}
|
|
|
2847
4106
|
</html>`;
|
|
2848
4107
|
}
|
|
2849
4108
|
|
|
4109
|
+
// src/stream.ts
|
|
4110
|
+
import { Transform } from "node:stream";
|
|
4111
|
+
var CucumberHtmlStream = class extends Transform {
|
|
4112
|
+
constructor(options = {}) {
|
|
4113
|
+
super({ objectMode: true });
|
|
4114
|
+
this.options = options;
|
|
4115
|
+
}
|
|
4116
|
+
options;
|
|
4117
|
+
envelopes = [];
|
|
4118
|
+
_transform(envelope, _encoding, callback) {
|
|
4119
|
+
this.envelopes.push(envelope);
|
|
4120
|
+
callback();
|
|
4121
|
+
}
|
|
4122
|
+
_flush(callback) {
|
|
4123
|
+
renderHtml(this.envelopes, renderOptions(this.options)).then(
|
|
4124
|
+
(html) => callback(null, html),
|
|
4125
|
+
(error) => callback(error instanceof Error ? error : new Error(String(error)))
|
|
4126
|
+
);
|
|
4127
|
+
}
|
|
4128
|
+
};
|
|
4129
|
+
|
|
2850
4130
|
// src/index.ts
|
|
2851
|
-
var version = "0.
|
|
4131
|
+
var version = "0.3.0";
|
|
2852
4132
|
var phase = "development";
|
|
2853
4133
|
async function generateReport(inputs, options = {}) {
|
|
2854
|
-
const
|
|
4134
|
+
const groups = await loadInputs(inputs);
|
|
4135
|
+
const envelopes = groups.flatMap((group) => group.envelopes);
|
|
2855
4136
|
const summary = summarizeEnvelopes(envelopes);
|
|
2856
4137
|
return {
|
|
2857
4138
|
html: await renderHtml(envelopes, {
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
accent: options.accent,
|
|
2862
|
-
summary
|
|
4139
|
+
...renderOptions(options),
|
|
4140
|
+
summary,
|
|
4141
|
+
provenance: groups.length > 1 ? provenanceFor(groups) : void 0
|
|
2863
4142
|
}),
|
|
2864
4143
|
summary
|
|
2865
4144
|
};
|
|
@@ -2868,6 +4147,7 @@ async function renderReport(inputs, options = {}) {
|
|
|
2868
4147
|
return (await generateReport(inputs, options)).html;
|
|
2869
4148
|
}
|
|
2870
4149
|
export {
|
|
4150
|
+
CucumberHtmlStream,
|
|
2871
4151
|
SUMMARY_SCHEMA_VERSION,
|
|
2872
4152
|
generateReport,
|
|
2873
4153
|
phase,
|