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>
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { PermissionKey, SystemRole } from "@nexus/shared";
|
|
|
|
import {
|
|
createAssignment,
|
|
createHappyPathTransaction,
|
|
createToolContext,
|
|
executeTool,
|
|
} from "./assistant-tools-allocation-status-test-helpers.js";
|
|
|
|
describe("assistant allocation status tools", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("routes allocation status updates through the real allocation router path", async () => {
|
|
const { assignmentUpdate, auditCreate, transaction } = createHappyPathTransaction();
|
|
const assignment = createAssignment();
|
|
const ctx = createToolContext(
|
|
{
|
|
assignment: {
|
|
findUnique: vi.fn().mockResolvedValue(assignment),
|
|
},
|
|
project: {
|
|
findUnique: vi.fn().mockResolvedValue({
|
|
id: "project_1",
|
|
name: "Project One",
|
|
shortCode: "PROJ-1",
|
|
budgetCents: 0,
|
|
}),
|
|
},
|
|
webhook: {
|
|
findMany: vi.fn().mockResolvedValue([]),
|
|
},
|
|
$transaction: transaction,
|
|
},
|
|
{
|
|
userRole: SystemRole.ADMIN,
|
|
permissions: [PermissionKey.MANAGE_ALLOCATIONS],
|
|
},
|
|
);
|
|
|
|
const result = await executeTool(
|
|
"update_allocation_status",
|
|
JSON.stringify({ allocationId: "assignment_1", newStatus: "ACTIVE" }),
|
|
ctx,
|
|
);
|
|
|
|
expect(JSON.parse(result.content)).toEqual(
|
|
expect.objectContaining({
|
|
success: true,
|
|
message:
|
|
"Updated allocation status: Carol Danvers → Project One (PROJ-1), 2026-06-01 to 2026-06-05: PROPOSED → ACTIVE",
|
|
}),
|
|
);
|
|
expect(ctx.db.assignment.findUnique).toHaveBeenCalledWith({
|
|
where: { id: "assignment_1" },
|
|
include: expect.objectContaining({
|
|
resource: expect.any(Object),
|
|
project: expect.any(Object),
|
|
}),
|
|
});
|
|
expect(assignmentUpdate).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
where: { id: "assignment_1" },
|
|
data: expect.objectContaining({
|
|
status: "ACTIVE",
|
|
}),
|
|
}),
|
|
);
|
|
expect(auditCreate).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|