Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 4 additions & 36 deletions tests/form.spec.ts
Original file line number Diff line number Diff line change
@@ -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"]', '[email protected]');

// // 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', () => {
Expand All @@ -44,11 +13,8 @@ test.describe('Form Submission Tests', () => {
await page.fill('input[name="name"]', 'John Doe');
await page.fill('input[name="email"]', '[email protected]');

// 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 }) => {
Expand Down Expand Up @@ -91,3 +57,5 @@ test.describe('Form Submission Tests', () => {
await expect(page.locator('input[name="email"]')).toHaveValue('');
});
});


Loading