import { beforeEach, describe, expect, it, vi } from "vitest"; import { SystemRole } from "@capakraken/shared"; vi.mock("@capakraken/application", async (importOriginal) => { const actual = await importOriginal(); return { ...actual, getDashboardBudgetForecast: vi.fn().mockResolvedValue([]), listAssignmentBookings: vi.fn().mockResolvedValue([]), }; }); vi.mock("../lib/audit.js", () => ({ createAuditEntry: vi.fn().mockResolvedValue(undefined), })); import { executeTool } from "../router/assistant-tools.js"; import { createToolContext } from "./assistant-tools-holiday-capacity-test-helpers.js"; describe("assistant pending vacation approvals tool", () => { beforeEach(() => { vi.clearAllMocks(); }); it("routes pending vacation approvals through the vacation router path", async () => { const db = { vacation: { findMany: vi.fn().mockResolvedValue([ { id: "vac_1", type: "ANNUAL", startDate: new Date("2026-07-01T00:00:00.000Z"), endDate: new Date("2026-07-03T00:00:00.000Z"), isHalfDay: false, resource: { displayName: "Bruce Banner", eid: "BB-1", chapter: "CGI" }, requestedBy: { id: "user_2", name: "Manager", email: "manager@example.com" }, }, ]), }, }; const ctx = createToolContext(db, [], SystemRole.MANAGER); const result = await executeTool( "get_pending_vacation_approvals", JSON.stringify({ limit: 10 }), ctx, ); expect(db.vacation.findMany).toHaveBeenCalledWith({ where: { status: "PENDING" }, include: { resource: { select: expect.any(Object) }, requestedBy: { select: { id: true, name: true, email: true } }, }, orderBy: { startDate: "asc" }, }); expect(JSON.parse(result.content)).toEqual([ expect.objectContaining({ id: "vac_1", resource: "Bruce Banner", eid: "BB-1", chapter: "CGI", }), ]); }); });