blastproof 0.28.0 → 0.30.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/README.md +1 -1
- package/dist/cli.js +331 -75
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -255,7 +255,7 @@ blastproof run # any failure exits 1 (strict, the default)
|
|
|
255
255
|
blastproof run --min-score 80 # one failing P2 is tolerated
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
`--min-score` **replaces** the all-must-pass rule rather than adding to it. Only executed tests count: filtered and unrouted tests are neither numerator nor denominator, and a run that executed nothing scores 100, so a docs-only PR is never blocked. JUnit carries the score as a `<property name="score">`, and unrouted tests appear as `<skipped/>` so the coverage gap shows up in CI rather than vanishing.
|
|
258
|
+
`--min-score` **replaces** the all-must-pass rule rather than adding to it. Only executed tests count: filtered and unrouted tests are neither numerator nor denominator, and a run that executed nothing scores 100, so a docs-only PR is never blocked. JUnit carries the score as a `<property name="score">`, and unrouted tests appear as `<skipped/>` so the coverage gap shows up in CI rather than vanishing. The warnings the run prints (uncommitted work, route drift, a step that names no value) are in both reports too: JUnit counts them in `<property name="warnings">` with their text in `<system-err>`, and the HTML report shows them right after the score.
|
|
259
259
|
|
|
260
260
|
**The verdict behind that number is pinned, and that is not the same as reproducible.** The model call that decides whether a step passed runs at temperature 0, so the same page and the same expectation are not re-sampled into a different answer — a gate that flips on identical input teaches people to re-run until green, which is worse than no gate. What pinning does not survive: provider-side batching, floating point, and a gateway routing two calls to different providers or quantizations. Expect far less variance, not a guarantee of the same output twice.
|
|
261
261
|
|
package/dist/cli.js
CHANGED
|
@@ -574,13 +574,13 @@ async function resolveTarget(page, target, resolveTimeoutMs = 2e3) {
|
|
|
574
574
|
if (!target.ref) throw new ActionError(`Element not found: ${describeTarget(target)} has no ref`);
|
|
575
575
|
const ref = bareRef(target.ref);
|
|
576
576
|
const locator = page.locator(`aria-ref=${ref}`);
|
|
577
|
-
let
|
|
577
|
+
let count2;
|
|
578
578
|
try {
|
|
579
|
-
|
|
579
|
+
count2 = await locator.count();
|
|
580
580
|
} catch {
|
|
581
|
-
|
|
581
|
+
count2 = 0;
|
|
582
582
|
}
|
|
583
|
-
if (
|
|
583
|
+
if (count2 === 0) {
|
|
584
584
|
throw new ActionError(
|
|
585
585
|
`Element not found: ${describeTarget(target)} (ref ${ref}) is no longer on the page; it changed since the snapshot. Choose the element again from the fresh snapshot.`
|
|
586
586
|
);
|
|
@@ -1269,6 +1269,141 @@ function deviceOptions(name) {
|
|
|
1269
1269
|
return options;
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
|
+
// src/session-capture.ts
|
|
1273
|
+
var SESSION_SEEDED_MARKER = "blastproof:session-seeded";
|
|
1274
|
+
async function readFalsyRecords() {
|
|
1275
|
+
const g = globalThis;
|
|
1276
|
+
const done = (request) => new Promise((resolve2, reject) => {
|
|
1277
|
+
request.onsuccess = () => resolve2(request.result);
|
|
1278
|
+
request.onerror = () => reject(request.error);
|
|
1279
|
+
});
|
|
1280
|
+
const encode = (value) => {
|
|
1281
|
+
if (value === null) return { v: "null" };
|
|
1282
|
+
if (typeof value === "number" && Number.isNaN(value)) return { v: "NaN" };
|
|
1283
|
+
if (Object.is(value, -0)) return { v: "-0" };
|
|
1284
|
+
if (value === 0 || value === "" || value === false) return { plain: value };
|
|
1285
|
+
return void 0;
|
|
1286
|
+
};
|
|
1287
|
+
const databases = [];
|
|
1288
|
+
for (const info of await g.indexedDB.databases()) {
|
|
1289
|
+
if (!info.name) continue;
|
|
1290
|
+
const db = await done(g.indexedDB.open(info.name));
|
|
1291
|
+
try {
|
|
1292
|
+
if (db.objectStoreNames.length === 0) {
|
|
1293
|
+
databases.push({ name: info.name, stores: [] });
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
const transaction = db.transaction(db.objectStoreNames, "readonly");
|
|
1297
|
+
const reads = [...db.objectStoreNames].map((name) => {
|
|
1298
|
+
const store = transaction.objectStore(name);
|
|
1299
|
+
return Promise.all([done(store.getAllKeys()), done(store.getAll())]).then(([keys, values]) => ({
|
|
1300
|
+
name,
|
|
1301
|
+
count: keys.length,
|
|
1302
|
+
keys: keys.flatMap((key, i) => key === 0 || key === "" ? [[i, key]] : []),
|
|
1303
|
+
values: values.flatMap((value, i) => {
|
|
1304
|
+
const encoded = encode(value);
|
|
1305
|
+
return encoded ? [[i, encoded]] : [];
|
|
1306
|
+
})
|
|
1307
|
+
}));
|
|
1308
|
+
});
|
|
1309
|
+
databases.push({ name: info.name, stores: await Promise.all(reads) });
|
|
1310
|
+
} finally {
|
|
1311
|
+
db.close();
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
return { origin: g.location.origin, databases };
|
|
1315
|
+
}
|
|
1316
|
+
function readSessionStorage() {
|
|
1317
|
+
const g = globalThis;
|
|
1318
|
+
const items = [];
|
|
1319
|
+
for (let i = 0; i < g.sessionStorage.length; i++) {
|
|
1320
|
+
const name = g.sessionStorage.key(i);
|
|
1321
|
+
if (name !== null) items.push({ name, value: g.sessionStorage.getItem(name) ?? "" });
|
|
1322
|
+
}
|
|
1323
|
+
return { origin: g.location.origin, items };
|
|
1324
|
+
}
|
|
1325
|
+
function seedSessionStorage(seed) {
|
|
1326
|
+
const g = globalThis;
|
|
1327
|
+
if (g.location.origin !== seed.origin) return;
|
|
1328
|
+
try {
|
|
1329
|
+
if (g.sessionStorage.getItem(seed.marker) !== null) return;
|
|
1330
|
+
for (const { name, value } of seed.items) g.sessionStorage.setItem(name, value);
|
|
1331
|
+
g.sessionStorage.setItem(seed.marker, "1");
|
|
1332
|
+
} catch {
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
var isMissing = (record, field) => !(field in record) && !(`${field}Encoded` in record);
|
|
1336
|
+
var isOutOfLine = (store) => store.keyPath === void 0 && store.keyPathArray === void 0;
|
|
1337
|
+
function repairIndexedDB(state, found) {
|
|
1338
|
+
const origins = structuredClone(state.origins);
|
|
1339
|
+
for (const origin of origins) {
|
|
1340
|
+
const databases = origin.indexedDB ?? [];
|
|
1341
|
+
if (origin.origin !== found.origin) {
|
|
1342
|
+
const broken = databases.some(
|
|
1343
|
+
(db) => db.stores.some(
|
|
1344
|
+
(store) => store.records.some((r) => isOutOfLine(store) && isMissing(r, "key") || isMissing(r, "value"))
|
|
1345
|
+
)
|
|
1346
|
+
);
|
|
1347
|
+
if (broken) delete origin.indexedDB;
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
for (const db of databases) {
|
|
1351
|
+
for (const store of db.stores) {
|
|
1352
|
+
const read = found.databases.find((d) => d.name === db.name)?.stores.find((s) => s.name === store.name);
|
|
1353
|
+
if (!read || read.count !== store.records.length) return void 0;
|
|
1354
|
+
const keys = new Map(read.keys);
|
|
1355
|
+
const values = new Map(read.values);
|
|
1356
|
+
for (const [i, record] of store.records.entries()) {
|
|
1357
|
+
if (isOutOfLine(store)) {
|
|
1358
|
+
const key = keys.get(i);
|
|
1359
|
+
if (isMissing(record, "key")) {
|
|
1360
|
+
if (key === void 0) return void 0;
|
|
1361
|
+
record.key = key;
|
|
1362
|
+
} else if (key !== void 0 && record.key !== key) {
|
|
1363
|
+
return void 0;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
const value = values.get(i);
|
|
1367
|
+
if (isMissing(record, "value")) {
|
|
1368
|
+
if (value === void 0) return void 0;
|
|
1369
|
+
if ("plain" in value) record.value = value.plain;
|
|
1370
|
+
else record.valueEncoded = value;
|
|
1371
|
+
} else if (value !== void 0 && "value" in record && record.value) {
|
|
1372
|
+
return void 0;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return { ...state, origins };
|
|
1379
|
+
}
|
|
1380
|
+
var CAPTURE_ATTEMPTS = 3;
|
|
1381
|
+
async function captureSession(context, page) {
|
|
1382
|
+
for (let attempt = 1; ; attempt++) {
|
|
1383
|
+
const state = await context.storageState({ indexedDB: true });
|
|
1384
|
+
const found = await page.evaluate(readFalsyRecords);
|
|
1385
|
+
const repaired = repairIndexedDB(state, found);
|
|
1386
|
+
if (repaired) {
|
|
1387
|
+
const sessionStorage = await page.evaluate(readSessionStorage);
|
|
1388
|
+
return {
|
|
1389
|
+
storageState: repaired,
|
|
1390
|
+
...sessionStorage.items.length > 0 && sessionStorage.origin !== "null" ? { sessionStorage } : {}
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
if (attempt === CAPTURE_ATTEMPTS) {
|
|
1394
|
+
throw new Error(`the app kept writing to its IndexedDB while the session was read (${CAPTURE_ATTEMPTS} attempts)`);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
async function seedSessionStorageInto(context, seed) {
|
|
1399
|
+
await context.addInitScript(seedSessionStorage, { ...seed, marker: SESSION_SEEDED_MARKER });
|
|
1400
|
+
}
|
|
1401
|
+
function isSessionStorageSeed(value) {
|
|
1402
|
+
return typeof value === "object" && value !== null && typeof value.origin === "string" && Array.isArray(value.items) && value.items.every(
|
|
1403
|
+
(item) => typeof item?.name === "string" && typeof item?.value === "string"
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1272
1407
|
// src/auth.ts
|
|
1273
1408
|
var AUTH_STATE_RELATIVE_PATH = path3.join(".blastproof", ".auth-state.json");
|
|
1274
1409
|
var AuthError = class extends Error {
|
|
@@ -1300,7 +1435,8 @@ async function fromStorageState(file) {
|
|
|
1300
1435
|
`Invalid storage state at ${file}: expected an object with "cookies" and "origins" arrays.`
|
|
1301
1436
|
);
|
|
1302
1437
|
}
|
|
1303
|
-
|
|
1438
|
+
const { sessionStorage, ...storageState } = parsed;
|
|
1439
|
+
return { storageState, ...isSessionStorageSeed(sessionStorage) ? { sessionStorage } : {} };
|
|
1304
1440
|
}
|
|
1305
1441
|
function fromStatic(auth, mask) {
|
|
1306
1442
|
const session = {};
|
|
@@ -1392,7 +1528,55 @@ async function fromSteps(options) {
|
|
|
1392
1528
|
throw new AuthError(`Authentication could not be verified: ${mask.mask(judgment.reason)}`);
|
|
1393
1529
|
}
|
|
1394
1530
|
}
|
|
1395
|
-
|
|
1531
|
+
let session;
|
|
1532
|
+
try {
|
|
1533
|
+
session = await captureSession(context, page);
|
|
1534
|
+
} catch (error) {
|
|
1535
|
+
throw new AuthError(
|
|
1536
|
+
`Signed in, but the session could not be captured: ${error instanceof Error ? error.message : String(error)}`
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
await checkWhereUsed(options, session, page, takeSnapshot);
|
|
1540
|
+
return session;
|
|
1541
|
+
} finally {
|
|
1542
|
+
await context.close();
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
async function checkWhereUsed(options, session, loginPage, takeSnapshot) {
|
|
1546
|
+
const { browser, brain, mask, maxRetries, timeoutMs } = options;
|
|
1547
|
+
const verify = options.auth.verify;
|
|
1548
|
+
if (!verify) return;
|
|
1549
|
+
let context;
|
|
1550
|
+
try {
|
|
1551
|
+
context = await browser.newContext(contextOptions(session, options.device));
|
|
1552
|
+
} catch (error) {
|
|
1553
|
+
throw new AuthError(
|
|
1554
|
+
"Signed in, but the captured session cannot be restored into a new browser context: " + (error instanceof Error ? error.message : String(error))
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
try {
|
|
1558
|
+
await seedContext(context, session);
|
|
1559
|
+
const page = await context.newPage();
|
|
1560
|
+
try {
|
|
1561
|
+
await page.goto(loginPage.url(), { timeout: timeoutMs });
|
|
1562
|
+
} catch (error) {
|
|
1563
|
+
throw new AuthError(
|
|
1564
|
+
"Signed in, but the page the login ended on did not open in a new browser context seeded with the session: " + (error instanceof Error ? error.message : String(error))
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
await waitForSettled(page);
|
|
1568
|
+
const judgment = await verifyJudgment(
|
|
1569
|
+
brain,
|
|
1570
|
+
verify,
|
|
1571
|
+
async () => withoutRefs(mask.mask(await takeSnapshot(page))),
|
|
1572
|
+
(text) => mask.mask(text),
|
|
1573
|
+
maxRetries
|
|
1574
|
+
);
|
|
1575
|
+
if (!judgment.pass) {
|
|
1576
|
+
throw new AuthError(
|
|
1577
|
+
`Signed in, but the captured session does not keep the sign-in: a new browser context seeded with it is not signed in (${mask.mask(judgment.reason)}). The app may keep its session where a storage state cannot hold it, such as memory or a service worker. Tests would start signed out, so none were run.`
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1396
1580
|
} finally {
|
|
1397
1581
|
await context.close();
|
|
1398
1582
|
}
|
|
@@ -1408,7 +1592,8 @@ async function writeCached(cwd, session) {
|
|
|
1408
1592
|
if (!session.storageState) return;
|
|
1409
1593
|
const file = path3.join(cwd, AUTH_STATE_RELATIVE_PATH);
|
|
1410
1594
|
await mkdir3(path3.dirname(file), { recursive: true });
|
|
1411
|
-
|
|
1595
|
+
const cached = session.sessionStorage ? { ...session.storageState, sessionStorage: session.sessionStorage } : session.storageState;
|
|
1596
|
+
await writeFile2(file, JSON.stringify(cached), "utf8");
|
|
1412
1597
|
}
|
|
1413
1598
|
async function authenticate(options) {
|
|
1414
1599
|
const { auth, cwd } = options;
|
|
@@ -1434,6 +1619,9 @@ function contextOptions(session, device) {
|
|
|
1434
1619
|
...session.extraHTTPHeaders ? { extraHTTPHeaders: session.extraHTTPHeaders } : {}
|
|
1435
1620
|
};
|
|
1436
1621
|
}
|
|
1622
|
+
async function seedContext(context, session) {
|
|
1623
|
+
if (session?.sessionStorage) await seedSessionStorageInto(context, session.sessionStorage);
|
|
1624
|
+
}
|
|
1437
1625
|
|
|
1438
1626
|
// src/config.ts
|
|
1439
1627
|
import { readFile as readFile2 } from "fs/promises";
|
|
@@ -1782,23 +1970,38 @@ function mapImpact(changedFiles, routes, ignore = []) {
|
|
|
1782
1970
|
};
|
|
1783
1971
|
}
|
|
1784
1972
|
|
|
1973
|
+
// src/report/warnings.ts
|
|
1974
|
+
function emitWarning(warning, into) {
|
|
1975
|
+
if (!warning) return;
|
|
1976
|
+
console.error(`${warning.spaced ? "\n" : ""}${warning.title}`);
|
|
1977
|
+
for (const line of warning.lines) console.error(line);
|
|
1978
|
+
into?.push(warning);
|
|
1979
|
+
}
|
|
1980
|
+
function warningText(warning) {
|
|
1981
|
+
return [warning.title, ...warning.lines].join("\n");
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1785
1984
|
// src/report/uncommitted.ts
|
|
1786
|
-
function printUncommitted(uncommitted, changedFiles, config, baseRef) {
|
|
1985
|
+
function printUncommitted(uncommitted, changedFiles, config, baseRef, into) {
|
|
1986
|
+
emitWarning(uncommittedWarning(uncommitted, changedFiles, config, baseRef), into);
|
|
1987
|
+
}
|
|
1988
|
+
function uncommittedWarning(uncommitted, changedFiles, config, baseRef) {
|
|
1787
1989
|
const inDiff = new Set(changedFiles.map((file) => file.replace(/\\/g, "/")));
|
|
1788
1990
|
const routes = config.routes ?? {};
|
|
1789
1991
|
const ignore = config.ignore ?? [];
|
|
1790
1992
|
const findings = uncommitted.filter((file) => !inDiff.has(file)).map((file) => ({ file, impact: mapImpact([file], routes, ignore) })).filter(({ impact }) => impact.ignoredFiles.length === 0);
|
|
1791
|
-
if (findings.length === 0) return;
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
warning: ${findings.length} file(s) changed in the working tree are not in the diff against '${baseRef}'
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1993
|
+
if (findings.length === 0) return void 0;
|
|
1994
|
+
return {
|
|
1995
|
+
kind: "uncommitted",
|
|
1996
|
+
title: `warning: ${findings.length} file(s) changed in the working tree are not in the diff against '${baseRef}':`,
|
|
1997
|
+
lines: [
|
|
1998
|
+
...findings.map(
|
|
1999
|
+
({ file, impact }) => impact.affectedRoutes.length > 0 ? ` ${file} -> ${impact.affectedRoutes.join(", ")}` : ` ${file} (matched by no routes: or ignore: glob)`
|
|
2000
|
+
),
|
|
2001
|
+
"Nothing above was considered. Commit or stash them to include them."
|
|
2002
|
+
],
|
|
2003
|
+
spaced: true
|
|
2004
|
+
};
|
|
1802
2005
|
}
|
|
1803
2006
|
|
|
1804
2007
|
// src/llm/brain.ts
|
|
@@ -2724,10 +2927,10 @@ async function embedScreenshot(file) {
|
|
|
2724
2927
|
}
|
|
2725
2928
|
var STYLES = `
|
|
2726
2929
|
:root { color-scheme: light dark; --bg:#fff; --fg:#111; --muted:#666; --line:#e3e3e3;
|
|
2727
|
-
--pass:#137333; --fail:#c5221f; --card:#fafafa; }
|
|
2930
|
+
--pass:#137333; --fail:#c5221f; --warn:#b06000; --card:#fafafa; }
|
|
2728
2931
|
@media (prefers-color-scheme: dark) {
|
|
2729
2932
|
:root { --bg:#15171a; --fg:#e8e8e8; --muted:#9aa0a6; --line:#2c2f34;
|
|
2730
|
-
--pass:#5bb974; --fail:#f28b82; --card:#1c1f23; }
|
|
2933
|
+
--pass:#5bb974; --fail:#f28b82; --warn:#fdd663; --card:#1c1f23; }
|
|
2731
2934
|
}
|
|
2732
2935
|
* { box-sizing: border-box; }
|
|
2733
2936
|
body { margin:0; padding:2rem 1.25rem; background:var(--bg); color:var(--fg);
|
|
@@ -2742,6 +2945,11 @@ h1 { font-size:1.35rem; margin:0 0 .25rem; }
|
|
|
2742
2945
|
.verdict { font-weight:600; }
|
|
2743
2946
|
.verdict.pass { color:var(--pass); } .verdict.fail { color:var(--fail); }
|
|
2744
2947
|
.counts { color:var(--muted); font-size:.9rem; }
|
|
2948
|
+
.warnings { padding:1rem 1.25rem; border:1px solid var(--warn); border-radius:10px;
|
|
2949
|
+
background:color-mix(in srgb, var(--warn) 8%, transparent); margin-bottom:1.5rem; }
|
|
2950
|
+
.warnings h2 { font-size:1rem; margin:0 0 .5rem; color:var(--warn); }
|
|
2951
|
+
.warnings h3 { font-size:.9rem; margin:.75rem 0 .25rem; }
|
|
2952
|
+
.warnings pre { margin:0; white-space:pre-wrap; font-size:.82rem; }
|
|
2745
2953
|
.incomplete { padding:1rem 1.25rem; border:1px solid var(--fail); border-radius:10px;
|
|
2746
2954
|
background:color-mix(in srgb, var(--fail) 10%, transparent); margin-bottom:1.5rem; font-weight:600; }
|
|
2747
2955
|
table { width:100%; border-collapse:collapse; margin-bottom:1.5rem; }
|
|
@@ -2827,6 +3035,13 @@ async function renderHtml(results, skipped, meta) {
|
|
|
2827
3035
|
const banner = meta.incomplete === void 0 ? "" : ` <section class="incomplete">Run stopped: ${escapeHtml(meta.incomplete)}</section>
|
|
2828
3036
|
|
|
2829
3037
|
`;
|
|
3038
|
+
const warnings = meta.warnings ?? [];
|
|
3039
|
+
const warningsSection = warnings.length === 0 ? "" : ` <section class="warnings">
|
|
3040
|
+
<h2>Warnings (${warnings.length})</h2>
|
|
3041
|
+
` + warnings.map(
|
|
3042
|
+
(w) => ` <h3>${escapeHtml(w.title)}</h3>` + (w.lines.length > 0 ? `
|
|
3043
|
+
<pre>${escapeHtml(w.lines.join("\n"))}</pre>` : "")
|
|
3044
|
+
).join("\n") + "\n </section>\n\n";
|
|
2830
3045
|
const rows = results.map((r) => {
|
|
2831
3046
|
const file = meta.cwd ? path8.relative(meta.cwd, r.file) : r.file;
|
|
2832
3047
|
const tagClass = r.status === "failed" ? "fail" : r.status === "not-run" ? "skip" : "pass";
|
|
@@ -2857,7 +3072,7 @@ ${banner} <section class="score">
|
|
|
2857
3072
|
<span class="counts">${passed} passed \xB7 ${failures.length} failed${notRun.length > 0 ? ` \xB7 ${notRun.length} not run` : ""}${skipped.length > 0 ? ` \xB7 ${skipped.length} skipped` : ""}</span>
|
|
2858
3073
|
</section>
|
|
2859
3074
|
|
|
2860
|
-
<table>
|
|
3075
|
+
${warningsSection} <table>
|
|
2861
3076
|
<thead><tr><th>Status</th><th>Priority</th><th>Test</th><th>File</th><th class="num">Time</th></tr></thead>
|
|
2862
3077
|
<tbody>
|
|
2863
3078
|
${rows}${rows && skippedRows ? "\n" : ""}${skippedRows}
|
|
@@ -2902,6 +3117,7 @@ function seconds2(ms) {
|
|
|
2902
3117
|
}
|
|
2903
3118
|
function renderJUnit(results, skipped, meta) {
|
|
2904
3119
|
const relative = (file) => meta.cwd ? path9.relative(meta.cwd, file) : file;
|
|
3120
|
+
const warnings = meta.warnings ?? [];
|
|
2905
3121
|
const failures = results.filter((result) => result.status === "failed").length;
|
|
2906
3122
|
const notRun = results.filter((result) => result.status === "not-run");
|
|
2907
3123
|
const lines = [
|
|
@@ -2921,6 +3137,9 @@ function renderJUnit(results, skipped, meta) {
|
|
|
2921
3137
|
' <property name="incomplete" value="true"/>',
|
|
2922
3138
|
` <property name="incomplete_reason" value="${escapeXml(meta.incomplete)}"/>`
|
|
2923
3139
|
] : [],
|
|
3140
|
+
// Emitted as 0 too (design D2): unlike a token count nobody reported, 0 is
|
|
3141
|
+
// a true claim here, that the run printed no warning.
|
|
3142
|
+
` <property name="warnings" value="${warnings.length}"/>`,
|
|
2924
3143
|
" </properties>"
|
|
2925
3144
|
];
|
|
2926
3145
|
for (const result of results) {
|
|
@@ -2951,6 +3170,9 @@ ${reason}` : reason;
|
|
|
2951
3170
|
" </testcase>"
|
|
2952
3171
|
);
|
|
2953
3172
|
}
|
|
3173
|
+
if (warnings.length > 0) {
|
|
3174
|
+
lines.push(` <system-err>${escapeXml(warnings.map(warningText).join("\n\n"))}</system-err>`);
|
|
3175
|
+
}
|
|
2954
3176
|
lines.push("</testsuite>", "");
|
|
2955
3177
|
return lines.join("\n");
|
|
2956
3178
|
}
|
|
@@ -3172,6 +3394,7 @@ async function runOne(browser, test, config, sessionDir, session, runMask, budge
|
|
|
3172
3394
|
const device = test.device ?? config.browser.device;
|
|
3173
3395
|
const context = await browser.newContext(contextOptions(test.auth ? session : void 0, device));
|
|
3174
3396
|
try {
|
|
3397
|
+
await seedContext(context, test.auth ? session : void 0);
|
|
3175
3398
|
const page = await context.newPage();
|
|
3176
3399
|
page.setDefaultTimeout(config.browser.timeout_ms);
|
|
3177
3400
|
const result = await executeTest(page, resolved, {
|
|
@@ -3191,41 +3414,60 @@ async function runOne(browser, test, config, sessionDir, session, runMask, budge
|
|
|
3191
3414
|
await context.close();
|
|
3192
3415
|
}
|
|
3193
3416
|
}
|
|
3194
|
-
function
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3417
|
+
function count(n, singular, plural) {
|
|
3418
|
+
return `${n} ${n === 1 ? singular : plural}`;
|
|
3419
|
+
}
|
|
3420
|
+
var IGNORED_NAMED = 3;
|
|
3421
|
+
function printImpactReport(impact, selection, changedCount, base, cwd) {
|
|
3422
|
+
const uncovered = new Set(selection.uncoveredRoutes);
|
|
3423
|
+
const unrouted = selection.unroutedSkipped;
|
|
3424
|
+
const gaps = [
|
|
3425
|
+
impact.unmappedFiles.length > 0 && count(impact.unmappedFiles.length, "unclassified file", "unclassified files"),
|
|
3426
|
+
uncovered.size > 0 && count(uncovered.size, "route no selected test covers", "routes no selected test covers"),
|
|
3427
|
+
unrouted.length > 0 && count(unrouted.length, "test with no routes:", "tests with no routes:")
|
|
3428
|
+
].filter((gap) => gap !== false);
|
|
3429
|
+
console.log(`
|
|
3430
|
+
${`--- Impact against ${base} `.padEnd(64, "-")}`);
|
|
3431
|
+
console.log(`Not covered: ${gaps.length > 0 ? gaps.join(" \xB7 ") : "nothing"}`);
|
|
3432
|
+
console.log(`
|
|
3433
|
+
Changed files: ${changedCount}`);
|
|
3434
|
+
const reaching = changedCount - impact.ignoredFiles.length - impact.unmappedFiles.length;
|
|
3435
|
+
if (reaching > 0) console.log(` ${reaching} reach a route`);
|
|
3204
3436
|
if (impact.ignoredFiles.length > 0) {
|
|
3205
|
-
|
|
3437
|
+
const named = impact.ignoredFiles.slice(0, IGNORED_NAMED).join(", ");
|
|
3438
|
+
const more = impact.ignoredFiles.length - IGNORED_NAMED;
|
|
3439
|
+
console.log(` ${impact.ignoredFiles.length} ignored by an ignore: glob: ${named}${more > 0 ? ` and ${more} more` : ""}`);
|
|
3206
3440
|
}
|
|
3207
|
-
if (
|
|
3208
|
-
console.log(
|
|
3209
|
-
for (const
|
|
3210
|
-
|
|
3211
|
-
|
|
3441
|
+
if (impact.unmappedFiles.length > 0) {
|
|
3442
|
+
console.log(` ${impact.unmappedFiles.length} unclassified, matched by no routes: or ignore: glob:`);
|
|
3443
|
+
for (const file of impact.unmappedFiles) console.log(` ${file}`);
|
|
3444
|
+
}
|
|
3445
|
+
console.log(`Routes the diff reaches: ${impact.affectedRoutes.length > 0 ? impact.affectedRoutes.length : "none"}`);
|
|
3446
|
+
for (const route of impact.affectedRoutes) {
|
|
3447
|
+
console.log(` ${route}${uncovered.has(route) ? " (no selected test covers it)" : ""}`);
|
|
3212
3448
|
}
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3449
|
+
console.log(`Tests: ${selection.selected.length} selected`);
|
|
3450
|
+
if (unrouted.length > 0) {
|
|
3451
|
+
console.log(` ${unrouted.length} ${unrouted.length === 1 ? "declares" : "declare"} no routes:, so --impacted cannot select ${unrouted.length === 1 ? "it" : "them"}:`);
|
|
3452
|
+
for (const test of unrouted) console.log(` ${test.summary} (${path10.relative(cwd, test.path)})`);
|
|
3216
3453
|
}
|
|
3217
3454
|
console.log("---------------------------------------------------------------");
|
|
3218
3455
|
}
|
|
3219
|
-
function reportNearMissedSecrets(variables) {
|
|
3456
|
+
function reportNearMissedSecrets(variables, warnings) {
|
|
3220
3457
|
for (const variable of variables) {
|
|
3221
|
-
|
|
3222
|
-
|
|
3458
|
+
emitWarning(
|
|
3459
|
+
{
|
|
3460
|
+
kind: "reformatted-secret",
|
|
3461
|
+
title: `warning: the application returned ${variable} in a different form than the value supplied (case or spacing). It was redacted, but a form this tool cannot recognise \u2014 an encoding, a hash \u2014 would not have been. Check what that page does with the value.`,
|
|
3462
|
+
lines: []
|
|
3463
|
+
},
|
|
3464
|
+
warnings
|
|
3223
3465
|
);
|
|
3224
3466
|
}
|
|
3225
3467
|
}
|
|
3226
|
-
async function finalize(results, skipped, options, sessionDir, secretsHeld, nearMissedSecrets, durationMs, impact, incomplete, spend, firstJudgeLog) {
|
|
3468
|
+
async function finalize(results, skipped, options, sessionDir, secretsHeld, nearMissedSecrets, warnings, durationMs, impact, incomplete, spend, firstJudgeLog) {
|
|
3227
3469
|
if (results.length > 0) printSummary(results);
|
|
3228
|
-
reportNearMissedSecrets(nearMissedSecrets);
|
|
3470
|
+
reportNearMissedSecrets(nearMissedSecrets, warnings);
|
|
3229
3471
|
if (spend) console.log(formatSpendLine(spend));
|
|
3230
3472
|
if (firstJudgeLog) console.log(firstJudgeLog.summaryLine());
|
|
3231
3473
|
const score = scoreOf(results, incomplete !== void 0);
|
|
@@ -3239,7 +3481,8 @@ async function finalize(results, skipped, options, sessionDir, secretsHeld, near
|
|
|
3239
3481
|
durationMs,
|
|
3240
3482
|
cwd: options.cwd,
|
|
3241
3483
|
incomplete: incomplete?.message,
|
|
3242
|
-
spend
|
|
3484
|
+
spend,
|
|
3485
|
+
warnings
|
|
3243
3486
|
});
|
|
3244
3487
|
await writeJUnit(target, xml);
|
|
3245
3488
|
console.log(`JUnit report: ${path10.relative(options.cwd, target)}`);
|
|
@@ -3253,6 +3496,7 @@ async function finalize(results, skipped, options, sessionDir, secretsHeld, near
|
|
|
3253
3496
|
cwd: options.cwd,
|
|
3254
3497
|
incomplete: incomplete?.message,
|
|
3255
3498
|
spend,
|
|
3499
|
+
warnings,
|
|
3256
3500
|
// A screenshot cannot be masked, so a run that held any `{{env.*}}` value
|
|
3257
3501
|
// links to it instead of carrying it (design
|
|
3258
3502
|
// withhold-a-screenshot-that-saw-a-secret, D1): the run's mask, not the
|
|
@@ -3286,29 +3530,36 @@ function declaredConfigRoutes(config) {
|
|
|
3286
3530
|
const routes = config.routes ? Object.values(config.routes) : [];
|
|
3287
3531
|
return [...new Set(routes.flat())].sort();
|
|
3288
3532
|
}
|
|
3289
|
-
function
|
|
3290
|
-
if (drift.drifted.length === 0) return;
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3533
|
+
function routeDriftWarning(drift, cwd) {
|
|
3534
|
+
if (drift.drifted.length === 0) return void 0;
|
|
3535
|
+
return {
|
|
3536
|
+
kind: "route-drift",
|
|
3537
|
+
title: "Route drift (test routes declared by no routes: mapping \u2014 contribute nothing to --impacted selection):",
|
|
3538
|
+
lines: [
|
|
3539
|
+
...drift.drifted.map(({ test, routes }) => ` ${test.summary} (${path10.relative(cwd, test.path)}): ${routes.join(", ")}`),
|
|
3540
|
+
"Fix the route typo, or add the route to a routes: mapping in .blastproof/config.yaml."
|
|
3541
|
+
]
|
|
3542
|
+
};
|
|
3298
3543
|
}
|
|
3299
|
-
function
|
|
3300
|
-
if (result.findings.length === 0) return;
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3544
|
+
function authoringWarning(result, cwd) {
|
|
3545
|
+
if (result.findings.length === 0) return void 0;
|
|
3546
|
+
return {
|
|
3547
|
+
kind: "authoring",
|
|
3548
|
+
title: "Authoring (a step enters a value but names none):",
|
|
3549
|
+
lines: [
|
|
3550
|
+
...result.findings.flatMap(({ test, origin, index, step }) => {
|
|
3551
|
+
const where = origin === "setup" ? `setup step ${index}` : `step ${index}`;
|
|
3552
|
+
return [
|
|
3553
|
+
` ${test.summary} (${path10.relative(cwd, test.path)}) ${where}:`,
|
|
3554
|
+
` ${step}`,
|
|
3555
|
+
` \u2192 ${suggestValueClause(step)}`
|
|
3556
|
+
];
|
|
3557
|
+
}),
|
|
3558
|
+
"The runner is forbidden from inventing values and enforces it: one it cannot trace to the step, the page or an {{env.*}} placeholder is refused, so a step supplying none fails at run time. Naming the value here is what makes it run.",
|
|
3559
|
+
"Steps are inspected in English only; steps in other languages are not checked."
|
|
3560
|
+
],
|
|
3561
|
+
spaced: true
|
|
3562
|
+
};
|
|
3312
3563
|
}
|
|
3313
3564
|
function printDryRun(selected, config, cwd) {
|
|
3314
3565
|
console.log(`
|
|
@@ -3344,6 +3595,7 @@ async function runCommand(options) {
|
|
|
3344
3595
|
}
|
|
3345
3596
|
throw error;
|
|
3346
3597
|
}
|
|
3598
|
+
const warnings = [];
|
|
3347
3599
|
const impacted = options.impacted ?? false;
|
|
3348
3600
|
const base = options.base ?? "main";
|
|
3349
3601
|
if (options.failOnUnmapped && !impacted) {
|
|
@@ -3353,6 +3605,7 @@ async function runCommand(options) {
|
|
|
3353
3605
|
return EXIT_USAGE;
|
|
3354
3606
|
}
|
|
3355
3607
|
let impact;
|
|
3608
|
+
let changedCount = 0;
|
|
3356
3609
|
if (impacted) {
|
|
3357
3610
|
let changedFiles;
|
|
3358
3611
|
try {
|
|
@@ -3365,7 +3618,8 @@ async function runCommand(options) {
|
|
|
3365
3618
|
throw error;
|
|
3366
3619
|
}
|
|
3367
3620
|
impact = mapImpact(changedFiles, config.routes ?? {}, config.ignore ?? []);
|
|
3368
|
-
|
|
3621
|
+
changedCount = changedFiles.length;
|
|
3622
|
+
printUncommitted(await getUncommittedFiles(options.cwd), changedFiles, config, base, warnings);
|
|
3369
3623
|
}
|
|
3370
3624
|
const testsDir = path10.join(options.cwd, TESTS_RELATIVE_DIR);
|
|
3371
3625
|
let files;
|
|
@@ -3398,9 +3652,9 @@ async function runCommand(options) {
|
|
|
3398
3652
|
}
|
|
3399
3653
|
}
|
|
3400
3654
|
const drift = detectRouteDrift(parsed, declaredConfigRoutes(config));
|
|
3401
|
-
|
|
3655
|
+
emitWarning(routeDriftWarning(drift, options.cwd), warnings);
|
|
3402
3656
|
const authoring = detectMissingValues(parsed);
|
|
3403
|
-
|
|
3657
|
+
emitWarning(authoringWarning(authoring, options.cwd), warnings);
|
|
3404
3658
|
if (options.failOnAuthoring && authoring.findings.length > 0) {
|
|
3405
3659
|
console.error(
|
|
3406
3660
|
`error: --fail-on-authoring: ${authoring.findings.length} step(s) enter a value but name none.`
|
|
@@ -3414,7 +3668,7 @@ async function runCommand(options) {
|
|
|
3414
3668
|
};
|
|
3415
3669
|
const selected = selection.selected;
|
|
3416
3670
|
if (impact) {
|
|
3417
|
-
printImpactReport(impact, selection, options.cwd);
|
|
3671
|
+
printImpactReport(impact, selection, changedCount, base, options.cwd);
|
|
3418
3672
|
}
|
|
3419
3673
|
if (options.dryRun) {
|
|
3420
3674
|
printDryRun(selected, config, options.cwd);
|
|
@@ -3432,7 +3686,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3432
3686
|
console.log(
|
|
3433
3687
|
impact ? "No impacted tests to run." : "No tests matched the given filters."
|
|
3434
3688
|
);
|
|
3435
|
-
return finalize(results, selection.unroutedSkipped, options, sessionDir, false, [], Date.now() - startedAt, impact);
|
|
3689
|
+
return finalize(results, selection.unroutedSkipped, options, sessionDir, false, [], warnings, Date.now() - startedAt, impact);
|
|
3436
3690
|
}
|
|
3437
3691
|
let decide;
|
|
3438
3692
|
try {
|
|
@@ -3557,6 +3811,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
3557
3811
|
sessionDir,
|
|
3558
3812
|
!runMask.isEmpty(),
|
|
3559
3813
|
runMask.nearMissedVariables(),
|
|
3814
|
+
warnings,
|
|
3560
3815
|
Date.now() - startedAt,
|
|
3561
3816
|
impact,
|
|
3562
3817
|
incomplete,
|
|
@@ -3732,6 +3987,7 @@ async function planCommand(options) {
|
|
|
3732
3987
|
let draft;
|
|
3733
3988
|
const context = await browser.newContext(contextOptions(session, config.browser.device));
|
|
3734
3989
|
try {
|
|
3990
|
+
await seedContext(context, session);
|
|
3735
3991
|
const page = await context.newPage();
|
|
3736
3992
|
page.setDefaultTimeout(config.browser.timeout_ms);
|
|
3737
3993
|
draft = await generateForRoute(page, {
|
|
@@ -3892,7 +4148,7 @@ function parsePositiveNumber(flag) {
|
|
|
3892
4148
|
};
|
|
3893
4149
|
}
|
|
3894
4150
|
var program = new Command();
|
|
3895
|
-
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.
|
|
4151
|
+
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.30.0");
|
|
3896
4152
|
program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
|
|
3897
4153
|
try {
|
|
3898
4154
|
const result = await initProject(process.cwd());
|