74 lines
2.9 KiB
TypeScript
74 lines
2.9 KiB
TypeScript
import { expect, test, type Page } from "@playwright/test";
|
|
|
|
// The jury guide exists only in a build made with
|
|
// VITE_DEMO_STAND=true. The browser suite builds that way (docker-compose.e2e.yml),
|
|
// while release E2E runs release images built without the flag. The spec
|
|
// reads the build from the landing page and checks the guide where it is
|
|
// served, and its absence where it is not. No demonstration data is needed:
|
|
// the guide only links to screens, and this spec does not sign in.
|
|
|
|
const guideLink = "Открыть гид для жюри";
|
|
const notFound = /Страница не найдена/;
|
|
|
|
async function isDemoBuild(page: Page): Promise<boolean> {
|
|
await page.goto("/");
|
|
await expect(
|
|
page.getByRole("heading", { level: 1, name: "Протокол подтвержденных навыков" }),
|
|
).toBeVisible();
|
|
return (await page.getByRole("link", { name: guideLink }).count()) > 0;
|
|
}
|
|
|
|
test("the start page offers the jury guide only in a demonstration build", async ({ page }) => {
|
|
const demo = await isDemoBuild(page);
|
|
|
|
if (demo) {
|
|
await expect(page.getByRole("heading", { level: 2, name: "Для жюри" })).toBeVisible();
|
|
} else {
|
|
await expect(page.getByRole("heading", { name: "Для жюри" })).toHaveCount(0);
|
|
}
|
|
});
|
|
|
|
test("the guide route serves the memo in a demonstration build and not-found elsewhere", async ({
|
|
page,
|
|
}) => {
|
|
const demo = await isDemoBuild(page);
|
|
await page.goto("/demo");
|
|
|
|
if (!demo) {
|
|
await expect(page.getByRole("heading", { level: 1, name: notFound })).toBeVisible();
|
|
return;
|
|
}
|
|
|
|
await expect(page.getByRole("heading", { level: 1, name: "Гид для жюри" })).toBeVisible();
|
|
await expect(page.getByText("Маршрут для жюри")).toBeVisible();
|
|
await expect(page.getByText(/Демонстрационн/)).toHaveCount(0);
|
|
for (const heading of [
|
|
"Что такое Lincodex",
|
|
"Маршрут за восемь минут",
|
|
"Что работает без имитации",
|
|
"Логины и пароль",
|
|
"Ограничения стенда",
|
|
]) {
|
|
await expect(page.getByRole("heading", { level: 2, name: heading })).toBeVisible();
|
|
}
|
|
await expect(page.getByText("candidate@demo.lincodex.test").first()).toBeVisible();
|
|
await expect(page.getByText("DEMO_ACCOUNT_PASSWORD").first()).toBeVisible();
|
|
});
|
|
|
|
test("every link of the guide opens a page of the application", async ({ page }) => {
|
|
const demo = await isDemoBuild(page);
|
|
test.skip(!demo, "The guide is not served by this build.");
|
|
|
|
await page.goto("/demo");
|
|
const hrefs = await page
|
|
.locator("main ol a[href^='/']")
|
|
.evaluateAll((links) => [...new Set(links.map((link) => link.getAttribute("href") ?? ""))]);
|
|
|
|
expect(hrefs.length).toBeGreaterThan(0);
|
|
for (const href of hrefs) {
|
|
await page.goto(href);
|
|
await expect(page.getByRole("heading", { level: 1 }).first()).toBeVisible();
|
|
await expect(page.getByRole("heading", { level: 1, name: notFound })).toHaveCount(0);
|
|
}
|
|
});
|