NODEDC_1C/llm_normalizer/backend/tests/assistantDataScopePolicy.te...

32 lines
1.0 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { createAssistantDataScopePolicy } from "../src/services/assistantDataScopePolicy";
function createPolicy() {
return createAssistantDataScopePolicy({
activeMcpChannel: "default",
mcpProxyUrl: "http://localhost",
executeAddressMcpQuery: vi.fn(async () => ({ rows: [] })),
repairAddressMojibake: (value: unknown) => String(value ?? "")
});
}
describe("assistantDataScopePolicy", () => {
it("recovers active organization from assistant-side living chat authority when grounded answer is absent", () => {
const policy = createPolicy();
const activeOrganization = policy.findLastAssistantActiveOrganization([
{
role: "assistant",
debug: {
execution_lane: "living_chat",
living_chat_selected_organization: "Org Selected",
assistant_active_organization: "Org Selected",
assistant_known_organizations: ["Org Selected", "Org Backup"]
}
}
]);
expect(activeOrganization).toBe("Org Selected");
});
});