Last active
December 1, 2022 14:05
-
-
Save EdgardoRodriguezSolano/5f303ac0c5dbd603b13db1c14019bce1 to your computer and use it in GitHub Desktop.
Re-collection test suggestion for tcf v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('didomiOnReady functions are called with the Didomi object when UI is not loaded (already have consent)', async t => { | |
// Consent string with creation date from today | |
const consentString = generateTCFv2ConsentString({ | |
purposeConsents: [1, 2, 3, 4, 7, 9, 10], | |
purposeLIs: [], | |
vendorConsents: [2], | |
vendorLIs: [], | |
specialFeatureOptins: [2], | |
created: new Date(), | |
lastUpdated: new Date(), | |
}); | |
await setCookie('euconsent-v2', consentString); | |
await t.eval(() => { | |
window.didomiOnReadyCalled = false; | |
window.didomiOnReady = window.didomiOnReady || []; | |
window.didomiOnReady.push(() => { | |
window.didomiOnReadyCalled = typeof window.Didomi === 'object'; | |
}); | |
}); | |
await configureSDK({ | |
website: { | |
vendors: { | |
iab: { | |
enabled: true, | |
include: [2], | |
version: 2, | |
}, | |
}, | |
}, | |
notice: { | |
daysBeforeShowingAgain: 30, | |
}, | |
cookies: { | |
local: { | |
customDomain: '', // We need this line for the test because if cookieDomain is set, document.cookie returns empty | |
}, | |
}, | |
}); | |
// The notice is not displayed | |
await t.expect(page.notice.container.exists).notOk(); | |
// didomiOnReady functions have been called and Didomi is an object | |
await t.expect(ClientFunction(() => window.didomiOnReadyCalled)()).eql(true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment