Skip to content

Commit 20b9fd1

Browse files
feat: enhance Weather Widget test to mock geolocation and increase timeout
1 parent 768b763 commit 20b9fd1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ yarn-error.log*
4040
*.tsbuildinfo
4141
next-env.d.ts
4242

43-
tests/reports
43+
tests/reports
44+
playwright-report

tests/form.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ test.describe("Form Submission Tests", () => {
6666
});
6767

6868
test.describe("Weather Widget", () => {
69-
test("should display current weather", async ({ page }) => {
69+
test("should display current weather", async ({ page, context }) => {
70+
// Mock geolocation to return a fixed location
71+
await context.grantPermissions(["geolocation"]);
72+
await context.setGeolocation({ latitude: 40.7128, longitude: -74.006 });
73+
7074
await page.goto("/form");
7175

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

7579
// Check if temperature and wind speed are displayed
7680
const temperature = await page.locator("text=Temperature:").isVisible();

0 commit comments

Comments
 (0)