45 lines
2.3 KiB
TypeScript
45 lines
2.3 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-P17b HR-workflows smoke (DoD D.19): Login -> /hr/leave -> tabs visible ->
|
|
* open the "new leave request" dialog (main action) -> dialog renders ->
|
|
* switch to the team tab via its server link (loader roundtrip, tab reflected
|
|
* in the URL).
|
|
*
|
|
* Module- and permission-gated like the HR core routes; 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 leavePath = process.env.E2E_TENANT_HR_LEAVE_PATH ?? dashboardPath.replace(/\/dashboard\/?$/u, "/hr/leave");
|
|
|
|
test.describe("hr workflows smoke", () => {
|
|
test("renders the leave workflow, opens the request dialog and switches tabs", async ({ page }) => {
|
|
skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD"], "HR leave smoke inputs not configured");
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const response = await page.goto(leavePath, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, response, "HR leave is not reachable in this environment");
|
|
|
|
await expect(page.locator('[data-ui-id="ui.hr.leave.tabs"]')).toBeVisible();
|
|
await expect(page.locator('[data-ui-id="ui.hr.leave.own.list"], [data-ui-id="ui.hr.leave.own.empty"]').first()).toBeVisible();
|
|
|
|
// Main action: open the new-request dialog (write stays out of the smoke
|
|
// run — the dialog itself proves the action wiring).
|
|
const newButton = page.locator('[data-ui-id="ui.hr.leave.new"]');
|
|
if (await newButton.isVisible()) {
|
|
await newButton.click();
|
|
await expect(page.locator('[data-ui-id="ui.hr.leave.newDialog"]')).toBeVisible();
|
|
await page.keyboard.press("Escape");
|
|
}
|
|
|
|
// Tab switch is a server link: the loader reflects the tab into the URL.
|
|
await page.locator('[data-ui-id="ui.hr.leave.tabs"] a').last().click();
|
|
await page.waitForURL(/[?&]tab=team(?:&|$)/u);
|
|
await expect(page.locator('[data-ui-id="ui.hr.leave.team.list"], [data-ui-id="ui.hr.leave.team.empty"]').first()).toBeVisible();
|
|
});
|
|
});
|