Закрепить дату складского supplier-overlap follow-up
This commit is contained in:
@@ -153,6 +153,133 @@ describe("assistantTransitionPolicy", () => {
|
||||
expect(carryover?.followupContext?.root_intent).toBe("inventory_on_hand_as_of_date");
|
||||
});
|
||||
|
||||
it("carries inventory root date into supplier-overlap current-stock follow-up", () => {
|
||||
const organization = "\u041e\u041e\u041e \"\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u041f\u043b\u044e\u0441\"";
|
||||
const warehouse = "\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434";
|
||||
const rootFilters = {
|
||||
period_from: "2021-09-01",
|
||||
period_to: "2021-09-30",
|
||||
as_of_date: "2021-09-30",
|
||||
organization,
|
||||
warehouse
|
||||
};
|
||||
const policy = buildPolicy({
|
||||
findLastAddressAssistantItem: () => ({
|
||||
text: "\u041d\u0430 30.09.2021 \u043f\u043e \u0441\u043a\u043b\u0430\u0434\u0443 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u043a\u0438.",
|
||||
debug: {
|
||||
detected_intent: "inventory_on_hand_as_of_date",
|
||||
selected_recipe: "address_inventory_on_hand_as_of_date_v1",
|
||||
extracted_filters: rootFilters,
|
||||
anchor_type: "warehouse",
|
||||
anchor_value_resolved: warehouse
|
||||
}
|
||||
}),
|
||||
findRecentInventoryRootFrame: () => ({
|
||||
intent: "inventory_on_hand_as_of_date",
|
||||
filters: rootFilters,
|
||||
anchorType: "warehouse",
|
||||
anchorValue: warehouse,
|
||||
currentFrameKind: "inventory_root"
|
||||
}),
|
||||
hasAddressFollowupContextSignal: () => false,
|
||||
hasStandaloneAddressTopicSignal: () => true,
|
||||
resolveAddressIntent: () => ({ intent: "inventory_supplier_stock_overlap_as_of_date" }),
|
||||
resolveAddressIntentFamily: (intent: unknown) =>
|
||||
String(intent ?? "").startsWith("inventory_") ? "inventory" : null
|
||||
});
|
||||
|
||||
const carryover = policy.resolveAddressFollowupCarryoverContext(
|
||||
"\u0423 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u0431\u044b\u043b\u0438 \u043a\u0443\u043f\u043b\u0435\u043d\u044b \u0442\u043e\u0432\u0430\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u043b\u0435\u0436\u0430\u0442 \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434",
|
||||
[],
|
||||
"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u0442\u043e\u0432\u0430\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442",
|
||||
{
|
||||
predecomposeContract: {
|
||||
intent: "inventory_supplier_stock_overlap_as_of_date"
|
||||
}
|
||||
},
|
||||
{
|
||||
session_context: {
|
||||
date_scope: rootFilters,
|
||||
organization_scope: organization,
|
||||
active_focus_object: {
|
||||
object_type: "organization",
|
||||
label: organization
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expect(carryover?.followupContext?.previous_intent).toBe("inventory_on_hand_as_of_date");
|
||||
expect(carryover?.followupContext?.target_intent).toBe("inventory_supplier_stock_overlap_as_of_date");
|
||||
expect(carryover?.followupContext?.previous_filters).toMatchObject(rootFilters);
|
||||
expect(carryover?.followupContext?.root_intent).toBe("inventory_on_hand_as_of_date");
|
||||
expect(carryover?.followupContext?.root_filters).toMatchObject(rootFilters);
|
||||
expect(carryover?.followupContext?.current_frame_kind).toBe("inventory_root");
|
||||
});
|
||||
|
||||
it("keeps supplier-overlap date on repeated current-residue supplier wording", () => {
|
||||
const organization = "\u041e\u041e\u041e \"\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u041f\u043b\u044e\u0441\"";
|
||||
const warehouse = "\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434";
|
||||
const rootFilters = {
|
||||
period_from: "2021-09-01",
|
||||
period_to: "2021-09-30",
|
||||
as_of_date: "2021-09-30",
|
||||
organization,
|
||||
warehouse
|
||||
};
|
||||
const policy = buildPolicy({
|
||||
findLastAddressAssistantItem: () => ({
|
||||
text: "\u041f\u043e \u0441\u043a\u043b\u0430\u0434\u0441\u043a\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u0442\u043a\u0443 \u043d\u0430 30.09.2021 \u043d\u0430\u0439\u0434\u0435\u043d\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0438.",
|
||||
debug: {
|
||||
detected_intent: "inventory_supplier_stock_overlap_as_of_date",
|
||||
selected_recipe: "address_inventory_supplier_stock_overlap_as_of_date_v1",
|
||||
extracted_filters: rootFilters,
|
||||
anchor_type: "warehouse",
|
||||
anchor_value_resolved: warehouse
|
||||
}
|
||||
}),
|
||||
findRecentInventoryRootFrame: () => ({
|
||||
intent: "inventory_on_hand_as_of_date",
|
||||
filters: rootFilters,
|
||||
anchorType: "warehouse",
|
||||
anchorValue: warehouse,
|
||||
currentFrameKind: "inventory_root"
|
||||
}),
|
||||
hasAddressFollowupContextSignal: () => false,
|
||||
hasStandaloneAddressTopicSignal: () => true,
|
||||
resolveAddressIntent: () => ({ intent: "inventory_supplier_stock_overlap_as_of_date" }),
|
||||
resolveAddressIntentFamily: (intent: unknown) =>
|
||||
String(intent ?? "").startsWith("inventory_") ? "inventory" : null
|
||||
});
|
||||
|
||||
const carryover = policy.resolveAddressFollowupCarryoverContext(
|
||||
"\u041f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0443 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0442\u043e\u0432\u0430\u0440\u043d\u044b\u0439 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434",
|
||||
[],
|
||||
"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0442\u043e\u0432\u0430\u0440\u044b, \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434",
|
||||
{
|
||||
predecomposeContract: {
|
||||
intent: "inventory_supplier_stock_overlap_as_of_date"
|
||||
}
|
||||
},
|
||||
{
|
||||
session_context: {
|
||||
date_scope: rootFilters,
|
||||
organization_scope: organization,
|
||||
active_focus_object: {
|
||||
object_type: "warehouse",
|
||||
label: warehouse
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expect(carryover?.followupContext?.previous_intent).toBe("inventory_supplier_stock_overlap_as_of_date");
|
||||
expect(carryover?.followupContext?.target_intent).toBe("inventory_supplier_stock_overlap_as_of_date");
|
||||
expect(carryover?.followupContext?.previous_filters).toMatchObject(rootFilters);
|
||||
expect(carryover?.followupContext?.root_intent).toBe("inventory_on_hand_as_of_date");
|
||||
expect(carryover?.followupContext?.current_frame_kind).toBe("inventory_root");
|
||||
});
|
||||
|
||||
it("builds continuation contract from extracted root carryover", () => {
|
||||
const policy = buildPolicy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user