Skip to content

Commit 8f63cbb

Browse files
feat: update Weather Widget test to reduce timeout and validate weather data format
1 parent 20b9fd1 commit 8f63cbb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/form.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,20 @@ test.describe("Weather Widget", () => {
7474
await page.goto("/form");
7575

7676
// Wait for the weather widget to load
77-
await page.waitForSelector("text=Current Weather", { timeout: 5000 });
77+
await page.waitForSelector("text=Current Weather", { timeout: 3000 });
7878

7979
// Check if temperature and wind speed are displayed
80-
const temperature = await page.locator("text=Temperature:").isVisible();
81-
const windSpeed = await page.locator("text=Wind Speed:").isVisible();
82-
83-
expect(temperature).toBeTruthy();
84-
expect(windSpeed).toBeTruthy();
80+
const temperatureText = await page
81+
.locator("text=Temperature:")
82+
.last()
83+
.textContent();
84+
const windSpeedText = await page
85+
.locator("text=Wind Speed:")
86+
.last()
87+
.textContent();
88+
89+
expect(temperatureText).toMatch(/Temperature: \d+\.\d+°C/);
90+
expect(windSpeedText).toMatch(/Wind Speed: \d+\.\d+ km\/h/);
8591
});
8692
});
8793

0 commit comments

Comments
 (0)