import { beforeEach, describe, expect, it, vi } from "vitest"; import { createToolContext, executeTool, } from "./assistant-tools-holiday-read-test-helpers.js"; describe("assistant holiday resolution error paths", () => { beforeEach(() => { vi.clearAllMocks(); }); it("returns a stable assistant error when a regional holiday range is incomplete", async () => { const ctx = createToolContext({}); const result = await executeTool( "list_holidays_by_region", JSON.stringify({ countryCode: "DE", periodStart: "2026-01-01" }), ctx, ); expect(JSON.parse(result.content)).toEqual({ error: "periodStart and periodEnd must both be provided when using a custom holiday range.", }); }); it("returns a stable assistant error when resource holidays are requested for an unknown resource", async () => { const ctx = createToolContext({ resource: { findUnique: vi.fn().mockResolvedValue(null), findFirst: vi.fn().mockResolvedValue(null), findMany: vi.fn().mockResolvedValue([]), }, }); const result = await executeTool( "get_resource_holidays", JSON.stringify({ identifier: "missing-resource", year: 2026 }), ctx, ); expect(JSON.parse(result.content)).toEqual({ error: "Resource not found: missing-resource", }); }); it("returns a stable assistant error when a holiday preview references an unknown country", async () => { const ctx = createToolContext({ country: { findUnique: vi.fn().mockResolvedValue(null), }, }); const result = await executeTool( "preview_resolved_holiday_calendar", JSON.stringify({ countryId: "missing-country", year: 2026 }), ctx, ); expect(JSON.parse(result.content)).toEqual({ error: "Country not found with the given criteria.", }); }); });