tolkira 0.1.1 → 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 +30 -16
- package/dist/cli.js +531 -92
- package/dist/cli.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +472 -88
- 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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
4
5
|
import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
5
6
|
import path4 from "node:path";
|
|
6
|
-
import {
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
7
8
|
import { parseArgs } from "node:util";
|
|
8
9
|
|
|
9
10
|
// src/input/load.ts
|
|
@@ -15,8 +16,7 @@ import path2 from "node:path";
|
|
|
15
16
|
import {
|
|
16
17
|
AttachmentContentEncoding,
|
|
17
18
|
HookType,
|
|
18
|
-
TestStepResultStatus
|
|
19
|
-
version as messagesVersion
|
|
19
|
+
TestStepResultStatus
|
|
20
20
|
} from "@cucumber/messages";
|
|
21
21
|
function isRecord(value) {
|
|
22
22
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -151,13 +151,13 @@ function createIdFactory(prefix) {
|
|
|
151
151
|
}
|
|
152
152
|
function normalizeUri(uri, index) {
|
|
153
153
|
if (!uri) return `features/legacy-${index}.feature`;
|
|
154
|
-
const slashed = uri.replace(/\\/g, "/");
|
|
154
|
+
const slashed = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
155
155
|
const normalized = slashed.replace(/^\.\//, "");
|
|
156
156
|
if (/^[a-z]:\//i.test(normalized) || slashed.startsWith("/")) {
|
|
157
157
|
const marker = slashed.lastIndexOf("/features/");
|
|
158
158
|
if (marker >= 0) return slashed.slice(marker + 1);
|
|
159
159
|
const parts = slashed.split("/").filter(Boolean);
|
|
160
|
-
return parts.
|
|
160
|
+
return parts[parts.length - 1] ?? `features/legacy-${index}.feature`;
|
|
161
161
|
}
|
|
162
162
|
return normalized || `features/legacy-${index}.feature`;
|
|
163
163
|
}
|
|
@@ -381,11 +381,11 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
381
381
|
const statuses = [];
|
|
382
382
|
let attachmentCounter = 0;
|
|
383
383
|
const meta = {
|
|
384
|
-
protocolVersion:
|
|
384
|
+
protocolVersion: "",
|
|
385
385
|
implementation: { name: "tolkira-legacy-json" },
|
|
386
|
-
runtime: { name: "
|
|
387
|
-
os: { name:
|
|
388
|
-
cpu: { name:
|
|
386
|
+
runtime: { name: "" },
|
|
387
|
+
os: { name: "" },
|
|
388
|
+
cpu: { name: "" }
|
|
389
389
|
};
|
|
390
390
|
envelopes.push({ meta });
|
|
391
391
|
envelopes.push({ testRunStarted: { id: runId, timestamp: timestamp(startedAt) } });
|
|
@@ -597,7 +597,7 @@ function parseLegacyValue(parsed, source, options = {}) {
|
|
|
597
597
|
envelopes.push({
|
|
598
598
|
gherkinDocument: { uri, feature: featureNode, comments: [] }
|
|
599
599
|
});
|
|
600
|
-
envelopes.push(
|
|
600
|
+
for (const envelope of scenarioEnvelopes) envelopes.push(envelope);
|
|
601
601
|
}
|
|
602
602
|
const success = !statuses.some(
|
|
603
603
|
(status) => status === TestStepResultStatus.FAILED || status === TestStepResultStatus.AMBIGUOUS || status === TestStepResultStatus.UNDEFINED
|
|
@@ -892,7 +892,7 @@ function looksLikeJUnit(content) {
|
|
|
892
892
|
const trimmed = content.replace(/^\uFEFF/, "").trimStart();
|
|
893
893
|
return trimmed.startsWith("<") && /<testsuites?\b/i.test(trimmed);
|
|
894
894
|
}
|
|
895
|
-
async function parseJUnitXml(content, source) {
|
|
895
|
+
async function parseJUnitXml(content, source, options = {}) {
|
|
896
896
|
const { XMLParser, XMLValidator } = await import("fast-xml-parser");
|
|
897
897
|
assertValidEntities(content, source);
|
|
898
898
|
const validation = XMLValidator.validate(content);
|
|
@@ -908,6 +908,7 @@ async function parseJUnitXml(content, source) {
|
|
|
908
908
|
attributeNamePrefix: "",
|
|
909
909
|
parseTagValue: false,
|
|
910
910
|
parseAttributeValue: false,
|
|
911
|
+
htmlEntities: true,
|
|
911
912
|
isArray: (name) => ARRAY_TAGS.has(name)
|
|
912
913
|
});
|
|
913
914
|
let parsed;
|
|
@@ -928,7 +929,9 @@ async function parseJUnitXml(content, source) {
|
|
|
928
929
|
const legacy = suites.map(
|
|
929
930
|
(suite, index) => featureFromSuite(suite, source, index)
|
|
930
931
|
);
|
|
931
|
-
const envelopes = parseLegacyValue(legacy, source, {
|
|
932
|
+
const envelopes = parseLegacyValue(legacy, source, {
|
|
933
|
+
idPrefix: options.idPrefix ?? "junit"
|
|
934
|
+
});
|
|
932
935
|
for (const envelope of envelopes) {
|
|
933
936
|
if (envelope.meta) {
|
|
934
937
|
envelope.meta.implementation = { name: "JUnit XML", version: "" };
|
|
@@ -1172,7 +1175,7 @@ function sniffLegacy(content) {
|
|
|
1172
1175
|
}
|
|
1173
1176
|
}
|
|
1174
1177
|
function looksLikeMessages(content) {
|
|
1175
|
-
const firstLine = content.split(/\r?\n
|
|
1178
|
+
const firstLine = content.replace(/^\uFEFF/, "").split(/\r?\n/, 20).map((line) => line.trim()).find(Boolean);
|
|
1176
1179
|
if (!firstLine) return false;
|
|
1177
1180
|
try {
|
|
1178
1181
|
return isEnvelopeLike(JSON.parse(firstLine));
|
|
@@ -1196,7 +1199,23 @@ async function canonicalPath(file) {
|
|
|
1196
1199
|
return path2.resolve(file);
|
|
1197
1200
|
}
|
|
1198
1201
|
}
|
|
1199
|
-
|
|
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) {
|
|
1200
1219
|
const requested = Array.isArray(inputs) ? inputs : [inputs];
|
|
1201
1220
|
if (requested.length === 0) {
|
|
1202
1221
|
throw new Error("No input files provided.");
|
|
@@ -1227,7 +1246,7 @@ async function loadEnvelopes(inputs) {
|
|
|
1227
1246
|
const ordered = [...files.values()].sort(
|
|
1228
1247
|
(a, b) => a.file.localeCompare(b.file)
|
|
1229
1248
|
);
|
|
1230
|
-
const
|
|
1249
|
+
const groups = [];
|
|
1231
1250
|
const seenContent = /* @__PURE__ */ new Set();
|
|
1232
1251
|
let totalBytes = 0;
|
|
1233
1252
|
for (const [index, input] of ordered.entries()) {
|
|
@@ -1244,41 +1263,105 @@ async function loadEnvelopes(inputs) {
|
|
|
1244
1263
|
totalBytes += info.size;
|
|
1245
1264
|
const extension = path2.extname(input.file).toLowerCase();
|
|
1246
1265
|
const legacy = sniffLegacy(content);
|
|
1266
|
+
let parsed = [];
|
|
1247
1267
|
if (legacy?.kind === "legacy") {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
);
|
|
1253
|
-
continue;
|
|
1254
|
-
}
|
|
1255
|
-
if (legacy?.kind === "malformed") {
|
|
1268
|
+
parsed = parseLegacyValue(legacy.parsed, input.file, {
|
|
1269
|
+
idPrefix: `legacy-${index}`
|
|
1270
|
+
});
|
|
1271
|
+
} else if (legacy?.kind === "malformed") {
|
|
1256
1272
|
parseLegacyJson(content, input.file, { idPrefix: `legacy-${index}` });
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
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
|
+
}
|
|
1262
1291
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
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
|
+
}
|
|
1266
1324
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
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
|
+
)) {
|
|
1269
1337
|
continue;
|
|
1270
1338
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
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
|
+
}
|
|
1276
1358
|
}
|
|
1277
1359
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1360
|
+
const provenance = /* @__PURE__ */ new Map();
|
|
1361
|
+
for (const [uri, files] of uriFiles) {
|
|
1362
|
+
if (files.size === 1) provenance.set(uri, [...files][0]);
|
|
1280
1363
|
}
|
|
1281
|
-
return
|
|
1364
|
+
return provenance;
|
|
1282
1365
|
}
|
|
1283
1366
|
|
|
1284
1367
|
// src/render/html.ts
|
|
@@ -1389,6 +1472,9 @@ var STATUS_ORDER = [
|
|
|
1389
1472
|
TestStepResultStatus3.AMBIGUOUS,
|
|
1390
1473
|
TestStepResultStatus3.FAILED
|
|
1391
1474
|
];
|
|
1475
|
+
function statusSeverity(status) {
|
|
1476
|
+
return STATUS_ORDER.indexOf(status.toUpperCase());
|
|
1477
|
+
}
|
|
1392
1478
|
var VALID_STATUS = /* @__PURE__ */ new Set([
|
|
1393
1479
|
"passed",
|
|
1394
1480
|
"failed",
|
|
@@ -1406,12 +1492,22 @@ function durationMs(duration2) {
|
|
|
1406
1492
|
if (!duration2) return 0;
|
|
1407
1493
|
const seconds = Number.isFinite(duration2.seconds) ? duration2.seconds : 0;
|
|
1408
1494
|
const nanos = Number.isFinite(duration2.nanos) ? duration2.nanos : 0;
|
|
1409
|
-
|
|
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;
|
|
1410
1504
|
}
|
|
1411
1505
|
function timestampIso(timestamp2) {
|
|
1412
1506
|
if (!timestamp2) return void 0;
|
|
1413
1507
|
const milliseconds = timestamp2.seconds * 1e3 + timestamp2.nanos / 1e6;
|
|
1414
|
-
|
|
1508
|
+
if (!Number.isFinite(milliseconds)) return void 0;
|
|
1509
|
+
const date = new Date(milliseconds);
|
|
1510
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
1415
1511
|
}
|
|
1416
1512
|
function normalizeText2(value) {
|
|
1417
1513
|
return (value ?? "").replace(/\r\n/g, "\n");
|
|
@@ -1547,8 +1643,10 @@ function featureTree(document) {
|
|
|
1547
1643
|
visit(document.children ?? []);
|
|
1548
1644
|
return map;
|
|
1549
1645
|
}
|
|
1550
|
-
function buildReportModel(envelopes) {
|
|
1646
|
+
function buildReportModel(envelopes, provenance) {
|
|
1551
1647
|
const features = /* @__PURE__ */ new Map();
|
|
1648
|
+
const featureUris = /* @__PURE__ */ new Map();
|
|
1649
|
+
const featureSeen = /* @__PURE__ */ new Set();
|
|
1552
1650
|
const featureOrder = [];
|
|
1553
1651
|
const scenarioTree = /* @__PURE__ */ new Map();
|
|
1554
1652
|
const featureByScenarioId = /* @__PURE__ */ new Map();
|
|
@@ -1596,8 +1694,12 @@ function buildReportModel(envelopes) {
|
|
|
1596
1694
|
}
|
|
1597
1695
|
if (envelope.gherkinDocument?.feature) {
|
|
1598
1696
|
const feature = envelope.gherkinDocument.feature;
|
|
1599
|
-
|
|
1600
|
-
|
|
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);
|
|
1601
1703
|
featureOrder.push(feature);
|
|
1602
1704
|
}
|
|
1603
1705
|
for (const [id, value] of featureTree(feature)) {
|
|
@@ -1735,8 +1837,8 @@ function buildReportModel(envelopes) {
|
|
|
1735
1837
|
featureName: feature?.name ?? pickle.uri,
|
|
1736
1838
|
...tree?.ruleName ? { ruleName: tree.ruleName } : {},
|
|
1737
1839
|
status,
|
|
1738
|
-
durationMs:
|
|
1739
|
-
attempt: latest.attempt,
|
|
1840
|
+
durationMs: finiteDuration(duration2),
|
|
1841
|
+
attempt: Number.isFinite(latest.attempt) ? latest.attempt : 0,
|
|
1740
1842
|
...timestampIso(latest.timestamp) ? { startedAt: timestampIso(latest.timestamp) } : {},
|
|
1741
1843
|
tags: pickle.tags.map((tag) => tag.name),
|
|
1742
1844
|
steps: stepRows,
|
|
@@ -1753,16 +1855,26 @@ function buildReportModel(envelopes) {
|
|
|
1753
1855
|
}
|
|
1754
1856
|
}
|
|
1755
1857
|
const featureRows = [];
|
|
1858
|
+
const inInputOrder = new Set(featureOrder);
|
|
1756
1859
|
const orderedFeatures = [
|
|
1757
1860
|
...featureOrder,
|
|
1758
|
-
...[...featureScenarios.keys()].filter(
|
|
1861
|
+
...[...featureScenarios.keys()].filter(
|
|
1862
|
+
(feature) => !inInputOrder.has(feature)
|
|
1863
|
+
)
|
|
1759
1864
|
];
|
|
1760
1865
|
for (const feature of orderedFeatures) {
|
|
1761
1866
|
const scenarios = featureScenarios.get(feature) ?? [];
|
|
1762
1867
|
if (scenarios.length === 0) continue;
|
|
1763
|
-
const status = scenarios.reduce((worst, scenario) => {
|
|
1764
|
-
|
|
1765
|
-
|
|
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;
|
|
1766
1878
|
featureRows.push({
|
|
1767
1879
|
id: `feature-${featureRows.length + 1}`,
|
|
1768
1880
|
name: feature.name,
|
|
@@ -1771,11 +1883,17 @@ function buildReportModel(envelopes) {
|
|
|
1771
1883
|
description: normalizeText2(feature.description),
|
|
1772
1884
|
tags: feature.tags.map((tag) => tag.name),
|
|
1773
1885
|
status,
|
|
1774
|
-
durationMs:
|
|
1886
|
+
durationMs: finiteDuration(
|
|
1887
|
+
scenarios.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
1888
|
+
),
|
|
1775
1889
|
scenarios,
|
|
1776
|
-
attachments: scenarios.reduce((sum, scenario) => sum + scenario.attachments.length, 0)
|
|
1890
|
+
attachments: scenarios.reduce((sum, scenario) => sum + scenario.attachments.length, 0),
|
|
1891
|
+
...sourceFile ? { sourceFile } : {}
|
|
1777
1892
|
});
|
|
1778
1893
|
}
|
|
1894
|
+
if (featureRows.some((feature) => !feature.sourceFile)) {
|
|
1895
|
+
for (const feature of featureRows) delete feature.sourceFile;
|
|
1896
|
+
}
|
|
1779
1897
|
const attachmentRows = scenarioRows.flatMap((scenario) => scenario.attachments);
|
|
1780
1898
|
const runAttachments = mapAttachments(attachments.get("") ?? []);
|
|
1781
1899
|
const allAttachments = [...attachmentRows, ...runAttachments];
|
|
@@ -1790,7 +1908,9 @@ function buildReportModel(envelopes) {
|
|
|
1790
1908
|
attachments: allAttachments.length,
|
|
1791
1909
|
attachmentBytes: allAttachments.reduce((sum, attachment) => sum + attachment.bytes, 0)
|
|
1792
1910
|
},
|
|
1793
|
-
durationMs:
|
|
1911
|
+
durationMs: finiteDuration(
|
|
1912
|
+
scenarioRows.reduce((sum, scenario) => sum + scenario.durationMs, 0)
|
|
1913
|
+
),
|
|
1794
1914
|
...startedAt ? { startedAt } : {},
|
|
1795
1915
|
...finishedAt ? { finishedAt } : {},
|
|
1796
1916
|
source,
|
|
@@ -1868,7 +1988,15 @@ function durationMs2(duration2) {
|
|
|
1868
1988
|
if (!duration2) return 0;
|
|
1869
1989
|
const seconds = Number.isFinite(duration2.seconds) ? duration2.seconds : 0;
|
|
1870
1990
|
const nanos = Number.isFinite(duration2.nanos) ? duration2.nanos : 0;
|
|
1871
|
-
|
|
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;
|
|
1872
2000
|
}
|
|
1873
2001
|
function scenarioStatus(results) {
|
|
1874
2002
|
if (results.length === 0) return "unknown";
|
|
@@ -1878,13 +2006,14 @@ function statusOrdinal(status) {
|
|
|
1878
2006
|
return STATUS_ORDER2.indexOf(status.toUpperCase());
|
|
1879
2007
|
}
|
|
1880
2008
|
function displayUri(uri) {
|
|
1881
|
-
const normalized = uri.replace(/\\/g, "/");
|
|
2009
|
+
const normalized = uri.replace(/\\/g, "/").replace(/^file:\/\/+/i, "");
|
|
1882
2010
|
if (!/^[a-z]:\//i.test(normalized) && !normalized.startsWith("/")) {
|
|
1883
2011
|
return normalized;
|
|
1884
2012
|
}
|
|
1885
2013
|
const marker = normalized.lastIndexOf("/features/");
|
|
1886
2014
|
if (marker >= 0) return normalized.slice(marker + 1);
|
|
1887
|
-
|
|
2015
|
+
const parts = normalized.split("/").filter(Boolean);
|
|
2016
|
+
return parts[parts.length - 1] ?? uri;
|
|
1888
2017
|
}
|
|
1889
2018
|
function featureTree2(document) {
|
|
1890
2019
|
const stepKeywords = /* @__PURE__ */ new Map();
|
|
@@ -2061,7 +2190,7 @@ function summarizeEnvelopes(input) {
|
|
|
2061
2190
|
uri: displayUri(pickle.uri ?? ""),
|
|
2062
2191
|
feature: tree.featureName,
|
|
2063
2192
|
status,
|
|
2064
|
-
durationMs:
|
|
2193
|
+
durationMs: finiteDuration2(scenarioDuration),
|
|
2065
2194
|
attempt: started?.attempt ?? 0,
|
|
2066
2195
|
tags: (pickle.tags ?? []).map((tag) => tag.name),
|
|
2067
2196
|
attachments: scenarioAttachments.length,
|
|
@@ -2081,7 +2210,7 @@ function summarizeEnvelopes(input) {
|
|
|
2081
2210
|
return {
|
|
2082
2211
|
schemaVersion: SUMMARY_SCHEMA_VERSION,
|
|
2083
2212
|
status: overall,
|
|
2084
|
-
durationMs:
|
|
2213
|
+
durationMs: finiteDuration2(totalDuration),
|
|
2085
2214
|
counts: {
|
|
2086
2215
|
features: featureSet.size,
|
|
2087
2216
|
scenarios: scenarioCounts,
|
|
@@ -2114,7 +2243,7 @@ function isLogoDataUri(value) {
|
|
|
2114
2243
|
|
|
2115
2244
|
// src/render/escape.ts
|
|
2116
2245
|
function escapeHtml(value) {
|
|
2117
|
-
return value.replace(/[&<>"']/g, (character) => {
|
|
2246
|
+
return String(value ?? "").replace(/[&<>"']/g, (character) => {
|
|
2118
2247
|
switch (character) {
|
|
2119
2248
|
case "&":
|
|
2120
2249
|
return "&";
|
|
@@ -2211,7 +2340,7 @@ img, video { max-width: 100%; height: auto; }
|
|
|
2211
2340
|
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
2212
2341
|
.tagFilter { display: flex; align-items: center; gap: 0.375rem; min-height: 2.125rem; max-width: 100%; }
|
|
2213
2342
|
.tagFilter > span { color: var(--muted); font-size: 0.75rem; }
|
|
2214
|
-
.tagFilter select { max-width: 100%; min-height: 1.875rem; padding: 0 1.5rem 0 0.5rem; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--paper); color: var(--ink-2); font-size: 0.75rem; }
|
|
2343
|
+
.tagFilter select { max-width: 100%; min-width: 0; min-height: 1.875rem; padding: 0 1.5rem 0 0.5rem; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--paper); color: var(--ink-2); font-size: 0.75rem; }
|
|
2215
2344
|
.tagFilter select:hover { color: var(--ink); }
|
|
2216
2345
|
.filters { display: flex; gap: 0.375rem; flex-wrap: wrap; }
|
|
2217
2346
|
.filter { min-height: 1.875rem; 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.75rem; }
|
|
@@ -2224,13 +2353,56 @@ img, video { max-width: 100%; height: auto; }
|
|
|
2224
2353
|
.expand { display: flex; gap: 0.25rem; margin-left: auto; }
|
|
2225
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; }
|
|
2226
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; }
|
|
2227
2392
|
.feature { border-bottom: 1px solid var(--line-strong); background: transparent; container-type: inline-size; }
|
|
2228
|
-
.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; }
|
|
2229
2402
|
.feature > summary::-webkit-details-marker, .scenarioButton::-webkit-details-marker { display: none; }
|
|
2230
2403
|
.feature > summary:focus-visible, .scenarioButton:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
2231
2404
|
.feature > summary:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--paper)); }
|
|
2232
2405
|
.feature h2 { margin: 0; min-width: 0; font-size: 1rem; line-height: 1.3; font-weight: 600; overflow-wrap: break-word; }
|
|
2233
|
-
.feature .fmeta { color: var(--muted); font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; }
|
|
2234
2406
|
.statusCell { display: flex; align-items: center; }
|
|
2235
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; }
|
|
2236
2408
|
.statusText.pass { color: var(--pass); border-color: color-mix(in oklab, var(--pass) 32%, var(--line)); background: var(--pass-soft); }
|
|
@@ -2244,7 +2416,7 @@ details[open] > summary .chev { transform: rotate(180deg); }
|
|
|
2244
2416
|
.scenario:last-child { border-bottom: 0; }
|
|
2245
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; }
|
|
2246
2418
|
.scenarioButton:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--paper)); }
|
|
2247
|
-
details[open] > summary.scenarioButton { background: var(--
|
|
2419
|
+
details[open] > summary.scenarioButton { background: var(--surface-2); }
|
|
2248
2420
|
.scenarioMain { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
|
|
2249
2421
|
.scenarioName { margin: 0; font-size: 0.875rem; line-height: 1.4; font-weight: 500; overflow-wrap: break-word; }
|
|
2250
2422
|
.scenarioSub { display: block; color: var(--muted); font-size: 0.75rem; }
|
|
@@ -2289,7 +2461,7 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2289
2461
|
.attachmentText summary { cursor: pointer; color: var(--accent-text); font-size: 0.75rem; }
|
|
2290
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); }
|
|
2291
2463
|
.fileLink { display: inline-block; margin: 0.3125rem 0; color: var(--accent-text); font-size: 0.75rem; }
|
|
2292
|
-
.meta span, .
|
|
2464
|
+
.meta span, .path, .description, .step, .featureSource, .featureUri, .fileLink, .attachment figcaption, .attachmentText summary, .detailMeta span { overflow-wrap: anywhere; }
|
|
2293
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; }
|
|
2294
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; }
|
|
2295
2467
|
.foot { margin-top: 1.75rem; color: var(--muted); font-size: 0.75rem; }
|
|
@@ -2300,12 +2472,19 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2300
2472
|
.panel h2 { margin: 0 0 0.375rem; font-size: 1.125rem; }
|
|
2301
2473
|
.panel h2.subhead { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
|
|
2302
2474
|
.panel p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.8125rem; }
|
|
2303
|
-
.featureTable { width: 100%; min-width:
|
|
2475
|
+
.featureTable { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.8125rem; }
|
|
2304
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; }
|
|
2305
2482
|
.featureTable td { padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--line); }
|
|
2306
2483
|
.featureTable td:last-child, .featureTable th:last-child { text-align: right; }
|
|
2307
2484
|
.featureTable tr:last-child td { border-bottom: 0; }
|
|
2308
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; }
|
|
2309
2488
|
.legend { display: grid; gap: 0.375rem; margin-top: 0.625rem; }
|
|
2310
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); }
|
|
2311
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); }
|
|
@@ -2322,7 +2501,7 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2322
2501
|
.runHead { grid-template-columns: 1fr; gap: 1.25rem; }
|
|
2323
2502
|
.health { border-left: 0; border-top: 1px solid var(--line-strong); padding: 1rem 0 0; }
|
|
2324
2503
|
.feature > summary { grid-template-columns: 4.75rem minmax(0, 1fr) 1.25rem; }
|
|
2325
|
-
.
|
|
2504
|
+
.featureUri { display: none; }
|
|
2326
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; }
|
|
2327
2506
|
.scenarioButton .statusCell { grid-area: status; align-self: start; }
|
|
2328
2507
|
.scenarioButton .thumbCell { grid-area: thumb; align-self: start; }
|
|
@@ -2345,14 +2524,21 @@ details[open] > summary.scenarioButton { background: var(--accent-soft); }
|
|
|
2345
2524
|
.thumb { width: 2.5rem; height: 1.875rem; }
|
|
2346
2525
|
.statusText { min-width: 3.125rem; }
|
|
2347
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; }
|
|
2348
2532
|
}
|
|
2349
2533
|
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
|
|
2350
2534
|
@container (max-width: 16rem) {
|
|
2351
2535
|
.runHead h1 { font-size: 1.3rem; }
|
|
2352
|
-
.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; }
|
|
2353
2537
|
.feature > summary .statusCell { grid-area: status; }
|
|
2354
2538
|
.feature > summary h2 { grid-area: title; }
|
|
2355
2539
|
.feature > summary .chev { grid-area: chev; }
|
|
2540
|
+
.featureShape { grid-area: shape; }
|
|
2541
|
+
.triageScenarios a { grid-template-columns: minmax(0, 1fr); gap: 0.125rem; }
|
|
2356
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; }
|
|
2357
2543
|
.scenarioButton .statusCell { grid-area: status; }
|
|
2358
2544
|
.scenarioButton .thumbCell { grid-area: thumb; }
|
|
@@ -2417,6 +2603,7 @@ var STEP_GLYPHS = {
|
|
|
2417
2603
|
unknown: "\xB7"
|
|
2418
2604
|
};
|
|
2419
2605
|
function durationLabel(milliseconds) {
|
|
2606
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) return "0 ms";
|
|
2420
2607
|
if (milliseconds < 1e3) return `${Math.round(milliseconds * 100) / 100} ms`;
|
|
2421
2608
|
return `${(milliseconds / 1e3).toFixed(2)} s`;
|
|
2422
2609
|
}
|
|
@@ -2440,11 +2627,140 @@ function displayStatuses(model) {
|
|
|
2440
2627
|
(status) => model.counts.scenarios[status] > 0
|
|
2441
2628
|
);
|
|
2442
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
|
+
}
|
|
2443
2759
|
function statusBar(model) {
|
|
2444
2760
|
const total = model.counts.scenarios.total;
|
|
2445
2761
|
if (total === 0) return "";
|
|
2446
2762
|
return `<div class="bar" aria-hidden="true">${displayStatuses(model).map(
|
|
2447
|
-
(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>`
|
|
2448
2764
|
).join("")}</div>`;
|
|
2449
2765
|
}
|
|
2450
2766
|
function countPills(model) {
|
|
@@ -2495,14 +2811,14 @@ function scenarioText(scenario) {
|
|
|
2495
2811
|
return [
|
|
2496
2812
|
scenario.name,
|
|
2497
2813
|
scenario.featureName,
|
|
2498
|
-
scenario.uri,
|
|
2814
|
+
displayUri(scenario.uri),
|
|
2499
2815
|
scenario.keyword,
|
|
2500
2816
|
scenario.description,
|
|
2501
2817
|
scenario.tags.join(" "),
|
|
2502
|
-
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(" ")
|
|
2503
2819
|
].join(" ");
|
|
2504
2820
|
}
|
|
2505
|
-
function renderScenario(scenario) {
|
|
2821
|
+
function renderScenario(scenario, featureIndex, scenarioIndex) {
|
|
2506
2822
|
const image = scenario.attachments.find(
|
|
2507
2823
|
(attachment) => attachment.kind === "image" && attachment.dataUri
|
|
2508
2824
|
);
|
|
@@ -2511,15 +2827,34 @@ function renderScenario(scenario) {
|
|
|
2511
2827
|
const description = scenario.description ? `<p class="description">${escapeHtml(scenario.description)}</p>` : "";
|
|
2512
2828
|
const extraAttachments = scenario.extraAttachments.length ? `<h4>Attachments</h4>${scenario.extraAttachments.map((attachment) => renderAttachment(attachment, scenario.name)).join("")}` : "";
|
|
2513
2829
|
const copyFailure = scenario.status === "failed" ? '<button class="copyFailure" type="button" data-copy-failure>Copy failure</button>' : "";
|
|
2514
|
-
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>`;
|
|
2515
2831
|
}
|
|
2516
|
-
function renderFeature(feature) {
|
|
2517
|
-
const
|
|
2518
|
-
const open = feature.status === "failed" || feature.scenarios.some(
|
|
2832
|
+
function renderFeature({ feature, scenarios }, featureIndex) {
|
|
2833
|
+
const open = feature.status === "failed" || scenarios.some(
|
|
2519
2834
|
(scenario) => scenario.attachments.some((attachment) => attachment.kind === "image")
|
|
2520
2835
|
);
|
|
2521
2836
|
const description = feature.description ? `<p class="description">${escapeHtml(feature.description)}</p>` : "";
|
|
2522
|
-
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>`;
|
|
2523
2858
|
}
|
|
2524
2859
|
function metadataLine(metadata) {
|
|
2525
2860
|
return Object.entries(metadata ?? {}).filter(([key, value]) => key.length > 0 && value.length > 0).map(
|
|
@@ -2532,12 +2867,15 @@ function renderReportView(model, options) {
|
|
|
2532
2867
|
const percent = total === 0 ? 0 : Math.round(passed / total * 1e3) / 10;
|
|
2533
2868
|
const meta = metadataLine(options.metadata);
|
|
2534
2869
|
const date = dateLabel(model.startedAt);
|
|
2535
|
-
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);
|
|
2536
2874
|
const tags = scenarioTags(model);
|
|
2537
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>` : "";
|
|
2538
|
-
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(
|
|
2539
2877
|
(status) => `<button class="filter" type="button" data-status="${status}" aria-pressed="true">${statusLabel(status)} <b>${model.counts.scenarios[status]}</b></button>`
|
|
2540
|
-
).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>`;
|
|
2541
2879
|
}
|
|
2542
2880
|
function renderAnalysisView(model, options, summary) {
|
|
2543
2881
|
const counts = model.counts.scenarios;
|
|
@@ -2558,9 +2896,7 @@ function renderAnalysisView(model, options, summary) {
|
|
|
2558
2896
|
model.environment?.protocol ? `<dt>Protocol</dt><dd>${escapeHtml(model.environment.protocol)}</dd>` : ""
|
|
2559
2897
|
].join("");
|
|
2560
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>`;
|
|
2561
|
-
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
|
|
2562
|
-
(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>`
|
|
2563
|
-
).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(
|
|
2564
2900
|
(status) => `<div class="legendRow ${statusClass(status)}"><span class="marker ${statusClass(status)}"></span><span>${statusLabel(status)}</span><b>${counts[status]}</b></div>`
|
|
2565
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>`;
|
|
2566
2902
|
}
|
|
@@ -2593,9 +2929,13 @@ var SCRIPT = `<script>
|
|
|
2593
2929
|
showView(views[next].getAttribute('data-view'));
|
|
2594
2930
|
});
|
|
2595
2931
|
var state = { query: '', hidden: new Set(), tag: '' };
|
|
2932
|
+
var searchOpened = [];
|
|
2596
2933
|
var scenarios = Array.prototype.slice.call(document.querySelectorAll('[data-scenario]'));
|
|
2597
2934
|
var features = Array.prototype.slice.call(document.querySelectorAll('[data-feature]'));
|
|
2598
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]');
|
|
2599
2939
|
function apply() {
|
|
2600
2940
|
var query = state.query.toLowerCase();
|
|
2601
2941
|
var tag = state.tag;
|
|
@@ -2615,14 +2955,32 @@ var SCRIPT = `<script>
|
|
|
2615
2955
|
feature.hidden = !any;
|
|
2616
2956
|
if (any && (query || state.hidden.size || tag)) feature.open = true;
|
|
2617
2957
|
});
|
|
2958
|
+
searchOpened.forEach(function (scenario) { scenario.open = false; });
|
|
2959
|
+
searchOpened = [];
|
|
2618
2960
|
if (query) {
|
|
2961
|
+
var opened = 0;
|
|
2619
2962
|
scenarios.forEach(function (scenario) {
|
|
2620
|
-
if (!scenario.hidden
|
|
2963
|
+
if (!scenario.hidden && opened < 20) {
|
|
2964
|
+
if (!scenario.open) searchOpened.push(scenario);
|
|
2965
|
+
scenario.open = true;
|
|
2966
|
+
opened += 1;
|
|
2967
|
+
}
|
|
2621
2968
|
});
|
|
2622
2969
|
}
|
|
2623
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
|
+
}
|
|
2624
2980
|
var empty = document.getElementById('empty-results');
|
|
2625
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);
|
|
2626
2984
|
highlightSearch();
|
|
2627
2985
|
}
|
|
2628
2986
|
function clearHighlights() {
|
|
@@ -2817,7 +3175,32 @@ var SCRIPT = `<script>
|
|
|
2817
3175
|
lightbox.addEventListener('click', function (event) { if (event.target === lightbox) closeDialog(); });
|
|
2818
3176
|
lightbox.addEventListener('close', restoreLightbox);
|
|
2819
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);
|
|
2820
3202
|
showView('report');
|
|
3203
|
+
revealHash();
|
|
2821
3204
|
})();
|
|
2822
3205
|
</script>`;
|
|
2823
3206
|
function inlineScriptHashes(html) {
|
|
@@ -2835,7 +3218,7 @@ function csp(hashes) {
|
|
|
2835
3218
|
}
|
|
2836
3219
|
async function renderHtml(envelopes, options) {
|
|
2837
3220
|
const safeEnvelopes = sanitizeEnvelopes(envelopes);
|
|
2838
|
-
const model = buildReportModel(safeEnvelopes);
|
|
3221
|
+
const model = buildReportModel(safeEnvelopes, options.provenance);
|
|
2839
3222
|
const summary = options.summary ?? summarizeEnvelopes(safeEnvelopes);
|
|
2840
3223
|
const logo = isLogoDataUri(options.logo) ? `<img class="logo" src="${escapeHtml(options.logo)}" alt="">` : "";
|
|
2841
3224
|
const accent = isValidAccent(options.accent) ? `<style>:root{--accent:${options.accent}}</style>` : "";
|
|
@@ -2855,9 +3238,10 @@ ${csp(hashes)}
|
|
|
2855
3238
|
}
|
|
2856
3239
|
|
|
2857
3240
|
// src/index.ts
|
|
2858
|
-
var version = "0.
|
|
3241
|
+
var version = "0.2.0";
|
|
2859
3242
|
async function generateReport(inputs, options = {}) {
|
|
2860
|
-
const
|
|
3243
|
+
const groups = await loadInputs(inputs);
|
|
3244
|
+
const envelopes = groups.flatMap((group) => group.envelopes);
|
|
2861
3245
|
const summary = summarizeEnvelopes(envelopes);
|
|
2862
3246
|
return {
|
|
2863
3247
|
html: await renderHtml(envelopes, {
|
|
@@ -2865,7 +3249,8 @@ async function generateReport(inputs, options = {}) {
|
|
|
2865
3249
|
metadata: options.metadata,
|
|
2866
3250
|
logo: options.logo,
|
|
2867
3251
|
accent: options.accent,
|
|
2868
|
-
summary
|
|
3252
|
+
summary,
|
|
3253
|
+
provenance: groups.length > 1 ? provenanceFor(groups) : void 0
|
|
2869
3254
|
}),
|
|
2870
3255
|
summary
|
|
2871
3256
|
};
|
|
@@ -3002,6 +3387,28 @@ async function readLogo(file) {
|
|
|
3002
3387
|
}
|
|
3003
3388
|
return `data:${mime};base64,${data.toString("base64")}`;
|
|
3004
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
|
+
}
|
|
3005
3412
|
async function runCli(argv, io = {
|
|
3006
3413
|
stdout: (text) => process.stdout.write(text),
|
|
3007
3414
|
stderr: (text) => process.stderr.write(text)
|
|
@@ -3028,10 +3435,34 @@ ${USAGE}`);
|
|
|
3028
3435
|
const inputs = parsed.positionals;
|
|
3029
3436
|
const output = parsed.values.out;
|
|
3030
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
|
+
}
|
|
3031
3444
|
if (inputs.length === 0 || !output && !wantsJson) {
|
|
3032
3445
|
io.stderr(USAGE);
|
|
3033
3446
|
return 2;
|
|
3034
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
|
+
}
|
|
3035
3466
|
let metadata;
|
|
3036
3467
|
let maxSizeMb;
|
|
3037
3468
|
let accent;
|
|
@@ -3040,7 +3471,7 @@ ${USAGE}`);
|
|
|
3040
3471
|
metadata = parseMetadata(parsed.values.meta);
|
|
3041
3472
|
maxSizeMb = parseMaxSize(parsed.values["max-size"]);
|
|
3042
3473
|
accent = parseAccent(parsed.values.accent);
|
|
3043
|
-
logo =
|
|
3474
|
+
logo = parsed.values.logo ? await readLogo(parsed.values.logo) : void 0;
|
|
3044
3475
|
} catch (error) {
|
|
3045
3476
|
const detail = error instanceof Error ? error.message : String(error);
|
|
3046
3477
|
io.stderr(`tolkira: ${detail}
|
|
@@ -3085,8 +3516,16 @@ ${USAGE}`);
|
|
|
3085
3516
|
return 1;
|
|
3086
3517
|
}
|
|
3087
3518
|
}
|
|
3088
|
-
|
|
3089
|
-
|
|
3519
|
+
function isMainModule() {
|
|
3520
|
+
const entry = process.argv[1];
|
|
3521
|
+
if (!entry) return false;
|
|
3522
|
+
try {
|
|
3523
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(entry);
|
|
3524
|
+
} catch {
|
|
3525
|
+
return false;
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
if (isMainModule()) {
|
|
3090
3529
|
runCli(process.argv.slice(2)).then((code) => {
|
|
3091
3530
|
process.exitCode = code;
|
|
3092
3531
|
});
|