feat: add DingTalk answer feedback workflow
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFeedbackProjectionJSONUsesOnlySafeFields(t *testing.T) {
|
||||
updated := time.Date(2026, 7, 21, 15, 0, 0, 0, time.UTC)
|
||||
detail := TurnDetail{Feedback: []AnswerFeedback{{
|
||||
ActorExternalID: "user-1", ActorDisplayName: "Alice", Value: "down", ReasonCode: "not_resolved", UpdatedAt: updated,
|
||||
}}}
|
||||
raw, err := json.Marshal(detail)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body := string(raw)
|
||||
for _, want := range []string{`"feedback"`, `"actor_external_id":"user-1"`, `"actor_display_name":"Alice"`, `"value":"down"`, `"reason_code":"not_resolved"`, `"updated_at"`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("feedback JSON missing %s: %s", want, body)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{"out_track", "provider_message", "answer_message_id", "actor_id", "token", "callback", "params"} {
|
||||
if strings.Contains(strings.ToLower(body), forbidden) {
|
||||
t.Errorf("feedback JSON leaked %q: %s", forbidden, body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTurnSummaryFeedbackCountsJSON(t *testing.T) {
|
||||
raw, err := json.Marshal(TurnSummary{FeedbackUpCount: 2, FeedbackDownCount: 3, FeedbackUnresolvedCount: 1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body := string(raw)
|
||||
for _, want := range []string{`"feedback_up_count":2`, `"feedback_down_count":3`, `"feedback_unresolved_count":1`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("summary JSON missing %s: %s", want, body)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user