tolkira 0.1.2 → 0.2.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 +15 -0
- package/README.md +16 -6
- package/dist/cli.js +517 -88
- package/dist/cli.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +470 -87
- package/dist/index.js.map +3 -3
- package/dist/input/junit.d.ts +3 -1
- package/dist/input/load.d.ts +11 -0
- package/dist/render/escape.d.ts +1 -1
- package/dist/render/html.d.ts +1 -0
- package/dist/report/model.d.ts +4 -1
- package/dist/summary.d.ts +1 -0
- package/docs/COMPATIBILITY.md +14 -4
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -16,8 +16,7 @@ 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";
|
|
22
21
|
function isRecord(value) {
|
|
23
22
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -152,13 +151,13 @@ function createIdFactory(prefix) {
|
|
|
152
151
|
}
|
|
153
152
|
function normalizeUri(uri, index) {
|
|
154
153
|
if (!uri) return `features/legacy-${index}.feature`;
|
|
155
|
-
const slashed = uri.replace(/\\/g, "/");
|
|
154
|
+
const slashed = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
156
155
|
const normalized = slashed.replace(/^\.\//, "");
|
|
157
156
|
if (/^[a-z]:\//i.test(normalized) || slashed.startsWith("/")) {
|
|
158
157
|
const marker = slashed.lastIndexOf("/features/");
|
|
159
158
|
if (marker >= 0) return slashed.slice(marker + 1);
|
|
160
159
|
const parts = slashed.split("/").filter(Boolean);
|
|
161
|
-
return parts.
|
|
160
|
+
return parts[parts.length - 1] ?? `features/legacy-${index}.feature`;
|
|
162
161
|
}
|
|
163
162
|
return normalized || `features/legacy-${index}.feature`;
|
|
164
163
|
}
|
|
@@ -382,11 +381,11 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
382
381
|
const statuses = [];
|
|
383
382
|
let attachmentCounter = 0;
|
|
384
383
|
const meta = {
|
|
385
|
-
protocolVersion:
|
|
384
|
+
protocolVersion: "",
|
|
386
385
|
implementation: { name: "tolkira-legacy-json" },
|
|
387
|
-
runtime: { name: "
|
|
388
|
-
os: { name:
|
|
389
|
-
cpu: { name:
|
|
386
|
+
runtime: { name: "" },
|
|
387
|
+
os: { name: "" },
|
|
388
|
+
cpu: { name: "" }
|
|
390
389
|
};
|
|
391
390
|
envelopes.push({ meta });
|
|
392
391
|
envelopes.push({ testRunStarted: { id: runId, timestamp: timestamp(startedAt) } });
|
|
@@ -598,7 +597,7 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
598
597
|
envelopes.push({
|
|
599
598
|
gherkinDocument: { uri, feature: featureNode, comments: [] }
|
|
600
599
|
});
|
|
601
|
-
envelopes.push(
|
|
600
|
+
for (const envelope of scenarioEnvelopes) envelopes.push(envelope);
|
|
602
601
|
}
|
|
603
602
|
const success = !statuses.some(
|
|
604
603
|
(status) => status === TestStepResultStatus.FAILED || status === TestStepResultStatus.AMBIGUOUS || status === TestStepResultStatus.UNDEFINED
|
|
@@ -893,7 +892,7 @@ function looksLikeJUnit(content) {
|
|
|
893
892
|
const trimmed = content.replace(/^\uFEFF/, "").trimStart();
|
|
894
893
|
return trimmed.startsWith("<") && /<testsuites?\b/i.test(trimmed);
|
|
895
894
|
}
|
|
896
|
-
async function parseJUnitXml(content, source) {
|
|
895
|
+
async function parseJUnitXml(content, source, options = {}) {
|
|
897
896
|
const { XMLParser, XMLValidator } = await import("fast-xml-parser");
|
|
898
897
|
assertValidEntities(content, source);
|
|
899
898
|
const validation = XMLValidator.validate(content);
|
|
@@ -930,7 +929,9 @@ async function parseJUnitXml(content, source) {
|
|
|
930
929
|
const legacy = suites.map(
|
|
931
930
|
(suite, index) => featureFromSuite(suite, source, index)
|
|
932
931
|
);
|
|
933
|
-
const envelopes = parseLegacyValue(legacy, source, {
|
|
932
|
+
const envelopes = parseLegacyValue(legacy, source, {
|
|
933
|
+
idPrefix: options.idPrefix ?? "junit"
|
|
934
|
+
});
|
|
934
935
|
for (const envelope of envelopes) {
|
|
935
936
|
if (envelope.meta) {
|
|
936
937
|
envelope.meta.implementation = { name: "JUnit XML", version: "" };
|
|
@@ -1174,7 +1175,7 @@ function sniffLegacy(content) {
|
|
|
1174
1175
|
}
|
|
1175
1176
|
}
|
|
1176
1177
|
function looksLikeMessages(content) {
|
|
1177
|
-
const firstLine = content.split(/\r?\n
|
|
1178
|
+
const firstLine = content.replace(/^\uFEFF/, "").split(/\r?\n/, 20).map((line) => line.trim()).find(Boolean);
|
|
1178
1179
|
if (!firstLine) return false;
|
|
1179
1180
|
try {
|
|
1180
1181
|
return isEnvelopeLike(JSON.parse(firstLine));
|
|
@@ -1198,7 +1199,23 @@ async function canonicalPath(file) {
|
|
|
1198
1199
|
return path2.resolve(file);
|
|
1199
1200
|
}
|
|
1200
1201
|
}
|
|
1201
|
-
|
|
1202
|
+
function collectGherkinIds(value) {
|
|
1203
|
+
const ids = [];
|
|
1204
|
+
const visit = (node) => {
|
|
1205
|
+
if (Array.isArray(node)) {
|
|
1206
|
+
for (const child of node) visit(child);
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (!node || typeof node !== "object") return;
|
|
1210
|
+
for (const [key, child] of Object.entries(node)) {
|
|
1211
|
+
if (key === "id" && typeof child === "string") ids.push(child);
|
|
1212
|
+
else visit(child);
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
visit(value);
|
|
1216
|
+
return ids;
|
|
1217
|
+
}
|
|
1218
|
+
async function loadInputs(inputs) {
|
|
1202
1219
|
const requested = Array.isArray(inputs) ? inputs : [inputs];
|
|
1203
1220
|
if (requested.length === 0) {
|
|
1204
1221
|
throw new Error("No input files provided.");
|
|
@@ -1229,7 +1246,7 @@ async function loadEnvelopes(inputs) {
|
|
|
1229
1246
|
const ordered = [...files.values()].sort(
|
|
1230
1247
|
(a, b) => a.file.localeCompare(b.file)
|
|
1231
1248
|
);
|
|
1232
|
-
const
|
|
1249
|
+
const groups = [];
|
|
1233
1250
|
const seenContent = /* @__PURE__ */ new Set();
|
|
1234
1251
|
let totalBytes = 0;
|
|
1235
1252
|
for (const [index, input] of ordered.entries()) {
|
|
@@ -1246,41 +1263,105 @@ async function loadEnvelopes(inputs) {
|
|
|
1246
1263
|
totalBytes += info.size;
|
|
1247
1264
|
const extension = path2.extname(input.file).toLowerCase();
|
|
1248
1265
|
const legacy = sniffLegacy(content);
|
|
1266
|
+
let parsed = [];
|
|
1249
1267
|
if (legacy?.kind === "legacy") {
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
);
|
|
1255
|
-
continue;
|
|
1256
|
-
}
|
|
1257
|
-
if (legacy?.kind === "malformed") {
|
|
1268
|
+
parsed = parseLegacyValue(legacy.parsed, input.file, {
|
|
1269
|
+
idPrefix: `legacy-${index}`
|
|
1270
|
+
});
|
|
1271
|
+
} else if (legacy?.kind === "malformed") {
|
|
1258
1272
|
parseLegacyJson(content, input.file, { idPrefix: `legacy-${index}` });
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1273
|
+
} else if (looksLikeJUnit(content)) {
|
|
1274
|
+
parsed = await parseJUnitXml(content, input.file, {
|
|
1275
|
+
idPrefix: `junit-${index}`
|
|
1276
|
+
});
|
|
1277
|
+
} else if (looksLikeMessages(content)) {
|
|
1278
|
+
parsed = parseMessages(content, input.file);
|
|
1279
|
+
} else if (input.explicit && extension === ".xml") {
|
|
1280
|
+
await parseJUnitXml(content, input.file, { idPrefix: `junit-${index}` });
|
|
1281
|
+
} else {
|
|
1282
|
+
if (input.explicit && MESSAGES_EXTENSIONS.has(extension) && content.trim().length === 0) {
|
|
1283
|
+
throw new Error(`Input is empty: ${input.file}`);
|
|
1284
|
+
}
|
|
1285
|
+
if (input.explicit) {
|
|
1286
|
+
invalidJson(content, input.file);
|
|
1287
|
+
}
|
|
1288
|
+
if (MESSAGES_EXTENSIONS.has(extension)) {
|
|
1289
|
+
parseMessages(content, input.file);
|
|
1290
|
+
}
|
|
1264
1291
|
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1292
|
+
groups.push({ file: input.file, envelopes: parsed });
|
|
1293
|
+
}
|
|
1294
|
+
if (groups.every((group) => group.envelopes.length === 0)) {
|
|
1295
|
+
throw new Error("No supported report files found.");
|
|
1296
|
+
}
|
|
1297
|
+
const seenIds = /* @__PURE__ */ new Map();
|
|
1298
|
+
for (const group of groups) {
|
|
1299
|
+
const file = path2.basename(group.file);
|
|
1300
|
+
for (const envelope of group.envelopes) {
|
|
1301
|
+
const ids = [
|
|
1302
|
+
["pickle", envelope.pickle?.id],
|
|
1303
|
+
["testCase", envelope.testCase?.id],
|
|
1304
|
+
["testCaseStarted", envelope.testCaseStarted?.id],
|
|
1305
|
+
["hook", envelope.hook?.id]
|
|
1306
|
+
];
|
|
1307
|
+
for (const step of envelope.testCase?.testSteps ?? []) {
|
|
1308
|
+
ids.push(["testStep", step.id]);
|
|
1309
|
+
}
|
|
1310
|
+
for (const id of collectGherkinIds(envelope.gherkinDocument)) {
|
|
1311
|
+
ids.push(["gherkin", id]);
|
|
1312
|
+
}
|
|
1313
|
+
for (const [kind, id] of ids) {
|
|
1314
|
+
if (!id) continue;
|
|
1315
|
+
const key = `${kind}:${id}`;
|
|
1316
|
+
const previous = seenIds.get(key);
|
|
1317
|
+
if (previous) {
|
|
1318
|
+
throw new Error(
|
|
1319
|
+
`Duplicate Cucumber Messages ${kind} id in ${previous} and ${file}. Merge the streams before splitting or use unique ids.`
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
seenIds.set(key, file);
|
|
1323
|
+
}
|
|
1268
1324
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1325
|
+
}
|
|
1326
|
+
return groups;
|
|
1327
|
+
}
|
|
1328
|
+
async function loadEnvelopes(inputs) {
|
|
1329
|
+
return (await loadInputs(inputs)).flatMap((group) => group.envelopes);
|
|
1330
|
+
}
|
|
1331
|
+
function provenanceFor(groups) {
|
|
1332
|
+
const names = /* @__PURE__ */ new Map();
|
|
1333
|
+
for (const group of groups) {
|
|
1334
|
+
if (!group.envelopes.some(
|
|
1335
|
+
(envelope) => envelope.gherkinDocument || envelope.pickle
|
|
1336
|
+
)) {
|
|
1271
1337
|
continue;
|
|
1272
1338
|
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1339
|
+
const name = path2.basename(group.file);
|
|
1340
|
+
const set = names.get(name) ?? /* @__PURE__ */ new Set();
|
|
1341
|
+
set.add(group.file);
|
|
1342
|
+
names.set(name, set);
|
|
1343
|
+
}
|
|
1344
|
+
const ambiguous = new Set(
|
|
1345
|
+
[...names.entries()].filter(([, files]) => files.size > 1).map(([name]) => name)
|
|
1346
|
+
);
|
|
1347
|
+
const uriFiles = /* @__PURE__ */ new Map();
|
|
1348
|
+
for (const group of groups) {
|
|
1349
|
+
const name = path2.basename(group.file);
|
|
1350
|
+
if (ambiguous.has(name)) continue;
|
|
1351
|
+
for (const envelope of group.envelopes) {
|
|
1352
|
+
for (const uri of [envelope.gherkinDocument?.uri, envelope.pickle?.uri]) {
|
|
1353
|
+
if (!uri) continue;
|
|
1354
|
+
const set = uriFiles.get(uri) ?? /* @__PURE__ */ new Set();
|
|
1355
|
+
set.add(name);
|
|
1356
|
+
uriFiles.set(uri, set);
|
|
1357
|
+
}
|
|
1278
1358
|
}
|
|
1279
1359
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1360
|
+
const provenance = /* @__PURE__ */ new Map();
|
|
1361
|
+
for (const [uri, files] of uriFiles) {
|
|
1362
|
+
if (files.size === 1) provenance.set(uri, [...files][0]);
|
|
1282
1363
|
}
|
|
1283
|
-
return
|
|
1364
|
+
return provenance;
|
|
1284
1365
|
}
|
|
1285
1366
|
|
|
1286
1367
|
// src/render/html.ts
|
|
@@ -1391,6 +1472,9 @@ var STATUS_ORDER = [
|
|
|
1391
1472
|
TestStepResultStatus3.AMBIGUOUS,
|
|
1392
1473
|
TestStepResultStatus3.FAILED
|
|
1393
1474
|
];
|
|
1475
|
+
function statusSeverity(status) {
|
|
1476
|
+
return STATUS_ORDER.indexOf(status.toUpperCase());
|
|
1477
|
+
}
|
|
1394
1478
|
var VALID_STATUS = /* @__PURE__ */ new Set([
|
|
1395
1479
|
"passed",
|
|
1396
1480
|
"failed",
|
|
@@ -1408,12 +1492,22 @@ function durationMs(duration2) {
|
|
|
1408
1492
|
if (!duration2) return 0;
|
|
1409
1493
|
const seconds = Number.isFinite(duration2.seconds) ? duration2.seconds : 0;
|
|
1410
1494
|
const nanos = Number.isFinite(duration2.nanos) ? duration2.nanos : 0;
|
|
1411
|
-
|
|
1495
|
+
const milliseconds = seconds * 1e3 + nanos / 1e6;
|
|
1496
|
+
if (!Number.isFinite(milliseconds) || milliseconds <= 0) return 0;
|
|
1497
|
+
const rounded = Math.round(milliseconds * 1e3) / 1e3;
|
|
1498
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1499
|
+
}
|
|
1500
|
+
function finiteDuration(value) {
|
|
1501
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
1502
|
+
const rounded = Math.round(value * 1e3) / 1e3;
|
|
1503
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1412
1504
|
}
|
|
1413
1505
|
function timestampIso(timestamp2) {
|
|
1414
1506
|
if (!timestamp2) return void 0;
|
|
1415
1507
|
const milliseconds = timestamp2.seconds * 1e3 + timestamp2.nanos / 1e6;
|
|
1416
|
-
|
|
1508
|
+
if (!Number.isFinite(milliseconds)) return void 0;
|
|
1509
|
+
const date = new Date(milliseconds);
|
|
1510
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
1417
1511
|
}
|
|
1418
1512
|
function normalizeText2(value) {
|
|
1419
1513
|
return (value ?? "").replace(/\r\n/g, "\n");
|
|
@@ -1549,8 +1643,10 @@ function featureTree(document) {
|
|
|
1549
1643
|
visit(document.children ?? []);
|
|
1550
1644
|
return map;
|
|
1551
1645
|
}
|
|
1552
|
-
function buildReportModel(envelopes) {
|
|
1646
|
+
function buildReportModel(envelopes, provenance) {
|
|
1553
1647
|
const features = /* @__PURE__ */ new Map();
|
|
1648
|
+
const featureUris = /* @__PURE__ */ new Map();
|
|
1649
|
+
const featureSeen = /* @__PURE__ */ new Set();
|
|
1554
1650
|
const featureOrder = [];
|
|
1555
1651
|
const scenarioTree = /* @__PURE__ */ new Map();
|
|
1556
1652
|
const featureByScenarioId = /* @__PURE__ */ new Map();
|
|
@@ -1598,8 +1694,12 @@ function buildReportModel(envelopes) {
|
|
|
1598
1694
|
}
|
|
1599
1695
|
if (envelope.gherkinDocument?.feature) {
|
|
1600
1696
|
const feature = envelope.gherkinDocument.feature;
|
|
1601
|
-
|
|
1602
|
-
|
|
1697
|
+
const uri = envelope.gherkinDocument.uri;
|
|
1698
|
+
const key = uri ?? feature.name;
|
|
1699
|
+
if (!features.has(key)) features.set(key, feature);
|
|
1700
|
+
if (!featureSeen.has(feature)) {
|
|
1701
|
+
featureSeen.add(feature);
|
|
1702
|
+
if (uri) featureUris.set(feature, uri);
|
|
1603
1703
|
featureOrder.push(feature);
|
|
1604
1704
|
}
|
|
1605
1705
|
for (const [id, value] of featureTree(feature)) {
|
|
@@ -1737,8 +1837,8 @@ function buildReportModel(envelopes) {
|
|
|
1737
1837
|
featureName: feature?.name ?? pickle.uri,
|
|
1738
1838
|
...tree?.ruleName ? { ruleName: tree.ruleName } : {},
|
|
1739
1839
|
status,
|
|
1740
|
-
durationMs:
|
|
1741
|
-
attempt: latest.attempt,
|
|
1840
|
+
durationMs: finiteDuration(duration2),
|
|
1841
|
+
attempt: Number.isFinite(latest.attempt) ? latest.attempt : 0,
|
|
1742
1842
|
...timestampIso(latest.timestamp) ? { startedAt: timestampIso(latest.timestamp) } : {},
|
|
1743
1843
|
tags: pickle.tags.map((tag) => tag.name),
|
|
1744
1844
|
steps: stepRows,
|
|
@@ -1755,16 +1855,26 @@ function buildReportModel(envelopes) {
|
|
|
1755
1855
|
}
|
|
1756
1856
|
}
|
|
1757
1857
|
const featureRows = [];
|
|
1858
|
+
const inInputOrder = new Set(featureOrder);
|
|
1758
1859
|
const orderedFeatures = [
|
|
1759
1860
|
...featureOrder,
|
|
1760
|
-
...[...featureScenarios.keys()].filter(
|
|
1861
|
+
...[...featureScenarios.keys()].filter(
|
|
1862
|
+
(feature) => !inInputOrder.has(feature)
|
|
1863
|
+
)
|
|
1761
1864
|
];
|
|
1762
1865
|
for (const feature of orderedFeatures) {
|
|
1763
1866
|
const scenarios = featureScenarios.get(feature) ?? [];
|
|
1764
1867
|
if (scenarios.length === 0) continue;
|
|
1765
|
-
const status = scenarios.reduce((worst, scenario) => {
|
|
1766
|
-
|
|
1767
|
-
|
|
1868
|
+
const status = scenarios.some((scenario) => scenario.status !== "passed") ? scenarios.reduce((worst, scenario) => {
|
|
1869
|
+
if (scenario.status === "passed") return worst;
|
|
1870
|
+
return statusSeverity(scenario.status) > statusSeverity(worst) ? scenario.status : worst;
|
|
1871
|
+
}, "unknown") : "passed";
|
|
1872
|
+
const featureUri = featureUris.get(feature) ?? scenarios[0]?.uri ?? "";
|
|
1873
|
+
const sourceFiles = /* @__PURE__ */ new Set([
|
|
1874
|
+
...scenarios.map((scenario) => provenance?.get(scenario.uri)),
|
|
1875
|
+
provenance?.get(featureUri)
|
|
1876
|
+
]);
|
|
1877
|
+
const sourceFile = sourceFiles.size === 1 && !sourceFiles.has(void 0) ? [...sourceFiles][0] : void 0;
|
|
1768
1878
|
featureRows.push({
|
|
1769
1879
|
id: `feature-${featureRows.length + 1}`,
|
|
1770
1880
|
name: feature.name,
|
|
@@ -1773,11 +1883,17 @@ function buildReportModel(envelopes) {
|
|
|
1773
1883
|
description: normalizeText2(feature.description),
|
|
1774
1884
|
tags: feature.tags.map((tag) => tag.name),
|
|
1775
1885
|
status,
|
|
1776
|
-
durationMs:
|
|
1886
|
+
durationMs: finiteDuration(
|
|
1887
|
+
scenarios.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
1888
|
+
),
|
|
1777
1889
|
scenarios,
|
|
1778
|
-
attachments: scenarios.reduce((sum, scenario) => sum + scenario.attachments.length, 0)
|
|
1890
|
+
attachments: scenarios.reduce((sum, scenario) => sum + scenario.attachments.length, 0),
|
|
1891
|
+
...sourceFile ? { sourceFile } : {}
|
|
1779
1892
|
});
|
|
1780
1893
|
}
|
|
1894
|
+
if (featureRows.some((feature) => !feature.sourceFile)) {
|
|
1895
|
+
for (const feature of featureRows) delete feature.sourceFile;
|
|
1896
|
+
}
|
|
1781
1897
|
const attachmentRows = scenarioRows.flatMap((scenario) => scenario.attachments);
|
|
1782
1898
|
const runAttachments = mapAttachments(attachments.get("") ?? []);
|
|
1783
1899
|
const allAttachments = [...attachmentRows, ...runAttachments];
|
|
@@ -1792,7 +1908,9 @@ function buildReportModel(envelopes) {
|
|
|
1792
1908
|
attachments: allAttachments.length,
|
|
1793
1909
|
attachmentBytes: allAttachments.reduce((sum, attachment) => sum + attachment.bytes, 0)
|
|
1794
1910
|
},
|
|
1795
|
-
durationMs:
|
|
1911
|
+
durationMs: finiteDuration(
|
|
1912
|
+
scenarioRows.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
1913
|
+
),
|
|
1796
1914
|
...startedAt ? { startedAt } : {},
|
|
1797
1915
|
...finishedAt ? { finishedAt } : {},
|
|
1798
1916
|
source,
|
|
@@ -1870,7 +1988,15 @@ function durationMs2(duration2) {
|
|
|
1870
1988
|
if (!duration2) return 0;
|
|
1871
1989
|
const seconds = Number.isFinite(duration2.seconds) ? duration2.seconds : 0;
|
|
1872
1990
|
const nanos = Number.isFinite(duration2.nanos) ? duration2.nanos : 0;
|
|
1873
|
-
|
|
1991
|
+
const milliseconds = seconds * 1e3 + nanos / 1e6;
|
|
1992
|
+
if (!Number.isFinite(milliseconds) || milliseconds <= 0) return 0;
|
|
1993
|
+
const rounded = Math.round(milliseconds * 1e3) / 1e3;
|
|
1994
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1995
|
+
}
|
|
1996
|
+
function finiteDuration2(value) {
|
|
1997
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
1998
|
+
const rounded = Math.round(value * 1e3) / 1e3;
|
|
1999
|
+
return Number.isFinite(rounded) ? rounded : 0;
|
|
1874
2000
|
}
|
|
1875
2001
|
function scenarioStatus(results) {
|
|
1876
2002
|
if (results.length === 0) return "unknown";
|
|
@@ -1880,13 +2006,14 @@ function statusOrdinal(status) {
|
|
|
1880
2006
|
return STATUS_ORDER2.indexOf(status.toUpperCase());
|
|
1881
2007
|
}
|
|
1882
2008
|
function displayUri(uri) {
|
|
1883
|
-
const normalized = uri.replace(/\\/g, "/");
|
|
2009
|
+
const normalized = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
1884
2010
|
if (!/^[a-z]:\//i.test(normalized) && !normalized.startsWith("/")) {
|
|
1885
2011
|
return normalized;
|
|
1886
2012
|
}
|
|
1887
2013
|
const marker = normalized.lastIndexOf("/features/");
|
|
1888
2014
|
if (marker >= 0) return normalized.slice(marker + 1);
|
|
1889
|
-
|
|
2015
|
+
const parts = normalized.split("/").filter(Boolean);
|
|
2016
|
+
return parts[parts.length - 1] ?? uri;
|
|
1890
2017
|
}
|
|
1891
2018
|
function featureTree2(document) {
|
|
1892
2019
|
const stepKeywords = /* @__PURE__ */ new Map();
|
|
@@ -2063,7 +2190,7 @@ function summarizeEnvelopes(input) {
|
|
|
2063
2190
|
uri: displayUri(pickle.uri ?? ""),
|
|
2064
2191
|
feature: tree.featureName,
|
|
2065
2192
|
status,
|
|
2066
|
-
durationMs:
|
|
2193
|
+
durationMs: finiteDuration2(scenarioDuration),
|
|
2067
2194
|
attempt: started?.attempt ?? 0,
|
|
2068
2195
|
tags: (pickle.tags ?? []).map((tag) => tag.name),
|
|
2069
2196
|
attachments: scenarioAttachments.length,
|
|
@@ -2083,7 +2210,7 @@ function summarizeEnvelopes(input) {
|
|
|
2083
2210
|
return {
|
|
2084
2211
|
schemaVersion: SUMMARY_SCHEMA_VERSION,
|
|
2085
2212
|
status: overall,
|
|
2086
|
-
durationMs:
|
|
2213
|
+
durationMs: finiteDuration2(totalDuration),
|
|
2087
2214
|
counts: {
|
|
2088
2215
|
features: featureSet.size,
|
|
2089
2216
|
scenarios: scenarioCounts,
|
|
@@ -2116,7 +2243,7 @@ function isLogoDataUri(value) {
|
|
|
2116
2243
|
|
|
2117
2244
|
// src/render/escape.ts
|
|
2118
2245
|
function escapeHtml(value) {
|
|
2119
|
-
return value.replace(/[&<>"']/g, (character) => {
|
|
2246
|
+
return String(value ?? "").replace(/[&<>"']/g, (character) => {
|
|
2120
2247
|
switch (character) {
|
|
2121
2248
|
case "&":
|
|
2122
2249
|
return "&";
|
|
@@ -2226,13 +2353,56 @@ img, video { max-width: 100%; height: auto; }
|
|
|
2226
2353
|
.expand { display: flex; gap: 0.25rem; margin-left: auto; }
|
|
2227
2354
|
.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
2355
|
.live { margin: 0.625rem 0 0; color: var(--muted); font-size: 0.75rem; }
|
|
2356
|
+
.searchNote { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.75rem; }
|
|
2357
|
+
.triageBox { margin: 1.25rem 0 1.5rem; }
|
|
2358
|
+
.triageBox > summary { display: none; }
|
|
2359
|
+
.triageSummary { align-items: baseline; gap: 0.25rem 0.5rem; }
|
|
2360
|
+
.triageSummary .triageTitle { font-weight: 600; }
|
|
2361
|
+
.triageSummaryLead { color: var(--muted); font-size: 0.8125rem; }
|
|
2362
|
+
.triageSummary .chev { margin-left: auto; }
|
|
2363
|
+
.triageBox .triage { margin: 0; }
|
|
2364
|
+
.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); }
|
|
2365
|
+
.triage h2 { margin: 0; font-size: 1.125rem; line-height: 1.3; }
|
|
2366
|
+
.triageLead { margin: 0.25rem 0 0.875rem; color: var(--muted); font-size: 0.8125rem; }
|
|
2367
|
+
.triageList { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.875rem; }
|
|
2368
|
+
.triageItem { display: grid; gap: 0.25rem; min-width: 0; padding-top: 0.875rem; border-top: 1px solid var(--line); }
|
|
2369
|
+
.triageItem:first-child { padding-top: 0; border-top: 0; }
|
|
2370
|
+
.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; }
|
|
2371
|
+
.triageFeature:hover { text-decoration: underline; text-underline-offset: 0.16em; }
|
|
2372
|
+
.triageCounts { margin: 0; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
2373
|
+
.triageScenarios { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.875rem; margin: 0.125rem 0 0; padding: 0; list-style: none; }
|
|
2374
|
+
.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; }
|
|
2375
|
+
.triageScenarios a:hover { color: var(--ink); text-decoration-color: currentColor; }
|
|
2376
|
+
.triageStatus { flex: none; font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.01em; }
|
|
2377
|
+
.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); }
|
|
2378
|
+
.triageMore { color: var(--muted); font-size: 0.75rem; }
|
|
2379
|
+
.triageReason { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
|
|
2380
|
+
.triageReasonLabel { color: var(--ink-2); font-weight: 500; }
|
|
2381
|
+
.triageRest { margin-top: 0.75rem; }
|
|
2382
|
+
.triageRest > summary { min-height: 1.5rem; padding-block: 0.125rem; color: var(--accent-text); font-size: 0.8125rem; cursor: pointer; }
|
|
2383
|
+
.triageRest .triageList { margin-top: 0.75rem; }
|
|
2384
|
+
.sources { margin: 0 0 1.5rem; }
|
|
2385
|
+
.sources h2 { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
|
|
2386
|
+
.sourceList { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
|
|
2387
|
+
.sourceItem { min-width: 0; padding: 0.75rem 0.875rem; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-2); }
|
|
2388
|
+
.sourceHead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.5rem; }
|
|
2389
|
+
.sourceName { color: var(--ink); font-size: 0.8125rem; font-weight: 600; overflow-wrap: anywhere; }
|
|
2390
|
+
.sourceCounts { margin: 0.25rem 0 0.5rem; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
2391
|
+
.sourceItem .bar { margin: 0; height: 0.25rem; }
|
|
2229
2392
|
.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)
|
|
2393
|
+
.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; }
|
|
2394
|
+
.feature > summary .statusCell { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
|
|
2395
|
+
.feature > summary h2 { grid-column: 2; grid-row: 1; }
|
|
2396
|
+
.feature > summary .chev { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
|
|
2397
|
+
.featureShape { grid-column: 2; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; min-width: 0; }
|
|
2398
|
+
.featureCounts { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
2399
|
+
.featureShape .bar { flex: 1 1 6rem; max-width: 16rem; margin: 0; height: 0.25rem; }
|
|
2400
|
+
.featureSource { color: var(--muted); font-size: 0.6875rem; }
|
|
2401
|
+
.featureUri { color: var(--muted); font-size: 0.6875rem; overflow-wrap: anywhere; }
|
|
2231
2402
|
.feature > summary::-webkit-details-marker, .scenarioButton::-webkit-details-marker { display: none; }
|
|
2232
2403
|
.feature > summary:focus-visible, .scenarioButton:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
2233
2404
|
.feature > summary:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--paper)); }
|
|
2234
2405
|
.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
2406
|
.statusCell { display: flex; align-items: center; }
|
|
2237
2407
|
.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
2408
|
.statusText.pass { color: var(--pass); border-color: color-mix(in oklab, var(--pass) 32%, var(--line)); background: var(--pass-soft); }
|
|
@@ -2246,7 +2416,7 @@ details[open] > summary .chev { transform: rotate(180deg); }
|
|
|
2246
2416
|
.scenario:last-child { border-bottom: 0; }
|
|
2247
2417
|
.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
2418
|
.scenarioButton:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--paper)); }
|
|
2249
|
-
details[open] > summary.scenarioButton { background: var(--
|
|
2419
|
+
details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
2250
2420
|
.scenarioMain { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
|
|
2251
2421
|
.scenarioName { margin: 0; font-size: 0.875rem; line-height: 1.4; font-weight: 500; overflow-wrap: break-word; }
|
|
2252
2422
|
.scenarioSub { display: block; color: var(--muted); font-size: 0.75rem; }
|
|
@@ -2291,7 +2461,7 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2291
2461
|
.attachmentText summary { cursor: pointer; color: var(--accent-text); font-size: 0.75rem; }
|
|
2292
2462
|
.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); }
|
|
2293
2463
|
.fileLink { display: inline-block; margin: 0.3125rem 0; color: var(--accent-text); font-size: 0.75rem; }
|
|
2294
|
-
.meta span, .
|
|
2464
|
+
.meta span, .path, .description, .step, .featureSource, .featureUri, .fileLink, .attachment figcaption, .attachmentText summary, .detailMeta span { overflow-wrap: anywhere; }
|
|
2295
2465
|
.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
2466
|
.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
2467
|
.foot { margin-top: 1.75rem; color: var(--muted); font-size: 0.75rem; }
|
|
@@ -2302,12 +2472,19 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2302
2472
|
.panel h2 { margin: 0 0 0.375rem; font-size: 1.125rem; }
|
|
2303
2473
|
.panel h2.subhead { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
|
|
2304
2474
|
.panel p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.8125rem; }
|
|
2305
|
-
.featureTable { width: 100%; min-width:
|
|
2475
|
+
.featureTable { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.8125rem; }
|
|
2306
2476
|
.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); }
|
|
2477
|
+
.featureTable th:not(:first-child) { text-align: right; }
|
|
2478
|
+
.featureTable th[scope="row"] { width: 38%; color: var(--ink); font-size: 0.8125rem; font-weight: 400; overflow-wrap: anywhere; }
|
|
2479
|
+
.featureTable .matrixName { display: block; }
|
|
2480
|
+
.featureTable .matrixUri { display: block; color: var(--muted); font-size: 0.6875rem; overflow-wrap: anywhere; }
|
|
2481
|
+
.featureTable th:first-child, .featureTable td:first-child { width: 38%; overflow-wrap: anywhere; }
|
|
2307
2482
|
.featureTable td { padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--line); }
|
|
2308
2483
|
.featureTable td:last-child, .featureTable th:last-child { text-align: right; }
|
|
2309
2484
|
.featureTable tr:last-child td { border-bottom: 0; }
|
|
2310
2485
|
.featureTable .num { text-align: right; font-family: var(--font-mono); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
|
|
2486
|
+
.featureTable .zero { color: var(--muted); }
|
|
2487
|
+
.matrixHint { display: none; }
|
|
2311
2488
|
.legend { display: grid; gap: 0.375rem; margin-top: 0.625rem; }
|
|
2312
2489
|
.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
2490
|
.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 +2501,7 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2324
2501
|
.runHead { grid-template-columns: 1fr; gap: 1.25rem; }
|
|
2325
2502
|
.health { border-left: 0; border-top: 1px solid var(--line-strong); padding: 1rem 0 0; }
|
|
2326
2503
|
.feature > summary { grid-template-columns: 4.75rem minmax(0, 1fr) 1.25rem; }
|
|
2327
|
-
.
|
|
2504
|
+
.featureUri { display: none; }
|
|
2328
2505
|
.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
2506
|
.scenarioButton .statusCell { grid-area: status; align-self: start; }
|
|
2330
2507
|
.scenarioButton .thumbCell { grid-area: thumb; align-self: start; }
|
|
@@ -2347,14 +2524,21 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2347
2524
|
.thumb { width: 2.5rem; height: 1.875rem; }
|
|
2348
2525
|
.statusText { min-width: 3.125rem; }
|
|
2349
2526
|
.filter { min-height: 1.75rem; }
|
|
2527
|
+
.matrixHint { display: block; margin: 0 0 0.5rem; font-size: 0.75rem; }
|
|
2528
|
+
.triageBox > summary { display: flex; flex-wrap: wrap; padding: 0.875rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
|
|
2529
|
+
.triageBox .triage { margin: 0.5rem 0 0; }
|
|
2530
|
+
.triageBox .triage h2, .triageBox .triage .triageLead { display: none; }
|
|
2531
|
+
.sources { display: none; }
|
|
2350
2532
|
}
|
|
2351
2533
|
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
|
|
2352
2534
|
@container (max-width: 16rem) {
|
|
2353
2535
|
.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; }
|
|
2536
|
+
.feature > summary { grid-template-columns: auto 1fr auto; grid-template-areas: "status . chev" "title title title" "shape shape shape"; gap: 0.5rem; }
|
|
2355
2537
|
.feature > summary .statusCell { grid-area: status; }
|
|
2356
2538
|
.feature > summary h2 { grid-area: title; }
|
|
2357
2539
|
.feature > summary .chev { grid-area: chev; }
|
|
2540
|
+
.featureShape { grid-area: shape; }
|
|
2541
|
+
.triageScenarios a { grid-template-columns: minmax(0, 1fr); gap: 0.125rem; }
|
|
2358
2542
|
.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
2543
|
.scenarioButton .statusCell { grid-area: status; }
|
|
2360
2544
|
.scenarioButton .thumbCell { grid-area: thumb; }
|
|
@@ -2419,6 +2603,7 @@ var STEP_GLYPHS = {
|
|
|
2419
2603
|
unknown: "\xB7"
|
|
2420
2604
|
};
|
|
2421
2605
|
function durationLabel(milliseconds) {
|
|
2606
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) return "0 ms";
|
|
2422
2607
|
if (milliseconds < 1e3) return `${Math.round(milliseconds * 100) / 100} ms`;
|
|
2423
2608
|
return `${(milliseconds / 1e3).toFixed(2)} s`;
|
|
2424
2609
|
}
|
|
@@ -2442,11 +2627,140 @@ function displayStatuses(model) {
|
|
|
2442
2627
|
(status) => model.counts.scenarios[status] > 0
|
|
2443
2628
|
);
|
|
2444
2629
|
}
|
|
2630
|
+
var TRIAGE_FEATURE_LIMIT = 20;
|
|
2631
|
+
var TRIAGE_SCENARIO_LIMIT = 3;
|
|
2632
|
+
var SOURCE_LIMIT = 6;
|
|
2633
|
+
var SEARCH_MESSAGE_LIMIT = 2e3;
|
|
2634
|
+
function compareStatus(a, b) {
|
|
2635
|
+
const passed = Number(a === "passed") - Number(b === "passed");
|
|
2636
|
+
return passed !== 0 ? passed : statusSeverity(b) - statusSeverity(a);
|
|
2637
|
+
}
|
|
2638
|
+
function bySeverity(items) {
|
|
2639
|
+
return items.map((item, index) => ({ item, index })).sort((a, b) => {
|
|
2640
|
+
const status = compareStatus(a.item.status, b.item.status);
|
|
2641
|
+
return status !== 0 ? status : a.index - b.index;
|
|
2642
|
+
}).map(({ item }) => item);
|
|
2643
|
+
}
|
|
2644
|
+
function orderFeatures(features) {
|
|
2645
|
+
return bySeverity(features).map((feature) => ({
|
|
2646
|
+
feature,
|
|
2647
|
+
scenarios: bySeverity(feature.scenarios)
|
|
2648
|
+
}));
|
|
2649
|
+
}
|
|
2650
|
+
function countStatuses(scenarios) {
|
|
2651
|
+
const counts = {};
|
|
2652
|
+
for (const scenario of scenarios) {
|
|
2653
|
+
counts[scenario.status] = (counts[scenario.status] ?? 0) + 1;
|
|
2654
|
+
}
|
|
2655
|
+
return counts;
|
|
2656
|
+
}
|
|
2657
|
+
function barWidth(count2, total) {
|
|
2658
|
+
return total === 0 ? 0 : Math.round(count2 / total * 1e3) / 10;
|
|
2659
|
+
}
|
|
2660
|
+
function attentionCounts(scenarios) {
|
|
2661
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2662
|
+
for (const scenario of scenarios) {
|
|
2663
|
+
if (scenario.status === "passed") continue;
|
|
2664
|
+
counts.set(scenario.status, (counts.get(scenario.status) ?? 0) + 1);
|
|
2665
|
+
}
|
|
2666
|
+
return [...counts.entries()].sort((a, b) => statusSeverity(b[0]) - statusSeverity(a[0])).map(([status, count2]) => `${count2} ${status}`).join(", ");
|
|
2667
|
+
}
|
|
2668
|
+
function featureBar(scenarios) {
|
|
2669
|
+
const total = scenarios.length;
|
|
2670
|
+
if (total === 0) return "";
|
|
2671
|
+
const counts = countStatuses(scenarios);
|
|
2672
|
+
const segments = ALL_STATUSES.filter((status) => counts[status]).map(
|
|
2673
|
+
(status) => `<i class="${statusClass(status)}" style="width:${barWidth(counts[status] ?? 0, total)}%"></i>`
|
|
2674
|
+
).join("");
|
|
2675
|
+
return `<span class="bar" aria-hidden="true">${segments}</span>`;
|
|
2676
|
+
}
|
|
2677
|
+
function featureShape(feature, scenarios) {
|
|
2678
|
+
const passed = scenarios.filter(
|
|
2679
|
+
(scenario) => scenario.status === "passed"
|
|
2680
|
+
).length;
|
|
2681
|
+
const attention = attentionCounts(scenarios);
|
|
2682
|
+
const counts = `${passed} of ${scenarios.length} passed${attention ? ` \xB7 ${attention}` : ""}`;
|
|
2683
|
+
const source = feature.sourceFile ? `<span class="featureSource">from ${escapeHtml(feature.sourceFile)}</span>` : "";
|
|
2684
|
+
return `<span class="featureShape"><span class="featureCounts">${counts}</span>${featureBar(scenarios)}${source}<span class="featureUri">${escapeHtml(displayUri(feature.uri))}</span></span>`;
|
|
2685
|
+
}
|
|
2686
|
+
function renderTriageRow({
|
|
2687
|
+
feature,
|
|
2688
|
+
scenarios,
|
|
2689
|
+
index
|
|
2690
|
+
}) {
|
|
2691
|
+
const failing = scenarios.filter(
|
|
2692
|
+
(scenario) => scenario.status !== "passed"
|
|
2693
|
+
);
|
|
2694
|
+
const links = failing.slice(0, TRIAGE_SCENARIO_LIMIT).map((scenario) => {
|
|
2695
|
+
const scenarioIndex = scenarios.indexOf(scenario) + 1;
|
|
2696
|
+
return `<li><a class="triageScenario" href="#scenario-${index + 1}-${scenarioIndex}"><span class="triageStatus ${statusClass(scenario.status)}">${statusLabel(scenario.status)}</span><span>${escapeHtml(scenario.name)}</span></a></li>`;
|
|
2697
|
+
}).join("");
|
|
2698
|
+
const more = failing.length > TRIAGE_SCENARIO_LIMIT ? `<li class="triageMore">+${failing.length - TRIAGE_SCENARIO_LIMIT} more in the report</li>` : "";
|
|
2699
|
+
const failed = scenarios.find((scenario) => scenario.status === "failed");
|
|
2700
|
+
const failedStep = failed?.steps.find(
|
|
2701
|
+
(step) => step.status === "failed" && step.message
|
|
2702
|
+
);
|
|
2703
|
+
const reason = failedStep?.message ? `${failedStep.keyword ? `${failedStep.keyword} ` : ""}${failedStep.text} \u2014 ${failedStep.message.split(/\r?\n/)[0].trim().slice(0, 120)}${failedStep.message.split(/\r?\n/)[0].trim().length > 120 ? "\u2026" : ""}` : "";
|
|
2704
|
+
return `<li class="triageItem"><a class="triageFeature" href="#feature-${index + 1}" title="${escapeHtml(displayUri(feature.uri))}"><span class="triageStatus ${statusClass(feature.status)}">${statusLabel(feature.status)}</span><span>${escapeHtml(feature.name)}</span></a><p class="triageCounts">${attentionCounts(scenarios)}</p><ul class="triageScenarios">${links}${more}</ul>${reason ? `<p class="triageReason"><span class="triageReasonLabel">First failure:</span> ${escapeHtml(reason)}</p>` : ""}</li>`;
|
|
2705
|
+
}
|
|
2706
|
+
function renderTriage(features) {
|
|
2707
|
+
const attention = features.map((entry, index) => ({ ...entry, index })).filter(
|
|
2708
|
+
({ scenarios }) => scenarios.some((scenario) => scenario.status !== "passed")
|
|
2709
|
+
);
|
|
2710
|
+
if (attention.length === 0) return "";
|
|
2711
|
+
const shown = attention.slice(0, 5);
|
|
2712
|
+
const rest = attention.slice(5, TRIAGE_FEATURE_LIMIT);
|
|
2713
|
+
const total = features.reduce(
|
|
2714
|
+
(sum, entry) => sum + entry.scenarios.length,
|
|
2715
|
+
0
|
|
2716
|
+
);
|
|
2717
|
+
const need = attention.reduce(
|
|
2718
|
+
(sum, entry) => sum + entry.scenarios.filter((scenario) => scenario.status !== "passed").length,
|
|
2719
|
+
0
|
|
2720
|
+
);
|
|
2721
|
+
const rows = shown.map(renderTriageRow).join("");
|
|
2722
|
+
const restBlock = rest.length ? `<details class="triageRest"><summary>Show ${rest.length} more feature${rest.length === 1 ? "" : "s"}</summary><ol class="triageList">${rest.map(renderTriageRow).join("")}</ol></details>` : "";
|
|
2723
|
+
const remainder = attention.length > TRIAGE_FEATURE_LIMIT ? `<p class="triageMore">${attention.length - TRIAGE_FEATURE_LIMIT} more feature${attention.length - TRIAGE_FEATURE_LIMIT === 1 ? "" : "s"} below.</p>` : "";
|
|
2724
|
+
const lead = `${need} of ${total} scenario${total === 1 ? "" : "s"} ${need === 1 ? "needs" : "need"} attention.`;
|
|
2725
|
+
return `<details class="triageBox" data-triage open><summary class="triageSummary"><span class="triageTitle">Needs attention</span><span class="triageSummaryLead">${lead}</span><span class="chev" aria-hidden="true"></span></summary><nav class="triage" aria-label="Needs attention"><h2 id="triage-heading">Needs attention</h2><p class="triageLead">${lead}</p><ol class="triageList">${rows}</ol>${restBlock}${remainder}</nav></details>`;
|
|
2726
|
+
}
|
|
2727
|
+
function renderSourceStrip(model) {
|
|
2728
|
+
if (model.features.some((feature) => !feature.sourceFile)) return "";
|
|
2729
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2730
|
+
model.features.forEach((feature, index) => {
|
|
2731
|
+
const file = feature.sourceFile;
|
|
2732
|
+
if (!file) return;
|
|
2733
|
+
const group = groups.get(file) ?? { features: [], order: index };
|
|
2734
|
+
group.features.push(feature);
|
|
2735
|
+
groups.set(file, group);
|
|
2736
|
+
});
|
|
2737
|
+
if (groups.size < 2) return "";
|
|
2738
|
+
const entries = [...groups.entries()].map(([file, group]) => ({
|
|
2739
|
+
file,
|
|
2740
|
+
features: group.features.length,
|
|
2741
|
+
scenarios: group.features.flatMap((feature) => feature.scenarios),
|
|
2742
|
+
status: bySeverity(group.features)[0]?.status ?? "unknown",
|
|
2743
|
+
order: group.order
|
|
2744
|
+
}));
|
|
2745
|
+
entries.sort((a, b) => {
|
|
2746
|
+
const status = compareStatus(a.status, b.status);
|
|
2747
|
+
return status !== 0 ? status : a.order - b.order;
|
|
2748
|
+
});
|
|
2749
|
+
const shown = entries.slice(0, SOURCE_LIMIT);
|
|
2750
|
+
const remainder = entries.length - shown.length;
|
|
2751
|
+
const items = shown.map((entry) => {
|
|
2752
|
+
const attention = attentionCounts(entry.scenarios);
|
|
2753
|
+
const counts = `${entry.features} feature${entry.features === 1 ? "" : "s"} \xB7 ${entry.scenarios.length} scenario${entry.scenarios.length === 1 ? "" : "s"}${attention ? ` \xB7 ${attention}` : ""}`;
|
|
2754
|
+
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>`;
|
|
2755
|
+
}).join("");
|
|
2756
|
+
const more = remainder > 0 ? `<p class="triageMore">${remainder} more input${remainder === 1 ? "" : "s"}</p>` : "";
|
|
2757
|
+
return `<section class="sources" aria-labelledby="sources-heading" data-sources><h2 id="sources-heading">Sources</h2><ul class="sourceList">${items}</ul>${more}</section>`;
|
|
2758
|
+
}
|
|
2445
2759
|
function statusBar(model) {
|
|
2446
2760
|
const total = model.counts.scenarios.total;
|
|
2447
2761
|
if (total === 0) return "";
|
|
2448
2762
|
return `<div class="bar" aria-hidden="true">${displayStatuses(model).map(
|
|
2449
|
-
(status) => `<i class="${statusClass(status)}" style="width:${model.counts.scenarios[status]
|
|
2763
|
+
(status) => `<i class="${statusClass(status)}" style="width:${barWidth(model.counts.scenarios[status], total)}%"></i>`
|
|
2450
2764
|
).join("")}</div>`;
|
|
2451
2765
|
}
|
|
2452
2766
|
function countPills(model) {
|
|
@@ -2497,14 +2811,14 @@ function scenarioText(scenario) {
|
|
|
2497
2811
|
return [
|
|
2498
2812
|
scenario.name,
|
|
2499
2813
|
scenario.featureName,
|
|
2500
|
-
scenario.uri,
|
|
2814
|
+
displayUri(scenario.uri),
|
|
2501
2815
|
scenario.keyword,
|
|
2502
2816
|
scenario.description,
|
|
2503
2817
|
scenario.tags.join(" "),
|
|
2504
|
-
scenario.steps.map((step) => `${step.keyword} ${step.text} ${step.message ?? ""}`).join(" ")
|
|
2818
|
+
scenario.steps.map((step) => `${step.keyword} ${step.text} ${(step.message ?? "").slice(0, SEARCH_MESSAGE_LIMIT)}`).join(" ")
|
|
2505
2819
|
].join(" ");
|
|
2506
2820
|
}
|
|
2507
|
-
function renderScenario(scenario) {
|
|
2821
|
+
function renderScenario(scenario, featureIndex, scenarioIndex) {
|
|
2508
2822
|
const image = scenario.attachments.find(
|
|
2509
2823
|
(attachment) => attachment.kind === "image" && attachment.dataUri
|
|
2510
2824
|
);
|
|
@@ -2513,15 +2827,34 @@ function renderScenario(scenario) {
|
|
|
2513
2827
|
const description = scenario.description ? `<p class="description">${escapeHtml(scenario.description)}</p>` : "";
|
|
2514
2828
|
const extraAttachments = scenario.extraAttachments.length ? `<h4>Attachments</h4>${scenario.extraAttachments.map((attachment) => renderAttachment(attachment, scenario.name)).join("")}` : "";
|
|
2515
2829
|
const copyFailure = scenario.status === "failed" ? '<button class="copyFailure" type="button" data-copy-failure>Copy failure</button>' : "";
|
|
2516
|
-
return `<details class="scenario" data-scenario data-status="${scenario.status}" data-uri="${escapeHtml(scenario.uri)}" data-tags="${escapeHtml(scenario.tags.join(" "))}" data-search="${escapeHtml(scenarioText(scenario))}" ${open ? "open" : ""}><summary class="scenarioButton"><span class="statusCell"><span class="statusText ${statusClass(scenario.status)}">${statusLabel(scenario.status)}</span></span><span class="thumbCell">${image ? `<img class="thumb" src="${escapeHtml(image.dataUri ?? "")}" alt="" loading="lazy">` : ""}</span><span class="scenarioMain"><h3 class="scenarioName">${escapeHtml(scenario.name)}</h3><span class="scenarioSub">${scenario.steps.length} step${scenario.steps.length === 1 ? "" : "s"}${scenario.tags.length ? ` <span class="tags">${scenario.tags.map((tag) => `<span class="tag">${escapeHtml(tag)}</span>`).join("")}</span>` : ""}</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"><h4>Steps</h4>${copyFailure}</div><ol class="steps">${steps}</ol>${extraAttachments}<div class="detailMeta"><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>`;
|
|
2830
|
+
return `<details class="scenario" id="scenario-${featureIndex + 1}-${scenarioIndex + 1}" data-scenario data-status="${scenario.status}" data-uri="${escapeHtml(displayUri(scenario.uri))}" data-tags="${escapeHtml(scenario.tags.join(" "))}" data-search="${escapeHtml(scenarioText(scenario))}" ${open ? "open" : ""}><summary class="scenarioButton"><span class="statusCell"><span class="statusText ${statusClass(scenario.status)}">${statusLabel(scenario.status)}</span></span><span class="thumbCell">${image ? `<img class="thumb" src="${escapeHtml(image.dataUri ?? "")}" alt="" loading="lazy">` : ""}</span><span class="scenarioMain"><h3 class="scenarioName">${escapeHtml(scenario.name)}</h3><span class="scenarioSub">${scenario.steps.length} step${scenario.steps.length === 1 ? "" : "s"}${scenario.tags.length ? ` <span class="tags">${scenario.tags.map((tag) => `<span class="tag">${escapeHtml(tag)}</span>`).join("")}</span>` : ""}</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"><h4>Steps</h4>${copyFailure}</div><ol class="steps">${steps}</ol>${extraAttachments}<div class="detailMeta"><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>`;
|
|
2517
2831
|
}
|
|
2518
|
-
function renderFeature(feature) {
|
|
2519
|
-
const
|
|
2520
|
-
const open = feature.status === "failed" || feature.scenarios.some(
|
|
2832
|
+
function renderFeature({ feature, scenarios }, featureIndex) {
|
|
2833
|
+
const open = feature.status === "failed" || scenarios.some(
|
|
2521
2834
|
(scenario) => scenario.attachments.some((attachment) => attachment.kind === "image")
|
|
2522
2835
|
);
|
|
2523
2836
|
const description = feature.description ? `<p class="description">${escapeHtml(feature.description)}</p>` : "";
|
|
2524
|
-
return `<details class="feature ${feature.status === "failed" ? "has-fail" : "has-pass"}" data-feature ${open ? "open" : ""}><summary><span class="statusCell"><span class="statusText ${statusClass(feature.status)}">${statusLabel(feature.status)}</span></span><h2>${escapeHtml(feature.name)}</h2><span class="
|
|
2837
|
+
return `<details class="feature ${feature.status === "failed" ? "has-fail" : "has-pass"}" id="feature-${featureIndex + 1}" data-feature ${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}<div class="rows">${scenarios.map(
|
|
2838
|
+
(scenario, scenarioIndex) => renderScenario(scenario, featureIndex, scenarioIndex)
|
|
2839
|
+
).join("")}</div></details>`;
|
|
2840
|
+
}
|
|
2841
|
+
function matrixStatuses(model) {
|
|
2842
|
+
return ALL_STATUSES.filter((status) => model.counts.scenarios[status] > 0).sort(
|
|
2843
|
+
compareStatus
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
function renderFeatureMatrix(model) {
|
|
2847
|
+
const statuses = matrixStatuses(model);
|
|
2848
|
+
const head = `<tr><th>Feature</th><th>Total</th>${statuses.map((status) => `<th>${statusLabel(status)}</th>`).join("")}<th>Duration</th></tr>`;
|
|
2849
|
+
const rows = model.features.map((feature) => {
|
|
2850
|
+
const counts = countStatuses(feature.scenarios);
|
|
2851
|
+
const cells = statuses.map((status) => {
|
|
2852
|
+
const count2 = counts[status] ?? 0;
|
|
2853
|
+
return `<td class="num${count2 === 0 ? " zero" : ""}">${count2}</td>`;
|
|
2854
|
+
}).join("");
|
|
2855
|
+
return `<tr><th scope="row"><span class="matrixName">${escapeHtml(feature.name)}</span><span class="matrixUri">${escapeHtml(displayUri(feature.uri))}</span></th><td class="num">${feature.scenarios.length}</td>${cells}<td class="num">${durationLabel(feature.durationMs)}</td></tr>`;
|
|
2856
|
+
}).join("");
|
|
2857
|
+
return `<table class="featureTable"><thead>${head}</thead><tbody>${rows}</tbody></table>`;
|
|
2525
2858
|
}
|
|
2526
2859
|
function metadataLine(metadata) {
|
|
2527
2860
|
return Object.entries(metadata ?? {}).filter(([key, value]) => key.length > 0 && value.length > 0).map(
|
|
@@ -2534,12 +2867,15 @@ function renderReportView(model, options) {
|
|
|
2534
2867
|
const percent = total === 0 ? 0 : Math.round(passed / total * 1e3) / 10;
|
|
2535
2868
|
const meta = metadataLine(options.metadata);
|
|
2536
2869
|
const date = dateLabel(model.startedAt);
|
|
2537
|
-
const
|
|
2870
|
+
const ordered = orderFeatures(model.features);
|
|
2871
|
+
const features = ordered.map((feature, index) => renderFeature(feature, index)).join("");
|
|
2872
|
+
const triage = renderTriage(ordered);
|
|
2873
|
+
const sources = renderSourceStrip(model);
|
|
2538
2874
|
const tags = scenarioTags(model);
|
|
2539
2875
|
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} of ${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(
|
|
2876
|
+
return `<div class="tabPanel" id="report-view" role="tabpanel" aria-labelledby="view-report" tabindex="0"><main class="shell"><header class="runHead"><div><p class="path">${escapeHtml(model.source)} / ${escapeHtml(options.title)}</p><h1>${escapeHtml(options.title)}</h1><p class="meta">${date ? `<span>${date}</span>` : ""}<span>${model.counts.features} feature${model.counts.features === 1 ? "" : "s"}</span><span>${model.counts.scenarios.total} scenarios</span><span>${durationLabel(model.durationMs)}</span><span>${escapeHtml(model.source)}</span>${meta}</p></div><div class="health"><div class="healthTop"><strong>${percent}%</strong><span>${passed} of ${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
2877
|
(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="sr" id="tolkira-copy-live" aria-live="polite"></p><div id="feature-list">${features || `<div class="empty">No scenarios in this report.</div>`}</div><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>`;
|
|
2878
|
+
).join("")}</div><div class="expand"><button type="button" data-expand="all">Expand all</button><button type="button" data-expand="none">Collapse all</button></div></div><p class="live sr" id="tolkira-live" role="status" aria-live="polite" data-total="${total}"></p><p class="sr" id="tolkira-copy-live" aria-live="polite"></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><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
2879
|
}
|
|
2544
2880
|
function renderAnalysisView(model, options, summary) {
|
|
2545
2881
|
const counts = model.counts.scenarios;
|
|
@@ -2560,9 +2896,7 @@ function renderAnalysisView(model, options, summary) {
|
|
|
2560
2896
|
model.environment?.protocol ? `<dt>Protocol</dt><dd>${escapeHtml(model.environment.protocol)}</dd>` : ""
|
|
2561
2897
|
].join("");
|
|
2562
2898
|
const runRows = `<dt>Duration</dt><dd>${durationLabel(model.durationMs)}</dd><dt>Features</dt><dd>${model.counts.features}</dd><dt>Scenarios</dt><dd>${counts.total}</dd><dt>Steps</dt><dd>${model.counts.steps.total}</dd><dt>Attachments</dt><dd>${model.counts.attachments}</dd><dt>Attachment size</dt><dd>${model.counts.attachmentBytes} bytes</dd><dt>Source</dt><dd>${escapeHtml(model.source)}</dd>`;
|
|
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} of ${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><div class="tableWrap" tabindex="0" role="region" aria-label="Feature
|
|
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(
|
|
2899
|
+
return `<div class="tabPanel" id="analysis-view" role="tabpanel" aria-labelledby="view-analysis" tabindex="0" hidden><main class="shell analysis"><header class="runHead"><div><p class="path">${escapeHtml(model.source)} / details</p><h1>Run details</h1><p class="meta">${dateLabel(model.startedAt) ? `<span>${dateLabel(model.startedAt)}</span>` : ""}<span>${escapeHtml(model.source)}</span></p></div><div class="health"><div class="healthTop"><strong>${counts.total === 0 ? 0 : Math.round(counts.passed / counts.total * 1e3) / 10}%</strong><span>${counts.passed} of ${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">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>All scenarios in the run.</p><div class="legend">${displayStatuses(model).map(
|
|
2566
2900
|
(status) => `<div class="legendRow ${statusClass(status)}"><span class="marker ${statusClass(status)}"></span><span>${statusLabel(status)}</span><b>${counts[status]}</b></div>`
|
|
2567
2901
|
).join("")}</div><h2 class="subhead">Run</h2><dl class="metaList">${runRows}</dl>${environmentRows ? `<h2 class="subhead">Cucumber environment</h2><dl class="metaList">${environmentRows}</dl>` : ""}${customRows ? `<h2 class="subhead">Custom metadata</h2><dl class="metaList">${customRows}</dl>` : ""}</section></div>${model.runAttachments.length ? `<section class="panel" style="margin-top:16px"><h2>Run attachments</h2>${model.runAttachments.map((attachment) => renderAttachment(attachment, "Run attachments")).join("")}</section>` : ""}<section class="panel" style="margin-top:16px"><h2>Agent summary</h2><p>The same run as stable JSON for CI tools and agents.</p><pre class="json" tabindex="0" aria-label="Agent summary JSON">${escapeHtml(JSON.stringify(preview))}</pre></section><p class="foot">Full summary: <code>tolkira ... --json</code></p></main></div>`;
|
|
2568
2902
|
}
|
|
@@ -2595,9 +2929,13 @@ var SCRIPT = `<script>
|
|
|
2595
2929
|
showView(views[next].getAttribute('data-view'));
|
|
2596
2930
|
});
|
|
2597
2931
|
var state = { query: '', hidden: new Set(), tag: '' };
|
|
2932
|
+
var searchOpened = [];
|
|
2598
2933
|
var scenarios = Array.prototype.slice.call(document.querySelectorAll('[data-scenario]'));
|
|
2599
2934
|
var features = Array.prototype.slice.call(document.querySelectorAll('[data-feature]'));
|
|
2600
2935
|
var live = document.getElementById('tolkira-live');
|
|
2936
|
+
var searchNote = document.getElementById('tolkira-search-note');
|
|
2937
|
+
var triage = document.querySelector('[data-triage]');
|
|
2938
|
+
var sources = document.querySelector('[data-sources]');
|
|
2601
2939
|
function apply() {
|
|
2602
2940
|
var query = state.query.toLowerCase();
|
|
2603
2941
|
var tag = state.tag;
|
|
@@ -2617,14 +2955,32 @@ var SCRIPT = `<script>
|
|
|
2617
2955
|
feature.hidden = !any;
|
|
2618
2956
|
if (any && (query || state.hidden.size || tag)) feature.open = true;
|
|
2619
2957
|
});
|
|
2958
|
+
searchOpened.forEach(function (scenario) { scenario.open = false; });
|
|
2959
|
+
searchOpened = [];
|
|
2620
2960
|
if (query) {
|
|
2961
|
+
var opened = 0;
|
|
2621
2962
|
scenarios.forEach(function (scenario) {
|
|
2622
|
-
if (!scenario.hidden
|
|
2963
|
+
if (!scenario.hidden && opened < 20) {
|
|
2964
|
+
if (!scenario.open) searchOpened.push(scenario);
|
|
2965
|
+
scenario.open = true;
|
|
2966
|
+
opened += 1;
|
|
2967
|
+
}
|
|
2623
2968
|
});
|
|
2624
2969
|
}
|
|
2625
2970
|
if (live) live.textContent = visible + ' of ' + scenarios.length + ' scenarios visible';
|
|
2971
|
+
if (searchNote) {
|
|
2972
|
+
if (query && visible > 20) {
|
|
2973
|
+
searchNote.textContent = '20 of ' + visible + ' matches expanded. Use Expand all to open the rest.';
|
|
2974
|
+
searchNote.hidden = false;
|
|
2975
|
+
} else {
|
|
2976
|
+
searchNote.hidden = true;
|
|
2977
|
+
searchNote.textContent = '';
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2626
2980
|
var empty = document.getElementById('empty-results');
|
|
2627
2981
|
if (empty) empty.hidden = visible !== 0;
|
|
2982
|
+
if (triage) triage.hidden = Boolean(query || tag || state.hidden.size);
|
|
2983
|
+
if (sources) sources.hidden = Boolean(query || tag || state.hidden.size);
|
|
2628
2984
|
highlightSearch();
|
|
2629
2985
|
}
|
|
2630
2986
|
function clearHighlights() {
|
|
@@ -2819,7 +3175,32 @@ var SCRIPT = `<script>
|
|
|
2819
3175
|
lightbox.addEventListener('click', function (event) { if (event.target === lightbox) closeDialog(); });
|
|
2820
3176
|
lightbox.addEventListener('close', restoreLightbox);
|
|
2821
3177
|
}
|
|
3178
|
+
function revealHash() {
|
|
3179
|
+
if (!location.hash) return;
|
|
3180
|
+
var id = '';
|
|
3181
|
+
try { id = decodeURIComponent(location.hash.slice(1)); } catch (error) { return; }
|
|
3182
|
+
var target = document.getElementById(id);
|
|
3183
|
+
if (!target) return;
|
|
3184
|
+
var node = target;
|
|
3185
|
+
while (node) {
|
|
3186
|
+
if (node.tagName === 'DETAILS') node.open = true;
|
|
3187
|
+
node = node.parentElement;
|
|
3188
|
+
}
|
|
3189
|
+
var focusTarget = target.tagName === 'DETAILS' ? target.querySelector('summary') : target;
|
|
3190
|
+
if (focusTarget) {
|
|
3191
|
+
try { focusTarget.focus({ preventScroll: true }); } catch (error) { focusTarget.focus(); }
|
|
3192
|
+
}
|
|
3193
|
+
target.scrollIntoView();
|
|
3194
|
+
}
|
|
3195
|
+
var compact = window.matchMedia('(max-width: 560px)');
|
|
3196
|
+
function syncCompact() {
|
|
3197
|
+
if (triage) triage.open = !compact.matches;
|
|
3198
|
+
}
|
|
3199
|
+
if (compact.addEventListener) compact.addEventListener('change', syncCompact);
|
|
3200
|
+
syncCompact();
|
|
3201
|
+
window.addEventListener('hashchange', revealHash);
|
|
2822
3202
|
showView('report');
|
|
3203
|
+
revealHash();
|
|
2823
3204
|
})();
|
|
2824
3205
|
</script>`;
|
|
2825
3206
|
function inlineScriptHashes(html) {
|
|
@@ -2837,7 +3218,7 @@ function csp(hashes) {
|
|
|
2837
3218
|
}
|
|
2838
3219
|
async function renderHtml(envelopes, options) {
|
|
2839
3220
|
const safeEnvelopes = sanitizeEnvelopes(envelopes);
|
|
2840
|
-
const model = buildReportModel(safeEnvelopes);
|
|
3221
|
+
const model = buildReportModel(safeEnvelopes, options.provenance);
|
|
2841
3222
|
const summary = options.summary ?? summarizeEnvelopes(safeEnvelopes);
|
|
2842
3223
|
const logo = isLogoDataUri(options.logo) ? `<img class="logo" src="${escapeHtml(options.logo)}" alt="">` : "";
|
|
2843
3224
|
const accent = isValidAccent(options.accent) ? `<style>:root{--accent:${options.accent}}</style>` : "";
|
|
@@ -2857,9 +3238,10 @@ ${csp(hashes)}
|
|
|
2857
3238
|
}
|
|
2858
3239
|
|
|
2859
3240
|
// src/index.ts
|
|
2860
|
-
var version = "0.
|
|
3241
|
+
var version = "0.2.0";
|
|
2861
3242
|
async function generateReport(inputs, options = {}) {
|
|
2862
|
-
const
|
|
3243
|
+
const groups = await loadInputs(inputs);
|
|
3244
|
+
const envelopes = groups.flatMap((group) => group.envelopes);
|
|
2863
3245
|
const summary = summarizeEnvelopes(envelopes);
|
|
2864
3246
|
return {
|
|
2865
3247
|
html: await renderHtml(envelopes, {
|
|
@@ -2867,7 +3249,8 @@ async function generateReport(inputs, options = {}) {
|
|
|
2867
3249
|
metadata: options.metadata,
|
|
2868
3250
|
logo: options.logo,
|
|
2869
3251
|
accent: options.accent,
|
|
2870
|
-
summary
|
|
3252
|
+
summary,
|
|
3253
|
+
provenance: groups.length > 1 ? provenanceFor(groups) : void 0
|
|
2871
3254
|
}),
|
|
2872
3255
|
summary
|
|
2873
3256
|
};
|
|
@@ -3004,6 +3387,28 @@ async function readLogo(file) {
|
|
|
3004
3387
|
}
|
|
3005
3388
|
return `data:${mime};base64,${data.toString("base64")}`;
|
|
3006
3389
|
}
|
|
3390
|
+
async function outputOverwritesInput(inputs, output, logo) {
|
|
3391
|
+
const outputPath = path4.resolve(output);
|
|
3392
|
+
const outputInfo = await stat2(outputPath).catch(() => void 0);
|
|
3393
|
+
if (!outputInfo?.isFile()) return false;
|
|
3394
|
+
const outputReal = realpathSync(outputPath);
|
|
3395
|
+
if (logo) {
|
|
3396
|
+
const logoInfo = await stat2(logo).catch(() => void 0);
|
|
3397
|
+
if (logoInfo?.isFile() && realpathSync(logo) === outputReal) return true;
|
|
3398
|
+
}
|
|
3399
|
+
for (const input of inputs) {
|
|
3400
|
+
const inputInfo = await stat2(input).catch(() => void 0);
|
|
3401
|
+
if (!inputInfo) continue;
|
|
3402
|
+
if (inputInfo.isFile() && realpathSync(input) === outputReal) return true;
|
|
3403
|
+
if (inputInfo.isDirectory()) {
|
|
3404
|
+
const directory = realpathSync(input);
|
|
3405
|
+
for (const file of await collectReportFiles(directory)) {
|
|
3406
|
+
if (realpathSync(file) === outputReal) return true;
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
return false;
|
|
3411
|
+
}
|
|
3007
3412
|
async function runCli(argv, io = {
|
|
3008
3413
|
stdout: (text) => process.stdout.write(text),
|
|
3009
3414
|
stderr: (text) => process.stderr.write(text)
|
|
@@ -3030,10 +3435,34 @@ ${USAGE}`);
|
|
|
3030
3435
|
const inputs = parsed.positionals;
|
|
3031
3436
|
const output = parsed.values.out;
|
|
3032
3437
|
const wantsJson = parsed.values.json;
|
|
3438
|
+
if (parsed.values.out === "") {
|
|
3439
|
+
io.stderr(`tolkira: --out requires a file path
|
|
3440
|
+
|
|
3441
|
+
${USAGE}`);
|
|
3442
|
+
return 2;
|
|
3443
|
+
}
|
|
3033
3444
|
if (inputs.length === 0 || !output && !wantsJson) {
|
|
3034
3445
|
io.stderr(USAGE);
|
|
3035
3446
|
return 2;
|
|
3036
3447
|
}
|
|
3448
|
+
if (parsed.values.logo === "") {
|
|
3449
|
+
io.stderr(`tolkira: --logo requires a file path
|
|
3450
|
+
|
|
3451
|
+
${USAGE}`);
|
|
3452
|
+
return 2;
|
|
3453
|
+
}
|
|
3454
|
+
if (!output && parsed.values.logo) {
|
|
3455
|
+
io.stderr(`tolkira: --logo requires --out
|
|
3456
|
+
|
|
3457
|
+
${USAGE}`);
|
|
3458
|
+
return 2;
|
|
3459
|
+
}
|
|
3460
|
+
if (output && await outputOverwritesInput(inputs, output, parsed.values.logo)) {
|
|
3461
|
+
io.stderr(`tolkira: --out must not overwrite an input file
|
|
3462
|
+
|
|
3463
|
+
${USAGE}`);
|
|
3464
|
+
return 2;
|
|
3465
|
+
}
|
|
3037
3466
|
let metadata;
|
|
3038
3467
|
let maxSizeMb;
|
|
3039
3468
|
let accent;
|
|
@@ -3042,7 +3471,7 @@ ${USAGE}`);
|
|
|
3042
3471
|
metadata = parseMetadata(parsed.values.meta);
|
|
3043
3472
|
maxSizeMb = parseMaxSize(parsed.values["max-size"]);
|
|
3044
3473
|
accent = parseAccent(parsed.values.accent);
|
|
3045
|
-
logo =
|
|
3474
|
+
logo = parsed.values.logo ? await readLogo(parsed.values.logo) : void 0;
|
|
3046
3475
|
} catch (error) {
|
|
3047
3476
|
const detail = error instanceof Error ? error.message : String(error);
|
|
3048
3477
|
io.stderr(`tolkira: ${detail}
|