fix: sync avatar update compatibility fixes
This commit is contained in:
parent
2ad9dd8bb2
commit
44c32521e7
6 changed files with 374 additions and 17 deletions
|
|
@ -11,15 +11,12 @@ import (
|
|||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
func TestAccountGetDefaultProfilePhotoEmojisUsesSeededEmojiSets(t *testing.T) {
|
||||
func TestAccountGetDefaultProfilePhotoEmojisUsesSeededEmojiSetsWhenSystemMissing(t *testing.T) {
|
||||
files := &fakeFiles{sets: map[domain.StickerSetKind][]domain.StickerSet{
|
||||
domain.StickerSetKindEmoji: {
|
||||
{DocumentIDs: []int64{1001, 0, 1002, 1001}},
|
||||
{DocumentIDs: []int64{1003}},
|
||||
},
|
||||
domain.StickerSetKindSystem: {
|
||||
{SystemKey: "animated_emoji", DocumentIDs: []int64{2001}},
|
||||
},
|
||||
}}
|
||||
r := New(Config{}, Deps{Files: files}, zaptest.NewLogger(t), clock.System)
|
||||
|
||||
|
|
@ -47,6 +44,97 @@ func TestAccountGetDefaultProfilePhotoEmojisUsesSeededEmojiSets(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAccountGetDefaultProfilePhotoEmojisPrefersSynthesizedDefaultStatuses(t *testing.T) {
|
||||
files := &fakeFiles{
|
||||
sets: map[domain.StickerSetKind][]domain.StickerSet{
|
||||
domain.StickerSetKindEmoji: {
|
||||
{ShortName: "FestiveFontEmoji", DocumentIDs: []int64{9001, 9002}},
|
||||
},
|
||||
domain.StickerSetKindSystem: {
|
||||
{ShortName: "StatusPack", SystemKey: domain.StickerSetSystemKeyEmojiDefaultStatuses, DocumentIDs: []int64{1001, 0, 1002, 1001}},
|
||||
{ShortName: "TelesrvDefaultStatuses", SystemKey: domain.StickerSetSystemKeyEmojiDefaultStatuses, DocumentIDs: []int64{7001, 0, 7002, 7001}},
|
||||
{SystemKey: "animated_emoji", DocumentIDs: []int64{4001, 4002}},
|
||||
},
|
||||
},
|
||||
docs: map[int64]domain.Document{
|
||||
1001: {ID: 1001, Attributes: []domain.DocumentAttribute{{Kind: domain.DocAttrCustomEmoji, TextColor: true}}},
|
||||
1002: {ID: 1002, Attributes: []domain.DocumentAttribute{{Kind: domain.DocAttrCustomEmoji, TextColor: true}}},
|
||||
7001: {ID: 7001, Attributes: []domain.DocumentAttribute{{Kind: domain.DocAttrSticker}}},
|
||||
7002: {ID: 7002, Attributes: []domain.DocumentAttribute{{Kind: domain.DocAttrSticker}}},
|
||||
},
|
||||
}
|
||||
r := New(Config{}, Deps{Files: files}, zaptest.NewLogger(t), clock.System)
|
||||
|
||||
got, err := r.onAccountGetDefaultProfilePhotoEmojis(context.Background(), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("get default profile photo emojis: %v", err)
|
||||
}
|
||||
list, ok := got.(*tg.EmojiList)
|
||||
if !ok {
|
||||
t.Fatalf("default profile photo emojis = %T, want *tg.EmojiList", got)
|
||||
}
|
||||
if len(list.DocumentID) != 2 || list.DocumentID[0] != 7001 || list.DocumentID[1] != 7002 {
|
||||
t.Fatalf("document ids = %v, want deduped synthesized default status ids", list.DocumentID)
|
||||
}
|
||||
if list.Hash == 0 {
|
||||
t.Fatal("emoji list hash = 0, want stable non-zero hash")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountGetDefaultProfilePhotoEmojisSkipsTextColorStatusPack(t *testing.T) {
|
||||
files := &fakeFiles{
|
||||
sets: map[domain.StickerSetKind][]domain.StickerSet{
|
||||
domain.StickerSetKindSystem: {
|
||||
{ShortName: "StatusPack", SystemKey: domain.StickerSetSystemKeyEmojiDefaultStatuses, DocumentIDs: []int64{1001, 0, 1002, 1001}},
|
||||
},
|
||||
},
|
||||
docs: map[int64]domain.Document{
|
||||
1001: {ID: 1001, Attributes: []domain.DocumentAttribute{{Kind: domain.DocAttrCustomEmoji, TextColor: true}}},
|
||||
1002: {ID: 1002, Attributes: []domain.DocumentAttribute{{Kind: domain.DocAttrCustomEmoji, TextColor: true}}},
|
||||
},
|
||||
}
|
||||
r := New(Config{}, Deps{Files: files}, zaptest.NewLogger(t), clock.System)
|
||||
|
||||
got, err := r.onAccountGetDefaultProfilePhotoEmojis(context.Background(), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("get default profile photo emojis: %v", err)
|
||||
}
|
||||
list, ok := got.(*tg.EmojiList)
|
||||
if !ok {
|
||||
t.Fatalf("default profile photo emojis = %T, want *tg.EmojiList", got)
|
||||
}
|
||||
if len(list.DocumentID) != 0 {
|
||||
t.Fatalf("document ids = %v, want text-color StatusPack filtered out", list.DocumentID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountGetDefaultProfilePhotoEmojisFallsBackToSystemBeforeCustomPacks(t *testing.T) {
|
||||
files := &fakeFiles{sets: map[domain.StickerSetKind][]domain.StickerSet{
|
||||
domain.StickerSetKindEmoji: {
|
||||
{ShortName: "FestiveFontEmoji", DocumentIDs: []int64{9001, 9002}},
|
||||
},
|
||||
domain.StickerSetKindSystem: {
|
||||
{SystemKey: "animated_emoji", DocumentIDs: []int64{4001, 4002, 4001}},
|
||||
},
|
||||
}}
|
||||
r := New(Config{}, Deps{Files: files}, zaptest.NewLogger(t), clock.System)
|
||||
|
||||
got, err := r.onAccountGetDefaultProfilePhotoEmojis(context.Background(), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("get default profile photo emojis: %v", err)
|
||||
}
|
||||
list, ok := got.(*tg.EmojiList)
|
||||
if !ok {
|
||||
t.Fatalf("default profile photo emojis = %T, want *tg.EmojiList", got)
|
||||
}
|
||||
if len(list.DocumentID) != 2 || list.DocumentID[0] != 4001 || list.DocumentID[1] != 4002 {
|
||||
t.Fatalf("document ids = %v, want animated_emoji ids before arbitrary custom packs", list.DocumentID)
|
||||
}
|
||||
if list.Hash == 0 {
|
||||
t.Fatal("emoji list hash = 0, want stable non-zero hash")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountGetDefaultProfilePhotoEmojisFallsBackToSystemAnimatedEmoji(t *testing.T) {
|
||||
files := &fakeFiles{sets: map[domain.StickerSetKind][]domain.StickerSet{
|
||||
domain.StickerSetKindSystem: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue