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
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:
@@ -34,22 +34,27 @@ async function main() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const contactUrl = urls.find((u) => u.includes('/de/kontakt'));
|
||||
// Ensure we select an actual product page (depth >= 7: http://host/de/produkte/category/product)
|
||||
const contactUrl = urls.find((u) => u.includes('/de/contact') || u.includes('/de/kontakt'));
|
||||
// Ensure we select an actual product page (depth >= 4 segments: /de/produkte/category/product)
|
||||
const productUrl = urls.find(
|
||||
(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) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (!productUrl) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -66,32 +71,34 @@ async function main() {
|
||||
|
||||
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('pageerror', (error: any) => console.error('💻 BROWSER ERROR:', error.message));
|
||||
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
|
||||
console.log(`\n🛡️ Authenticating through Gatekeeper...`);
|
||||
// 3. Authenticate through Gatekeeper via Direct Cookie Insertion
|
||||
console.log(`\n🛡️ Authenticating through Gatekeeper via Cookie Injection...`);
|
||||
try {
|
||||
// Navigate to a protected page so Gatekeeper redirects us to the login screen
|
||||
await page.goto(contactUrl, { waitUntil: 'networkidle0', timeout: 30000 });
|
||||
|
||||
// Check if we landed on the Gatekeeper login page
|
||||
const isGatekeeperPage = await page.$('input[name="password"]');
|
||||
if (isGatekeeperPage) {
|
||||
await page.type('input[name="password"]', gatekeeperPassword);
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle0', timeout: 30000 }),
|
||||
page.click('button[type="submit"]'),
|
||||
]);
|
||||
console.log(`✅ Gatekeeper authentication successful!`);
|
||||
} else {
|
||||
console.log(`✅ Already authenticated (no Gatekeeper gate detected).`);
|
||||
}
|
||||
const domain = new URL(targetUrl).hostname;
|
||||
await page.setCookie({
|
||||
name: 'klz_gatekeeper_session',
|
||||
value: gatekeeperPassword,
|
||||
domain: domain,
|
||||
path: '/',
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
});
|
||||
console.log(`✅ Gatekeeper cookie injected for domain: ${domain}`);
|
||||
} catch (err: any) {
|
||||
console.error(`❌ Gatekeeper authentication failed: ${err.message}`);
|
||||
console.error(`❌ Gatekeeper cookie injection failed: ${err.message}`);
|
||||
await browser.close();
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -114,7 +121,10 @@ async function main() {
|
||||
timeout: 15000,
|
||||
});
|
||||
} 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;
|
||||
}
|
||||
|
||||
@@ -169,7 +179,10 @@ async function main() {
|
||||
timeout: 15000,
|
||||
});
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user