Skip and warn on emoji import when name conflicts with system emoji (#19516)
This changes import behavior related to emoji imports when the name conflicts with the name of a system emoji. Previously, the import would fail, but now a warning is logged and the conflicting emoji is skipped.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
40f48432a6
Коммит
03d059bd2a
@@ -1343,34 +1343,37 @@ func TestImportValidateDirectPostImportData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportValidateEmojiImportData(t *testing.T) {
|
||||
data := EmojiImportData{
|
||||
Name: ptrStr("parrot2"),
|
||||
Image: ptrStr("/path/to/image"),
|
||||
var testCases = []struct {
|
||||
testName string
|
||||
name *string
|
||||
image *string
|
||||
expectError bool
|
||||
expectSystemEmoji bool
|
||||
}{
|
||||
{"success", ptrStr("parrot2"), ptrStr("/path/to/image"), false, false},
|
||||
{"system emoji", ptrStr("smiley"), ptrStr("/path/to/image"), true, true},
|
||||
{"empty name", ptrStr(""), ptrStr("/path/to/image"), true, false},
|
||||
{"empty image", ptrStr("parrot2"), ptrStr(""), true, false},
|
||||
{"empty name and image", ptrStr(""), ptrStr(""), true, false},
|
||||
{"nil name", nil, ptrStr("/path/to/image"), true, false},
|
||||
{"nil image", ptrStr("parrot2"), nil, true, false},
|
||||
{"nil name and image", nil, nil, true, false},
|
||||
}
|
||||
|
||||
err := validateEmojiImportData(&data)
|
||||
assert.Nil(t, err, "Validation should succeed")
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
data := EmojiImportData{
|
||||
Name: tc.name,
|
||||
Image: tc.image,
|
||||
}
|
||||
|
||||
*data.Name = "smiley"
|
||||
err = validateEmojiImportData(&data)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
*data.Name = ""
|
||||
err = validateEmojiImportData(&data)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
*data.Name = ""
|
||||
*data.Image = ""
|
||||
err = validateEmojiImportData(&data)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
*data.Image = "/path/to/image"
|
||||
data.Name = nil
|
||||
err = validateEmojiImportData(&data)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
data.Name = ptrStr("parrot")
|
||||
data.Image = nil
|
||||
err = validateEmojiImportData(&data)
|
||||
assert.NotNil(t, err)
|
||||
err := validateEmojiImportData(&data)
|
||||
if tc.expectError {
|
||||
require.NotNil(t, err)
|
||||
assert.Equal(t, tc.expectSystemEmoji, err.Id == "model.emoji.system_emoji_name.app_error")
|
||||
} else {
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user