77 lines
3.7 KiB
TypeScript
77 lines
3.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
|
||
import { runAddressDecomposeStage } from "../src/services/address_runtime/decomposeStage";
|
||
import { composeFactualReply } from "../src/services/address_runtime/composeStage";
|
||
|
||
describe("inventory aging follow-up", () => {
|
||
it("keeps carried date window for 'на эту дату' aging follow-up", () => {
|
||
const result = runAddressDecomposeStage("Какие остатки по товарам на эту дату относятся к старым закупкам", {
|
||
previous_intent: "inventory_purchase_provenance_for_item",
|
||
previous_filters: {
|
||
item: "Четки Пост (84*117)",
|
||
as_of_date: "2021-09-30",
|
||
period_from: "2021-09-01",
|
||
period_to: "2021-09-30",
|
||
warehouse: "Основной склад",
|
||
organization: "ООО \\Альтернатива Плюс\\"
|
||
},
|
||
previous_anchor_type: "unknown",
|
||
previous_anchor_value: null
|
||
});
|
||
|
||
expect(result).not.toBeNull();
|
||
expect(result?.intent.intent).toBe("inventory_aging_by_purchase_date");
|
||
expect(result?.filters.extracted_filters.as_of_date).toBe("2021-09-30");
|
||
expect(result?.filters.extracted_filters.period_from).toBe("2021-09-01");
|
||
expect(result?.filters.extracted_filters.period_to).toBe("2021-09-30");
|
||
expect(result?.filters.extracted_filters.sort).toBe("period_asc");
|
||
expect(result?.baseReasons).toContain("as_of_date_from_followup_context");
|
||
expect(result?.baseReasons).toContain("period_from_followup_context");
|
||
});
|
||
|
||
it("renders aging answer as oldest-first item list instead of raw documents", () => {
|
||
const reply = composeFactualReply(
|
||
"inventory_aging_by_purchase_date",
|
||
[
|
||
{
|
||
period: "2019-02-06T00:00:00Z",
|
||
registrator: "Поступление товаров и услуг 00000000004 от 06.02.2019 0:00:00",
|
||
account_dt: "41.01",
|
||
account_kt: "60.01",
|
||
amount: 833.33,
|
||
analytics: ["Четки Пост (84*117)", "Основной склад", "Торговый дом \\Союз\\"],
|
||
item: "Четки Пост (84*117)",
|
||
warehouse: "Основной склад",
|
||
organization: "ООО \\Альтернатива Плюс\\"
|
||
},
|
||
{
|
||
period: "2020-11-20T12:00:00Z",
|
||
registrator: "Поступление товаров и услуг 00000000030 от 20.11.2020 12:00:00",
|
||
account_dt: "41.01",
|
||
account_kt: "60.01",
|
||
amount: 7250,
|
||
analytics: ["Зеркало для инвалидов поворотное травмобезопасное", "Основной склад", "ВИЗАНТИЯ"],
|
||
item: "Зеркало для инвалидов поворотное травмобезопасное",
|
||
warehouse: "Основной склад",
|
||
organization: "ООО \\Альтернатива Плюс\\"
|
||
}
|
||
],
|
||
{
|
||
asOfDate: "2021-09-30",
|
||
useRubCurrency: true
|
||
}
|
||
);
|
||
|
||
expect(reply.responseType).toBe("FACTUAL_SUMMARY");
|
||
expect(reply.text).toContain("К старым закупкам на 30.09.2021");
|
||
expect(reply.text).toContain("Позиции от самых старых закупок:");
|
||
expect(reply.text).toContain("Ограничения:");
|
||
expect(reply.text).not.toContain("Блок 1");
|
||
expect(reply.text).not.toContain("exact-контур");
|
||
expect(reply.text.indexOf("1. Четки Пост (84*117)")).toBeGreaterThan(-1);
|
||
expect(reply.text.indexOf("2. Зеркало для инвалидов поворотное травмобезопасное")).toBeGreaterThan(
|
||
reply.text.indexOf("1. Четки Пост (84*117)")
|
||
);
|
||
});
|
||
});
|