Skip to content

Commit 12380e3

Browse files
Create test-weather.spec.ts
1 parent 1690f3f commit 12380e3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/test-weather.spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { test, expect } from "@playwright/test";
2+
test.describe("Weather Widget", () => {
3+
test("should display current weather", async ({ page, context }) => {
4+
// Mock geolocation to return a fixed location
5+
await context.grantPermissions(["geolocation"]);
6+
await context.setGeolocation({ latitude: 40.7128, longitude: -74.006 });
7+
8+
await page.goto("/form");
9+
10+
// Wait for the weather widget to load
11+
await page.waitForSelector("text=Current Weather", { timeout: 3000 });
12+
13+
// Check if temperature and wind speed are displayed
14+
const temperatureText = await page
15+
.locator("text=Temperature:")
16+
.last()
17+
.textContent();
18+
const windSpeedText = await page
19+
.locator("text=Wind Speed:")
20+
.last()
21+
.textContent();
22+
23+
expect(temperatureText).toMatch(/Temperature: \d+\.\d+°C/);
24+
expect(windSpeedText).toMatch(/Wind Speed: \d+(\.\d+)? km\/h/);
25+
});
26+
});
27+
28+
test.describe("Task List", () => {
29+
test("should allow adding and deleting tasks", async ({ page }) => {
30+
await page.goto("/");
31+
32+
// Add a new task
33+
await page.fill('input[placeholder="Add a new task"]', "Test Task");
34+
await page.click("text=Add Task");
35+
36+
// Verify the task is added
37+
await expect(page.locator("text=Test Task")).toBeVisible();
38+
39+
// Delete the task
40+
await page.click("text=Delete");
41+
42+
// Verify the task is removed
43+
await expect(page.locator("text=Test Task")).not.toBeVisible();
44+
});
45+
});

0 commit comments

Comments
 (0)