NODEDC_1C/llm_normalizer/backend/tests/assistantAddressLaneAttempt...

53 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it, vi } from "vitest";
import { runAssistantAddressLaneAttemptRuntime } from "../src/services/assistantAddressLaneAttemptRuntimeAdapter";
describe("assistant address lane attempt runtime adapter", () => {
it("uses scoped followup context when available", async () => {
const runAddressQueryTryHandle = vi.fn(async () => ({
response_type: "READY"
}));
const result = await runAssistantAddressLaneAttemptRuntime({
messageUsed: "msg",
carryMeta: {
followupContext: {
previous_intent: "docs_by_counterparty"
}
},
analysisDateHint: "2020-07-31",
activeOrganization: "ООО Тест",
mergeFollowupContextWithOrganizationScope: () => ({
previous_intent: "docs_by_counterparty",
active_organization: "ООО Тест"
}),
runAddressQueryTryHandle
});
expect(runAddressQueryTryHandle).toHaveBeenCalledWith("msg", {
followupContext: {
previous_intent: "docs_by_counterparty",
active_organization: "ООО Тест"
},
analysisDateHint: "2020-07-31"
});
expect(result).toEqual({
response_type: "READY"
});
});
it("falls back to plain attempt when scoped followup context is empty", async () => {
const runAddressQueryTryHandle = vi.fn(async () => null);
await runAssistantAddressLaneAttemptRuntime({
messageUsed: "msg",
carryMeta: null,
analysisDateHint: null,
activeOrganization: null,
mergeFollowupContextWithOrganizationScope: () => null,
runAddressQueryTryHandle
});
expect(runAddressQueryTryHandle).toHaveBeenCalledWith("msg", {
analysisDateHint: null
});
});
});