Rollen Chunk 6: Team-Tab mit Matrix-Kalender und Genehmigungen
Docker Image / test (push) Canceled after 0s
Docker Image / image (push) Canceled after 0s

This commit is contained in:
loki committed 2026-10-11 20:19:06 +02:00
1 parent f84159584a
commit 44c4f6ada4
1 file changed
+66
+66
View File
@@ -28,6 +28,8 @@ vi.mock("@/lib/api-client", async (importOriginal) => ({
saveVacation: vi.fn(),
createOvertimeAdjustment: vi.fn(),
saveSettings: vi.fn(),
getTeam: vi.fn(),
decideVacation: vi.fn(),
}));
vi.mock("@/lib/auth-client", () => ({
@@ -770,3 +772,67 @@ test("shows login instead of failure on misconfigured auth", async () => {
).toBeInTheDocument();
expect(screen.queryByRole("alert")).toBeNull();
});
test("shows the team tab only for team leads and admins", async () => {
const { getAuthStatus } = await import("@/lib/auth-client");
for (const [role, visible] of [
["benutzer", false],
["teamleiter", true],
["admin", true],
] as const) {
vi.mocked(getAuthStatus).mockResolvedValue({
enabled: true,
mode: "password",
ssoEnabled: false,
setupRequired: false,
user: { email: "loki@example.org", role },
});
mockApp(true);
const { unmount } = render(<Home />);
await screen.findByText("2:30 Std.");
const tab = screen.queryByRole("tab", { name: "Team" });
expect(!!tab).toBe(visible);
unmount();
}
});
test("team tab lists members and allowances", async () => {
const { getAuthStatus } = await import("@/lib/auth-client");
const { getTeam } = await import("@/lib/api-client");
vi.mocked(getAuthStatus).mockResolvedValue({
enabled: true,
mode: "password",
ssoEnabled: false,
setupRequired: false,
user: { email: "loki@example.org", role: "admin" },
});
vi.mocked(getTeam).mockResolvedValue({
year: new Date().getFullYear(),
team: [
{
id: "u-1",
name: "Admin",
email: "admin@example.org",
role: "admin",
entitlementUnits: 60,
carryoverUnits: 0,
usedUnits: 0,
pendingUnits: 0,
remainingUnits: 60,
requests: [],
trash: 0,
sickDays: [],
weekdayTargets: { 0: 0, 1: 480, 2: 480, 3: 480, 4: 480, 5: 480, 6: 0 },
holidays: [],
},
],
});
mockApp(true);
render(<Home />);
await screen.findByText("2:30 Std.");
fireEvent.click(screen.getByRole("tab", { name: "Team" }));
expect(
await screen.findByRole("heading", { name: "Team" }),
).toBeInTheDocument();
expect(screen.getByRole("table")).toBeInTheDocument();
});