- Accounts: account and admin pages in Cross Events' layout (top bar, sidebar, a page per section, dark footer); quick links to the church's sites (GET /me/apps); nightly pg_dump backups with Admin -> Backups (run, keep, download, audited; heartbeat lastBackupAt); a fuller built-in privacy notice with headings and bullets; a fixed favicon. /backups/ ignored (anchored, so src/backups is kept). - Contracts 1.11.0: people.removeDemo (only @example.com, never an admin). - Events: uploads served from the folder they're saved in (a backend started outside backend/ answered 404 for a logo it had just saved); Branding checks the file loads before saving; logout waits for the sign-out call so Accounts signs out too; set-demo removes the last demo's people from Accounts. Tests: Accounts 62 + e2e 8, Events 782, contracts 225; npm run check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
6.9 KiB
TypeScript
112 lines
6.9 KiB
TypeScript
import { expect, test, type Page } from "@playwright/test";
|
|
|
|
// The release checks (ROADMAP-v3 §9) on Accounts' real pages: signing in from a deep link lands
|
|
// back on that page, through sign-up, a password reset and two-step sign-in set up on the way; a
|
|
// foreign return address is refused. A test product (e2e/server.ts) starts and finishes sign-ins.
|
|
const PRODUCT = "http://localhost:5211";
|
|
const helper = async (page: Page, path: string) => (await (await page.request.get(`${PRODUCT}${path}`)).text()).trim();
|
|
|
|
async function signIn(page: Page, email: string, password = "Correct-horse-1") {
|
|
await page.getByLabel("Email address").fill(email);
|
|
await page.getByLabel("Password").fill(password);
|
|
await page.getByRole("button", { name: "Sign in" }).click();
|
|
}
|
|
|
|
test("signing in from a deep link returns to that exact page", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=${encodeURIComponent("/events/youth-camp/register?ticket=adult")}`);
|
|
await expect(page.getByRole("heading", { name: "Sign in to Hope Family Church" })).toBeVisible();
|
|
await signIn(page, "thandi@hope.test");
|
|
await expect(page.locator("#return")).toHaveText("/events/youth-camp/register?ticket=adult");
|
|
await expect(page.locator("#email")).toHaveText("thandi@hope.test");
|
|
});
|
|
|
|
test("a wrong password says so without saying whether the account exists", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=/`);
|
|
await signIn(page, "thandi@hope.test", "not-the-password");
|
|
await expect(page.locator("main").getByRole("alert")).toHaveText("That email address and password don't match.");
|
|
await signIn(page, "nobody@hope.test", "not-the-password");
|
|
await expect(page.locator("main").getByRole("alert")).toHaveText("That email address and password don't match.");
|
|
});
|
|
|
|
test("a foreign return address ends on the product's home page", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=${encodeURIComponent("//evil.example/steal")}`);
|
|
await signIn(page, "thandi@hope.test");
|
|
await expect(page.locator("#return")).toHaveText("/");
|
|
});
|
|
|
|
test("sign-up with an emailed code, back to the page", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=${encodeURIComponent("/give?fund=building")}`);
|
|
await page.getByRole("button", { name: "Create an account" }).click();
|
|
await page.getByLabel("Your name").fill("New Person");
|
|
await page.getByLabel("Email address").fill("new@hope.test");
|
|
await page.getByLabel("Password").fill("Correct-horse-2");
|
|
await page.getByLabel(/privacy notice/).check();
|
|
await page.getByRole("button", { name: "Create account" }).click();
|
|
await expect(page.getByRole("heading", { name: "Check your email" })).toBeVisible();
|
|
await page.getByLabel("Code").fill(await helper(page, "/test/code?to=new@hope.test"));
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
await expect(page.locator("#return")).toHaveText("/give?fund=building");
|
|
await expect(page.locator("#email")).toHaveText("new@hope.test");
|
|
});
|
|
|
|
test("forgot password in the middle of signing in still returns to the page", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?returnTo=/my-tickets`);
|
|
await page.getByRole("link", { name: "Forgot your password?" }).click();
|
|
await page.getByLabel("Email address").fill("thandi@hope.test");
|
|
await page.getByRole("button", { name: "Send the link" }).click();
|
|
await expect(page.getByRole("status")).toContainText("a link is on its way");
|
|
await page.goto(await helper(page, "/test/link?to=thandi@hope.test"));
|
|
await page.getByLabel("New password").fill("Correct-horse-1");
|
|
await page.getByRole("button", { name: "Save and sign in" }).click();
|
|
await signIn(page, "thandi@hope.test");
|
|
await expect(page.locator("#return")).toHaveText("/my-tickets");
|
|
});
|
|
|
|
test("a product asking for two-step sign-in: set up with an app, recovery codes, then back", async ({ page }) => {
|
|
await page.goto(`${PRODUCT}/start?mfa=1&returnTo=/dashboard`);
|
|
await signIn(page, "thandi@hope.test");
|
|
await expect(page.getByRole("heading", { name: "Set up two-step sign-in" })).toBeVisible();
|
|
await page.getByRole("button", { name: /An authenticator app/ }).click();
|
|
const key = (await page.getByText(/Or type this key:/).innerText()).replace(/.*:\s*/, "").trim();
|
|
await page.getByLabel("Code").fill(await helper(page, `/test/totp?secret=${key}`));
|
|
await page.getByRole("button", { name: "Turn on" }).click();
|
|
await expect(page.getByRole("heading", { name: "Save your recovery codes" })).toBeVisible();
|
|
await page.getByRole("button", { name: "I've saved them" }).click();
|
|
await expect(page.locator("#return")).toHaveText("/dashboard");
|
|
await expect(page.locator("#amr")).toHaveText("pwd otp mfa");
|
|
});
|
|
|
|
test("the account page: signs in first, links to the church's sites, then saves details", async ({ page }) => {
|
|
await page.goto("/account");
|
|
await expect(page.getByRole("heading", { name: "Sign in to Hope Family Church" })).toBeVisible();
|
|
await page.getByLabel("Email address").fill("new@hope.test");
|
|
await page.getByLabel("Password").fill("Correct-horse-2");
|
|
await page.getByRole("button", { name: "Sign in" }).click();
|
|
await expect(page.getByRole("heading", { name: "Hi, New" })).toBeVisible();
|
|
// 1.3.0: a quick link to each site that signs in here (the test product is a website).
|
|
await expect(page.getByRole("link", { name: /Website/ })).toHaveAttribute("href", "http://localhost:5211/");
|
|
await page.getByRole("navigation", { name: "Your account" }).getByRole("link", { name: "Your details" }).click();
|
|
await expect(page).toHaveURL(/\/account\/details$/);
|
|
await page.getByLabel("Name").fill("New Person-Smith");
|
|
await page.getByRole("button", { name: "Save", exact: true }).click();
|
|
await expect(page.getByRole("status")).toContainText("Your details are saved");
|
|
});
|
|
|
|
test("admin: needs two-step sign-in, then lists people", async ({ page }) => {
|
|
await page.goto("/admin");
|
|
await signIn(page, "admin@hope.test");
|
|
await expect(page.getByRole("heading", { name: "Set up two-step sign-in" })).toBeVisible();
|
|
await expect(page.getByText("Admins must use a second step")).toBeVisible();
|
|
await page.getByRole("button", { name: /An authenticator app/ }).click();
|
|
const key = (await page.getByText(/Or type this key:/).innerText()).replace(/.*:\s*/, "").trim();
|
|
await page.getByLabel("Code").fill(await helper(page, `/test/totp?secret=${key}`));
|
|
await page.getByRole("button", { name: "Turn on" }).click();
|
|
await page.getByRole("button", { name: "I've saved them" }).click();
|
|
await expect(page.getByRole("heading", { name: "People", level: 1 })).toBeVisible();
|
|
await expect(page.getByText("thandi@hope.test")).toBeVisible();
|
|
// 1.3.0: every admin section has its own address, down the side; Backups is one.
|
|
await page.getByRole("navigation", { name: "Admin" }).getByRole("link", { name: "Backups" }).click();
|
|
await expect(page.getByRole("heading", { name: "Database backups" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Back up now" })).toBeVisible();
|
|
});
|