Skip to content

Commit

Permalink
Fix takealot.com on mobile (#291)
Browse files Browse the repository at this point in the history
* Fix tekealot.com on mobile

* Enable mobile tests for takealot
  • Loading branch information
muodov authored Nov 17, 2023
1 parent cdf245e commit 94d424c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/eval-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const snippets = {
EVAL_SIRDATA_0: () => document.cookie.includes('euconsent-v2'),
EVAL_SNIGEL_0: () => !!document.cookie.match('snconsent'),
EVAL_STEAMPOWERED_0: () => JSON.parse(decodeURIComponent(document.cookie.split(';').find(s => s.trim().startsWith('cookieSettings')).split('=')[1])).preference_state === 2,
EVAL_TAKEALOT_0: () => document.body.classList.remove('freeze') || (document.body.style = '') || true,
EVAL_TARTEAUCITRON_0: () => tarteaucitron.userInterface.respondAll(false) || true,
EVAL_TARTEAUCITRON_1: () => tarteaucitron.userInterface.respondAll(true) || true,
EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)[0].includes('false'),
Expand Down
9 changes: 7 additions & 2 deletions rules/autoconsent/takealot-com.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"name": "takealot.com",
"cosmetic": true,
"prehideSelectors": ["div[class^=\"cookies-banner-module_cookie-banner_\"]"],
"prehideSelectors": ["div[class^=\"cookies-banner-module_\"]"],
"detectCmp": [{ "exists": "div[class^=\"cookies-banner-module_cookie-banner_\"]" }],
"detectPopup": [{ "exists": "div[class^=\"cookies-banner-module_cookie-banner_\"]" }],
"optIn": [
{ "click": "button[class*=\"cookies-banner-module_dismiss-button_\"]" }
],
"optOut": [
{ "hide": ["div[class^=\"cookies-banner-module_cookie-banner_\"]"] }
{ "hide": ["div[class^=\"cookies-banner-module_\"]"] },
{
"if": { "exists": "div[class^=\"cookies-banner-module_small-cookie-banner_\"]" },
"then": [{ "eval": "EVAL_TAKEALOT_0"}],
"else": []
}
]
}
10 changes: 9 additions & 1 deletion tests/takealot-com.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ import generateCMPTests from "../playwright/runner";

generateCMPTests('takealot.com', [
'https://www.takealot.com/',
], {});
], {
mobile: false,
});

generateCMPTests('takealot.com', [
'https://www.takealot.com/',
], {
mobile: true,
});

0 comments on commit 94d424c

Please sign in to comment.