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