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>
66 lines
2.0 KiB
TypeScript
66 lines
2.0 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,
|
|
getDashboardBudgetForecast: vi.fn().mockResolvedValue([]),
|
|
listAssignmentBookings: vi.fn().mockResolvedValue([]),
|
|
};
|
|
});
|
|
|
|
vi.mock("../lib/audit.js", () => ({
|
|
createAuditEntry: vi.fn().mockResolvedValue(undefined),
|
|
}));
|
|
|
|
import { executeTool } from "../router/assistant-tools.js";
|
|
import { createToolContext } from "./assistant-tools-holiday-test-helpers.js";
|
|
|
|
describe("assistant holiday calendar mutation tools - guards", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("rejects holiday calendar mutations for non-admin assistant users", async () => {
|
|
const ctx = createToolContext({}, [], SystemRole.MANAGER);
|
|
const result = await executeTool(
|
|
"create_holiday_calendar",
|
|
JSON.stringify({
|
|
name: "Hamburg Feiertage",
|
|
scopeType: "STATE",
|
|
countryId: "country_de",
|
|
stateCode: "HH",
|
|
}),
|
|
ctx,
|
|
);
|
|
|
|
expect(JSON.parse(result.content)).toEqual(
|
|
expect.objectContaining({
|
|
error: "You do not have permission to perform this action.",
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("returns a stable error when a holiday calendar scope already exists", async () => {
|
|
const ctx = createToolContext({
|
|
country: {
|
|
findUnique: vi.fn().mockResolvedValue({ id: "country_de", name: "Germany" }),
|
|
},
|
|
holidayCalendar: {
|
|
findFirst: vi.fn().mockResolvedValue({ id: "cal_existing" }),
|
|
},
|
|
});
|
|
|
|
const result = await executeTool(
|
|
"create_holiday_calendar",
|
|
JSON.stringify({ name: "Germany National", scopeType: "COUNTRY", countryId: "country_de" }),
|
|
ctx,
|
|
);
|
|
|
|
expect(JSON.parse(result.content)).toEqual({
|
|
error: "A holiday calendar for this scope already exists.",
|
|
});
|
|
});
|
|
});
|