70 lines
2.9 KiB
TypeScript
70 lines
2.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
|
|
describe("Cancel request feature", () => {
|
|
describe("Cancel procedure validation", () => {
|
|
it("should define the cancel procedure in the request router", async () => {
|
|
const { appRouter } = await import("./routers");
|
|
// Verify the cancel procedure exists
|
|
expect(appRouter._def.procedures).toHaveProperty("request.cancel");
|
|
}, 15000);
|
|
|
|
it("should have cancel as a callable procedure", async () => {
|
|
const { appRouter } = await import("./routers");
|
|
const procedure = (appRouter._def.procedures as any)["request.cancel"];
|
|
expect(procedure).toBeDefined();
|
|
expect(procedure._def).toBeDefined();
|
|
}, 15000);
|
|
});
|
|
|
|
describe("Schema validation", () => {
|
|
it("should include 'annulee' in request statuses", async () => {
|
|
const { requestStatuses } = await import("../drizzle/schema");
|
|
expect(requestStatuses).toContain("annulee");
|
|
});
|
|
|
|
it("should include 'annulation' in request history actions", async () => {
|
|
const { requestHistory } = await import("../drizzle/schema");
|
|
const actionColumn = requestHistory.action;
|
|
// Verify the column exists and has the right enum values
|
|
expect(actionColumn).toBeDefined();
|
|
expect(actionColumn.enumValues).toContain("annulation");
|
|
});
|
|
|
|
it("should include 'annulation_demande' in admin notification types", async () => {
|
|
const { adminNotifications } = await import("../drizzle/schema");
|
|
const typeColumn = adminNotifications.type;
|
|
expect(typeColumn).toBeDefined();
|
|
expect(typeColumn.enumValues).toContain("annulation_demande");
|
|
});
|
|
|
|
it("should include 'modification_demande' in admin notification types", async () => {
|
|
const { adminNotifications } = await import("../drizzle/schema");
|
|
const typeColumn = adminNotifications.type;
|
|
expect(typeColumn).toBeDefined();
|
|
expect(typeColumn.enumValues).toContain("modification_demande");
|
|
});
|
|
});
|
|
|
|
describe("Update procedure with notification", () => {
|
|
it("should define the update procedure in the request router", async () => {
|
|
const { appRouter } = await import("./routers");
|
|
expect(appRouter._def.procedures).toHaveProperty("request.update");
|
|
}, 15000);
|
|
|
|
it("should have update as a callable procedure", async () => {
|
|
const { appRouter } = await import("./routers");
|
|
const procedure = (appRouter._def.procedures as any)["request.update"];
|
|
expect(procedure).toBeDefined();
|
|
expect(procedure._def).toBeDefined();
|
|
}, 15000);
|
|
});
|
|
|
|
describe("Calendar integration", () => {
|
|
it("getApprovedReservations should only return validated requests (not annulee)", async () => {
|
|
// The getApprovedReservations function filters by status = 'validee'
|
|
// so cancelled requests are automatically excluded from the calendar
|
|
const dbModule = await import("./db");
|
|
expect(typeof dbModule.getApprovedReservations).toBe("function");
|
|
});
|
|
});
|
|
});
|