Skip to content

Commit

Permalink
UHF-6187: Added mock cookies.
Browse files Browse the repository at this point in the history
  • Loading branch information
dire committed Oct 5, 2023
1 parent 8ccb57e commit fe1f3e1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ dist/**/*.map
yarn.lock

# BackstopJS
backstop_data/fast
backstop_data/full
backstop_data/*/bitmaps_reference
backstop_data/*/bitmaps_test
backstop_data/*/html_report
3 changes: 2 additions & 1 deletion backstop_data/backstop_dynamic_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ function getConfig(hostname, type) {
],
'mergeImgHack': true,
'onBeforeScript': 'onBefore.js',
// 'onReadyScript': 'puppet/onReady.js',
// 'onReadyScript': 'onReady.js',
'paths': {
'bitmaps_reference': `backstop_data/${type}/bitmaps_reference`,
'bitmaps_test': `backstop_data/${type}/bitmaps_test`,
Expand All @@ -434,6 +434,7 @@ function getConfig(hostname, type) {
'asyncCompareLimit': 100,
'debug': false,
'debugWindow': false,
'hostname': `${hostname}`,
}
};
}
Expand Down
31 changes: 30 additions & 1 deletion backstop_data/fast/engine_scripts/onBefore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
module.exports = async (page, scenario, vp, isReference) => {
module.exports = async (page, scenario, vp, isReference, browserContext, config) => {
await page.emulateMedia({ reducedMotion: 'reduce' });
const { hostname } = config;

// Add cookies to browser
browserContext.addCookies([
{
'name': 'cookie-agreed-version',
'value': '1.1.0',
'domain': hostname,
'path': '/',
'httpOnly': false,
'secure': false
},
{
'name': 'cookie-agreed',
'value': '2',
'domain': hostname,
'path': '/',
'httpOnly': false,
'secure': false
},
{
'name': 'cookie-agreed-categories',
'value': '%5B%22essential%22%2C%22preference%22%2C%22statistics%22%2C%22marketing%22%2C%22chat%22%5D',
'domain': hostname,
'path': '/',
'httpOnly': false,
'secure': false
}
]);
};
31 changes: 30 additions & 1 deletion backstop_data/full/engine_scripts/onBefore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
module.exports = async (page, scenario, vp, isReference) => {
module.exports = async (page, scenario, vp, isReference, browserContext, config) => {
await page.emulateMedia({ reducedMotion: 'reduce' });
const { hostname } = config;

// Add cookies to browser
browserContext.addCookies([
{
'name': 'cookie-agreed-version',
'value': '1.1.0',
'domain': hostname,
'path': '/',
'httpOnly': false,
'secure': false
},
{
'name': 'cookie-agreed',
'value': '2',
'domain': hostname,
'path': '/',
'httpOnly': false,
'secure': false
},
{
'name': 'cookie-agreed-categories',
'value': '%5B%22essential%22%2C%22preference%22%2C%22statistics%22%2C%22marketing%22%2C%22chat%22%5D',
'domain': hostname,
'path': '/',
'httpOnly': false,
'secure': false
}
]);
};

0 comments on commit fe1f3e1

Please sign in to comment.