105 lines
5.4 KiB
TypeScript
105 lines
5.4 KiB
TypeScript
import { expect, test } from "./utils/test";
|
|
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
|
import { getTenantCredentials, loginAsTenantUser } from "./utils/auth";
|
|
import { compactMobileViewport, expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile";
|
|
import { escapeRegExp, skipIfUnavailable } from "./utils/navigation";
|
|
import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness";
|
|
|
|
const credentials = getTenantCredentials();
|
|
const apiPath = process.env.E2E_TENANT_API_PATH;
|
|
const apiKeysPath = process.env.E2E_TENANT_API_KEYS_PATH;
|
|
const apiLogsPath = process.env.E2E_TENANT_API_LOGS_PATH;
|
|
const readinessEndpoint = "/v1/e2e-readiness";
|
|
|
|
test.describe("tenant API logs mobile a11y", () => {
|
|
test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true });
|
|
|
|
test.beforeEach(() => {
|
|
skipOrFailWhenE2eInputsMissing(
|
|
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_API_PATH", "E2E_TENANT_API_KEYS_PATH", "E2E_TENANT_API_LOGS_PATH"],
|
|
"Tenant API logs E2E inputs not configured"
|
|
);
|
|
});
|
|
|
|
test("shows seeded API log summary and navigates to details", async ({ page }) => {
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const response = await page.goto(`${apiPath!}?groupBy=method&groupBy=endpoint`, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, response, `Tenant API overview path ${apiPath}`);
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(apiPath!)}(?:[?#].*)?$`, "u"));
|
|
await expectApiTabs(page);
|
|
|
|
await expect(page.getByText(readinessEndpoint, { exact: true }).first()).toBeVisible();
|
|
await expect(page.getByText("GET", { exact: true }).first()).toBeVisible();
|
|
const detailsLink = page.getByRole("link", { name: /details|details\s*→|details\s*->/iu }).first();
|
|
if ((await detailsLink.count()) === 0) {
|
|
skipOrFailWhenE2eFixtureMissing("Tenant API summary details link is not visible for this fixture");
|
|
}
|
|
await detailsLink.click();
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(apiLogsPath!)}.*(?:method=GET|endpoint=%2Fv1%2Fe2e-readiness)`, "u"));
|
|
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
});
|
|
|
|
test("shows seeded API logs without tenant delete controls", async ({ page }) => {
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const response = await page.goto(`${apiLogsPath!}?method=GET&endpoint=%2Fv1%2Fe2e-readiness`, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, response, `Tenant API logs path ${apiLogsPath}`);
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(apiLogsPath!)}(?:[?#].*)?$`, "u"));
|
|
await expectApiTabs(page);
|
|
|
|
await expect(page.getByText(readinessEndpoint, { exact: true }).first()).toBeVisible();
|
|
await expect(page.getByText("GET", { exact: true }).first()).toBeVisible();
|
|
await expect(page.getByText("200", { exact: true }).first()).toBeVisible();
|
|
await expect(page.locator('input[type="search"], input[name="q"], input[name="search"]').first()).toBeVisible();
|
|
await expect(page.locator('form button:has-text("Delete"), form button:has-text("Löschen")')).toHaveCount(0);
|
|
|
|
const methodLink = page.getByRole("link", { name: /^GET$/u }).first();
|
|
if ((await methodLink.count()) > 0) {
|
|
await methodLink.click();
|
|
await expect(page).toHaveURL(/method=GET/u);
|
|
}
|
|
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
});
|
|
});
|
|
|
|
test.describe("tenant API logs compact mobile a11y", () => {
|
|
test.use({ viewport: compactMobileViewport, isMobile: true, hasTouch: true });
|
|
|
|
test.beforeEach(() => {
|
|
skipOrFailWhenE2eInputsMissing(
|
|
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_API_PATH", "E2E_TENANT_API_KEYS_PATH", "E2E_TENANT_API_LOGS_PATH"],
|
|
"Tenant API logs E2E inputs not configured"
|
|
);
|
|
});
|
|
|
|
test("keeps logs usable at 320px", async ({ page }) => {
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const logsResponse = await page.goto(`${apiLogsPath!}?method=GET&endpoint=%2Fv1%2Fe2e-readiness`, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, logsResponse, `Tenant API logs path ${apiLogsPath}`);
|
|
await expectApiTabs(page);
|
|
await expect(page.getByText(readinessEndpoint, { exact: true }).first()).toBeVisible();
|
|
await expect(page.getByText("GET", { exact: true }).first()).toBeVisible();
|
|
await expect(page.getByText("200", { exact: true }).first()).toBeVisible();
|
|
await expect(page.locator('input[type="search"], input[name="q"], input[name="search"]').first()).toBeVisible();
|
|
await expect(page.locator('form button:has-text("Delete"), form button:has-text("Löschen")')).toHaveCount(0);
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
});
|
|
});
|
|
|
|
async function expectApiTabs(page: import("@playwright/test").Page) {
|
|
// The API sub-nav tab bar is responsive (hidden lg:flex): the four tab links
|
|
// are rendered but collapsed on mobile viewports, so assert they are present
|
|
// in the markup rather than visibly displayed. The content assertions in each
|
|
// test prove the active sub-page actually rendered.
|
|
await expect(page.locator(`a[href="${apiPath!}"]`).first()).toBeAttached();
|
|
await expect(page.locator(`a[href="${apiLogsPath!}"]`).first()).toBeAttached();
|
|
await expect(page.locator(`a[href="${apiKeysPath!}"]`).first()).toBeAttached();
|
|
}
|