Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

tests/reports
tests/reports
playwright-report
10 changes: 4 additions & 6 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { defineConfig } from '@playwright/test';
import { defineConfig } from "@playwright/test";

export default defineConfig({
webServer: {
command: 'npm run dev',
command: "npm run dev",
port: 3000,
reuseExistingServer: true,
},
reporter: [
['list'],
['html', { outputFolder: 'playwright-report' }]
],
workers: 4, // Specify the number of workers
reporter: [["list"], ["html", { outputFolder: "playwright-report" }]],
});
76 changes: 45 additions & 31 deletions tests/form.spec.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
// import { test, expect } from '@playwright/test';

// test('Form submission works correctly', async ({ page }) => {
// await page.goto('/form');

// // Ensure form elements are present
// await expect(page.locator('input[placeholder="Enter your name"]')).toBeVisible();
// await expect(page.locator('input[placeholder="Enter your email"]')).toBeVisible();
// await expect(page.locator('button[type="submit"]')).toHaveText('Submit');

// // Fill out the form
// await page.fill('input[placeholder="Enter your name"]', 'John Doe');
// await page.fill('input[placeholder="Enter your email"]', '[email protected]');

// // Submit the form
// await page.click('button[type="submit"]');

// // Wait for success message
// await expect(page.locator('p')).toHaveText('Thank you, John Doe!');
// });

// test('Shows validation error if fields are missing', async ({ page }) => {
// await page.goto('/form');

// // Try to submit without filling anything
// await page.click('button[type="submit"]');

// // Expect an error message
// await expect(page.locator('p')).toHaveText('Submission failed. Please try again.');
// });

import { test, expect } from "@playwright/test";

test.describe("Form Submission Tests", () => {
Expand Down Expand Up @@ -95,3 +64,48 @@ test.describe("Form Submission Tests", () => {
await expect(page.locator('input[name="email"]')).toHaveValue("");
});
});

test.describe("Weather Widget", () => {
test("should display current weather", async ({ page, context }) => {
// Mock geolocation to return a fixed location
await context.grantPermissions(["geolocation"]);
await context.setGeolocation({ latitude: 40.7128, longitude: -74.006 });

await page.goto("/form");

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

// Check if temperature and wind speed are displayed
const temperatureText = await page
.locator("text=Temperature:")
.last()
.textContent();
const windSpeedText = await page
.locator("text=Wind Speed:")
.last()
.textContent();

expect(temperatureText).toMatch(/Temperature: \d+\.\d+°C/);
expect(windSpeedText).toMatch(/Wind Speed: \d+\.\d+ km\/h/);
});
});

test.describe("Task List", () => {
test("should allow adding and deleting tasks", async ({ page }) => {
await page.goto("/");

// Add a new task
await page.fill('input[placeholder="Add a new task"]', "Test Task");
await page.click("text=Add Task");

// Verify the task is added
await expect(page.locator("text=Test Task")).toBeVisible();

// Delete the task
await page.click("text=Delete");

// Verify the task is removed
await expect(page.locator("text=Test Task")).not.toBeVisible();
});
});
Loading