-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,721 additions
and
2,299 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@guardian/consent-management-platform': patch | ||
--- | ||
|
||
testing exeperimentation |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -871,6 +871,11 @@ | |
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.56.0.tgz#ef20350fec605a7f7035a01764731b2de0f3782b" | ||
integrity sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A== | ||
|
||
"@guardian/[email protected]": | ||
version "0.0.0-beta-20240129231944" | ||
resolved "https://registry.yarnpkg.com/@guardian/consent-management-platform/-/consent-management-platform-0.0.0-beta-20240129231944.tgz#f980a59bbb5617614cea8f946e33a17316727d6f" | ||
integrity sha512-0K+xzKZtqCLUZmPBXo+zVP17mcZnC6dvJuj2D0R7N8QovY5XZH5+JaqWN9O+YkcHyEKCwo4m+nJ4RpeGNMqdQQ== | ||
|
||
"@guardian/eslint-config-typescript@^9.0.1": | ||
version "9.0.1" | ||
resolved "https://registry.yarnpkg.com/@guardian/eslint-config-typescript/-/eslint-config-typescript-9.0.1.tgz#42d63f6b4d0c0414d5a7a6a4da3b288fa53df709" | ||
|
@@ -4725,9 +4730,9 @@ playwright-aws-lambda@^0.10.0: | |
lambdafs "^2.1.1" | ||
|
||
playwright-core@^1.40.1: | ||
version "1.40.1" | ||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.40.1.tgz#442d15e86866a87d90d07af528e0afabe4c75c05" | ||
integrity sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ== | ||
version "1.41.1" | ||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.41.1.tgz#9c152670010d9d6f970f34b68e3e935d3c487431" | ||
integrity sha512-/KPO5DzXSMlxSX77wy+HihKGOunh3hqndhqeo/nMxfigiKzogn8kfL0ZBDu0L1RKgan5XHCPmn6zXd2NUJgjhg== | ||
|
||
prelude-ls@^1.2.1: | ||
version "1.2.1" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,9 +88,12 @@ | |
"svelte": "~3.59.1", | ||
"tslib": "^2.5.3", | ||
"typescript": "~5.1.3", | ||
"wait-for-expect": "^3" | ||
"wait-for-expect": "^3", | ||
"playwright-core": "^1.40.1" | ||
}, | ||
"peerDependencies": { | ||
"@guardian/libs": "^15.0.0" | ||
} | ||
"@guardian/libs": "^15.0.0", | ||
"playwright-core": "^1.40.1" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import type { Page, Request } from 'playwright-core'; | ||
|
||
/** | ||
* This function console logs an info message. | ||
* | ||
* @param {string} message | ||
*/ | ||
const log_info = (message: string): void => { | ||
console.log(`(cmp monitoring) info: ${message}`); | ||
}; | ||
|
||
|
||
/** | ||
* This function waits for the page to load | ||
* clicks the accept all button | ||
* | ||
* @param {Page} page | ||
* @param {string} textToPrintToConsole | ||
*/ | ||
export const clickAcceptAllCookies = async (page: Page, textToPrintToConsole: string = "Accept All") => { | ||
|
||
log_info(`Clicking on "${textToPrintToConsole}" on CMP`); | ||
|
||
const acceptAllButton = page.frameLocator('[id*="sp_message_iframe"]').locator('button.sp_choice_type_11'); | ||
await acceptAllButton.click(); | ||
|
||
log_info(`Clicked on "${textToPrintToConsole}"`); | ||
}; | ||
|
||
/** | ||
* This function checks for interaction with GAM | ||
* Using this after advice from Commercial to check that cookies were accepted as we otherwise do not interact with GAM | ||
* This has to be adjusted if anything in the interaction with GAM changes or we stop using GAM | ||
* | ||
* @param {Page} page | ||
* @return {*} {Promise<void>} | ||
*/ | ||
export const checkTopAdHasLoaded = async (page: Page) => { | ||
log_info(`Waiting for interaction with GAM: Start`); | ||
|
||
const gamUrl = /https:\/\/securepubads.g.doubleclick.net\/gampad\/ads/; | ||
|
||
const getEncodedParamsFromRequest = ( | ||
request: Request, | ||
paramName: string, | ||
): URLSearchParams | null => { | ||
const url = new URL(request.url()); | ||
const param = url.searchParams.get(paramName); | ||
if (!param) return null; | ||
const paramDecoded = decodeURIComponent(param); | ||
const searchParams = new URLSearchParams(paramDecoded); | ||
return searchParams; | ||
}; | ||
|
||
const assertOnSlotFromRequest = (request: Request, expectedSlot: string) => { | ||
const isURL = request.url().match(gamUrl); | ||
if (!isURL) return false; | ||
const searchParams = getEncodedParamsFromRequest(request, 'prev_scp'); | ||
if (searchParams === null) return false; | ||
const slot = searchParams.get('slot'); | ||
if (slot !== expectedSlot) return false; | ||
return true; | ||
}; | ||
|
||
const waitForGAMRequestForSlot = (page: Page, slotExpected: string) => { | ||
return page.waitForRequest((request) => | ||
assertOnSlotFromRequest(request, slotExpected), | ||
); | ||
}; | ||
|
||
const gamRequestPromise = waitForGAMRequestForSlot( | ||
page, | ||
'top-above-nav', | ||
); | ||
await gamRequestPromise; | ||
|
||
log_info(`Waiting for interaction with GAM: Complete`); | ||
}; |
Oops, something went wrong.