test: robust E2E form verification with direct Gatekeeper auth and verbose logging
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Successful in 2m19s
Build & Deploy / 🏗️ Build (push) Successful in 3m37s
Build & Deploy / 🚀 Deploy (push) Successful in 22s
Build & Deploy / 🧪 Post-Deploy Verification (push) Failing after 5m15s
Build & Deploy / 🔔 Notify (push) Successful in 2s

This commit is contained in:
2026-03-11 10:05:32 +01:00
parent 03d10f9a83
commit 678ca784a1

View File

@@ -34,22 +34,27 @@ async function main() {
process.exit(1); process.exit(1);
} }
const contactUrl = urls.find((u) => u.includes('/de/kontakt')); const contactUrl = urls.find((u) => u.includes('/de/contact') || u.includes('/de/kontakt'));
// Ensure we select an actual product page (depth >= 7: http://host/de/produkte/category/product) // Ensure we select an actual product page (depth >= 4 segments: /de/produkte/category/product)
const productUrl = urls.find( const productUrl = urls.find(
(u) => (u) =>
u.includes('/de/produkte/') && new URL(u).pathname.split('/').filter(Boolean).length >= 4, (u.includes('/de/produkte/') || u.includes('/de/products/')) &&
new URL(u).pathname.split('/').filter(Boolean).length >= 4,
); );
if (!contactUrl) { if (!contactUrl) {
console.error(`❌ Could not find contact page in sitemap. Ensure /de/kontakt exists.`); console.error(
`❌ Could not find contact page in sitemap. Checked patterns: /de/contact, /de/kontakt`,
);
console.log('Available URLs (first 20):', urls.slice(0, 20));
process.exit(1); process.exit(1);
} }
if (!productUrl) { if (!productUrl) {
console.error( console.error(
`❌ Could not find a product page in sitemap. Form testing requires at least one product page.`, `❌ Could not find a product page in sitemap. Checked patterns: /de/produkte/, /de/products/`,
); );
console.log('Available URLs (first 20):', urls.slice(0, 20));
process.exit(1); process.exit(1);
} }
@@ -66,32 +71,34 @@ async function main() {
const page = await browser.newPage(); const page = await browser.newPage();
// Set viewport for consistent layout
await page.setViewport({ width: 1280, height: 800 });
page.on('console', (msg) => console.log('💻 BROWSER CONSOLE:', msg.text())); page.on('console', (msg) => console.log('💻 BROWSER CONSOLE:', msg.text()));
page.on('pageerror', (error: any) => console.error('💻 BROWSER ERROR:', error.message)); page.on('pageerror', (error: any) => console.error('💻 BROWSER ERROR:', error.message));
page.on('requestfailed', (request) => { page.on('requestfailed', (request) => {
console.error('💻 BROWSER REQUEST FAILED:', request.url(), request.failure()?.errorText); // Only log failures for main document and API calls to reduce noise
const resourceType = request.resourceType();
if (resourceType === 'document' || resourceType === 'fetch' || resourceType === 'xhr') {
console.error('💻 BROWSER REQUEST FAILED:', request.url(), request.failure()?.errorText);
}
}); });
// 3. Authenticate through Gatekeeper login form // 3. Authenticate through Gatekeeper via Direct Cookie Insertion
console.log(`\n🛡 Authenticating through Gatekeeper...`); console.log(`\n🛡 Authenticating through Gatekeeper via Cookie Injection...`);
try { try {
// Navigate to a protected page so Gatekeeper redirects us to the login screen const domain = new URL(targetUrl).hostname;
await page.goto(contactUrl, { waitUntil: 'networkidle0', timeout: 30000 }); await page.setCookie({
name: 'klz_gatekeeper_session',
// Check if we landed on the Gatekeeper login page value: gatekeeperPassword,
const isGatekeeperPage = await page.$('input[name="password"]'); domain: domain,
if (isGatekeeperPage) { path: '/',
await page.type('input[name="password"]', gatekeeperPassword); secure: true,
await Promise.all([ httpOnly: true,
page.waitForNavigation({ waitUntil: 'networkidle0', timeout: 30000 }), });
page.click('button[type="submit"]'), console.log(`✅ Gatekeeper cookie injected for domain: ${domain}`);
]);
console.log(`✅ Gatekeeper authentication successful!`);
} else {
console.log(`✅ Already authenticated (no Gatekeeper gate detected).`);
}
} catch (err: any) { } catch (err: any) {
console.error(`❌ Gatekeeper authentication failed: ${err.message}`); console.error(`❌ Gatekeeper cookie injection failed: ${err.message}`);
await browser.close(); await browser.close();
process.exit(1); process.exit(1);
} }
@@ -114,7 +121,10 @@ async function main() {
timeout: 15000, timeout: 15000,
}); });
} catch (e) { } catch (e) {
console.error('Failed to find Contact Form input. Page Title:', await page.title()); console.error('Failed to find Contact Form input.');
console.log('Page Title:', await page.title());
const bodySnippet = await page.evaluate(() => document.body.innerText.slice(0, 500));
console.log('Page Content Snippet:', bodySnippet);
throw e; throw e;
} }
@@ -169,7 +179,10 @@ async function main() {
timeout: 15000, timeout: 15000,
}); });
} catch (e) { } catch (e) {
console.error('Failed to find Product Quote Form input. Page Title:', await page.title()); console.error('Failed to find Product Quote Form input.');
console.log('Page Title:', await page.title());
const bodySnippet = await page.evaluate(() => document.body.innerText.slice(0, 500));
console.log('Page Content Snippet:', bodySnippet);
throw e; throw e;
} }