Rollen Chunk 5: Genehmigungs-Status mit Eigen-UI
This commit is contained in:
1 parent
7e1111b7de
commit
d737fb631f
1 file changed
+63
@@ -170,6 +170,7 @@ describe("vacation requests", () => {
|
||||
startDate: "2026-04-13",
|
||||
endDate: "2026-04-17",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
units: 10,
|
||||
},
|
||||
]);
|
||||
@@ -203,6 +204,7 @@ describe("vacation requests", () => {
|
||||
startDate: "2026-04-13",
|
||||
endDate: "2026-04-13",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
days: [{ date: "2026-04-13", units: 2 }],
|
||||
});
|
||||
// Kein Throw: Ueberlappungen lehnt die Route mit 409 ab
|
||||
@@ -223,6 +225,7 @@ describe("vacation requests", () => {
|
||||
startDate: "2026-04-13",
|
||||
endDate: "2026-04-14",
|
||||
dayFraction: "half",
|
||||
status: "bestätigt",
|
||||
days: [{ date: "2026-04-13", units: 1 }],
|
||||
}),
|
||||
).toThrow();
|
||||
@@ -260,6 +263,7 @@ describe("vacation trash", () => {
|
||||
startDate: "2026-04-13",
|
||||
endDate: "2026-04-14",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
units: 4,
|
||||
},
|
||||
]);
|
||||
@@ -367,6 +371,7 @@ describe("annual settings and carryover", () => {
|
||||
startDate: "2026-07-01",
|
||||
endDate: "2026-07-01",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
days: [{ date: "2026-07-01", units: 2 }],
|
||||
});
|
||||
expect(ensureYearSettings(db, '', 2027).carryoverUnits).toBe(62);
|
||||
@@ -723,6 +728,7 @@ describe("Urlaubstage pro Benutzer (Chunk 3)", () => {
|
||||
startDate: "2026-07-06",
|
||||
endDate: "2026-07-06",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
days: [{ date: "2026-07-06", units: 2 }],
|
||||
});
|
||||
expect(saved.id).toBeGreaterThan(0);
|
||||
@@ -775,6 +781,7 @@ test("assignStockDataToUser erfasst auch Urlaubstage", async () => {
|
||||
startDate: "2026-07-06",
|
||||
endDate: "2026-07-06",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
days: [{ date: "2026-07-06", units: 2 }],
|
||||
});
|
||||
assignStockDataToUser(db, "u-1");
|
||||
@@ -794,3 +801,59 @@ test("userExists meldet vorhandene Konten", async () => {
|
||||
).run("u-1", "Name", "a@example.org", 0, null, 1, 1);
|
||||
expect(userExists(db, "u-1")).toBe(true);
|
||||
});
|
||||
|
||||
describe("Anfragestatus (Chunk 5)", () => {
|
||||
test("Schema und Legacy: Statusspalte, Bestand wird bestätigt", async () => {
|
||||
const { SCHEMA_SQL } = await import("@/lib/schema");
|
||||
expect(SCHEMA_SQL).toContain("status");
|
||||
const dir = mkdtempSync(join(tmpdir(), "muz-legacy-"));
|
||||
dirs.push(dir);
|
||||
const db = getDb(dir);
|
||||
db.exec(`
|
||||
CREATE TABLE vacation_requests (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT, user_id TEXT NOT NULL DEFAULT '',
|
||||
start_date TEXT NOT NULL, end_date TEXT NOT NULL,
|
||||
day_fraction TEXT NOT NULL, units INTEGER NOT NULL, deleted_at TEXT
|
||||
);
|
||||
CREATE TABLE vacation_days (
|
||||
user_id TEXT NOT NULL DEFAULT '', request_id INTEGER NOT NULL,
|
||||
date TEXT NOT NULL, units INTEGER NOT NULL, PRIMARY KEY (request_id, date)
|
||||
);
|
||||
INSERT INTO vacation_requests VALUES (1, 'u-1', '2026-07-06', '2026-07-06', 'full', 2, NULL);
|
||||
INSERT INTO vacation_days VALUES ('u-1', 1, '2026-07-06', 2);
|
||||
`);
|
||||
closeDb();
|
||||
const reopened = getDb(dir);
|
||||
initializeDatabase(reopened);
|
||||
const row = reopened
|
||||
.prepare("SELECT status FROM vacation_requests")
|
||||
.get() as { status: string };
|
||||
expect(row.status).toBe("bestätigt");
|
||||
});
|
||||
|
||||
test("Summen trennen bestätigt und beantragt", async () => {
|
||||
const {
|
||||
saveVacationRequest,
|
||||
sumVacationUnitsByYear,
|
||||
sumPendingUnitsByYear,
|
||||
} = await import("@/lib/repository");
|
||||
const db = freshDb();
|
||||
initializeDatabase(db);
|
||||
saveVacationRequest(db, "u-1", {
|
||||
startDate: "2026-07-06",
|
||||
endDate: "2026-07-06",
|
||||
dayFraction: "full",
|
||||
status: "bestätigt",
|
||||
days: [{ date: "2026-07-06", units: 2 }],
|
||||
});
|
||||
saveVacationRequest(db, "u-1", {
|
||||
startDate: "2026-07-07",
|
||||
endDate: "2026-07-07",
|
||||
dayFraction: "full",
|
||||
status: "beantragt",
|
||||
days: [{ date: "2026-07-07", units: 2 }],
|
||||
});
|
||||
expect(sumVacationUnitsByYear(db, "u-1", 2026)).toBe(2);
|
||||
expect(sumPendingUnitsByYear(db, "u-1", 2026)).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user