Merge branch 'master' into mark-as-unread

Этот коммит содержится в:
Harrison Healey
2019-11-19 09:45:03 -05:00
родитель 2f066da704 c40f0a4aea
Коммит de913e7537
108 изменённых файлов: 11124 добавлений и 1190 удалений

Просмотреть файл

@@ -899,7 +899,7 @@ func TestGetPushNotificationMessage(t *testing.T) {
}
}
func TestBuildPushNotificationMessage(t *testing.T) {
func TestBuildPushNotificationMessageMentions(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -949,3 +949,67 @@ func TestBuildPushNotificationMessage(t *testing.T) {
})
}
}
func TestBuildPushNotificationMessageContents(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
team := th.CreateTeam()
sender := th.CreateUser()
receiver := th.CreateUser()
th.LinkUserToTeam(sender, team)
th.LinkUserToTeam(receiver, team)
channel := th.CreateChannel(team)
th.AddUserToChannel(sender, channel)
th.AddUserToChannel(receiver, channel)
post := th.CreatePost(channel)
explicitMention := false
channelWideMention := false
replyToThreadType := ""
receiverLocale := utils.GetUserTranslations(receiver.Locale)
for name, tc := range map[string]struct {
contentsConfig string
expectedMsg *model.PushNotification
}{
"only post ID, channel ID, and message included in push notification": {
contentsConfig: model.ID_LOADED_NOTIFICATION,
expectedMsg: &model.PushNotification{
PostId: post.Id,
ChannelId: post.ChannelId,
Category: model.CATEGORY_CAN_REPLY,
Version: model.PUSH_MESSAGE_V2,
Type: model.PUSH_TYPE_ID_LOADED,
Message: receiverLocale("api.push_notification.id_loaded.default_message"),
},
},
"full contents included in push notification": {
contentsConfig: model.GENERIC_NOTIFICATION,
expectedMsg: &model.PushNotification{
Category: model.CATEGORY_CAN_REPLY,
Version: model.PUSH_MESSAGE_V2,
Type: model.PUSH_TYPE_MESSAGE,
PostId: post.Id,
TeamId: channel.TeamId,
ChannelId: channel.Id,
ChannelName: channel.Name,
RootId: post.RootId,
SenderId: post.UserId,
SenderName: sender.Username,
Message: fmt.Sprintf("%s posted a message.", sender.Username),
},
},
} {
t.Run(name, func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.PushNotificationContents = tc.contentsConfig })
msg, err := th.App.BuildPushNotificationMessage(post, receiver, channel, channel.Name, sender.Username, explicitMention, channelWideMention, replyToThreadType)
require.Nil(t, err)
assert.Equal(t, tc.expectedMsg, msg)
})
}
}