chore(ci): Setup visual regression testing with BackstopJS
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

This commit is contained in:
2026-02-21 23:30:22 +01:00
parent cef86717d9
commit 8c9f51b74a
7 changed files with 607 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
/* 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',
});
};

View File

@@ -0,0 +1,20 @@
/* eslint-disable */
module.exports = async (page, scenario, vp) => {
console.log('SCENARIO > ' + scenario.label);
// Disable CSS animations instantly to avoid flaky screenshots
await page.evaluate(() => {
const style = document.createElement('style');
style.innerHTML = `
* {
animation: none !important;
transition: none !important;
caret-color: transparent !important;
}
`;
document.head.appendChild(style);
});
// Example: Wait for fonts to load
await page.evaluate(() => document.fonts.ready);
};