53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
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
|
||
});
|
||
});
|
||
});
|