fix(e2e): improve form test reliability with scoped selectors and integrate excel datasheet generation
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 32s
Build & Deploy / 🧪 QA (push) Successful in 3m27s
Build & Deploy / 🏗️ Build (push) Failing after 3m47s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 32s
Build & Deploy / 🧪 QA (push) Successful in 3m27s
Build & Deploy / 🏗️ Build (push) Failing after 3m47s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
This commit is contained in:
@@ -67,7 +67,7 @@ async function main() {
|
||||
const page = await browser.newPage();
|
||||
|
||||
page.on('console', (msg) => console.log('💻 BROWSER CONSOLE:', msg.text()));
|
||||
page.on('pageerror', (error) => console.error('💻 BROWSER ERROR:', error.message));
|
||||
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);
|
||||
});
|
||||
@@ -109,7 +109,10 @@ async function main() {
|
||||
// Ensure form is visible and interactive
|
||||
try {
|
||||
// Find the form input by name
|
||||
await page.waitForSelector('input[name="name"]', { visible: true, timeout: 15000 });
|
||||
await page.waitForSelector('form#contact-form input[name="name"]', {
|
||||
visible: true,
|
||||
timeout: 15000,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Failed to find Contact Form input. Page Title:', await page.title());
|
||||
throw e;
|
||||
@@ -119,10 +122,10 @@ async function main() {
|
||||
await page.evaluate(() => new Promise((resolve) => setTimeout(resolve, 2000)));
|
||||
|
||||
// Fill form fields
|
||||
await page.type('input[name="name"]', 'Automated E2E Test');
|
||||
await page.type('input[name="email"]', 'testing@mintel.me');
|
||||
await page.type('form#contact-form input[name="name"]', 'Automated E2E Test');
|
||||
await page.type('form#contact-form input[name="email"]', 'testing@mintel.me');
|
||||
await page.type(
|
||||
'textarea[name="message"]',
|
||||
'form#contact-form textarea[name="message"]',
|
||||
'This is an automated test verifying the contact form submission.',
|
||||
);
|
||||
|
||||
@@ -131,10 +134,10 @@ async function main() {
|
||||
|
||||
console.log(` Submitting Contact Form...`);
|
||||
|
||||
// Explicitly click submit and wait for navigation/state-change
|
||||
// Explicitly click submit and wait for success state (using the success Card role="alert")
|
||||
await Promise.all([
|
||||
page.waitForSelector('[role="alert"]', { timeout: 15000 }),
|
||||
page.click('button[type="submit"]'),
|
||||
page.click('form#contact-form button[type="submit"]'),
|
||||
]);
|
||||
|
||||
const alertText = await page.$eval('[role="alert"]', (el) => el.textContent);
|
||||
@@ -160,7 +163,10 @@ async function main() {
|
||||
|
||||
// The product form uses dynamic IDs, so we select by input type in the specific form context
|
||||
try {
|
||||
await page.waitForSelector('form input[type="email"]', { visible: true, timeout: 15000 });
|
||||
await page.waitForSelector('form#quote-request-form input[type="email"]', {
|
||||
visible: true,
|
||||
timeout: 15000,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Failed to find Product Quote Form input. Page Title:', await page.title());
|
||||
throw e;
|
||||
@@ -170,9 +176,9 @@ async function main() {
|
||||
await page.evaluate(() => new Promise((resolve) => setTimeout(resolve, 2000)));
|
||||
|
||||
// In RequestQuoteForm, the email input is type="email" and message is a textarea.
|
||||
await page.type('form input[type="email"]', 'testing@mintel.me');
|
||||
await page.type('form#quote-request-form input[type="email"]', 'testing@mintel.me');
|
||||
await page.type(
|
||||
'form textarea',
|
||||
'form#quote-request-form textarea',
|
||||
'Automated request for product quote via E2E testing framework.',
|
||||
);
|
||||
|
||||
@@ -184,7 +190,7 @@ async function main() {
|
||||
// Submit and wait for success state
|
||||
await Promise.all([
|
||||
page.waitForSelector('[role="alert"]', { timeout: 15000 }),
|
||||
page.click('form button[type="submit"]'),
|
||||
page.click('form#quote-request-form button[type="submit"]'),
|
||||
]);
|
||||
|
||||
const alertText = await page.$eval('[role="alert"]', (el) => el.textContent);
|
||||
|
||||
Reference in New Issue
Block a user