@decocms/parity 0.33.58 → 0.33.59
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/dist/cli.js +65 -26
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -39022,6 +39022,21 @@ var DISABLE_ANIMATIONS_CSS = `
|
|
|
39022
39022
|
scroll-behavior: auto !important;
|
|
39023
39023
|
}
|
|
39024
39024
|
`;
|
|
39025
|
+
function injectStyleScript(css) {
|
|
39026
|
+
return `
|
|
39027
|
+
(function () {
|
|
39028
|
+
var apply = function () {
|
|
39029
|
+
var style = document.createElement('style');
|
|
39030
|
+
style.textContent = ${JSON.stringify(css)};
|
|
39031
|
+
document.documentElement.appendChild(style);
|
|
39032
|
+
};
|
|
39033
|
+
if (document.documentElement) return apply();
|
|
39034
|
+
new MutationObserver(function (_, o) {
|
|
39035
|
+
if (document.documentElement) { o.disconnect(); apply(); }
|
|
39036
|
+
}).observe(document, { childList: true });
|
|
39037
|
+
})();
|
|
39038
|
+
`;
|
|
39039
|
+
}
|
|
39025
39040
|
var USER_AGENT_BY_VIEWPORT = {
|
|
39026
39041
|
mobile: "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36",
|
|
39027
39042
|
tablet: "Mozilla/5.0 (iPad; CPU OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1",
|
|
@@ -39167,30 +39182,11 @@ async function newContext(browser, opts) {
|
|
|
39167
39182
|
return page;
|
|
39168
39183
|
};
|
|
39169
39184
|
}
|
|
39170
|
-
|
|
39171
|
-
content:
|
|
39172
|
-
try {
|
|
39173
|
-
const style = document.createElement('style');
|
|
39174
|
-
style.textContent = ${JSON.stringify(DISABLE_ANIMATIONS_CSS)};
|
|
39175
|
-
(document.head || document.documentElement).appendChild(style);
|
|
39176
|
-
} catch (e) {}
|
|
39177
|
-
`
|
|
39178
|
-
});
|
|
39185
|
+
if (!opts.keepMotion)
|
|
39186
|
+
await ctx.addInitScript({ content: injectStyleScript(DISABLE_ANIMATIONS_CSS) });
|
|
39179
39187
|
if (opts.hideScrollbars) {
|
|
39180
39188
|
await ctx.addInitScript({
|
|
39181
|
-
content:
|
|
39182
|
-
(function () {
|
|
39183
|
-
var apply = function () {
|
|
39184
|
-
var style = document.createElement('style');
|
|
39185
|
-
style.textContent = 'html, body, * { scrollbar-width: none !important; } ::-webkit-scrollbar { display: none !important; }';
|
|
39186
|
-
document.documentElement.appendChild(style);
|
|
39187
|
-
};
|
|
39188
|
-
if (document.documentElement) return apply();
|
|
39189
|
-
new MutationObserver(function (_, o) {
|
|
39190
|
-
if (document.documentElement) { o.disconnect(); apply(); }
|
|
39191
|
-
}).observe(document, { childList: true });
|
|
39192
|
-
})();
|
|
39193
|
-
`
|
|
39189
|
+
content: injectStyleScript("html, body, * { scrollbar-width: none !important; } ::-webkit-scrollbar { display: none !important; }")
|
|
39194
39190
|
});
|
|
39195
39191
|
}
|
|
39196
39192
|
await ctx.addInitScript({ content: CAROUSEL_STABILIZER_INIT_SCRIPT });
|
|
@@ -39221,6 +39217,29 @@ var ACCEPT_SELECTORS = [
|
|
|
39221
39217
|
'button[id*="accept" i][id*="cookie" i]'
|
|
39222
39218
|
];
|
|
39223
39219
|
var LOOSE_ACCEPT_SELECTOR = 'button:has-text("Aceitar")';
|
|
39220
|
+
function clickConsentButtonByText() {
|
|
39221
|
+
const LABEL = /^(continuar e fechar|aceitar e fechar|continuar|fechar|entendi|ok)$/i;
|
|
39222
|
+
const CONSENT = /cookie/i;
|
|
39223
|
+
const MAX_DEPTH = 4;
|
|
39224
|
+
const MAX_BANNER_TEXT = 1500;
|
|
39225
|
+
for (const b of Array.from(document.querySelectorAll("button, [role='button']"))) {
|
|
39226
|
+
if (!LABEL.test((b.textContent ?? "").replace(/\s+/g, " ").trim()))
|
|
39227
|
+
continue;
|
|
39228
|
+
if (b.checkVisibility && !b.checkVisibility())
|
|
39229
|
+
continue;
|
|
39230
|
+
let el = b.parentElement;
|
|
39231
|
+
for (let d = 0;el && d < MAX_DEPTH; d++, el = el.parentElement) {
|
|
39232
|
+
const text = el.textContent ?? "";
|
|
39233
|
+
if (text.length > MAX_BANNER_TEXT)
|
|
39234
|
+
break;
|
|
39235
|
+
if (CONSENT.test(text)) {
|
|
39236
|
+
b.click();
|
|
39237
|
+
return true;
|
|
39238
|
+
}
|
|
39239
|
+
}
|
|
39240
|
+
}
|
|
39241
|
+
return false;
|
|
39242
|
+
}
|
|
39224
39243
|
async function acceptCookieBanner(page, opts = {}) {
|
|
39225
39244
|
const selectors = opts.loose ? [...ACCEPT_SELECTORS, LOOSE_ACCEPT_SELECTOR] : ACCEPT_SELECTORS;
|
|
39226
39245
|
for (const sel of selectors) {
|
|
@@ -39235,6 +39254,12 @@ async function acceptCookieBanner(page, opts = {}) {
|
|
|
39235
39254
|
return true;
|
|
39236
39255
|
}
|
|
39237
39256
|
}
|
|
39257
|
+
if (await page.evaluate(clickConsentButtonByText).catch(() => false)) {
|
|
39258
|
+
await page.waitForTimeout(300).catch(() => {
|
|
39259
|
+
return;
|
|
39260
|
+
});
|
|
39261
|
+
return true;
|
|
39262
|
+
}
|
|
39238
39263
|
return false;
|
|
39239
39264
|
}
|
|
39240
39265
|
|
|
@@ -44576,6 +44601,14 @@ async function dismissOverlays(page, ctx) {
|
|
|
44576
44601
|
const sels = overlaySelectorsFor(ctx.rc);
|
|
44577
44602
|
dlog2(ctx, ` dismissOverlays: checking ${sels.length} selector(s)…`);
|
|
44578
44603
|
const dismissals = [];
|
|
44604
|
+
if (await acceptCookieBanner(page).catch(() => false)) {
|
|
44605
|
+
dismissals.push({
|
|
44606
|
+
reason: "selector-match",
|
|
44607
|
+
tag: "cookie-consent",
|
|
44608
|
+
method: "close-button",
|
|
44609
|
+
dismissed: true
|
|
44610
|
+
});
|
|
44611
|
+
}
|
|
44579
44612
|
for (const sel of sels) {
|
|
44580
44613
|
try {
|
|
44581
44614
|
const overlay = page.locator(sel).first();
|
|
@@ -67542,7 +67575,7 @@ async function migrateCommand(opts) {
|
|
|
67542
67575
|
let platformSeen = null;
|
|
67543
67576
|
let assetsResolved = null;
|
|
67544
67577
|
for (const vp of viewports) {
|
|
67545
|
-
const ctx = await newContext(browser, { viewport: vp });
|
|
67578
|
+
const ctx = await newContext(browser, { viewport: vp, keepMotion: true });
|
|
67546
67579
|
const page = await ctx.newPage();
|
|
67547
67580
|
try {
|
|
67548
67581
|
await page.goto(opts.url, { waitUntil: "domcontentloaded", timeout: 30000 });
|
|
@@ -67763,7 +67796,7 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
|
|
|
67763
67796
|
const blocksByPath = new Map;
|
|
67764
67797
|
const contentMap = {};
|
|
67765
67798
|
for (const target of resolvedPages) {
|
|
67766
|
-
const ctx = await newContext(browser, { viewport });
|
|
67799
|
+
const ctx = await newContext(browser, { viewport, keepMotion: true });
|
|
67767
67800
|
const page = await ctx.newPage();
|
|
67768
67801
|
const pageComponents = [];
|
|
67769
67802
|
try {
|
|
@@ -71862,7 +71895,10 @@ function isHarnessSide(explicitSelector) {
|
|
|
71862
71895
|
return !explicitSelector;
|
|
71863
71896
|
}
|
|
71864
71897
|
async function gatherBenchSide(browser, opts) {
|
|
71865
|
-
const ctx = await newContext(browser, {
|
|
71898
|
+
const ctx = await newContext(browser, {
|
|
71899
|
+
viewport: opts.viewport,
|
|
71900
|
+
keepMotion: true
|
|
71901
|
+
});
|
|
71866
71902
|
const page = await ctx.newPage();
|
|
71867
71903
|
const side = {
|
|
71868
71904
|
url: opts.url,
|
|
@@ -76599,7 +76635,10 @@ async function readDelta(page, selector, base) {
|
|
|
76599
76635
|
};
|
|
76600
76636
|
}
|
|
76601
76637
|
async function gatherStates(browser, opts) {
|
|
76602
|
-
const ctx = await newContext(browser, {
|
|
76638
|
+
const ctx = await newContext(browser, {
|
|
76639
|
+
viewport: opts.viewport,
|
|
76640
|
+
keepMotion: true
|
|
76641
|
+
});
|
|
76603
76642
|
const page = await ctx.newPage();
|
|
76604
76643
|
const out = {
|
|
76605
76644
|
motion: { found: false, error: "not read" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.59",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|