@geonosis/walk 2.12.0 → 3.0.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/CHANGELOG.md +8 -0
- package/bin/geonosis-walk.mjs +7 -192
- package/dist/browser.d.ts +124 -0
- package/dist/browser.js +242 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +100 -0
- package/dist/index.d.ts +7 -153
- package/dist/index.js +5 -13
- package/dist/options.d.ts +19 -0
- package/dist/options.js +64 -0
- package/dist/probes/buy-box-above-fold.d.ts +14 -0
- package/dist/probes/buy-box-above-fold.js +54 -0
- package/dist/probes/empty-section.d.ts +16 -0
- package/dist/probes/empty-section.js +29 -0
- package/dist/probes/error-page-status.d.ts +20 -0
- package/dist/probes/error-page-status.js +37 -0
- package/dist/probes/fabricated-claim.d.ts +14 -0
- package/dist/probes/fabricated-claim.js +29 -0
- package/dist/probes/fake-session.d.ts +14 -0
- package/dist/probes/fake-session.js +45 -0
- package/dist/probes/index.d.ts +9 -0
- package/dist/probes/index.js +42 -0
- package/dist/probes/light-on-light.d.ts +15 -0
- package/dist/probes/light-on-light.js +26 -0
- package/dist/probes/link-integrity.d.ts +14 -0
- package/dist/probes/link-integrity.js +69 -0
- package/dist/probes/money-format.d.ts +14 -0
- package/dist/probes/money-format.js +33 -0
- package/dist/probes/ops-leakage.d.ts +13 -0
- package/dist/probes/ops-leakage.js +29 -0
- package/dist/probes/orphan-url.d.ts +13 -0
- package/dist/probes/orphan-url.js +54 -0
- package/dist/probes/placeholder-asset.d.ts +14 -0
- package/dist/probes/placeholder-asset.js +40 -0
- package/dist/probes/stub-only-entity.d.ts +14 -0
- package/dist/probes/stub-only-entity.js +30 -0
- package/dist/probes/thin-page.d.ts +14 -0
- package/dist/probes/thin-page.js +30 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.js +10 -0
- package/dist/walk-cli.js +41 -47
- package/dist/walk.d.ts +23 -0
- package/dist/walk.js +93 -0
- package/package.json +5 -4
- package/dist/chunk-VCGYSFL5.js +0 -956
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/probes/index.ts
|
|
2
|
+
import { buyBoxAboveFold } from "./buy-box-above-fold.js";
|
|
3
|
+
import { emptySection } from "./empty-section.js";
|
|
4
|
+
import { errorPageStatus } from "./error-page-status.js";
|
|
5
|
+
import { fabricatedClaim } from "./fabricated-claim.js";
|
|
6
|
+
import { fakeSession } from "./fake-session.js";
|
|
7
|
+
import { lightOnLight } from "./light-on-light.js";
|
|
8
|
+
import { linkIntegrity } from "./link-integrity.js";
|
|
9
|
+
import { moneyFormat } from "./money-format.js";
|
|
10
|
+
import { opsLeakage } from "./ops-leakage.js";
|
|
11
|
+
import { orphanUrl } from "./orphan-url.js";
|
|
12
|
+
import { placeholderAsset } from "./placeholder-asset.js";
|
|
13
|
+
import { stubOnlyEntity } from "./stub-only-entity.js";
|
|
14
|
+
import { thinPage } from "./thin-page.js";
|
|
15
|
+
var PROBES = [
|
|
16
|
+
buyBoxAboveFold,
|
|
17
|
+
emptySection,
|
|
18
|
+
errorPageStatus,
|
|
19
|
+
fabricatedClaim,
|
|
20
|
+
fakeSession,
|
|
21
|
+
lightOnLight,
|
|
22
|
+
linkIntegrity,
|
|
23
|
+
moneyFormat,
|
|
24
|
+
opsLeakage,
|
|
25
|
+
orphanUrl,
|
|
26
|
+
placeholderAsset,
|
|
27
|
+
stubOnlyEntity,
|
|
28
|
+
thinPage
|
|
29
|
+
];
|
|
30
|
+
var probeById = (id) => {
|
|
31
|
+
const probe = PROBES.find((one) => one.id === id);
|
|
32
|
+
if (probe === undefined) {
|
|
33
|
+
throw new Error(`no probe called "${id}" — known probes: ${PROBES.map((one) => one.id).join(", ")}`);
|
|
34
|
+
}
|
|
35
|
+
return probe;
|
|
36
|
+
};
|
|
37
|
+
var DEFAULT_PROBES = PROBES.filter((one) => one.needs === undefined);
|
|
38
|
+
export {
|
|
39
|
+
DEFAULT_PROBES,
|
|
40
|
+
PROBES,
|
|
41
|
+
probeById
|
|
42
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* An element that declares its own surface, and is invisible on the one behind it.
|
|
4
|
+
*
|
|
5
|
+
* A Medusa storefront's t34 shipped a "cream" chip on a cream page and t22 a skeleton on paper;
|
|
6
|
+
* both passed a screenshot review, because a JPEG of two colours a reader cannot tell apart looks
|
|
7
|
+
* exactly like a JPEG of a surface that is there. The DOM tells the truth, so the probe reads
|
|
8
|
+
* painted backgrounds and computes the WCAG ratio rather than looking at pixels.
|
|
9
|
+
*
|
|
10
|
+
* It only judges an element that is trying to be a distinct surface and is distinguished by nothing
|
|
11
|
+
* else: an opaque background of its own, no background image, no border, no shadow, no outline, and
|
|
12
|
+
* a box that does not simply repaint the one behind it. Every one of those exclusions is a shape a
|
|
13
|
+
* designer used deliberately, and a probe that fired on them would be switched off within a week.
|
|
14
|
+
*/
|
|
15
|
+
export declare const lightOnLight: Probe;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/probes/light-on-light.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { numberOption, stringOption, stringsOption } from "../options.js";
|
|
4
|
+
var lightOnLight = {
|
|
5
|
+
class: "light-on-light",
|
|
6
|
+
id: "light-on-light",
|
|
7
|
+
run: async (page, { options, url }) => {
|
|
8
|
+
const minContrast = numberOption(options, "minContrast", 1.05);
|
|
9
|
+
const hits = await collect(page, {
|
|
10
|
+
ignore: stringsOption(options, "ignore", []),
|
|
11
|
+
kind: "contrast",
|
|
12
|
+
minContrast,
|
|
13
|
+
selector: stringOption("light-on-light", options, "selector", "*")
|
|
14
|
+
});
|
|
15
|
+
return hits.map((hit) => ({
|
|
16
|
+
class: "light-on-light",
|
|
17
|
+
evidence: `${hit.background} on ${hit.container} (${hit.containerSelector}) — contrast ${hit.contrast.toFixed(2)}, floor ${minContrast}`,
|
|
18
|
+
selector: hit.selector,
|
|
19
|
+
severity: "major",
|
|
20
|
+
url
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
lightOnLight
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Controls that go nowhere, and links that go somewhere gone.
|
|
4
|
+
*
|
|
5
|
+
* The dead half is a DOM read: an `href` that is absent, empty, `#` or `javascript:` is a control a
|
|
6
|
+
* buyer will click and nothing will happen — a Medusa storefront shipped a kit default's "Looking
|
|
7
|
+
* for a gift?" pointing at `#` on every category page. The broken half is a request: same-origin
|
|
8
|
+
* links are HEAD-ed (GET when a server answers 405 or 501, which some do), and anything from 400 up
|
|
9
|
+
* is a link that 404s in front of the buyer.
|
|
10
|
+
*
|
|
11
|
+
* Another origin is left alone unless asked for: a gate that fails because someone else's site was
|
|
12
|
+
* down is a gate that gets disabled, and it would make the walk a crawler of the whole internet.
|
|
13
|
+
*/
|
|
14
|
+
export declare const linkIntegrity: Probe;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/probes/link-integrity.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { flagOption, stringOption, stringsOption } from "../options.js";
|
|
4
|
+
var DEAD = ["", "#"];
|
|
5
|
+
var linkIntegrity = {
|
|
6
|
+
class: "link-integrity",
|
|
7
|
+
id: "link-integrity",
|
|
8
|
+
run: async (page, { memo, options, url }) => {
|
|
9
|
+
const dead = stringsOption(options, "deadHrefs", DEAD);
|
|
10
|
+
const ignore = stringsOption(options, "ignore", []);
|
|
11
|
+
const checkExternal = flagOption(options, "checkExternal", false);
|
|
12
|
+
const origin = new URL(url).origin;
|
|
13
|
+
const hits = await collect(page, {
|
|
14
|
+
kind: "links",
|
|
15
|
+
selector: stringOption("link-integrity", options, "selector", 'a,[role="link"]')
|
|
16
|
+
});
|
|
17
|
+
const found = [];
|
|
18
|
+
for (const hit of hits) {
|
|
19
|
+
const href = hit.href;
|
|
20
|
+
if (href === null || dead.includes(href.trim()) || href.trim().startsWith("javascript:")) {
|
|
21
|
+
found.push({
|
|
22
|
+
class: "link-integrity",
|
|
23
|
+
evidence: `dead control: href ${href === null ? "absent" : `"${href}"`} on "${hit.text}"`,
|
|
24
|
+
selector: hit.selector,
|
|
25
|
+
severity: "major",
|
|
26
|
+
url
|
|
27
|
+
});
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const target = hit.resolved;
|
|
31
|
+
if (!target.startsWith("http"))
|
|
32
|
+
continue;
|
|
33
|
+
if (ignore.some((pattern) => new RegExp(pattern).test(target)))
|
|
34
|
+
continue;
|
|
35
|
+
if (!checkExternal && new URL(target).origin !== origin)
|
|
36
|
+
continue;
|
|
37
|
+
const status = await statusOf(page, memo, target);
|
|
38
|
+
if (status < 400)
|
|
39
|
+
continue;
|
|
40
|
+
found.push({
|
|
41
|
+
class: "link-integrity",
|
|
42
|
+
evidence: `${target} answered ${status}`,
|
|
43
|
+
selector: hit.selector,
|
|
44
|
+
severity: "blocking",
|
|
45
|
+
url
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var statusOf = async (page, memo, target) => {
|
|
52
|
+
const key = `link-integrity:${target}`;
|
|
53
|
+
const seen = memo.get(key);
|
|
54
|
+
if (typeof seen === "number")
|
|
55
|
+
return seen;
|
|
56
|
+
let status;
|
|
57
|
+
try {
|
|
58
|
+
const head = await page.request.head(target, { failOnStatusCode: false });
|
|
59
|
+
status = head.status() === 405 || head.status() === 501 ? (await page.request.get(target, { failOnStatusCode: false })).status() : head.status();
|
|
60
|
+
} catch (error) {
|
|
61
|
+
status = 599;
|
|
62
|
+
memo.set(`${key}:why`, error.message);
|
|
63
|
+
}
|
|
64
|
+
memo.set(key, status);
|
|
65
|
+
return status;
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
linkIntegrity
|
|
69
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A price on the page in a shape this repo does not write.
|
|
4
|
+
*
|
|
5
|
+
* `£24` beside `£24.00` is not a rendering bug and not a broken page; it is two answers to "what
|
|
6
|
+
* does a price look like here", and the one a reader meets is whichever component happened to
|
|
7
|
+
* format it. A currency that lost its minor units, a thousands separator that appears on one page
|
|
8
|
+
* and not the next, a bare number where every other price carries a symbol.
|
|
9
|
+
*
|
|
10
|
+
* `accept` is REQUIRED (D-031): what a correct price looks like is a fact about a business, never
|
|
11
|
+
* about a kit, and a probe that ran with no accepted shape would report a clean page for every repo
|
|
12
|
+
* that had not configured it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const moneyFormat: Probe;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/probes/money-format.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
|
|
4
|
+
var AMOUNT = String.raw`\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{1,2})?`;
|
|
5
|
+
var MONEY = String.raw`[€$£¥₺]\s?${AMOUNT}|${AMOUNT}\s?(?:USD|EUR|GBP|TRY|JPY)\b`;
|
|
6
|
+
var moneyFormat = {
|
|
7
|
+
class: "content-integrity",
|
|
8
|
+
id: "money-format",
|
|
9
|
+
needs: (options) => {
|
|
10
|
+
const accept = requireStrings("money-format", options, "accept");
|
|
11
|
+
assertPatterns("money-format", accept, patternFlags("money-format", options));
|
|
12
|
+
},
|
|
13
|
+
run: async (page, { options, url }) => {
|
|
14
|
+
const flags = patternFlags("money-format", options);
|
|
15
|
+
const accept = requireStrings("money-format", options, "accept").map((pattern) => new RegExp(`^(?:${pattern})$`, flags));
|
|
16
|
+
const hits = await collect(page, {
|
|
17
|
+
flags,
|
|
18
|
+
kind: "matches",
|
|
19
|
+
patterns: [stringOption("money-format", options, "find", MONEY)],
|
|
20
|
+
scope: stringOption("money-format", options, "scope", "")
|
|
21
|
+
});
|
|
22
|
+
return hits.filter((hit) => !accept.some((one) => one.test(hit.text.trim()))).map((hit) => ({
|
|
23
|
+
class: "content-integrity",
|
|
24
|
+
evidence: `"${hit.text}" is money in a shape this repo does not accept`,
|
|
25
|
+
selector: hit.selector,
|
|
26
|
+
severity: "major",
|
|
27
|
+
url
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
moneyFormat
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The operations side, showing through into what a customer is offered.
|
|
4
|
+
*
|
|
5
|
+
* A Medusa storefront's checkout offered a US buyer of 5,000 mailer boxes four ocean-freight options — the
|
|
6
|
+
* INBOUND freight the logistics side books, registered in the same seed as store-visible shipping.
|
|
7
|
+
* The words that mean "internal" are a repo's own vocabulary, so `patterns` is required (D-031).
|
|
8
|
+
*
|
|
9
|
+
* `scope` is what separates this from a page-wide word hunt: the same words in a footnote about how
|
|
10
|
+
* the company sources board are not a leak. The probe's own fixture pair is exactly that — the same
|
|
11
|
+
* two phrases inside the delivery fieldset and outside it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const opsLeakage: Probe;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/probes/ops-leakage.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
|
|
4
|
+
var opsLeakage = {
|
|
5
|
+
class: "ops-leakage",
|
|
6
|
+
id: "ops-leakage",
|
|
7
|
+
needs: (options) => {
|
|
8
|
+
const patterns = requireStrings("ops-leakage", options, "patterns");
|
|
9
|
+
assertPatterns("ops-leakage", patterns, patternFlags("ops-leakage", options));
|
|
10
|
+
},
|
|
11
|
+
run: async (page, { options, url }) => {
|
|
12
|
+
const hits = await collect(page, {
|
|
13
|
+
flags: patternFlags("ops-leakage", options),
|
|
14
|
+
kind: "text",
|
|
15
|
+
patterns: requireStrings("ops-leakage", options, "patterns"),
|
|
16
|
+
scope: stringOption("ops-leakage", options, "scope", "")
|
|
17
|
+
});
|
|
18
|
+
return hits.map((hit) => ({
|
|
19
|
+
class: "ops-leakage",
|
|
20
|
+
evidence: `"${hit.text}" is offered to the customer, matching /${hit.pattern}/`,
|
|
21
|
+
selector: hit.selector,
|
|
22
|
+
severity: "blocking",
|
|
23
|
+
url
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
opsLeakage
|
|
29
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A page the walk was told about that nothing on the walk links to.
|
|
4
|
+
*
|
|
5
|
+
* It answers 200, it renders, every per-page probe passes it — and the only way a reader reaches it
|
|
6
|
+
* is by being handed the URL. That is not a fact any one page can know, which is why this is the
|
|
7
|
+
* probe with a report-level half: `run` records what each page links to, and `finish` names the
|
|
8
|
+
* walked URLs nothing pointed at.
|
|
9
|
+
*
|
|
10
|
+
* A page that is deliberately unlinked — a campaign landing page, a print view — goes in `entry`,
|
|
11
|
+
* which is the repo's list and empty by default.
|
|
12
|
+
*/
|
|
13
|
+
export declare const orphanUrl: Probe;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/probes/orphan-url.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { stringOption, stringsOption } from "../options.js";
|
|
4
|
+
var MEMO = "orphan-url:linked";
|
|
5
|
+
var linkedIn = (memo) => {
|
|
6
|
+
const seen = memo.get(MEMO);
|
|
7
|
+
if (seen instanceof Set)
|
|
8
|
+
return seen;
|
|
9
|
+
const fresh = new Set;
|
|
10
|
+
memo.set(MEMO, fresh);
|
|
11
|
+
return fresh;
|
|
12
|
+
};
|
|
13
|
+
var bare = (url) => {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = new URL(url);
|
|
16
|
+
return `${parsed.origin}${parsed.pathname.replace(/\/index\.html?$/, "/")}`;
|
|
17
|
+
} catch {
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var orphanUrl = {
|
|
22
|
+
class: "content-integrity",
|
|
23
|
+
finish: ({ memo, options, urls }) => {
|
|
24
|
+
if (urls.length < 2)
|
|
25
|
+
return [];
|
|
26
|
+
const linked = linkedIn(memo);
|
|
27
|
+
const entry = stringsOption(options, "entry", []).map(bare);
|
|
28
|
+
return urls.filter((url) => !linked.has(bare(url)) && !entry.includes(bare(url))).map((url) => ({
|
|
29
|
+
class: "content-integrity",
|
|
30
|
+
evidence: `no page in this walk links to ${bare(url)} — it is reachable only by being handed the URL`,
|
|
31
|
+
severity: "major",
|
|
32
|
+
url
|
|
33
|
+
}));
|
|
34
|
+
},
|
|
35
|
+
id: "orphan-url",
|
|
36
|
+
run: async (page, { memo, options, url }) => {
|
|
37
|
+
const linked = linkedIn(memo);
|
|
38
|
+
const here = bare(url);
|
|
39
|
+
for (const hit of await collect(page, {
|
|
40
|
+
kind: "links",
|
|
41
|
+
selector: stringOption("orphan-url", options, "selector", 'a,[role="link"]')
|
|
42
|
+
})) {
|
|
43
|
+
if (hit.resolved === "")
|
|
44
|
+
continue;
|
|
45
|
+
const target = bare(hit.resolved);
|
|
46
|
+
if (target !== here)
|
|
47
|
+
linked.add(target);
|
|
48
|
+
}
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
orphanUrl
|
|
54
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* One mark in many slots, and marks whose own name says they are stand-ins.
|
|
4
|
+
*
|
|
5
|
+
* A Medusa storefront shipped ONE green-square SVG for thirteen content-icon keys and one stacked-shippers
|
|
6
|
+
* photo for four of six category tiles. A screenshot showed thirteen shapes; the DOM showed one
|
|
7
|
+
* repeated, which is what `new Set(signatures).size` is for. A signature is the resolved `src` of
|
|
8
|
+
* an image or the geometry of an SVG's own shapes, so two files that draw the same thing under
|
|
9
|
+
* different names still read as different marks, and one file under two names reads as one.
|
|
10
|
+
*
|
|
11
|
+
* `signatures` is the second half: patterns matched against the signature AND the element's
|
|
12
|
+
* alt/aria-label/title, because the audit's own placeholder said "placeholder" in its label.
|
|
13
|
+
*/
|
|
14
|
+
export declare const placeholderAsset: Probe;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/probes/placeholder-asset.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { assertPatterns, numberOption, patternFlags, stringOption, stringsOption } from "../options.js";
|
|
4
|
+
var placeholderAsset = {
|
|
5
|
+
class: "placeholder-asset",
|
|
6
|
+
id: "placeholder-asset",
|
|
7
|
+
run: async (page, { options, url }) => {
|
|
8
|
+
const maxRepeats = numberOption(options, "maxRepeats", 2);
|
|
9
|
+
const signatures = stringsOption(options, "signatures", []);
|
|
10
|
+
const flags = patternFlags("placeholder-asset", options);
|
|
11
|
+
assertPatterns("placeholder-asset", signatures, flags);
|
|
12
|
+
const hits = await collect(page, {
|
|
13
|
+
assetSelector: stringOption("placeholder-asset", options, "assets", "img,svg"),
|
|
14
|
+
kind: "assets",
|
|
15
|
+
scope: stringOption("placeholder-asset", options, "scope", "body")
|
|
16
|
+
});
|
|
17
|
+
const named = hits.filter((hit) => signatures.some((pattern) => new RegExp(pattern, flags).test(`${hit.signature} ${hit.label}`))).map((hit) => ({
|
|
18
|
+
class: "placeholder-asset",
|
|
19
|
+
evidence: `asset matches a placeholder signature: ${hit.signature.slice(0, 120)}`,
|
|
20
|
+
selector: hit.selector,
|
|
21
|
+
severity: "major",
|
|
22
|
+
url
|
|
23
|
+
}));
|
|
24
|
+
const bySignature = new Map;
|
|
25
|
+
for (const hit of hits) {
|
|
26
|
+
bySignature.set(hit.signature, [...bySignature.get(hit.signature) ?? [], hit.selector]);
|
|
27
|
+
}
|
|
28
|
+
const repeated = [...bySignature.entries()].filter(([, selectors]) => selectors.length > maxRepeats).map(([signature, selectors]) => ({
|
|
29
|
+
class: "placeholder-asset",
|
|
30
|
+
evidence: `the same asset in ${selectors.length} slots, more than the ${maxRepeats} allowed — ${signature.slice(0, 120)}`,
|
|
31
|
+
selector: selectors[0],
|
|
32
|
+
severity: "major",
|
|
33
|
+
url
|
|
34
|
+
}));
|
|
35
|
+
return [...named, ...repeated];
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
placeholderAsset
|
|
40
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A page that offers to sell something the backend does not have.
|
|
4
|
+
*
|
|
5
|
+
* A Medusa storefront rendered full product pages with an Add to cart for three handles that were
|
|
6
|
+
* in no live store: a buyer could configure `standard-mailer-box` and never place an order for it.
|
|
7
|
+
* The page cannot know this on its own, so the authoritative set is required (D-031) — it comes
|
|
8
|
+
* from the store's own API, the seed, or wherever the repo's truth actually lives.
|
|
9
|
+
*
|
|
10
|
+
* The affordance matters as much as the id: a retired handle that renders an explainer and no way
|
|
11
|
+
* to buy is the FIX (a redirect stub), not the bug, and a probe that could not tell them apart
|
|
12
|
+
* would fire on every correct retirement.
|
|
13
|
+
*/
|
|
14
|
+
export declare const stubOnlyEntity: Probe;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/probes/stub-only-entity.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { requireStrings, stringOption } from "../options.js";
|
|
4
|
+
var stubOnlyEntity = {
|
|
5
|
+
class: "stub-only-entity",
|
|
6
|
+
id: "stub-only-entity",
|
|
7
|
+
needs: (options) => {
|
|
8
|
+
requireStrings("stub-only-entity", options, "known");
|
|
9
|
+
},
|
|
10
|
+
run: async (page, { options, url }) => {
|
|
11
|
+
const known = new Set(requireStrings("stub-only-entity", options, "known"));
|
|
12
|
+
const attribute = stringOption("stub-only-entity", options, "attribute", "data-entity-id");
|
|
13
|
+
const hits = await collect(page, {
|
|
14
|
+
affordance: stringOption("stub-only-entity", options, "affordance", ""),
|
|
15
|
+
attribute,
|
|
16
|
+
kind: "entities",
|
|
17
|
+
selector: stringOption("stub-only-entity", options, "selector", `[${attribute}]`)
|
|
18
|
+
});
|
|
19
|
+
return hits.filter((hit) => hit.id !== "" && hit.affordance && !known.has(hit.id)).map((hit) => ({
|
|
20
|
+
class: "stub-only-entity",
|
|
21
|
+
evidence: `"${hit.id}" can be bought here and is in no authoritative set of ${known.size} entities`,
|
|
22
|
+
selector: hit.selector,
|
|
23
|
+
severity: "blocking",
|
|
24
|
+
url
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
stubOnlyEntity
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Probe } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A page that renders correctly and says almost nothing.
|
|
4
|
+
*
|
|
5
|
+
* The page is not broken: it has a heading, a layout, a 200. It has three sentences where a reader
|
|
6
|
+
* came for an answer, and every gate in the stack reads it as fine — a screenshot looks like a
|
|
7
|
+
* page, a link check passes, a status check passes. Only counting the words a reader is actually
|
|
8
|
+
* shown says otherwise.
|
|
9
|
+
*
|
|
10
|
+
* `minWords` is REQUIRED (D-031), because how much a page owes a reader is a property of what the
|
|
11
|
+
* page is for — a checkout step owes almost nothing, a guide owes a lot — and a floor the kit
|
|
12
|
+
* picked would be somebody else's idea of thin applied to every repo that never chose one.
|
|
13
|
+
*/
|
|
14
|
+
export declare const thinPage: Probe;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/probes/thin-page.ts
|
|
2
|
+
import { collect } from "../browser.js";
|
|
3
|
+
import { requireNumber, stringOption } from "../options.js";
|
|
4
|
+
var thinPage = {
|
|
5
|
+
class: "content-integrity",
|
|
6
|
+
id: "thin-page",
|
|
7
|
+
needs: (options) => {
|
|
8
|
+
requireNumber("thin-page", options, "minWords");
|
|
9
|
+
},
|
|
10
|
+
run: async (page, { options, url }) => {
|
|
11
|
+
const minWords = requireNumber("thin-page", options, "minWords");
|
|
12
|
+
const scope = stringOption("thin-page", options, "scope", "body");
|
|
13
|
+
const hits = await collect(page, {
|
|
14
|
+
headingSelector: stringOption("thin-page", options, "headingSelector", "h1,h2,h3,h4,h5,h6"),
|
|
15
|
+
kind: "prose",
|
|
16
|
+
mediaSelector: stringOption("thin-page", options, "mediaSelector", "img,svg,video,iframe,canvas"),
|
|
17
|
+
selector: scope
|
|
18
|
+
});
|
|
19
|
+
return hits.filter((hit) => hit.words < minWords).map((hit) => ({
|
|
20
|
+
class: "content-integrity",
|
|
21
|
+
evidence: `${scope} renders ${hit.words} word(s), ${hit.headingWords} of them headings — the floor is ${minWords}`,
|
|
22
|
+
...hit.selector === "" ? {} : { selector: hit.selector },
|
|
23
|
+
severity: "major",
|
|
24
|
+
url
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
thinPage
|
|
30
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Page } from 'playwright';
|
|
2
|
+
/**
|
|
3
|
+
* The ten defect classes the walk is mechanical about.
|
|
4
|
+
*
|
|
5
|
+
* Six are a storefront CX audit's own groups, generalised; `light-on-light` is that audit's
|
|
6
|
+
* browser-proof probe (a cream chip on a cream page reads as broken, and the screenshot says it is
|
|
7
|
+
* fine), `buy-box-above-fold` is one of its groups promoted to a class, and `error-page-status`
|
|
8
|
+
* came from an error surface served with a 200, which every health check read as healthy.
|
|
9
|
+
* `content-integrity` is the tenth: a page that renders correctly and says nothing — a section with
|
|
10
|
+
* a heading and no body, a price in a shape the repo does not write, a page nothing links to. Four
|
|
11
|
+
* of an audit's own defects were filed under `fabricated-claim`'s forbidden-string engine for want
|
|
12
|
+
* of it, which is a class borrowing another class's mechanism. What the ten do NOT cover — a number that disagrees with a number on another page, copy
|
|
13
|
+
* that promises a control nobody built, four levels of taxonomy for fourteen products — is in
|
|
14
|
+
* `docs/walk-review-inventory-2026-08-30.md`, and stays the walker's judgement. A green walk report
|
|
15
|
+
* is not a clean surface.
|
|
16
|
+
*/
|
|
17
|
+
export type DefectClass = 'buy-box-above-fold' | 'content-integrity' | 'error-page-status' | 'fabricated-claim' | 'fake-session' | 'light-on-light' | 'link-integrity' | 'ops-leakage' | 'placeholder-asset' | 'stub-only-entity';
|
|
18
|
+
/** `blocking` breaks trust or the buy path; `major` confuses the buyer; `minor` is polish. */
|
|
19
|
+
export type Severity = 'blocking' | 'major' | 'minor';
|
|
20
|
+
/**
|
|
21
|
+
* One defect, as the build plan's contract states it. `evidence` is the measured value — the two
|
|
22
|
+
* colours and the ratio, the status code, the matched text — never a restatement of the class,
|
|
23
|
+
* because the reader's next question is always "what did you actually see".
|
|
24
|
+
*/
|
|
25
|
+
export type Finding = {
|
|
26
|
+
class: DefectClass;
|
|
27
|
+
evidence: string;
|
|
28
|
+
selector?: string;
|
|
29
|
+
severity: Severity;
|
|
30
|
+
url: string;
|
|
31
|
+
};
|
|
32
|
+
export type Viewport = {
|
|
33
|
+
height: number;
|
|
34
|
+
width: number;
|
|
35
|
+
};
|
|
36
|
+
export type ProbeContext = {
|
|
37
|
+
/**
|
|
38
|
+
* One walk, one memo. `link-integrity` would otherwise send a HEAD request for the same footer
|
|
39
|
+
* link once per page, which is forty requests for one answer on a forty-page walk.
|
|
40
|
+
*/
|
|
41
|
+
memo: Map<string, unknown>;
|
|
42
|
+
/** This probe's own block of the `options` map, already narrowed by id. */
|
|
43
|
+
options: Record<string, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* The status the page's OWN response carried. Read from `page.goto`, because nothing on a loaded
|
|
46
|
+
* page remembers it and a second request for it would ask a different question of a server that
|
|
47
|
+
* may not answer twice the same way.
|
|
48
|
+
*/
|
|
49
|
+
status: number;
|
|
50
|
+
url: string;
|
|
51
|
+
viewport: Viewport;
|
|
52
|
+
};
|
|
53
|
+
export type Probe = {
|
|
54
|
+
class: DefectClass;
|
|
55
|
+
id: string;
|
|
56
|
+
/**
|
|
57
|
+
* D-031, per probe: a probe that cannot mean anything without an option refuses the run when it
|
|
58
|
+
* is missing, naming the option. Five of the eight have one — a claim list, an authoritative id
|
|
59
|
+
* set, what "signed in" looks like, the operations patterns, the buy-box selector — because none
|
|
60
|
+
* of those five can have a default that is true of a repo that has not configured it. A probe
|
|
61
|
+
* that ran and reported nothing because nobody told it what to look for is indistinguishable
|
|
62
|
+
* from a clean page.
|
|
63
|
+
*/
|
|
64
|
+
needs?: (options: Record<string, unknown>) => void;
|
|
65
|
+
run: (page: Page, context: ProbeContext) => Promise<Finding[]>;
|
|
66
|
+
/**
|
|
67
|
+
* The reading no single page can make. `orphan-url` is the reason it exists: whether anything
|
|
68
|
+
* links to a page is a fact about the whole walk, and a probe handed one page at a time can only
|
|
69
|
+
* record what it saw. Called once, after every page, with the pages walked; each finding is filed
|
|
70
|
+
* against the page whose `url` it names.
|
|
71
|
+
*/
|
|
72
|
+
finish?: (context: FinishContext) => Finding[];
|
|
73
|
+
};
|
|
74
|
+
/** What a probe knows once the walk is over: its own memo, its options, and where it went. */
|
|
75
|
+
export type FinishContext = {
|
|
76
|
+
memo: Map<string, unknown>;
|
|
77
|
+
options: Record<string, unknown>;
|
|
78
|
+
urls: string[];
|
|
79
|
+
};
|
|
80
|
+
export type PageReport = {
|
|
81
|
+
findings: Finding[];
|
|
82
|
+
url: string;
|
|
83
|
+
};
|
|
84
|
+
export type WalkReport = {
|
|
85
|
+
/**
|
|
86
|
+
* Keyed by the classes that RAN. A zero therefore means "probed for, none found"; a class that is
|
|
87
|
+
* absent was never looked for. All eight keys with five zeros would read as five clean gates
|
|
88
|
+
* nobody enabled.
|
|
89
|
+
*/
|
|
90
|
+
counts: Partial<Record<DefectClass, number>>;
|
|
91
|
+
finishedAt: string;
|
|
92
|
+
pages: PageReport[];
|
|
93
|
+
probes: string[];
|
|
94
|
+
startedAt: string;
|
|
95
|
+
viewport: Viewport;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The walk could not run: no browser, no URL, a page that did not answer, a probe with no option it
|
|
99
|
+
* needs. Distinct from "the walk ran and found nothing", which is a report with zeros in it — the
|
|
100
|
+
* CLI turns this into exit 2 and that into exit 0.
|
|
101
|
+
*/
|
|
102
|
+
export declare class WalkError extends Error {
|
|
103
|
+
constructor(message: string);
|
|
104
|
+
}
|