ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.40: вынос runAddressLaneAttempt (с merge контекста и вызовом addressQueryService) в отдельный runtime-адаптер из handleMessage

This commit is contained in:
2026-04-10 23:15:08 +03:00
parent 5520dbccbc
commit bac6ebe701
6 changed files with 158 additions and 25 deletions
@@ -0,0 +1,52 @@
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
});
});
});