From f86709281c9f25bd6b265a1a408ba306b59775ee Mon Sep 17 00:00:00 2001 From: Maxim Tsoy Date: Tue, 13 Aug 2024 11:26:33 +0200 Subject: [PATCH] Add rule for tesla --- lib/eval-snippets.ts | 1 + rules/autoconsent/tesla.json | 35 +++++++++++++++++++++++++++++++++++ tests/tesla.spec.ts | 5 +++++ 3 files changed, 41 insertions(+) create mode 100644 rules/autoconsent/tesla.json create mode 100644 tests/tesla.spec.ts diff --git a/lib/eval-snippets.ts b/lib/eval-snippets.ts index 3a1c9412..5d248b8e 100644 --- a/lib/eval-snippets.ts +++ b/lib/eval-snippets.ts @@ -134,6 +134,7 @@ export const snippets = { EVAL_TEALIUM_2: () => utag.gdpr.setConsentValue(true) || true, EVAL_TEALIUM_3: () => utag.gdpr.getConsentState() !== 1, EVAL_TEALIUM_DONOTSELL_CHECK: () => utag.gdpr.dns?.getDnsState() !== 1, + EVAL_TESLA_TEST: () => document.cookie.includes('tsla-cookie-consent=rejected'), EVAL_TESTCMP_0: () => window.results.results[0] === 'button_clicked', EVAL_TESTCMP_COSMETIC_0: () => window.results.results[0] === 'banner_hidden', EVAL_THEFREEDICTIONARY_0: () => cmpUi.showPurposes() || cmpUi.rejectAll() || true, diff --git a/rules/autoconsent/tesla.json b/rules/autoconsent/tesla.json new file mode 100644 index 00000000..70b3bed0 --- /dev/null +++ b/rules/autoconsent/tesla.json @@ -0,0 +1,35 @@ +{ + "name": "tesla", + "vendorUrl": "https://tesla.com/", + "runContext": { + "main": true, + "frame": false, + "urlPattern": "^https://(www\\.)?tesla\\.com/" + }, + "prehideSelectors": [], + "detectCmp": [ + { + "exists": "#cookie_banner" + } + ], + "detectPopup": [ + { + "visible": "#cookie_banner" + } + ], + "optIn": [ + { + "waitForThenClick": "#tsla-accept-cookie" + } + ], + "optOut": [ + { + "waitForThenClick": "#tsla-reject-cookie" + } + ], + "test": [ + { + "eval": "EVAL_TESLA_TEST" + } + ] +} \ No newline at end of file diff --git a/tests/tesla.spec.ts b/tests/tesla.spec.ts new file mode 100644 index 00000000..bf95e108 --- /dev/null +++ b/tests/tesla.spec.ts @@ -0,0 +1,5 @@ +import generateCMPTests from "../playwright/runner"; + +generateCMPTests('tesla', [ + 'https://www.tesla.com/nl_nl/' +]);