summaryrefslogtreecommitdiffstats
path: root/app/notification_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/notification_test.go')
-rw-r--r--app/notification_test.go114
1 files changed, 77 insertions, 37 deletions
diff --git a/app/notification_test.go b/app/notification_test.go
index 818ad1d9d..8fbcf3a78 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -1043,7 +1043,7 @@ func TestGetDirectMessageNotificationEmailSubject(t *testing.T) {
th := Setup()
defer th.TearDown()
- expectedPrefix := "[http://localhost:8065] New Direct Message from sender on"
+ expectedPrefix := "[http://localhost:8065] New Direct Message from @sender on"
post := &model.Post{
CreateAt: 1501804801000,
}
@@ -1054,6 +1054,38 @@ func TestGetDirectMessageNotificationEmailSubject(t *testing.T) {
}
}
+func TestGetGroupMessageNotificationEmailSubjectFull(t *testing.T) {
+ th := Setup()
+ defer th.TearDown()
+
+ expectedPrefix := "[http://localhost:8065] New Group Message in sender on"
+ post := &model.Post{
+ CreateAt: 1501804801000,
+ }
+ translateFunc := utils.GetUserTranslations("en")
+ emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
+ subject := getGroupMessageNotificationEmailSubject(post, translateFunc, "http://localhost:8065", "sender", emailNotificationContentsType)
+ if !strings.HasPrefix(subject, expectedPrefix) {
+ t.Fatal("Expected subject line prefix '" + expectedPrefix + "', got " + subject)
+ }
+}
+
+func TestGetGroupMessageNotificationEmailSubjectGeneric(t *testing.T) {
+ th := Setup()
+ defer th.TearDown()
+
+ expectedPrefix := "[http://localhost:8065] New Group Message on"
+ post := &model.Post{
+ CreateAt: 1501804801000,
+ }
+ translateFunc := utils.GetUserTranslations("en")
+ emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_GENERIC
+ subject := getGroupMessageNotificationEmailSubject(post, translateFunc, "http://localhost:8065", "sender", emailNotificationContentsType)
+ if !strings.HasPrefix(subject, expectedPrefix) {
+ t.Fatal("Expected subject line prefix '" + expectedPrefix + "', got " + subject)
+ }
+}
+
func TestGetNotificationEmailSubject(t *testing.T) {
th := Setup()
defer th.TearDown()
@@ -1081,21 +1113,22 @@ func TestGetNotificationEmailBodyFullNotificationPublicChannel(t *testing.T) {
DisplayName: "ChannelName",
Type: model.CHANNEL_OPEN,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
if !strings.Contains(body, "You have a new notification.") {
t.Fatal("Expected email text 'You have a new notification. Got " + body)
}
- if !strings.Contains(body, "CHANNEL: "+channel.DisplayName) {
- t.Fatal("Expected email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body)
+ if !strings.Contains(body, "Channel: "+channel.DisplayName) {
+ t.Fatal("Expected email text 'Channel: " + channel.DisplayName + "'. Got " + body)
}
- if !strings.Contains(body, senderName+" - ") {
- t.Fatal("Expected email text '" + senderName + " - '. Got " + body)
+ if !strings.Contains(body, "@"+senderName+" - ") {
+ t.Fatal("Expected email text '@" + senderName + " - '. Got " + body)
}
if !strings.Contains(body, post.Message) {
t.Fatal("Expected email text '" + post.Message + "'. Got " + body)
@@ -1117,21 +1150,22 @@ func TestGetNotificationEmailBodyFullNotificationGroupChannel(t *testing.T) {
DisplayName: "ChannelName",
Type: model.CHANNEL_GROUP,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
- if !strings.Contains(body, "You have a new notification.") {
- t.Fatal("Expected email text 'You have a new notification. Got " + body)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ if !strings.Contains(body, "You have a new Group Message.") {
+ t.Fatal("Expected email text 'You have a new Group Message. Got " + body)
}
- if !strings.Contains(body, "CHANNEL: Group Message") {
- t.Fatal("Expected email text 'CHANNEL: Group Message'. Got " + body)
+ if !strings.Contains(body, "Channel: ChannelName") {
+ t.Fatal("Expected email text 'Channel: ChannelName'. Got " + body)
}
- if !strings.Contains(body, senderName+" - ") {
- t.Fatal("Expected email text '" + senderName + " - '. Got " + body)
+ if !strings.Contains(body, "@"+senderName+" - ") {
+ t.Fatal("Expected email text '@" + senderName + " - '. Got " + body)
}
if !strings.Contains(body, post.Message) {
t.Fatal("Expected email text '" + post.Message + "'. Got " + body)
@@ -1153,21 +1187,22 @@ func TestGetNotificationEmailBodyFullNotificationPrivateChannel(t *testing.T) {
DisplayName: "ChannelName",
Type: model.CHANNEL_PRIVATE,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
if !strings.Contains(body, "You have a new notification.") {
t.Fatal("Expected email text 'You have a new notification. Got " + body)
}
- if !strings.Contains(body, "CHANNEL: "+channel.DisplayName) {
- t.Fatal("Expected email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body)
+ if !strings.Contains(body, "Channel: "+channel.DisplayName) {
+ t.Fatal("Expected email text 'Channel: " + channel.DisplayName + "'. Got " + body)
}
- if !strings.Contains(body, senderName+" - ") {
- t.Fatal("Expected email text '" + senderName + " - '. Got " + body)
+ if !strings.Contains(body, "@"+senderName+" - ") {
+ t.Fatal("Expected email text '@" + senderName + " - '. Got " + body)
}
if !strings.Contains(body, post.Message) {
t.Fatal("Expected email text '" + post.Message + "'. Got " + body)
@@ -1189,18 +1224,19 @@ func TestGetNotificationEmailBodyFullNotificationDirectChannel(t *testing.T) {
DisplayName: "ChannelName",
Type: model.CHANNEL_DIRECT,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
- if !strings.Contains(body, "You have a new direct message.") {
- t.Fatal("Expected email text 'You have a new direct message. Got " + body)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ if !strings.Contains(body, "You have a new Direct Message.") {
+ t.Fatal("Expected email text 'You have a new Direct Message. Got " + body)
}
- if !strings.Contains(body, senderName+" - ") {
- t.Fatal("Expected email text '" + senderName + " - '. Got " + body)
+ if !strings.Contains(body, "@"+senderName+" - ") {
+ t.Fatal("Expected email text '@" + senderName + " - '. Got " + body)
}
if !strings.Contains(body, post.Message) {
t.Fatal("Expected email text '" + post.Message + "'. Got " + body)
@@ -1223,18 +1259,19 @@ func TestGetNotificationEmailBodyGenericNotificationPublicChannel(t *testing.T)
DisplayName: "ChannelName",
Type: model.CHANNEL_OPEN,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_GENERIC
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
- if !strings.Contains(body, "You have a new notification from "+senderName) {
- t.Fatal("Expected email text 'You have a new notification from " + senderName + "'. Got " + body)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ if !strings.Contains(body, "You have a new notification from @"+senderName) {
+ t.Fatal("Expected email text 'You have a new notification from @" + senderName + "'. Got " + body)
}
- if strings.Contains(body, "CHANNEL: "+channel.DisplayName) {
- t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body)
+ if strings.Contains(body, "Channel: "+channel.DisplayName) {
+ t.Fatal("Did not expect email text 'Channel: " + channel.DisplayName + "'. Got " + body)
}
if strings.Contains(body, post.Message) {
t.Fatal("Did not expect email text '" + post.Message + "'. Got " + body)
@@ -1256,15 +1293,16 @@ func TestGetNotificationEmailBodyGenericNotificationGroupChannel(t *testing.T) {
DisplayName: "ChannelName",
Type: model.CHANNEL_GROUP,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_GENERIC
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
- if !strings.Contains(body, "You have a new notification from "+senderName) {
- t.Fatal("Expected email text 'You have a new notification from " + senderName + "'. Got " + body)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ if !strings.Contains(body, "You have a new Group Message from @"+senderName) {
+ t.Fatal("Expected email text 'You have a new Group Message from @" + senderName + "'. Got " + body)
}
if strings.Contains(body, "CHANNEL: "+channel.DisplayName) {
t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body)
@@ -1289,15 +1327,16 @@ func TestGetNotificationEmailBodyGenericNotificationPrivateChannel(t *testing.T)
DisplayName: "ChannelName",
Type: model.CHANNEL_PRIVATE,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_GENERIC
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
- if !strings.Contains(body, "You have a new notification from "+senderName) {
- t.Fatal("Expected email text 'You have a new notification from " + senderName + "'. Got " + body)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ if !strings.Contains(body, "You have a new notification from @"+senderName) {
+ t.Fatal("Expected email text 'You have a new notification from @" + senderName + "'. Got " + body)
}
if strings.Contains(body, "CHANNEL: "+channel.DisplayName) {
t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body)
@@ -1322,15 +1361,16 @@ func TestGetNotificationEmailBodyGenericNotificationDirectChannel(t *testing.T)
DisplayName: "ChannelName",
Type: model.CHANNEL_DIRECT,
}
+ channelName := "ChannelName"
senderName := "sender"
teamName := "team"
teamURL := "http://localhost:8065/" + teamName
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_GENERIC
translateFunc := utils.GetUserTranslations("en")
- body := th.App.getNotificationEmailBody(recipient, post, channel, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
- if !strings.Contains(body, "You have a new direct message from "+senderName) {
- t.Fatal("Expected email text 'You have a new direct message from " + senderName + "'. Got " + body)
+ body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, translateFunc)
+ if !strings.Contains(body, "You have a new Direct Message from @"+senderName) {
+ t.Fatal("Expected email text 'You have a new Direct Message from @" + senderName + "'. Got " + body)
}
if strings.Contains(body, "CHANNEL: "+channel.DisplayName) {
t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body)