Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ketch and eu-cookie-compliance #351

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion lib/cmps/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class AutoConsentCMP extends AutoConsentCMPBase {
}

async evaluateRuleStep(rule: AutoConsentRuleStep) {
const results = [];
const results: Array<Promise<boolean> | boolean> = [];
const logsConfig = this.autoconsent.config.logs;
if (rule.exists) {
results.push(this.elementExists(rule.exists));
Expand Down Expand Up @@ -282,6 +282,8 @@ export class AutoConsentCMP extends AutoConsentCMPBase {
results.push(this._runRulesSequentially(rule.then));
} else if (rule.else) {
results.push(this._runRulesSequentially(rule.else));
} else {
results.push(true);
muodov marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (rule.any) {
Expand Down
13 changes: 10 additions & 3 deletions rules/autoconsent/eu-cookie-compliance.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"name": "eu-cookie-compliance-banner",
"detectCmp": [{ "exists": ".eu-cookie-compliance-banner-info" }],
"detectPopup": [{ "exists": ".eu-cookie-compliance-popup-open" }],
"detectCmp": [{ "exists": "body.eu-cookie-compliance-popup-open" }],
"detectPopup": [{ "exists": "body.eu-cookie-compliance-popup-open" }],
"optIn": [{ "click": ".agree-button" }],
"optOut": [
{ "click": ".decline-button,.eu-cookie-compliance-save-preferences-button", "optional": true },
{
"if": {
"visible": ".decline-button,.eu-cookie-compliance-save-preferences-button"
},
"then": [{
"click": ".decline-button,.eu-cookie-compliance-save-preferences-button"
}]
},
{ "hide": ".eu-cookie-compliance-banner-info, #sliding-popup" }
],
"test": [
Expand Down
43 changes: 23 additions & 20 deletions rules/autoconsent/ketch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "ketch",
"vendorUrl": "https://www.ketch.com",
"runContext": {
"frame": false,
"main": true
Expand All @@ -24,37 +25,39 @@
"exists": "#lanyard_root button[class='confirmButton']"
},
"then": [
{ "waitForThenClick":"#lanyard_root div[class^='buttons'] > :nth-child(2)" },
{ "waitForThenClick":"#lanyard_root div[class*=buttons] > :nth-child(2)" },
{ "click": "#lanyard_root button[class='confirmButton']" }
],
"else": [
{ "waitForThenClick":"#lanyard_root div[class^='buttons'] > :nth-child(2)" }
{ "waitForThenClick":"#lanyard_root div[class*=buttons] > :nth-child(2)" }
]
}
],
"optOut": [
{
"click": "#lanyard_root button[class^='link']",
{
"if": {
"exists": "#lanyard_root [aria-describedby=banner-description]"
},
"then": [
{
"waitForThenClick":"#lanyard_root div[class*=buttons] > button[class*=secondaryButton]",
"comment": "can be either settings or reject button"
}
]
},
{
"waitFor": "#lanyard_root [aria-describedby=preference-description],#lanyard_root [aria-describedby=modal-description]",
"timeout": 1000,
"optional": true
},
{
"if": {
"exists": "#lanyard_root button[class*='confirmButton']"
},
"exists": "#lanyard_root [aria-describedby=preference-description],#lanyard_root [aria-describedby=modal-description]"
},
"then": [
{ "waitForThenClick": "#lanyard_root button[class*='rejectButton']" },
{ "click": "#lanyard_root button[class*='confirmButton']" }
],
"else": [
{
"click": "#lanyard_root div[class^='buttons'] > :nth-child(1)",
"optional": true
},
{ "waitForThenClick": "#lanyard_root input:checked" },
{ "click": "#consentsTab > div:nth-child(2) > div > div[class^='actions'] > button:nth-child(1)" }
{ "waitForThenClick": "#lanyard_root button[class*=rejectButton]" },
{ "click": "#lanyard_root button[class*=confirmButton],#lanyard_root div[class*=actions_] > button:nth-child(1)" }
]
}
],
"test": []
}

]
}
2 changes: 1 addition & 1 deletion tests/eu-cookie-compliance-banner.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import generateCMPTests from "../playwright/runner";

generateCMPTests('eu-cookie-compliance-banner', [
'https://www.bauwion.de/',
'https://www.theposh.com/table/226',
'https://publichealth.jhu.edu/',
]);
2 changes: 1 addition & 1 deletion tests/ketch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import generateCMPTests from "../playwright/runner";
generateCMPTests("ketch", [
"https://www.smartsheet.com/",
"https://www.ketch.com/",
"https://www.patreon.com/",
"https://www.forbes.com/",
]);
Loading