Skip to content
File

Blob: tests/e2e/specs/04-profile-and-signout.spec.ts

typescript33 lines
1import { LOGIN_URL_PATTERN, test, expect, loginViaUi } from "../fixtures/anvil-test";
2 
3test.describe("Profile and sign out", () => {
4 test("can view profile page", async ({ livePage, e2eContext, operatorIdentity }) => {
5 await loginViaUi(livePage, e2eContext, operatorIdentity);
6 
7 await livePage.goto("/app/me");
8 
9 await expect(livePage.getByRole("heading", { name: "Profile & Settings" })).toBeVisible();
10 
11 // Use heading role to distinguish from the user menu button which also shows the name.
12 await expect(livePage.getByRole("heading", { name: operatorIdentity.displayName })).toBeVisible();
13 await expect(livePage.getByText(operatorIdentity.email)).toBeVisible();
14 await expect(livePage.getByText(`@${operatorIdentity.slug}`)).toBeVisible();
15 });
16 
17 test("can sign out and is redirected to login", async ({ livePage, e2eContext, operatorIdentity }) => {
18 await loginViaUi(livePage, e2eContext, operatorIdentity);
19 
20 await livePage.goto("/app/me");
21 await livePage.getByRole("button", { name: "Sign Out" }).click();
22 const confirmDialog = livePage.getByRole("dialog", { name: "Sign out?" });
23 await expect(confirmDialog).toBeVisible();
24 await confirmDialog.getByRole("button", { name: "Sign Out" }).click();
25 
26 await livePage.waitForURL(LOGIN_URL_PATTERN);
27 
28 // Session should be cleared — navigating to a protected route redirects back.
29 await livePage.goto("/app/projects");
30 await livePage.waitForURL(LOGIN_URL_PATTERN);
31 });
32});