fix(e2e): await hydration before form submits, skip cleanup on 403
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 2m27s
Build & Deploy / 🏗️ Build (push) Successful in 4m49s
Build & Deploy / 🚀 Deploy (push) Successful in 14s
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 2m27s
Build & Deploy / 🏗️ Build (push) Successful in 4m49s
Build & Deploy / 🚀 Deploy (push) Successful in 14s
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
fix(blog): bypass image optimization for post feature image chore(release): bump version to 2.2.7
This commit is contained in:
@@ -98,7 +98,7 @@ async function main() {
|
||||
await page.goto(contactUrl, { waitUntil: 'networkidle0', timeout: 30000 });
|
||||
|
||||
// Ensure React has hydrated completely
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => {});
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => { });
|
||||
|
||||
// Ensure form is visible and interactive
|
||||
try {
|
||||
@@ -109,6 +109,9 @@ async function main() {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Wait specifically for hydration logic to initialize the onSubmit handler
|
||||
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');
|
||||
@@ -117,6 +120,9 @@ async function main() {
|
||||
'This is an automated test verifying the contact form submission.',
|
||||
);
|
||||
|
||||
// Give state a moment to settle
|
||||
await page.evaluate(() => new Promise((resolve) => setTimeout(resolve, 500)));
|
||||
|
||||
console.log(` Submitting Contact Form...`);
|
||||
|
||||
// Explicitly click submit and wait for navigation/state-change
|
||||
@@ -137,7 +143,7 @@ async function main() {
|
||||
await page.goto(productUrl, { waitUntil: 'networkidle0', timeout: 30000 });
|
||||
|
||||
// Ensure React has hydrated completely
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => {});
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => { });
|
||||
|
||||
// The product form uses dynamic IDs, so we select by input type in the specific form context
|
||||
try {
|
||||
@@ -147,6 +153,9 @@ async function main() {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Wait specifically for hydration logic to initialize the onSubmit handler
|
||||
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(
|
||||
@@ -154,6 +163,9 @@ async function main() {
|
||||
'Automated request for product quote via E2E testing framework.',
|
||||
);
|
||||
|
||||
// Give state a moment to settle
|
||||
await page.evaluate(() => new Promise((resolve) => setTimeout(resolve, 500)));
|
||||
|
||||
console.log(` Submitting Product Quote Form...`);
|
||||
|
||||
// Submit and wait for success state
|
||||
@@ -189,11 +201,16 @@ async function main() {
|
||||
});
|
||||
console.log(` ✅ Deleted submission: ${doc.id}`);
|
||||
} catch (delErr: any) {
|
||||
console.error(` ❌ Failed to delete submission ${doc.id}: ${delErr.message}`);
|
||||
// Log but don't fail, 403s on Directus / Payload APIs for guest Gatekeeper sessions are normal
|
||||
console.warn(` ⚠️ Cleanup attempt on ${doc.id} returned an error, typically due to API Auth separation: ${delErr.message}`);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error(`❌ Cleanup failed: ${err.message}`);
|
||||
if (err.response?.status === 403) {
|
||||
console.warn(` ⚠️ Cleanup fetch failed with 403 Forbidden. This is expected if the runner lacks admin API credentials. Test submissions remain in the database.`);
|
||||
} else {
|
||||
console.error(` ❌ Cleanup fetch failed: ${err.message}`);
|
||||
}
|
||||
// Don't mark the whole test as failed just because cleanup failed
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user