Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions lib/eval-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,31 @@ export const snippets = {
EVAL_PUBTECH_0: () =>
document.cookie.includes('euconsent-v2') &&
(document.cookie.match(/.YAAAAAAAAAAA/) || document.cookie.match(/.aAAAAAAAAAAA/) || document.cookie.match(/.YAAACFgAAAAA/)),
EVAL_SHOPIFY_TEST: () =>
document.cookie.includes('gdpr_cookie_consent=0') ||
(document.cookie.includes('_tracking_consent=') &&
EVAL_SHOPIFY_TEST: () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shopify eval should be reverted to it's original state, and we should create a new eval for polaris.

if (document.cookie.includes('gdpr_cookie_consent=0')) return true;
if (document.cookie.includes('polaris_consent_settings=')) {
const settings = JSON.parse(
decodeURIComponent(
document.cookie
.split(';')
.find((s) => s.trim().startsWith('polaris_consent_settings'))
.split('=')[1],
),
);
if (settings.adsPermitted === false) return true;
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
}
return (
document.cookie.includes('_tracking_consent=') &&
JSON.parse(
decodeURIComponent(
document.cookie
.split(';')
.find((s) => s.trim().startsWith('_tracking_consent'))
.split('=')[1],
),
).purposes.a === false),
).purposes.a === false
);
},
EVAL_SKYSCANNER_TEST: () => document.cookie.match(/gdpr=[^;]*adverts:::false/) && !document.cookie.match(/gdpr=[^;]*init:::true/),
EVAL_SIRDATA_UNBLOCK_SCROLL: () => {
document.documentElement.classList.forEach((cls) => {
Expand Down
67 changes: 67 additions & 0 deletions rules/autoconsent/shopify-polaris.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "shopify-polaris",
"vendorUrl": "https://shopify.dev/docs/api/customer-privacy",
"cosmetic": false,
"prehideSelectors": ["#polaris-css-lockdown-container"],
"detectCmp": [
{
"exists": ["#polaris-css-lockdown-container", ".polaris-consent-widget"]
}
],
"detectPopup": [
{
"visible": ["#polaris-css-lockdown-container", ".polaris-consent-widget"]
}
],
"optIn": [
{
"waitForThenClick": [
"#polaris-css-lockdown-container",
"[role=\"region\"][aria-label=\"Cookie consent\"] .polaris-consent-widget__actions button:last-child"
],
"timeout": 5000
}
],
"optOut": [
{
"if": {
"exists": ["#polaris-css-lockdown-container", "xpath//button[normalize-space()='Decline']"]
},
"then": [
{
"waitForThenClick": ["#polaris-css-lockdown-container", "xpath//button[normalize-space()='Decline']"],
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
"timeout": 5000
}
],
"else": [
{
"if": {
"exists": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"]
},
"then": [
{
"waitForThenClick": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"],
"timeout": 5000
}
],
"else": [
{
"waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutLink\"]"],
"timeout": 5000
}
]
}
]
},
{
"waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutClose\"]"],
"timeout": 5000,
"optional": true
}
],
"test": [
{
"eval": "EVAL_SHOPIFY_TEST"
}
]
}
4 changes: 4 additions & 0 deletions tests/shopify-polaris.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('shopify-polaris', ['https://www.mcgeeandco.com/products/calvert-brass-tissue-box-cover']);
generateCMPTests('shopify-polaris', ['https://mightyvault.com/'], { testOptOut: false, testSelfTest: false });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we skipping opt-out testing? If the rule applies here but can't do opt-out, then we should fix the rule.

Loading