Skip to content

Commit 768b763

Browse files
feat: implement form submission tests and add weather widget and task list tests
1 parent 3438192 commit 768b763

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

tests/form.spec.ts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,3 @@
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-
321
import { test, expect } from "@playwright/test";
332

343
test.describe("Form Submission Tests", () => {
@@ -95,3 +64,38 @@ test.describe("Form Submission Tests", () => {
9564
await expect(page.locator('input[name="email"]')).toHaveValue("");
9665
});
9766
});
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

Comments
 (0)