Rollen Chunk 6: Team-Tab mit Matrix-Kalender und Genehmigungen
This commit is contained in:
1 parent
3cefcefad1
commit
89ebd49c1c
1 file changed
+46
@@ -857,3 +857,49 @@ describe("Anfragestatus (Chunk 5)", () => {
|
||||
expect(sumPendingUnitsByYear(db, "u-1", 2026)).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Team (Chunk 6)", () => {
|
||||
test("listAllUsers liest alle Konten mit Rolle", async () => {
|
||||
const { listAllUsers } = await import("@/lib/repository");
|
||||
const db = freshDb();
|
||||
initializeDatabase(db);
|
||||
db.prepare(
|
||||
'INSERT INTO "user" (id, name, email, emailVerified, image, createdAt, updatedAt, role) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
).run("u-1", "Admin", "admin@example.org", 0, null, 1, 1, "admin");
|
||||
db.prepare(
|
||||
'INSERT INTO "user" (id, name, email, emailVerified, image, createdAt, updatedAt, role) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
).run("u-2", "Benutzer", "benutzer@example.org", 0, null, 2, 2, "benutzer");
|
||||
expect(listAllUsers(db)).toEqual([
|
||||
{ id: "u-1", name: "Admin", email: "admin@example.org", role: "admin" },
|
||||
{
|
||||
id: "u-2",
|
||||
name: "Benutzer",
|
||||
email: "benutzer@example.org",
|
||||
role: "benutzer",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test("setVacationStatus setzt bestätigt oder abgelehnt", async () => {
|
||||
const {
|
||||
saveVacationRequest,
|
||||
setVacationStatus,
|
||||
getVacationRequest,
|
||||
} = await import("@/lib/repository");
|
||||
const db = freshDb();
|
||||
initializeDatabase(db);
|
||||
const saved = saveVacationRequest(db, "u-1", {
|
||||
startDate: "2026-07-06",
|
||||
endDate: "2026-07-06",
|
||||
dayFraction: "full",
|
||||
status: "beantragt",
|
||||
days: [{ date: "2026-07-06", units: 2 }],
|
||||
});
|
||||
expect(setVacationStatus(db, "u-1", saved.id, "bestätigt")).toBe(true);
|
||||
expect(getVacationRequest(db, "u-1", saved.id)?.status).toBe("bestätigt");
|
||||
// Bestätigte sind entschieden: Ablehnen wirkt nur auf offene Anfragen.
|
||||
expect(setVacationStatus(db, "u-1", saved.id, "abgelehnt")).toBe(false);
|
||||
expect(getVacationRequest(db, "u-1", saved.id)?.status).toBe("bestätigt");
|
||||
expect(setVacationStatus(db, "u-1", 999, "bestätigt")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user