Skip to content

Commit 542ed51

Browse files
committed
style(compat-corpus): formatted representative site corpus fixtures
- Normalized representative site JSON arrays and matching release fixture output. - Rewrapped compat corpus script and test formatting without behavior changes.
1 parent a560fa2 commit 542ed51

4 files changed

Lines changed: 50 additions & 128 deletions

File tree

scripts/compat-corpus.mjs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,12 @@ export function releaseGateSeedSemantics(corpus) {
432432
nonBlankMap: site.renderExpectations?.nonBlankMap === true,
433433
coarseIpDnsClassesOnly: site.redaction?.coarseIpDnsClassesOnly === true,
434434
unsupportedSurfaces: [...(site.unsupportedSurfaces || [])].sort(),
435-
expectedDeltas: (Array.isArray(site.expectedDeltas) ? site.expectedDeltas : []).map((row) => ({
436-
surface: row.surface,
437-
classification: row.classification || 'expected-delta',
438-
})),
435+
expectedDeltas: (Array.isArray(site.expectedDeltas) ? site.expectedDeltas : []).map(
436+
(row) => ({
437+
surface: row.surface,
438+
classification: row.classification || 'expected-delta',
439+
}),
440+
),
439441
},
440442
}));
441443
}
@@ -713,7 +715,11 @@ async function observePage(page, spec, events, startedAt, navigationError) {
713715
},
714716
console: events.console,
715717
pageErrors: events.pageErrors,
716-
requestFailures: normalizeRequestFailures(events.requestFailures, events.responses, !navigationError),
718+
requestFailures: normalizeRequestFailures(
719+
events.requestFailures,
720+
events.responses,
721+
!navigationError,
722+
),
717723
responses: events.responses,
718724
selectors: dom.selectors || [],
719725
rendering: {
@@ -1074,7 +1080,6 @@ function failureKey(item) {
10741080
return `${item.resourceType}:${item.urlClass.scheme}:${item.urlClass.hostClass}:${item.failureClass}`;
10751081
}
10761082

1077-
10781083
function normalizeRequestFailures(failures, responses, pageOK) {
10791084
const rows = Array.isArray(failures) ? failures : [];
10801085
if (!pageOK) return rows;
@@ -1085,10 +1090,7 @@ function normalizeRequestFailures(failures, responses, pageOK) {
10851090
if (!hasDocumentResponse) return rows;
10861091
return rows.filter(
10871092
(row) =>
1088-
!(
1089-
row.resourceType === 'document' &&
1090-
/ERR_ABORTED/i.test(String(row.failureClass || ''))
1091-
),
1093+
!(row.resourceType === 'document' && /ERR_ABORTED/i.test(String(row.failureClass || ''))),
10921094
);
10931095
}
10941096
function responseKey(item) {

test/e2e/representative-sites.json

Lines changed: 28 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@
55
"url": "https://naver.com",
66
"profile": "desktop",
77
"primaryFlow": "desktop-homepage",
8-
"readiness": [
9-
"body",
10-
"a[href]"
11-
],
12-
"primarySelectors": [
13-
"body",
14-
"a[href]",
15-
"input[type=search], input[name=query], input[name=q]"
16-
],
8+
"readiness": ["body", "a[href]"],
9+
"primarySelectors": ["body", "a[href]", "input[type=search], input[name=query], input[name=q]"],
1710
"iframeExpectations": {
1811
"adCandidates": true
1912
}
@@ -24,15 +17,8 @@
2417
"url": "https://m.naver.com",
2518
"profile": "mobile",
2619
"primaryFlow": "mobile-homepage",
27-
"readiness": [
28-
"body",
29-
"a[href]"
30-
],
31-
"primarySelectors": [
32-
"body",
33-
"a[href]",
34-
"input[type=search], input[name=query], input[name=q]"
35-
],
20+
"readiness": ["body", "a[href]"],
21+
"primarySelectors": ["body", "a[href]", "input[type=search], input[name=query], input[name=q]"],
3622
"iframeExpectations": {
3723
"adCandidates": true
3824
},
@@ -50,14 +36,8 @@
5036
"url": "https://www.google.com/search?q=zeroproxy",
5137
"profile": "desktop",
5238
"primaryFlow": "search-results",
53-
"readiness": [
54-
"body"
55-
],
56-
"primarySelectors": [
57-
"textarea[name=q], input[name=q]",
58-
"#search, [role=main]",
59-
"a[href]"
60-
],
39+
"readiness": ["body"],
40+
"primarySelectors": ["textarea[name=q], input[name=q]", "#search, [role=main]", "a[href]"],
6141
"expectedDeltas": [
6242
{
6343
"surface": "rendering",
@@ -72,9 +52,7 @@
7252
"url": "https://www.google.com/maps",
7353
"profile": "desktop",
7454
"primaryFlow": "maps-shell",
75-
"readiness": [
76-
"body"
77-
],
55+
"readiness": ["body"],
7856
"primarySelectors": [
7957
"input[aria-label], input[role=combobox], #searchboxinput",
8058
"canvas, [role=application], [aria-label*=Map], [aria-label*=map]"
@@ -96,13 +74,8 @@
9674
"fixture": "embedded-google-maps.html",
9775
"profile": "desktop",
9876
"primaryFlow": "embedded-map-iframe",
99-
"readiness": [
100-
"iframe[data-corpus-google-maps]"
101-
],
102-
"primarySelectors": [
103-
"main",
104-
"iframe[data-corpus-google-maps]"
105-
],
77+
"readiness": ["iframe[data-corpus-google-maps]"],
78+
"primarySelectors": ["main", "iframe[data-corpus-google-maps]"],
10679
"iframeExpectations": {
10780
"nonBlank": true,
10881
"googleMaps": true
@@ -121,29 +94,17 @@
12194
"url": "https://www.wikipedia.org",
12295
"profile": "desktop",
12396
"primaryFlow": "static-homepage",
124-
"readiness": [
125-
"body"
126-
],
127-
"primarySelectors": [
128-
"input[name=search], input[type=search]",
129-
"a[href]",
130-
"main, body"
131-
]
97+
"readiness": ["body"],
98+
"primarySelectors": ["input[name=search], input[type=search]", "a[href]", "main, body"]
13299
},
133100
{
134101
"id": "github",
135102
"site": "github.com",
136103
"url": "https://github.com",
137104
"profile": "desktop",
138105
"primaryFlow": "unauthenticated-homepage",
139-
"readiness": [
140-
"body"
141-
],
142-
"primarySelectors": [
143-
"header, nav",
144-
"a[href]",
145-
"main, [role=main]"
146-
],
106+
"readiness": ["body"],
107+
"primarySelectors": ["header, nav", "a[href]", "main, [role=main]"],
147108
"expectedDeltas": [
148109
{
149110
"surface": "rendering",
@@ -158,44 +119,26 @@
158119
"url": "https://news.ycombinator.com",
159120
"profile": "desktop",
160121
"primaryFlow": "link-list",
161-
"readiness": [
162-
"body"
163-
],
164-
"primarySelectors": [
165-
".athing, .titleline",
166-
"a[href]",
167-
"table"
168-
]
122+
"readiness": ["body"],
123+
"primarySelectors": [".athing, .titleline", "a[href]", "table"]
169124
},
170125
{
171126
"id": "reddit",
172127
"site": "reddit.com",
173128
"url": "https://www.reddit.com",
174129
"profile": "desktop",
175130
"primaryFlow": "app-shell-feed",
176-
"readiness": [
177-
"body"
178-
],
179-
"primarySelectors": [
180-
"body",
181-
"a[href]",
182-
"shreddit-app, [role=main], main"
183-
]
131+
"readiness": ["body"],
132+
"primarySelectors": ["body", "a[href]", "shreddit-app, [role=main], main"]
184133
},
185134
{
186135
"id": "x-com",
187136
"site": "x.com",
188137
"url": "https://x.com",
189138
"profile": "desktop",
190139
"primaryFlow": "unauthenticated-landing",
191-
"readiness": [
192-
"body"
193-
],
194-
"primarySelectors": [
195-
"body",
196-
"a[href], [role=button]",
197-
"main, [role=main]"
198-
],
140+
"readiness": ["body"],
141+
"primarySelectors": ["body", "a[href], [role=button]", "main, [role=main]"],
199142
"expectedDeltas": [
200143
{
201144
"surface": "rendering",
@@ -210,14 +153,8 @@
210153
"url": "https://www.amazon.com",
211154
"profile": "desktop",
212155
"primaryFlow": "commerce-homepage",
213-
"readiness": [
214-
"body"
215-
],
216-
"primarySelectors": [
217-
"input[type=search], input[name=field-keywords]",
218-
"a[href]",
219-
"img"
220-
],
156+
"readiness": ["body"],
157+
"primarySelectors": ["input[type=search], input[name=field-keywords]", "a[href]", "img"],
221158
"expectedDeltas": [
222159
{
223160
"surface": "rendering",
@@ -232,14 +169,8 @@
232169
"url": "https://www.nytimes.com",
233170
"profile": "desktop",
234171
"primaryFlow": "news-homepage",
235-
"readiness": [
236-
"body"
237-
],
238-
"primarySelectors": [
239-
"main, [role=main]",
240-
"a[href]",
241-
"img, picture"
242-
],
172+
"readiness": ["body"],
173+
"primarySelectors": ["main, [role=main]", "a[href]", "img, picture"],
243174
"expectedDeltas": [
244175
{
245176
"surface": "script-runtime",
@@ -254,14 +185,8 @@
254185
"url": "https://www.cloudflare.com",
255186
"profile": "desktop",
256187
"primaryFlow": "security-baseline-homepage",
257-
"readiness": [
258-
"body"
259-
],
260-
"primarySelectors": [
261-
"main, [role=main]",
262-
"nav, header",
263-
"a[href]"
264-
],
188+
"readiness": ["body"],
189+
"primarySelectors": ["main, [role=main]", "nav, header", "a[href]"],
265190
"expectedDeltas": [
266191
{
267192
"surface": "navigation",
@@ -276,20 +201,11 @@
276201
"url": "https://ipleak.net",
277202
"profile": "desktop",
278203
"primaryFlow": "leak-test-surface",
279-
"readiness": [
280-
"body"
281-
],
282-
"primarySelectors": [
283-
"body",
284-
"#content, main, table",
285-
"iframe, section, div"
286-
],
204+
"readiness": ["body"],
205+
"primarySelectors": ["body", "#content, main, table", "iframe, section, div"],
287206
"redaction": {
288207
"coarseIpDnsClassesOnly": true
289208
},
290-
"unsupportedSurfaces": [
291-
"webrtc",
292-
"webtransport"
293-
]
209+
"unsupportedSurfaces": ["webrtc", "webtransport"]
294210
}
295211
]

test/e2e/representative-sites.release.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,7 @@
286286
"googleMapsFrame": false,
287287
"nonBlankMap": false,
288288
"coarseIpDnsClassesOnly": true,
289-
"unsupportedSurfaces": [
290-
"webrtc",
291-
"webtransport"
292-
],
289+
"unsupportedSurfaces": ["webrtc", "webtransport"],
293290
"expectedDeltas": []
294291
}
295292
}

test/js/compat-corpus.test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ test('representative release gate excludes expected corpus deltas from triage co
307307
{
308308
...native,
309309
selectors: [{ selector: 'main', count: 0, visible: false }],
310-
rendering: { ...native.rendering, visibleTextLength: 10, screenshot: { sha256: 'b', byteBucket: '<64KiB' } },
310+
rendering: {
311+
...native.rendering,
312+
visibleTextLength: 10,
313+
screenshot: { sha256: 'b', byteBucket: '<64KiB' },
314+
},
311315
pageErrors: [{ name: 'SyntaxError' }],
312316
},
313317
{
@@ -323,7 +327,10 @@ test('representative release gate excludes expected corpus deltas from triage co
323327
],
324328
},
325329
);
326-
const gate = buildReleaseGateReport([{ id: 'expected-site' }], [{ site: 'expected-site', comparison: expected }]);
330+
const gate = buildReleaseGateReport(
331+
[{ id: 'expected-site' }],
332+
[{ site: 'expected-site', comparison: expected }],
333+
);
327334
assert.equal(gate.status, 'pass');
328335
assert.equal(gate.metrics.expectedDeltaSites, 1);
329336
assert.equal(gate.metrics.triageSites, 0);

0 commit comments

Comments
 (0)