package run import ( "testing" "git.iwork-ai.com/xdc/iqudo-top1/internal/model" ) func TestBuildStartPresentation(t *testing.T) { config := startPresentationConfig{ SummaryFieldKeys: []string{"order_id", "customer_name", "pet_name"}, ItemFieldKeys: []string{"product_images", "product_names", "product_ids"}, ImageFieldKeys: []string{"product_images"}, OpeningTitle: "开场话术", OpeningTemplate: "您好,{{input.customer_name}},看到您购买了{{input.product_names}}。", } fields := map[string]model.ScenarioField{ "order_id": {FieldKey: "order_id", FieldName: "订单号"}, "customer_name": {FieldKey: "customer_name", FieldName: "客户称呼"}, "pet_name": {FieldKey: "pet_name", FieldName: "宠物名称"}, "product_images": {FieldKey: "product_images", FieldName: "订单商品图片"}, "product_names": {FieldKey: "product_names", FieldName: "订单商品名称"}, "product_ids": {FieldKey: "product_ids", FieldName: "订单商品 ID"}, } context := runtimeContext(map[string]interface{}{ "order_id": "ORDER-001", "customer_name": "王女士", "product_images": []interface{}{"https://img.example.com/a.jpg", "https://img.example.com/b.jpg"}, "product_names": []interface{}{"商品 A", "商品 B"}, "product_ids": []interface{}{"SKU-A", "SKU-B"}, }, nil, nil) got := buildStartPresentation(config, fields, context) if len(got.Summary) != 2 { t.Fatalf("summary length = %d, want 2", len(got.Summary)) } if len(got.Items) != 2 || len(got.Items[0].Fields) != 3 { t.Fatalf("items = %#v, want two complete product rows", got.Items) } if got.Items[0].Fields[0].Kind != "image" { t.Fatalf("image kind = %q, want image", got.Items[0].Fields[0].Kind) } if got.Opening == nil || got.Opening.Content != "您好,王女士,看到您购买了商品 A、商品 B。" { t.Fatalf("opening = %#v", got.Opening) } }