78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { SystemRole } from "@capakraken/shared";
|
|
|
|
import {
|
|
createToolContext,
|
|
executeTool,
|
|
getDashboardOverview,
|
|
} from "./assistant-tools-dashboard-test-helpers.js";
|
|
|
|
describe("assistant dashboard tools overview", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("routes statistics through the dashboard overview path", async () => {
|
|
vi.mocked(getDashboardOverview).mockResolvedValue({
|
|
totalResources: 12,
|
|
activeResources: 10,
|
|
inactiveResources: 2,
|
|
totalProjects: 7,
|
|
activeProjects: 4,
|
|
inactiveProjects: 3,
|
|
totalAllocations: 21,
|
|
activeAllocations: 18,
|
|
cancelledAllocations: 3,
|
|
approvedVacations: 6,
|
|
totalEstimates: 9,
|
|
budgetSummary: {
|
|
totalBudgetCents: 1_234_56,
|
|
totalCostCents: 654_32,
|
|
avgUtilizationPercent: 53,
|
|
},
|
|
budgetBasis: {
|
|
remainingBudgetCents: 58_024,
|
|
budgetedProjects: 5,
|
|
unbudgetedProjects: 2,
|
|
trackedAssignmentCount: 18,
|
|
windowStart: null,
|
|
windowEnd: null,
|
|
},
|
|
projectsByStatus: [
|
|
{ status: "ACTIVE", count: 4 },
|
|
{ status: "DRAFT", count: 2 },
|
|
{ status: "DONE", count: 1 },
|
|
],
|
|
chapterUtilization: [
|
|
{ chapter: "CGI", resourceCount: 5, avgChargeabilityTarget: 78 },
|
|
{ chapter: "Compositing", resourceCount: 3, avgChargeabilityTarget: 74 },
|
|
{ chapter: "Unassigned", resourceCount: 2, avgChargeabilityTarget: 0 },
|
|
],
|
|
recentActivity: [],
|
|
});
|
|
|
|
const ctx = createToolContext({}, { userRole: SystemRole.CONTROLLER });
|
|
const result = await executeTool("get_statistics", "{}", ctx);
|
|
|
|
expect(JSON.parse(result.content)).toEqual({
|
|
activeResources: 10,
|
|
totalProjects: 7,
|
|
activeProjects: 4,
|
|
totalAllocations: 21,
|
|
approvedVacations: 6,
|
|
totalEstimates: 9,
|
|
totalBudget: "1.234,56 EUR",
|
|
projectsByStatus: {
|
|
ACTIVE: 4,
|
|
DRAFT: 2,
|
|
DONE: 1,
|
|
},
|
|
topChapters: [
|
|
{ chapter: "CGI", count: 5 },
|
|
{ chapter: "Compositing", count: 3 },
|
|
{ chapter: "Unassigned", count: 2 },
|
|
],
|
|
});
|
|
});
|
|
});
|