feat(asset-ai): generate contextual presentations and drilldown plans
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { resultScope, followupSuggestions } from "./presentation.js";
|
||||
import { applyAction } from "./execute.js";
|
||||
import type { AssistantResult, QueryPlan } from "../../../shared/assets/assistant.js";
|
||||
const plan: QueryPlan = { kind:"assets", category:"inventory", groupBy:"type", view:"table", filters:{type:["4.5T"],city:["嘉兴市"]} };
|
||||
function result(p:QueryPlan): AssistantResult { return {plan:p,title:"合成",summary:"",source:"",fetchedAt:"",groups:[],rows:[{id:"1",plate:"合成",type:"4.5T",vehicleClass:"4.5T普货",model:"合成",region:"华东",city:"嘉兴市",department:"合成",status:"可运营"}],metrics:[]}; }
|
||||
test("followups advance beyond current grouping and never offer an existing list or period comparison",()=>{
|
||||
assert.deepEqual(followupSuggestions(result(plan)),["保持当前筛选,按车型细分拆分","查看当前范围车辆明细","当前库存中待交车有多少"]);
|
||||
const flow = {...plan,kind:"flow" as const,category:"all" as const,groupBy:"none" as const,view:"list" as const,comparePrevious:true,start:"2026-09-17",end:"2026-09-23"};
|
||||
assert.deepEqual(followupSuggestions(result(flow)),["按天用表格展示"]);
|
||||
});
|
||||
test("scope keeps exclusions, specified vehicles and unknown source time visible without inventing freshness",()=>{
|
||||
const scope=resultScope({...plan,excludeFilters:{region:["华南"]},vehicleIds:["1"],topN:3},"合成公司");
|
||||
assert.equal(scope.company,"合成公司");
|
||||
assert.ok(scope.filters.includes("排除区域:华南"));
|
||||
assert.ok(scope.filters.includes("指定 1 台车辆"));
|
||||
assert.equal(scope.sourceUpdatedAt,null);
|
||||
assert.match(scope.definitions.join(""),/完整筛选范围/);
|
||||
});
|
||||
test("opening inventory from a briefing leaves briefing mode and keeps inherited geographic scope",()=>{
|
||||
const briefing:QueryPlan={...plan,category:"all",analysis:"briefing"};
|
||||
const next=applyAction(briefing,{type:"category",category:"inventory"},result(briefing));
|
||||
assert.equal(next.category,"inventory");assert.equal(next.analysis,"distribution");assert.deepEqual(next.filters,briefing.filters);
|
||||
});
|
||||
Reference in New Issue
Block a user