|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | + |
| 3 | +test("all primary pages load and are not blank", async ({ page }) => { |
| 4 | + await page.goto("/login"); |
| 5 | + |
| 6 | + await page.getByLabel("Email").fill("navigation@example.com"); |
| 7 | + await page.getByLabel("Password").fill("password123"); |
| 8 | + await page.getByRole("button", { name: "Sign in" }).click(); |
| 9 | + |
| 10 | + const checks = [ |
| 11 | + { link: "Dashboard", pathSuffix: "/", heading: /^dashboard$/i }, |
| 12 | + { link: "Problems", pathSuffix: "/problems", heading: /^problems$/i }, |
| 13 | + { |
| 14 | + link: "Competitions", |
| 15 | + pathSuffix: "/competitions", |
| 16 | + heading: /^competitions$/i, |
| 17 | + }, |
| 18 | + { link: "Learn", pathSuffix: "/learn", heading: /^learn$/i }, |
| 19 | + { link: "Progress", pathSuffix: "/progress", heading: /^progress$/i }, |
| 20 | + ]; |
| 21 | + |
| 22 | + for (const item of checks) { |
| 23 | + await page.getByRole("link", { name: item.link }).click(); |
| 24 | + await expect(page).toHaveURL(new RegExp(`${item.pathSuffix}$`)); |
| 25 | + await expect(page.getByRole("heading", { name: item.heading })).toBeVisible(); |
| 26 | + } |
| 27 | +}); |
| 28 | + |
| 29 | +test("problem arena route opens from problems list", async ({ page }) => { |
| 30 | + await page.goto("/login"); |
| 31 | + |
| 32 | + await page.getByLabel("Email").fill("arena@example.com"); |
| 33 | + await page.getByLabel("Password").fill("password123"); |
| 34 | + await page.getByRole("button", { name: "Sign in" }).click(); |
| 35 | + |
| 36 | + await page.getByRole("link", { name: "Problems" }).click(); |
| 37 | + await page.getByText("KNN Classifier on Iris", { exact: false }).first().click(); |
| 38 | + |
| 39 | + await expect(page).toHaveURL(/\/problems\/knn-classifier-iris/); |
| 40 | + await expect( |
| 41 | + page.getByRole("heading", { name: /knn classifier on iris/i }) |
| 42 | + ).toBeVisible(); |
| 43 | +}); |
| 44 | + |
| 45 | +test("topics in sidebar navigate to filtered problems", async ({ page }) => { |
| 46 | + await page.goto("/login"); |
| 47 | + |
| 48 | + await page.getByLabel("Email").fill("topics@example.com"); |
| 49 | + await page.getByLabel("Password").fill("password123"); |
| 50 | + await page.getByRole("button", { name: "Sign in" }).click(); |
| 51 | + |
| 52 | + await page.getByRole("link", { name: "Learn" }).click(); |
| 53 | + await page.getByRole("button", { name: "Data Preprocessing" }).click(); |
| 54 | + |
| 55 | + await expect(page).toHaveURL(/\/problems\?category=Data\+Preprocessing$/); |
| 56 | + await expect(page.getByRole("heading", { name: /^problems$/i })).toBeVisible(); |
| 57 | +}); |
0 commit comments