44 lines
2.7 KiB
TypeScript
44 lines
2.7 KiB
TypeScript
import AxeBuilder from "@axe-core/playwright";
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
// 1.7.0 (WEBSITE-1.0-PLAN §3, §9): the church's brand style and shared footer on Accounts' public
|
|
// pages. The e2e church (e2e/server.ts) has the "warm" pairing, round corners and service times.
|
|
const PRODUCT = "http://localhost:5211";
|
|
|
|
test("the sign-in page uses the church's fonts and corners, and shows its footer", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=/`);
|
|
await expect(page.getByRole("heading", { name: "Sign in to Hope Family Church" })).toBeVisible();
|
|
await expect(page.locator("html")).toHaveAttribute("data-cc-fonts", "warm");
|
|
await expect(page.locator("html")).toHaveAttribute("data-cc-corners", "round");
|
|
|
|
const heading = page.getByRole("heading", { name: "Sign in to Hope Family Church" });
|
|
expect(await heading.evaluate((el) => getComputedStyle(el).fontFamily)).toContain("CC Fraunces");
|
|
expect(await page.locator("body").evaluate((el) => getComputedStyle(el).fontFamily)).toContain("CC Nunito Sans");
|
|
// The font files themselves load from this site (self-hosted), not from anyone else.
|
|
await page.evaluate(() => document.fonts.ready);
|
|
expect(await page.evaluate(() => document.fonts.check('600 20px "CC Fraunces"'))).toBe(true);
|
|
expect(await page.getByRole("button", { name: "Sign in" }).evaluate((el) => getComputedStyle(el).borderRadius)).toBe("9999px");
|
|
|
|
const footer = page.locator("footer");
|
|
await expect(footer.getByRole("heading", { name: "Service times" })).toBeVisible();
|
|
await expect(footer).toContainText("Sundays 09:00");
|
|
await expect(footer.getByRole("link", { name: "office@hope.test" })).toHaveAttribute("href", "mailto:office@hope.test");
|
|
await expect(footer.getByRole("link", { name: "Website" })).toHaveAttribute("href", PRODUCT);
|
|
await expect(footer.getByRole("link", { name: "Privacy notice" })).toHaveAttribute("href", "/privacy");
|
|
});
|
|
|
|
test("fonts never come from another site", async ({ page }) => {
|
|
const foreign: string[] = [];
|
|
page.on("request", (r) => { if (/\.(woff2?|ttf|otf)(\?|$)/.test(r.url()) && !r.url().startsWith("http://localhost:3210/")) foreign.push(r.url()); });
|
|
await page.goto(`${PRODUCT}/start?returnTo=/`);
|
|
await page.evaluate(() => document.fonts.ready);
|
|
expect(foreign).toEqual([]);
|
|
});
|
|
|
|
test("the sign-in page with the footer passes axe (WCAG 2.2 AA)", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=/`);
|
|
await expect(page.locator("footer")).toBeVisible();
|
|
const results = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]).analyze();
|
|
expect(results.violations.map((v) => `${v.id}: ${v.nodes.map((n) => n.target.join(" ")).join(", ")}`)).toEqual([]);
|
|
});
|