diff --git a/scripts/check-forms.ts b/scripts/check-forms.ts index 1ad226f6..224668ab 100644 --- a/scripts/check-forms.ts +++ b/scripts/check-forms.ts @@ -143,11 +143,12 @@ async function main() { const alertText = await page.$eval('[role="alert"]', (el) => el.textContent); console.log(` Alert text: ${alertText}`); - if (alertText?.includes('Failed') || alertText?.includes('went wrong')) { - throw new Error(`Form submitted but showed error: ${alertText}`); + const errorKeywords = ['Failed', 'went wrong', 'fehlgeschlagen', 'schief gelaufen']; + if (errorKeywords.some((kw) => alertText?.toLowerCase().includes(kw.toLowerCase()))) { + throw new Error(`Form submitted but showed error state: ${alertText}`); } - console.log(`✅ Contact Form submitted successfully! (Success state verified)`); + console.log(`✅ Contact Form submitted successfully! (Success state verified via alert text)`); } catch (err: any) { console.error(`❌ Contact Form Test Failed: ${err.message}`); hasErrors = true; @@ -196,11 +197,14 @@ async function main() { const alertText = await page.$eval('[role="alert"]', (el) => el.textContent); console.log(` Alert text: ${alertText}`); - if (alertText?.includes('Failed') || alertText?.includes('went wrong')) { - throw new Error(`Form submitted but showed error: ${alertText}`); + const errorKeywords = ['Failed', 'went wrong', 'fehlgeschlagen', 'schief gelaufen']; + if (errorKeywords.some((kw) => alertText?.toLowerCase().includes(kw.toLowerCase()))) { + throw new Error(`Product Quote Form submitted but showed error state: ${alertText}`); } - console.log(`✅ Product Quote Form submitted successfully! (Success state verified)`); + console.log( + `✅ Product Quote Form submitted successfully! (Success state verified via alert text)`, + ); } catch (err: any) { console.error(`❌ Product Quote Form Test Failed: ${err.message}`); hasErrors = true;