From 474bc83493a38780f2c6bc19401c6a266f078474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hartmut=20N=C3=B6renberg?= Date: Tue, 31 Mar 2026 23:47:09 +0200 Subject: [PATCH] test(api): cover assistant skill gap tool routing --- ...sistant-tools-dashboard-skill-gaps.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 packages/api/src/__tests__/assistant-tools-dashboard-skill-gaps.test.ts diff --git a/packages/api/src/__tests__/assistant-tools-dashboard-skill-gaps.test.ts b/packages/api/src/__tests__/assistant-tools-dashboard-skill-gaps.test.ts new file mode 100644 index 0000000..1385647 --- /dev/null +++ b/packages/api/src/__tests__/assistant-tools-dashboard-skill-gaps.test.ts @@ -0,0 +1,38 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { SystemRole } from "@capakraken/shared"; + +import { + createToolContext, + executeTool, + getDashboardSkillGapSummary, +} from "./assistant-tools-dashboard-test-helpers.js"; + +describe("assistant dashboard tools skill gaps", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("routes skill gap reads through the dashboard router path", async () => { + vi.mocked(getDashboardSkillGapSummary).mockResolvedValue({ + roleGaps: [ + { role: "Pipeline TD", needed: 4, filled: 1, gap: 3, fillRate: 25 }, + ], + totalOpenPositions: 3, + skillSupplyTop10: [{ skill: "houdini", resourceCount: 5 }], + resourcesByRole: [{ role: "Pipeline TD", count: 2 }], + }); + + const ctx = createToolContext({}, { userRole: SystemRole.CONTROLLER }); + const result = await executeTool("get_skill_gaps", "{}", ctx); + + expect(getDashboardSkillGapSummary).toHaveBeenCalledTimes(1); + expect(JSON.parse(result.content)).toEqual({ + roleGaps: [ + { role: "Pipeline TD", needed: 4, filled: 1, gap: 3, fillRate: 25 }, + ], + totalOpenPositions: 3, + skillSupplyTop10: [{ skill: "houdini", resourceCount: 5 }], + resourcesByRole: [{ role: "Pipeline TD", count: 2 }], + }); + }); +});