b41c1d2501
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61) Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com> Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
118 lines
3.3 KiB
TypeScript
118 lines
3.3 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { PermissionKey } from "@nexus/shared";
|
|
import { createToolContext, executeTool } from "./assistant-tools-resource-test-helpers.js";
|
|
|
|
describe("assistant resource read tools - computation graph", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("returns a filtered resource computation graph through the assistant", async () => {
|
|
const resourceRecord = {
|
|
id: "resource_augsburg",
|
|
displayName: "Bruce Banner",
|
|
eid: "bruce.banner",
|
|
fte: 1,
|
|
lcrCents: 5_000,
|
|
chargeabilityTarget: 80,
|
|
countryId: "country_de",
|
|
federalState: "BY",
|
|
metroCityId: "city_augsburg",
|
|
availability: {
|
|
monday: 8,
|
|
tuesday: 8,
|
|
wednesday: 8,
|
|
thursday: 8,
|
|
friday: 8,
|
|
saturday: 0,
|
|
sunday: 0,
|
|
},
|
|
country: {
|
|
id: "country_de",
|
|
code: "DE",
|
|
name: "Deutschland",
|
|
dailyWorkingHours: 8,
|
|
scheduleRules: null,
|
|
},
|
|
metroCity: { id: "city_augsburg", name: "Augsburg" },
|
|
managementLevelGroup: {
|
|
id: "mlg_1",
|
|
name: "Senior",
|
|
targetPercentage: 0.8,
|
|
},
|
|
};
|
|
|
|
const ctx = createToolContext(
|
|
{
|
|
resource: {
|
|
findUnique: vi.fn().mockResolvedValue(resourceRecord),
|
|
findFirst: vi.fn(),
|
|
findUniqueOrThrow: vi.fn().mockResolvedValue(resourceRecord),
|
|
},
|
|
assignment: {
|
|
findMany: vi.fn().mockResolvedValue([]),
|
|
},
|
|
vacation: {
|
|
findMany: vi.fn().mockResolvedValue([]),
|
|
},
|
|
holidayCalendar: {
|
|
findMany: vi.fn().mockResolvedValue([]),
|
|
},
|
|
calculationRule: {
|
|
findMany: vi.fn().mockResolvedValue([]),
|
|
},
|
|
},
|
|
{
|
|
permissions: [PermissionKey.VIEW_COSTS, PermissionKey.USE_ASSISTANT_ADVANCED_TOOLS],
|
|
},
|
|
);
|
|
|
|
const result = await executeTool(
|
|
"get_resource_computation_graph",
|
|
JSON.stringify({
|
|
resourceId: "resource_augsburg",
|
|
month: "2026-08",
|
|
domain: "SAH",
|
|
}),
|
|
ctx,
|
|
);
|
|
|
|
const parsed = JSON.parse(result.content) as {
|
|
resource: { id: string; displayName: string };
|
|
requestedDomain: string;
|
|
totalNodeCount: number;
|
|
selectedNodeCount: number;
|
|
nodes: Array<{ id: string; domain: string }>;
|
|
meta: {
|
|
countryCode: string | null;
|
|
federalState: string | null;
|
|
metroCityName: string | null;
|
|
resolvedHolidays: Array<{ name: string; scope: string }>;
|
|
};
|
|
};
|
|
|
|
expect(parsed.resource).toEqual({
|
|
id: "resource_augsburg",
|
|
eid: "bruce.banner",
|
|
displayName: "Bruce Banner",
|
|
});
|
|
expect(parsed.requestedDomain).toBe("SAH");
|
|
expect(parsed.totalNodeCount).toBeGreaterThan(parsed.selectedNodeCount);
|
|
expect(parsed.selectedNodeCount).toBeGreaterThan(0);
|
|
expect(parsed.nodes.every((node) => node.domain === "SAH")).toBe(true);
|
|
expect(parsed.meta).toMatchObject({
|
|
countryCode: "DE",
|
|
federalState: "BY",
|
|
metroCityName: "Augsburg",
|
|
});
|
|
expect(parsed.meta.resolvedHolidays).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
name: "Augsburger Friedensfest",
|
|
scope: "CITY",
|
|
}),
|
|
]),
|
|
);
|
|
});
|
|
});
|