fix(e2e): implement aggressive asset-interception for cache-busting
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m14s
Build & Deploy / 🏗️ Build (push) Successful in 2m26s
Build & Deploy / 🚀 Deploy (push) Successful in 15s
Build & Deploy / 🧪 Post-Deploy Verification (push) Failing after 4m2s
Build & Deploy / 🔔 Notify (push) Successful in 3s

This commit is contained in:
2026-04-12 23:50:23 +02:00
parent 65efbd147c
commit 52e18b10d6

View File

@@ -12,8 +12,8 @@ async function main() {
console.log(`\n🚀 Starting E2E Form Submission Check for: ${targetUrl}`);
// 0. Settlement Delay: Wait for deployment to settle (sync containers/Varnish)
console.log(`⏳ Waiting 5s for deployment settlement...`);
await delay(5000);
console.log(`⏳ Waiting 10s for deployment settlement...`);
await delay(10000);
// 1. Fetch Sitemap to discover the contact page and a product page
const sitemapUrl = `${targetUrl.replace(/\/$/, '')}/sitemap.xml`;
@@ -80,6 +80,24 @@ async function main() {
const page = await browser.newPage();
// Enable Request Interception to force cache-busting on ALL static assets
await page.setRequestInterception(true);
page.on('request', (request) => {
const url = request.url();
// Intercept Next.js chunks and data to bypass Varnish 404-caching
if (
(url.includes('/_next/static/') || url.includes('/_next/data/')) &&
!url.includes('?cb=') &&
!url.includes('&cb=')
) {
const buster = `cb=${Date.now()}`;
const newUrl = url.includes('?') ? `${url}&${buster}` : `${url}?${buster}`;
request.continue({ url: newUrl });
} else {
request.continue();
}
});
let chunkErrorsDetected = false;
page.on('console', (msg) => {
const text = msg.text();
@@ -110,7 +128,7 @@ async function main() {
// First attempt
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
await delay(2000); // Allow initial JS execution
await delay(3000); // Allow initial JS execution
if (chunkErrorsDetected) {
const cbUrl = `${url}${url.includes('?') ? '&' : '?'}cb=${Date.now()}`;
@@ -120,7 +138,7 @@ async function main() {
}
// Wait for network to settle slightly
await page.waitForNetworkIdle({ idleTime: 500, timeout: 10000 }).catch(() => {});
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 10000 }).catch(() => {});
};
// 3. Authenticate through Gatekeeper login form