fix(minutes): align search scope enums

This commit is contained in:
Dennis
2026-08-11 22:49:27 +08:00
parent a3f5a83527
commit 3d4e43f4fc
2 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -224,7 +224,7 @@ func executeMinutesSearch(rt *shortcut.RuntimeContext) error {
if err != nil {
return err
}
belonging := map[string]string{"mine": "created", "shared": "shared", "all": "noLimit"}[rt.Str("scope")]
belonging := map[string]string{"mine": "createdByMe", "shared": "sharedToMe", "all": "noLimit"}[rt.Str("scope")]
token := rt.Str("cursor")
seenTokens := map[string]bool{}
seenIDs := map[string]bool{}
@@ -10,6 +10,7 @@ import (
"errors"
"os"
"path/filepath"
"reflect"
"testing"
apperrors "github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/errors"
@@ -108,6 +109,30 @@ func TestCrossPlatformCoverageMinutesSearchPaginatesFiltersAndRejectsUnknownE2E(
t.Fatalf("search calls=%#v", calls)
}
for _, test := range []struct {
scope string
belonging string
}{
{scope: "mine", belonging: "createdByMe"},
{scope: "shared", belonging: "sharedToMe"},
{scope: "all", belonging: "noLimit"},
} {
t.Run("scope "+test.scope, func(t *testing.T) {
scoped := &minutesE2ECaller{responses: map[string][]string{
"minutes/list_by_keyword_and_time_range": {`{"success":true,"result":{"itemList":[],"hasNext":false}}`},
}}
payload, _, err := runMinutesAlignmentCLI(t, scoped, "minutes", "+search", "--query", "needle", "--scope", test.scope, "--limit", "1")
if err != nil || payload["count"] != float64(0) || payload["complete"] != true {
t.Fatalf("scope %s payload=%#v err=%v", test.scope, payload, err)
}
calls := scoped.arguments["minutes/list_by_keyword_and_time_range"]
want := map[string]any{"belongingConditionId": test.belonging, "keyword": "needle", "maxResults": 1}
if len(calls) != 1 || !reflect.DeepEqual(calls[0], want) {
t.Fatalf("scope %s calls=%#v, want exactly %#v", test.scope, calls, want)
}
})
}
unknown := &minutesE2ECaller{responses: map[string][]string{"minutes/list_by_keyword_and_time_range": {`{"success":true,"result":{}}`}}}
if payload, output, err := runMinutesAlignmentCLI(t, unknown, "minutes", "+search", "--query", "周会"); err == nil || payload != nil || output != "" {
t.Fatalf("unknown list accepted: payload=%#v output=%q err=%v", payload, output, err)