NODEDC_1C/llm_normalizer/backend/tests/addressInventoryRootFrameRe...

66 lines
3.2 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 } from "vitest";
import { runAddressDecomposeStage } from "../src/services/address_runtime/decomposeStage";
describe("inventory root frame regressions", () => {
it("restores inventory root frame for restatement on the same period after foreign domain drift", () => {
const result = runAddressDecomposeStage(
"ладно ок. покажи мне еще раз позиции на складе на тот же период рассмотрения",
{
previous_intent: "customer_revenue_and_payments",
previous_filters: {
organization: "ООО \\Альтернатива Плюс\\"
},
previous_anchor_type: "organization",
previous_anchor_value: "ООО \\Альтернатива Плюс\\",
root_intent: "inventory_on_hand_as_of_date",
root_filters: {
organization: "ООО \\Альтернатива Плюс\\",
period_from: "2022-02-01",
period_to: "2022-02-28",
as_of_date: "2022-02-28"
},
root_anchor_type: "organization",
root_anchor_value: "ООО \\Альтернатива Плюс\\",
current_frame_kind: "generic"
}
);
expect(result).not.toBeNull();
expect(result?.intent.intent).toBe("inventory_on_hand_as_of_date");
expect(result?.intent.reasons).toContain("intent_restored_to_inventory_root_frame");
expect(result?.filters.extracted_filters.organization).toBe("ООО \\Альтернатива Плюс\\");
expect(result?.filters.extracted_filters.period_from).toBe("2022-02-01");
expect(result?.filters.extracted_filters.period_to).toBe("2022-02-28");
expect(result?.filters.extracted_filters.as_of_date).toBe("2022-02-28");
expect(result?.filters.warnings).toContain("period_from_from_followup_context");
expect(result?.filters.warnings).toContain("period_to_from_followup_context");
});
it("promotes selected-object provenance slang with 'где мы взяли это' into inventory provenance", () => {
const result = runAddressDecomposeStage(
'По выбранному объекту "Зеркало для инвалидов поворотное травмобезопасное": где мы взяли это говнище?',
{
previous_intent: "inventory_on_hand_as_of_date",
previous_filters: {
organization: "ООО \\Альтернатива Плюс\\",
warehouse: "Основной склад",
period_from: "2022-02-01",
period_to: "2022-02-28",
as_of_date: "2022-02-28"
},
previous_anchor_type: "unknown",
previous_anchor_value: null
}
);
expect(result).not.toBeNull();
expect(result?.intent.intent).toBe("inventory_purchase_provenance_for_item");
expect(result?.filters.extracted_filters.item).toBe("Зеркало для инвалидов поворотное травмобезопасное");
expect(result?.filters.extracted_filters.as_of_date).toBe("2022-02-28");
expect(
result?.baseReasons?.includes("intent_adjusted_to_inventory_followup_context") ||
result?.intent.reasons.includes("inventory_selected_object_provenance_signal_detected")
).toBe(true);
});
});