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>
99 lines
3.1 KiB
TypeScript
99 lines
3.1 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { SystemRole } from "@nexus/shared";
|
|
|
|
vi.mock("@nexus/application", async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import("@nexus/application")>();
|
|
return {
|
|
...actual,
|
|
approveEstimateVersion: vi.fn(),
|
|
cloneEstimate: vi.fn(),
|
|
commitDispoImportBatch: vi.fn(),
|
|
countPlanningEntries: vi.fn().mockResolvedValue({ countsByRoleId: new Map() }),
|
|
createEstimateExport: vi.fn(),
|
|
createEstimatePlanningHandoff: vi.fn(),
|
|
createEstimateRevision: vi.fn(),
|
|
assessDispoImportReadiness: vi.fn(),
|
|
loadResourceDailyAvailabilityContexts: vi.fn().mockResolvedValue(new Map()),
|
|
getDashboardDemand: vi.fn().mockResolvedValue([]),
|
|
getDashboardBudgetForecast: vi.fn().mockResolvedValue([]),
|
|
getDashboardOverview: vi.fn(),
|
|
getDashboardSkillGapSummary: vi.fn().mockResolvedValue({
|
|
roleGaps: [],
|
|
totalOpenPositions: 0,
|
|
skillSupplyTop10: [],
|
|
resourcesByRole: [],
|
|
}),
|
|
getDashboardProjectHealth: vi.fn().mockResolvedValue([]),
|
|
getDashboardPeakTimes: vi.fn().mockResolvedValue([]),
|
|
getDashboardTopValueResources: vi.fn().mockResolvedValue([]),
|
|
getEstimateById: vi.fn(),
|
|
listAssignmentBookings: vi.fn().mockResolvedValue([]),
|
|
stageDispoImportBatch: vi.fn(),
|
|
submitEstimateVersion: vi.fn(),
|
|
updateEstimateDraft: vi.fn(),
|
|
};
|
|
});
|
|
|
|
import { executeTool } from "../router/assistant-tools.js";
|
|
import { createToolContext } from "./assistant-tools-notification-test-helpers.js";
|
|
|
|
describe("assistant task creation tools success", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("creates a task for a user through the notification router", async () => {
|
|
const db = {
|
|
notification: {
|
|
create: vi.fn().mockResolvedValue({ id: "task_2", userId: "user_2" }),
|
|
findUnique: vi.fn().mockResolvedValue({
|
|
id: "task_2",
|
|
title: "Follow up",
|
|
category: "TASK",
|
|
taskStatus: "OPEN",
|
|
}),
|
|
},
|
|
user: {
|
|
findUnique: vi
|
|
.fn()
|
|
.mockResolvedValue({ id: "user_2", email: "user2@example.com", name: "User Two" }),
|
|
},
|
|
};
|
|
const ctx = createToolContext(db, SystemRole.ADMIN);
|
|
|
|
const result = await executeTool(
|
|
"create_task_for_user",
|
|
JSON.stringify({
|
|
userId: "user_2",
|
|
title: "Follow up",
|
|
dueDate: "2026-04-03T11:00:00.000Z",
|
|
channel: "in_app",
|
|
}),
|
|
ctx,
|
|
);
|
|
|
|
expect(db.notification.create).toHaveBeenCalledWith({
|
|
data: expect.objectContaining({
|
|
userId: "user_2",
|
|
type: "TASK_CREATED",
|
|
category: "TASK",
|
|
taskStatus: "OPEN",
|
|
title: "Follow up",
|
|
dueDate: new Date("2026-04-03T11:00:00.000Z"),
|
|
senderId: "user_1",
|
|
channel: "in_app",
|
|
}),
|
|
});
|
|
expect(db.notification.findUnique).toHaveBeenCalledWith({
|
|
where: { id: "task_2" },
|
|
});
|
|
expect(JSON.parse(result.content)).toEqual(
|
|
expect.objectContaining({
|
|
success: true,
|
|
taskId: "task_2",
|
|
message: 'Created task "Follow up" for user_2.',
|
|
}),
|
|
);
|
|
});
|
|
});
|