feat: sync bot keyboards and callbacks
Sync telesrv b96f2dd (feat(bot): complete keyboards callbacks and durable delivery). Skipped private docs and preserved public README files per sync rules; normalized the appearance seed log label for public naming.
This commit is contained in:
parent
0c99ae0a9d
commit
bf965f610c
80 changed files with 7212 additions and 349 deletions
43
internal/store/memory/message_markup_test.go
Normal file
43
internal/store/memory/message_markup_test.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package memory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
func TestPrivateReplyKeyboardSurvivesBothBoxesAndHistory(t *testing.T) {
|
||||
store := NewMessageStore(NewDialogStore())
|
||||
markup := &domain.MessageReplyMarkup{
|
||||
Type: domain.MessageReplyMarkupKeyboard,
|
||||
Keyboard: [][]domain.MarkupButton{{{Type: domain.MarkupButtonText, Text: "Help"}}},
|
||||
Resize: true,
|
||||
SingleUse: true,
|
||||
Persistent: true,
|
||||
Placeholder: "Choose",
|
||||
}
|
||||
res, err := store.SendPrivateText(context.Background(), domain.SendPrivateTextRequest{
|
||||
SenderUserID: 10, RecipientUserID: 20, RandomID: 30,
|
||||
Message: "pick", Date: 40, ReplyMarkup: markup,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("SendPrivateText: %v", err)
|
||||
}
|
||||
assertReplyKeyboard := func(name string, got *domain.MessageReplyMarkup) {
|
||||
t.Helper()
|
||||
if got == nil || got.Kind() != domain.MessageReplyMarkupKeyboard || len(got.Keyboard) != 1 ||
|
||||
len(got.Keyboard[0]) != 1 || got.Keyboard[0][0].Text != "Help" || !got.Resize ||
|
||||
!got.SingleUse || !got.Persistent || got.Placeholder != "Choose" {
|
||||
t.Fatalf("%s = %#v", name, got)
|
||||
}
|
||||
}
|
||||
assertReplyKeyboard("sender", res.SenderMessage.ReplyMarkup)
|
||||
assertReplyKeyboard("recipient", res.RecipientMessage.ReplyMarkup)
|
||||
markup.Keyboard[0][0].Text = "mutated"
|
||||
list, err := store.GetByIDs(context.Background(), 20, []int{res.RecipientMessage.ID})
|
||||
if err != nil || len(list.Messages) != 1 {
|
||||
t.Fatalf("GetByIDs = %+v, %v", list, err)
|
||||
}
|
||||
assertReplyKeyboard("recipient history", list.Messages[0].ReplyMarkup)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue