|
1 | | -// import { test, expect } from '@playwright/test'; |
2 | | - |
3 | | -// test('Form submission works correctly', async ({ page }) => { |
4 | | -// await page.goto('/form'); |
5 | | - |
6 | | -// // Ensure form elements are present |
7 | | -// await expect(page.locator('input[placeholder="Enter your name"]')).toBeVisible(); |
8 | | -// await expect(page.locator('input[placeholder="Enter your email"]')).toBeVisible(); |
9 | | -// await expect(page.locator('button[type="submit"]')).toHaveText('Submit'); |
10 | | - |
11 | | -// // Fill out the form |
12 | | -// await page.fill('input[placeholder="Enter your name"]', 'John Doe'); |
13 | | -// await page.fill('input[placeholder="Enter your email"]', '[email protected]'); |
14 | | - |
15 | | -// // Submit the form |
16 | | -// await page.click('button[type="submit"]'); |
17 | | - |
18 | | -// // Wait for success message |
19 | | -// await expect(page.locator('p')).toHaveText('Thank you, John Doe!'); |
20 | | -// }); |
21 | | - |
22 | | -// test('Shows validation error if fields are missing', async ({ page }) => { |
23 | | -// await page.goto('/form'); |
24 | | - |
25 | | -// // Try to submit without filling anything |
26 | | -// await page.click('button[type="submit"]'); |
27 | | - |
28 | | -// // Expect an error message |
29 | | -// await expect(page.locator('p')).toHaveText('Submission failed. Please try again.'); |
30 | | -// }); |
31 | | - |
32 | 1 | import { test, expect } from "@playwright/test"; |
33 | 2 |
|
34 | 3 | test.describe("Form Submission Tests", () => { |
@@ -95,3 +64,38 @@ test.describe("Form Submission Tests", () => { |
95 | 64 | await expect(page.locator('input[name="email"]')).toHaveValue(""); |
96 | 65 | }); |
97 | 66 | }); |
| 67 | + |
| 68 | +test.describe("Weather Widget", () => { |
| 69 | + test("should display current weather", async ({ page }) => { |
| 70 | + await page.goto("/form"); |
| 71 | + |
| 72 | + // Wait for the weather widget to load |
| 73 | + await page.waitForSelector("text=Current Weather"); |
| 74 | + |
| 75 | + // Check if temperature and wind speed are displayed |
| 76 | + const temperature = await page.locator("text=Temperature:").isVisible(); |
| 77 | + const windSpeed = await page.locator("text=Wind Speed:").isVisible(); |
| 78 | + |
| 79 | + expect(temperature).toBeTruthy(); |
| 80 | + expect(windSpeed).toBeTruthy(); |
| 81 | + }); |
| 82 | +}); |
| 83 | + |
| 84 | +test.describe("Task List", () => { |
| 85 | + test("should allow adding and deleting tasks", async ({ page }) => { |
| 86 | + await page.goto("/"); |
| 87 | + |
| 88 | + // Add a new task |
| 89 | + await page.fill('input[placeholder="Add a new task"]', "Test Task"); |
| 90 | + await page.click("text=Add Task"); |
| 91 | + |
| 92 | + // Verify the task is added |
| 93 | + await expect(page.locator("text=Test Task")).toBeVisible(); |
| 94 | + |
| 95 | + // Delete the task |
| 96 | + await page.click("text=Delete"); |
| 97 | + |
| 98 | + // Verify the task is removed |
| 99 | + await expect(page.locator("text=Test Task")).not.toBeVisible(); |
| 100 | + }); |
| 101 | +}); |
0 commit comments