Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+71
@@ -0,0 +1,71 @@
|
||||
import { expect, test } from "./utils/test";
|
||||
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
||||
import { getTenantCredentials, loginAsTenantUser, tenantSettingsChatbotPath } 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 chatbotPath = process.env.E2E_TENANT_CHATBOT_PATH ?? (dashboardPath ? tenantSettingsChatbotPath(dashboardPath) : undefined);
|
||||
|
||||
test.describe("tenant chatbot 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 chatbot settings E2E inputs not configured");
|
||||
if (!chatbotPath) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant chatbot settings path could not be derived; set E2E_TENANT_CHATBOT_PATH");
|
||||
}
|
||||
});
|
||||
|
||||
test("renders access controls without mobile overflow or critical a11y violations", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(chatbotPath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant chatbot settings path ${chatbotPath}`);
|
||||
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(chatbotPath!)}(?:[?#].*)?$`, "u"));
|
||||
|
||||
await expect(page.locator('[data-ui-id="ui.settings.chatbot.page"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.chatbot.master.form"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.chatbot.defaults.form"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.chatbot.providers"]').first()).toBeVisible();
|
||||
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
});
|
||||
|
||||
test("submits tenant default access contract with csrf without mutating data", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(chatbotPath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant chatbot settings path ${chatbotPath}`);
|
||||
|
||||
const form = page.locator('[data-ui-id="ui.settings.chatbot.defaults.form"]').first();
|
||||
await expect(form).toBeVisible();
|
||||
await form.locator('input[name="accessMode"][value="all_members"]').setChecked(true);
|
||||
|
||||
const defaultCapability = form.locator('input[name="defaultCapability"]').first();
|
||||
if ((await defaultCapability.count()) > 0) {
|
||||
await defaultCapability.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, "op", /^update-tenant-defaults$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "accessMode", /^all_members$/u)).toBe(true);
|
||||
if ((await defaultCapability.count()) > 0) {
|
||||
expect(postDataIncludesField(submitted.value, "defaultCapability", /.+/u)).toBe(true);
|
||||
}
|
||||
if ((await csrf.count()) > 0) {
|
||||
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user