diff --git a/tests/form.spec.ts b/tests/form.spec.ts index dbd4356..bc1b0c5 100644 --- a/tests/form.spec.ts +++ b/tests/form.spec.ts @@ -1,34 +1,3 @@ -// import { test, expect } from '@playwright/test'; - -// test('Form submission works correctly', async ({ page }) => { -// await page.goto('/form'); - -// // Ensure form elements are present -// await expect(page.locator('input[placeholder="Enter your name"]')).toBeVisible(); -// await expect(page.locator('input[placeholder="Enter your email"]')).toBeVisible(); -// await expect(page.locator('button[type="submit"]')).toHaveText('Submit'); - -// // Fill out the form -// await page.fill('input[placeholder="Enter your name"]', 'John Doe'); -// await page.fill('input[placeholder="Enter your email"]', 'john@example.com'); - -// // Submit the form -// await page.click('button[type="submit"]'); - -// // Wait for success message -// await expect(page.locator('p')).toHaveText('Thank you, John Doe!'); -// }); - -// test('Shows validation error if fields are missing', async ({ page }) => { -// await page.goto('/form'); - -// // Try to submit without filling anything -// await page.click('button[type="submit"]'); - -// // Expect an error message -// await expect(page.locator('p')).toHaveText('Submission failed. Please try again.'); -// }); - import { test, expect } from '@playwright/test'; test.describe('Form Submission Tests', () => { @@ -44,11 +13,8 @@ test.describe('Form Submission Tests', () => { await page.fill('input[name="name"]', 'John Doe'); await page.fill('input[name="email"]', 'john@example.com'); - // Submit the form - await page.click('button[type="submit"]'); - - // Expect success message - await expect(page.locator('#message')).toHaveText(`Hello John Doe, your form has been submitted successfully!`); + // Intentionally fail this expectation + await expect(page.locator('#message')).toHaveText(`This message does not exist`); }); test('❌ Shows validation error if fields are missing', async ({ page }) => { @@ -91,3 +57,5 @@ test.describe('Form Submission Tests', () => { await expect(page.locator('input[name="email"]')).toHaveValue(''); }); }); + +