|
| 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 | +}); |
0 commit comments