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,76 @@
|
||||
import { expect, test } from "./utils/test";
|
||||
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
||||
import { getTenantCredentials, loginAsTenantUser } 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 apiKeysPath = process.env.E2E_TENANT_API_KEYS_PATH;
|
||||
|
||||
test.describe("tenant API keys mobile a11y", () => {
|
||||
test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true });
|
||||
|
||||
test.beforeEach(() => {
|
||||
skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_API_KEYS_PATH"], "Tenant API key E2E inputs not configured");
|
||||
});
|
||||
|
||||
test("opens create form without mobile overflow or critical a11y violations", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(apiKeysPath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant API keys path ${apiKeysPath}`);
|
||||
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(apiKeysPath!)}(?:[?#].*)?$`, "u"));
|
||||
|
||||
const newLink = page.getByRole("link", { name: /^(new|neu)$/iu }).first();
|
||||
if ((await newLink.count()) === 0) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant API key create link is not visible for this fixture");
|
||||
}
|
||||
await newLink.click();
|
||||
await expect(page).toHaveURL(/\/settings\/api\/keys\/new(?:[?#].*)?$/u);
|
||||
|
||||
const form = page.locator('form:has(input[name="action"][value="create"])').first();
|
||||
await expect(form).toBeVisible();
|
||||
await expect(form.locator('input[name="alias"]').first()).toBeVisible();
|
||||
await expect(form.locator('input[name="expires"]').first()).toBeVisible();
|
||||
await expect(form.locator('input[name="active"]').first()).toBeAttached();
|
||||
await expect(form.locator('input[name="csrf"]').first()).not.toHaveValue("");
|
||||
await expect.poll(async () => form.locator('input[name="entities[]"]').count()).toBeGreaterThan(0);
|
||||
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
});
|
||||
|
||||
test("submits create contract with alias, entity permissions, and csrf without mutating data", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(apiKeysPath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant API keys path ${apiKeysPath}`);
|
||||
|
||||
const newLink = page.getByRole("link", { name: /^(new|neu)$/iu }).first();
|
||||
if ((await newLink.count()) === 0) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant API key create link is not visible for this fixture");
|
||||
}
|
||||
await newLink.click();
|
||||
|
||||
const form = page.locator('form:has(input[name="action"][value="create"])').first();
|
||||
await expect(form).toBeVisible();
|
||||
await form.locator('input[name="alias"]').fill(`e2e-contract-${Date.now()}`);
|
||||
if ((await form.locator('input[name$="-read"]').count()) > 0) {
|
||||
await form.locator('input[name$="-read"]').first().click({ force: true });
|
||||
}
|
||||
|
||||
const submitted = await interceptCurrentRoutePost(page, {
|
||||
status: 200,
|
||||
body: JSON.stringify({ apiKey: { key: "tc_test_redacted_contract", alias: "e2e-contract" } }),
|
||||
contentType: "application/json",
|
||||
});
|
||||
await form.locator('button[type="submit"]').last().click();
|
||||
|
||||
await expect.poll(() => submitted.value).not.toBeNull();
|
||||
expect(postDataIncludesField(submitted.value, "action", /^create$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "alias", /^e2e-contract-/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "entities[]", /"entityId"/u)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user