User banning
banned user is redirected to suspended page and cannot access site
Renders//admin/suspended
Admin ban page Act
Open the admin ban page
await adminBan.goto();
Ban user “N-ZAP”, reason “Test ban reason”
await adminBan.banUser("N-ZAP", { reason: "Test ban reason" });
Act
Go to “/”
await navigate({ page, url: "/" });
Assert
the page URL is SUSPENDED_PAGE
await expect(page).toHaveURL(SUSPENDED_PAGE);
Suspended page Assert
heading is visible
await expect(suspended.locators.heading).toBeVisible();
reason “Test ban reason” is visible
await expect(suspended.reason("Test ban reason")).toBeVisible();no end time is visible
await expect(suspended.locators.noEndTime).toBeVisible();
Act
Go to “/builds”
await navigate({ page, url: "/builds" });
Assert
the page URL is SUSPENDED_PAGE
await expect(page).toHaveURL(SUSPENDED_PAGE);
Act
Go to “/calendar”
await navigate({ page, url: "/calendar" });
Assert
the page URL is SUSPENDED_PAGE
await expect(page).toHaveURL(SUSPENDED_PAGE);
Admin ban page Act
Open the admin ban page
await adminBan.goto();
Unban user “N-ZAP”
await adminBan.unbanUser("N-ZAP");
Act
Go to “/”
await navigate({ page, url: "/" });
Assert
the page URL is not SUSPENDED_PAGE
await expect(page).not.toHaveURL(SUSPENDED_PAGE);
Source
test("banned user is redirected to suspended page and cannot access site", async ({
page,
}) => {
await impersonate(page, ADMIN_ID);
const adminBan = new AdminBanPage(page);
await adminBan.goto();
await adminBan.banUser("N-ZAP", { reason: "Test ban reason" });
await impersonate(page, NZAP_TEST_ID);
await navigate({ page, url: "/" });
const suspended = new SuspendedPage(page);
await expect(page).toHaveURL(SUSPENDED_PAGE);
await expect(suspended.locators.heading).toBeVisible();
await expect(suspended.reason("Test ban reason")).toBeVisible();
await expect(suspended.locators.noEndTime).toBeVisible();
await navigate({ page, url: "/builds" });
await expect(page).toHaveURL(SUSPENDED_PAGE);
await navigate({ page, url: "/calendar" });
await expect(page).toHaveURL(SUSPENDED_PAGE);
await impersonate(page, ADMIN_ID);
await adminBan.goto();
await adminBan.unbanUser("N-ZAP");
await impersonate(page, NZAP_TEST_ID);
await navigate({ page, url: "/" });
await expect(page).not.toHaveURL(SUSPENDED_PAGE);
})timed ban shows expiration date on suspended page
Renders/admin/suspended
Admin ban page Act
Open the admin ban page
await adminBan.goto();
Ban user “N-ZAP”, expires at startOfHour(setHours(addDays(new Date(), 1), 12)) reason “Temporary ban”
await adminBan.banUser("N-ZAP", {
expiresAt: startOfHour(setHours(addDays(new Date(), 1), 12)),
reason: "Temporary ban",
});
Act
Go to “/”
await navigate({ page, url: "/" });
Assert
the page URL is SUSPENDED_PAGE
await expect(page).toHaveURL(SUSPENDED_PAGE);
Suspended page Assert
heading is visible
await expect(suspended.locators.heading).toBeVisible();
reason “Temporary ban” is visible
await expect(suspended.reason("Temporary ban")).toBeVisible();no end time is not visible
await expect(suspended.locators.noEndTime).not.toBeVisible();
ends at is visible
await expect(suspended.locators.endsAt).toBeVisible();
Source
test("timed ban shows expiration date on suspended page", async ({
page,
}) => {
await impersonate(page, ADMIN_ID);
const adminBan = new AdminBanPage(page);
await adminBan.goto();
await adminBan.banUser("N-ZAP", {
expiresAt: startOfHour(setHours(addDays(new Date(), 1), 12)),
reason: "Temporary ban",
});
await impersonate(page, NZAP_TEST_ID);
await navigate({ page, url: "/" });
const suspended = new SuspendedPage(page);
await expect(page).toHaveURL(SUSPENDED_PAGE);
await expect(suspended.locators.heading).toBeVisible();
await expect(suspended.reason("Temporary ban")).toBeVisible();
await expect(suspended.locators.noEndTime).not.toBeVisible();
await expect(suspended.locators.endsAt).toBeVisible();
// the time based expiration logic itself is covered by app/features/ban/core/banned.test.ts
})AdminBanPage.gotoe2e/pages/ban/admin-ban-page.ts:27
No JSDoc
async goto() {
await navigate({ page: this.page, url: ADMIN_PAGE });
}AdminBanPage.banUsere2e/pages/ban/admin-ban-page.ts:31
No JSDoc
async banUser(
userName: string,
options: { expiresAt?: Date; reason?: string } = {},
) {
const form = this.locators.banForm;
await selectUser({
page: this.page,
userName,
labelName: "User",
within: form,
});
if (options.expiresAt) {
// …SuspendedPage.locators.headinge2e/pages/ban/suspended-page.ts:11
No JSDoc
page.getByText("Account suspended")SuspendedPage.reasone2e/pages/ban/suspended-page.ts:17
No JSDoc
reason(reason: string) {
return this.page.getByText(`Reason: ${reason}`);
}SuspendedPage.locators.noEndTimee2e/pages/ban/suspended-page.ts:13
No JSDoc
page.getByText("no end time set")AdminBanPage.unbanUsere2e/pages/ban/admin-ban-page.ts:54
No JSDoc
async unbanUser(userName: string) {
const form = this.locators.unbanForm;
await selectUser({
page: this.page,
userName,
labelName: "User",
within: form,
});
await this.save(form);
}AdminBanPagee2e/pages/ban/admin-ban-page.ts:11
SuspendedPagee2e/pages/ban/suspended-page.ts:4
SuspendedPage.locators.endsAte2e/pages/ban/suspended-page.ts:12
No JSDoc
page.getByText("Ends:")