feat: sync AI compose and ChatBot features
This commit is contained in:
parent
35e5d38f4d
commit
b7269b135f
75 changed files with 5426 additions and 123 deletions
42
internal/rpc/bots_hooks_test.go
Normal file
42
internal/rpc/bots_hooks_test.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/gotd/td/clock"
|
||||
"github.com/gotd/td/tg"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
func TestPushBotTextDraftUsesUserTypingDraftAction(t *testing.T) {
|
||||
sessions := &captureSessions{}
|
||||
r := New(Config{}, Deps{Sessions: sessions}, zaptest.NewLogger(t), clock.System)
|
||||
ctx := WithSessionID(WithAuthKeyID(context.Background(), [8]byte{1}), 77)
|
||||
|
||||
r.PushBotTextDraft(ctx, domain.ChatBotUserID, 1001, 4242, "Hello from AI")
|
||||
|
||||
short, ok := sessions.lastUserPush().(*tg.UpdateShort)
|
||||
if !ok {
|
||||
t.Fatalf("pushed update = %T, want *tg.UpdateShort", sessions.lastUserPush())
|
||||
}
|
||||
update, ok := short.Update.(*tg.UpdateUserTyping)
|
||||
if !ok {
|
||||
t.Fatalf("short update = %T, want *tg.UpdateUserTyping", short.Update)
|
||||
}
|
||||
if update.UserID != domain.ChatBotUserID {
|
||||
t.Fatalf("typing user_id = %d, want ChatBot", update.UserID)
|
||||
}
|
||||
action, ok := update.Action.(*tg.SendMessageTextDraftAction)
|
||||
if !ok {
|
||||
t.Fatalf("typing action = %T, want *tg.SendMessageTextDraftAction", update.Action)
|
||||
}
|
||||
if action.RandomID != 4242 || action.Text.Text != "Hello from AI" {
|
||||
t.Fatalf("draft action = random_id %d text %q", action.RandomID, action.Text.Text)
|
||||
}
|
||||
if snap := sessions.snapshot(); snap.userID != 1001 || snap.sessionID != 77 {
|
||||
t.Fatalf("push target/excluded session = user %d session %d, want user 1001 session 77", snap.userID, snap.sessionID)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue