import "@testing-library/jest-dom"; import { fireEvent, render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { buildHrHubVM, buildHrRequestTemplateListVM, type HrHubHrefs } from "@hivegrid/view-models"; import { expectNoAxeViolations, runAxe } from "@hivegrid/ui-app/test-setup/axe"; import { HrAdminPayslipsPage } from "./HrAdminPayslipsPage"; import { HrAdminRequestTemplatesPage } from "./HrAdminRequestTemplatesPage"; import { HrHubPage } from "./HrHubPage"; vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string, values?: Record) => values ? `${key}:${Object.values(values).join("/")}` : key, i18n: { language: "de" }, }), })); const ids = [ "leave", "sick", "documents", "payslips", "announcements", "requests", "surveys", "teamDirectory", "teamLeave", "leaveApprovals", "requestApprovals", "directory", "locations", "announcementAdmin", "payslipAdmin", "requestTemplates", "uploadReminders", "surveyAdmin", ] as const; const hrefs = Object.fromEntries(ids.map((id) => [id, `/acme/hr/${id}`])) as HrHubHrefs; const hubVm = buildHrHubVM({ moduleActive: true, hrefs, counts: { ownLeave: 1, ownSick: 0, ownRequests: 1, pendingLeaveApprovals: 2, pendingRequestApprovals: 1, visibleTeamMembers: 6, }, capabilities: { canReadAll: true, canWrite: true, canApproveLeave: true, canViewSurveyResults: true, }, }); describe("R-UX3 personnel accessibility and ID freedom", () => { it("exposes the role-aware hub as labelled sections without critical axe violations", async () => { const { container } = render(); expect(screen.getByRole("heading", { name: "hr.hub.section.forMe.label" })).toBeInTheDocument(); expect(screen.getByRole("heading", { name: "hr.hub.section.myTeam.label" })).toBeInTheDocument(); expect(screen.getByRole("heading", { name: "hr.hub.section.administration.label" })).toBeInTheDocument(); expect((await runAxe(container)).violations).toEqual([]); }); it("keeps payslip file and employee ids out of visible controls", async () => { const { container } = render( , ); const fileInput = screen.getByLabelText("hr.payslips.field.filesHint"); expect(fileInput).toHaveAttribute("accept", "application/pdf,.pdf"); fireEvent.change(fileInput, { target: { files: [ new File(["%PDF-1.7"], "mira.pdf", { type: "application/pdf" }), new File(["%PDF-1.7"], "jo.pdf", { type: "application/pdf" }), ], }, }); expect(screen.getByText("hr.payslips.upload.selected:2")).toBeInTheDocument(); expect(screen.getByRole("combobox", { name: "hr.payslips.field.employee" })).toBeInTheDocument(); expect(container.textContent).toContain("Mira Muster"); expect(container.textContent).not.toContain("opaque-user-id"); expect(container.textContent).not.toContain("opaque-file-id"); await expectNoAxeViolations( , ); }); it("uses named team context in the request-template approver picker", () => { const { container } = render( , ); fireEvent.click(screen.getByRole("button", { name: "hr.requests.templates.action.create" })); fireEvent.click(screen.getByRole("combobox", { name: "hr.requests.field.approver" })); expect(screen.getByText("Mira Muster · Montage · Teamleitung")).toBeInTheDocument(); expect(container.textContent).not.toContain("opaque-approver-id"); }); });