fix: keep only setting command entries
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user