forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

auth-shell.spec.ts33 lines, 1.6 KiBHistoryRawDownload
1import { expect, test } from "@playwright/test";
2
3const schoolId = process.env.E2E_SCHOOL_ID;
4const username = process.env.E2E_ADMIN_USERNAME ?? "admin";
5const password = process.env.E2E_ADMIN_PASSWORD ?? "admin123";
6
7test("sign-in reaches the authenticated shell with keyboard-accessible navigation", async ({ page }) => {
8 await page.goto("/login");
9 await expect(page.locator("#login-username")).toBeVisible();
10 await page.locator("#login-username").fill(username);
11 await page.locator("#login-password").fill(password);
12 await page.locator("form").getByRole("button", { name: /log in|sign in|giriş yap/i }).click();
13
14 const chooser = page.getByRole("heading", { name: /choose your school|okulunu seç/i });
15 const shell = page.getByRole("main");
16 await expect(chooser.or(shell)).toBeVisible();
17 if (await chooser.isVisible()) {
18 if (!schoolId) throw new Error("login returned a school chooser; set E2E_SCHOOL_ID to the school uuid");
19 await page.getByRole("button", { name: schoolId }).click();
20 }
21
22 await expect(page).toHaveURL(/\/$/);
23 await expect(page.getByRole("main")).toBeVisible();
24
25 // The mobile tab bar is absent on desktop but must be reachable and named on
26 // a touch viewport. This catches accidental removal of its accessible nav.
27 if (test.info().project.name === "mobile") {
28 const navigation = page.getByRole("navigation", { name: /menu|menü/i });
29 await expect(navigation).toBeVisible();
30 await navigation.getByRole("button", { name: /account|hesap/i }).focus();
31 await expect(navigation.getByRole("button", { name: /account|hesap/i })).toBeFocused();
32 }
33});