Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import { expect, test } from "./utils/test";
|
||||
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
||||
import { getTenantCredentials, loginAsTenantUser, tenantSettingsNotificationsPath } from "./utils/auth";
|
||||
import { expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile";
|
||||
import { escapeRegExp, interceptCurrentRoutePost, postDataIncludesField, skipIfUnavailable } from "./utils/navigation";
|
||||
import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness";
|
||||
|
||||
const credentials = getTenantCredentials();
|
||||
const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH;
|
||||
const notificationsPath =
|
||||
process.env.E2E_TENANT_NOTIFICATIONS_PATH ?? (dashboardPath ? tenantSettingsNotificationsPath(dashboardPath) : undefined);
|
||||
|
||||
test.describe("tenant notification settings mobile a11y", () => {
|
||||
test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true });
|
||||
|
||||
test.beforeEach(() => {
|
||||
skipOrFailWhenE2eInputsMissing(
|
||||
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"],
|
||||
"Tenant notification settings E2E inputs not configured"
|
||||
);
|
||||
if (!notificationsPath) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant notification settings path could not be derived; set E2E_TENANT_NOTIFICATIONS_PATH");
|
||||
}
|
||||
});
|
||||
|
||||
test("renders notification categories without mobile overflow or critical a11y violations", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(notificationsPath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant notification settings path ${notificationsPath}`);
|
||||
|
||||
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(notificationsPath!)}(?:[?#].*)?$`, "u"));
|
||||
await expect(page.locator('[data-ui-id="ui.settings.notifications.page"]').first()).toBeVisible();
|
||||
|
||||
for (const category of ["default", "billing", "team"]) {
|
||||
await expect(page.locator(`[data-ui-id="ui.settings.notifications.category.${category}"]`).first()).toBeVisible();
|
||||
await expect(page.locator(`[data-ui-id="ui.settings.notifications.preference.${category}.in_app"]`).first()).toBeVisible();
|
||||
await expect(page.locator(`[data-ui-id="ui.settings.notifications.preference.${category}.email"]`).first()).toBeVisible();
|
||||
}
|
||||
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
});
|
||||
|
||||
test("submits preference update contract with csrf without mutating data", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(notificationsPath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant notification settings path ${notificationsPath}`);
|
||||
|
||||
const form = page.locator('[data-ui-id="ui.settings.notifications.preference.team.email"]').first();
|
||||
await expect(form).toBeVisible();
|
||||
const checkbox = form.locator('input[name="enabled"]').first();
|
||||
await checkbox.setChecked(true);
|
||||
|
||||
const csrf = form.locator('input[name="csrf"]').first();
|
||||
if ((await csrf.count()) > 0) {
|
||||
await expect(csrf).not.toHaveValue("");
|
||||
}
|
||||
|
||||
const submitted = await interceptCurrentRoutePost(page, { status: 204 });
|
||||
await form.locator('button[type="submit"]').first().click();
|
||||
|
||||
await expect.poll(() => submitted.value).not.toBeNull();
|
||||
expect(postDataIncludesField(submitted.value, "action", /^update-preference$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "category", /^team$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "channel", /^EMAIL$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "enabled", /^(on|true)$/u)).toBe(true);
|
||||
if ((await csrf.count()) > 0) {
|
||||
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user