Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/tests/e2e/hr-core-smoke.spec.ts
T

49 lines
2.7 KiB
TypeScript

import { expect, test } from "./utils/test";
import { getTenantCredentials, loginAsTenantUser } from "./utils/auth";
import { skipIfUnavailable } from "./utils/navigation";
import { skipOrFailWhenE2eInputsMissing } from "./utils/readiness";
/**
* AK-P17a HR-core smoke (DoD D.19): Login -> /hr hub -> directory via hub link
* -> table/empty state visible; then the password-safe list where the
* never-list contract must hold (no revealed secret value anywhere before an
* explicit, audited reveal).
*
* The routes are module-gated (`tenantHasModule('hr')`) and permission-gated
* (`hr.read_own` / `hr.passwordsafe.use`, 404 instead of 403). Skips without
* E2E credentials or when the route is not reachable in this environment.
*/
const credentials = getTenantCredentials();
const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH ?? "/app/dashboard";
const hrHubPath = process.env.E2E_TENANT_HR_PATH ?? dashboardPath.replace(/\/dashboard\/?$/u, "/hr");
const tenantSlug = hrHubPath.split("/").filter(Boolean)[0] ?? "app";
test.describe("hr core smoke", () => {
test("opens the hub, the employee directory and the password-safe list", async ({ page }) => {
skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD"], "HR smoke inputs not configured");
await loginAsTenantUser(page, credentials!);
const response = await page.goto(hrHubPath, { waitUntil: "domcontentloaded" });
await skipIfUnavailable(page, response, "HR hub is not reachable in this environment");
await expect(page.locator('[data-ui-id="ui.hr.hub.section.forMe"]')).toBeVisible();
// Main action: follow the hub link into the employee directory. The
// directory renders either the table or the plain-text empty state.
const directoryLink = page
.locator('[data-ui-id="ui.hr.hub.item.teamDirectory"], [data-ui-id="ui.hr.hub.item.directory"]')
.first();
await expect(directoryLink).toBeVisible();
await directoryLink.click();
await page.waitForURL(/\/hr\/directory(?:[/?#]|$)/u);
await expect(page.locator('[data-ui-id="ui.hr.directory.table"], [data-ui-id="ui.hr.directory.empty"]').first()).toBeVisible();
// Password-safe list: vault cards or empty state — and never a revealed
// secret value outside the audited on-demand reveal (DoD #3 never-list).
const safeResponse = await page.goto(`/${tenantSlug}/passwords`, { waitUntil: "domcontentloaded" });
await skipIfUnavailable(page, safeResponse, "Password safe is not reachable in this environment");
await expect(page.locator('[data-ui-id="ui.hr.passwordSafe.list"], [data-ui-id="ui.hr.passwordSafe.empty"]').first()).toBeVisible();
await expect(page.locator('[data-ui-id="ui.hr.vault.revealed"]')).toHaveCount(0);
});
});