fix: keep only setting command entries

This commit is contained in:
姚章浩
2026-08-14 12:35:33 +08:00
parent 19ed4b50df
commit 18c81232ce
4 changed files with 24 additions and 16 deletions
+20 -6
View File
@@ -159,19 +159,33 @@ func TestControllerExplicitlyTestsAndActivatesSupportGroup(t *testing.T) {
t.Fatalf("reply=%q", out)
}
}
func TestControllerHelpIsHandledLocally(t *testing.T) {
func TestControllerOnlyHandlesSettingEntrypoints(t *testing.T) {
r := newMemoryRepo()
c := NewController(r)
if !c.ShouldHandle(context.Background(), "t", "u", "/help") {
t.Fatal("help must be intercepted before QA")
if c.ShouldHandle(context.Background(), "t", "u", "/help") {
t.Fatal("help must not enter the settings controller")
}
out, err := c.Handle(context.Background(), SettingInput{TenantKey: "t", StaffID: "u", Text: "/help", ConversationType: "direct"})
if err != nil {
t.Fatal(err)
}
want := "设置回答语言:/setting language <auto|zh-CN|en|ja|ko|es>\n例如:/setting language en"
if out != want {
t.Fatalf("help=%q want %q", out, want)
if out != "" {
t.Fatalf("help reply=%q must be empty", out)
}
}
func TestControllerChineseSettingAliasRunsSubcommands(t *testing.T) {
r := newMemoryRepo()
c := NewController(r)
if !c.ShouldHandle(context.Background(), "t", "u", "/设置 language ja") {
t.Fatal("Chinese setting alias must be handled")
}
out, err := c.Handle(context.Background(), SettingInput{TenantKey: "t", Channel: "dingtalk", StaffID: "u", Text: "/设置 language ja", ConversationType: "direct"})
if err != nil {
t.Fatal(err)
}
if r.prefs["t/u"] != "ja" || !strings.Contains(out, "ja") {
t.Fatalf("pref=%q reply=%q", r.prefs["t/u"], out)
}
}