Skip to content

Commit df48f0d

Browse files
Copilotgfauredev
andcommitted
Add Playwright E2E tests using dx serve, remove custom Python server
Co-authored-by: gfauredev <19304085+gfauredev@users.noreply.github.com>
1 parent 31f688c commit df48f0d

5 files changed

Lines changed: 219 additions & 0 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ target
1414

1515
# WebAssembly build output
1616
dist/
17+
18+
# Node.js / Playwright
19+
node_modules/
20+
test-results/
21+
playwright-report/

e2e/app.spec.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
// base_path from Dioxus.toml
4+
const BASE = "/LogOut";
5+
6+
test.describe("Home page", () => {
7+
test("renders title and tagline", async ({ page }) => {
8+
await page.goto(`${BASE}/`);
9+
await expect(page.locator("h1")).toHaveText("💪 LogOut");
10+
await expect(page.locator(".home-tagline")).toHaveText(
11+
"Turn off your computer, Log your workOut"
12+
);
13+
});
14+
15+
test("has navigation links", async ({ page }) => {
16+
await page.goto(`${BASE}/`);
17+
await expect(
18+
page.locator("a", { hasText: "Start New Workout" })
19+
).toBeVisible();
20+
await expect(
21+
page.locator("a", { hasText: "Browse Exercises" })
22+
).toBeVisible();
23+
});
24+
25+
test("navigates to active session page", async ({ page }) => {
26+
await page.goto(`${BASE}/`);
27+
await page.click("a:has-text('Start New Workout')");
28+
await expect(page.locator(".session-header__title")).toContainText(
29+
"Active Session"
30+
);
31+
});
32+
33+
test("navigates to exercise list page", async ({ page }) => {
34+
await page.goto(`${BASE}/`);
35+
await page.click("a:has-text('Browse Exercises')");
36+
await expect(page.locator("h1")).toHaveText("Exercise Database");
37+
});
38+
});
39+
40+
test.describe("Exercise list page", () => {
41+
test("renders with search input", async ({ page }) => {
42+
await page.goto(`${BASE}/exercises`);
43+
await expect(page.locator(".search-input")).toBeVisible();
44+
await expect(page.locator("h1")).toHaveText("Exercise Database");
45+
});
46+
47+
test("has back link to home", async ({ page }) => {
48+
await page.goto(`${BASE}/exercises`);
49+
await page.click("a:has-text('Back')");
50+
await expect(page.locator("h1")).toHaveText("💪 LogOut");
51+
});
52+
});
53+
54+
test.describe("Active session page", () => {
55+
test("renders session header with timer", async ({ page }) => {
56+
await page.goto(`${BASE}/session`);
57+
await expect(page.locator(".session-header__title")).toContainText(
58+
"Active Session"
59+
);
60+
await expect(
61+
page.locator("button", { hasText: "Finish Session" })
62+
).toBeVisible();
63+
});
64+
65+
test("has exercise search input", async ({ page }) => {
66+
await page.goto(`${BASE}/session`);
67+
await expect(
68+
page.locator('input[placeholder="Search for an exercise..."]')
69+
).toBeVisible();
70+
});
71+
72+
test("has analytics button", async ({ page }) => {
73+
await page.goto(`${BASE}/session`);
74+
await expect(
75+
page.locator("button", { hasText: "Analytics" })
76+
).toBeVisible();
77+
});
78+
79+
test("finish session navigates to home", async ({ page }) => {
80+
await page.goto(`${BASE}/session`);
81+
await page.click("button:has-text('Finish Session')");
82+
await expect(page.locator("h1")).toHaveText("💪 LogOut");
83+
});
84+
});

package-lock.json

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "logout",
3+
"version": "1.0.0",
4+
"description": "Turn off your computer, Log your workOut",
5+
"main": "sw.js",
6+
"scripts": {
7+
"test:e2e": "npx playwright test",
8+
"test:e2e:headed": "npx playwright test --headed"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/gfauredev/LogOut.git"
13+
},
14+
"keywords": [],
15+
"author": "",
16+
"license": "ISC",
17+
"type": "commonjs",
18+
"bugs": {
19+
"url": "https://github.com/gfauredev/LogOut/issues"
20+
},
21+
"homepage": "https://github.com/gfauredev/LogOut#readme",
22+
"devDependencies": {
23+
"@playwright/test": "^1.58.2"
24+
}
25+
}

playwright.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { defineConfig } from "@playwright/test";
2+
3+
export default defineConfig({
4+
testDir: "./e2e",
5+
timeout: 30_000,
6+
retries: 1,
7+
use: {
8+
baseURL: "http://localhost:8080",
9+
headless: true,
10+
},
11+
projects: [
12+
{
13+
name: "chromium",
14+
use: { browserName: "chromium" },
15+
},
16+
],
17+
webServer: [
18+
{
19+
command: "dx serve --port 8080",
20+
port: 8080,
21+
timeout: 10 * 60 * 1000,
22+
reuseExistingServer: !process.env.CI,
23+
stdout: "pipe",
24+
},
25+
],
26+
});

0 commit comments

Comments
 (0)