Files
dingtalk-workspace-cli/internal/shortcut/chatmsg/card_ref_test.go
栩朝 15a2fea0dc fix(chat): split references and harden card updates
Split chat message and group references by task, update intent routing and context budget, distinguish accepted card updates from verified writes, and explain the ambiguous chat --from flag.
2026-08-14 18:38:31 +08:00

50 lines
2.1 KiB
Go

// Copyright 2026 Alibaba Group
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package chatmsg
import "testing"
func TestCrossPlatformCoverageProjectStreamingCardReceipt(t *testing.T) {
complete := ProjectStreamingCardReceipt(map[string]any{
"result": map[string]any{
"bizId": "biz-1",
"openMessageId": "msg-1",
"openConversationId": "cid-1",
},
}, "biz-1")
if complete["contractVersion"] != StreamingCardContractVersion || complete["referencePairAvailable"] != true {
t.Fatalf("complete receipt = %#v", complete)
}
ref, _ := complete["cardRef"].(map[string]any)
if ref["bizId"] != "biz-1" || ref["openMessageId"] != "msg-1" || ref["openConversationId"] != "cid-1" {
t.Fatalf("cardRef = %#v", ref)
}
if _, exists := complete["capabilityGap"]; exists {
t.Fatalf("complete receipt has capability gap: %#v", complete)
}
partial := ProjectStreamingCardReceipt(map[string]any{"result": map[string]any{"bizId": "biz-2"}}, "biz-2")
if partial["referencePairAvailable"] != false || partial["capabilityGap"] == "" {
t.Fatalf("partial receipt = %#v", partial)
}
}
func TestCrossPlatformCoverageProjectStreamingCardUpdate(t *testing.T) {
payload := ProjectStreamingCardUpdate(map[string]any{"result": map[string]any{"updated": true}}, "biz-1", CardUpdateVerification{Accepted: true, Verified: true, Evidence: "updated=true"})
if payload["contractVersion"] != StreamingCardContractVersion || payload["verified"] != true || payload["verificationEvidence"] != "updated=true" {
t.Fatalf("payload = %#v", payload)
}
if _, exists := payload["result"]; !exists {
t.Fatal("lower response was not preserved")
}
}
func TestCrossPlatformCoverageProjectAcceptedUnverifiedStreamingCardUpdate(t *testing.T) {
payload := ProjectStreamingCardUpdate(map[string]any{"success": true}, "biz-1", CardUpdateVerification{Accepted: true, Verified: false, Evidence: "success=true"})
if payload["accepted"] != true || payload["verified"] != false || payload["warning"] == "" {
t.Fatalf("payload = %#v", payload)
}
}