Files
klz-cables.com/backstop_data/engine_scripts/puppet/onBefore.js
Marc Mintel 8c9f51b74a
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 1m52s
Build & Deploy / 🏗️ Build (push) Successful in 4m1s
Build & Deploy / 🚀 Deploy (push) Successful in 28s
Build & Deploy / ⚡ Lighthouse (push) Successful in 3m0s
Build & Deploy / 🧪 Smoke Test (push) Successful in 3m13s
Build & Deploy / ♿ WCAG (push) Failing after 1m48s
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 📸 Visual Diff (push) Has been cancelled
chore(ci): Setup visual regression testing with BackstopJS
2026-02-21 23:30:22 +01:00

27 lines
856 B
JavaScript

/* eslint-disable */
module.exports = async (page, scenario, vp, isReference, browserContext) => {
console.log('onBefore: Setting up Gatekeeper Auth Cookie...');
// BackstopJS might be hitting localhost, testing, or staging URLs
const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || 'klz2026';
// Extract domain from the scenario URL
let targetDomain = 'localhost';
try {
const urlObj = new URL(scenario.url);
targetDomain = urlObj.hostname;
} catch (e) {
// ignore
}
// Inject the ForwardAuth session cookie
await page.setCookie({
name: 'klz_gatekeeper_session',
value: gatekeeperPassword,
domain: targetDomain, // Puppeteer requires exact or matching domain for cookies
path: '/',
httpOnly: true,
secure: targetDomain !== 'localhost' && targetDomain !== 'host.docker.internal',
});
};