MM-56629 Render Markdown in batched email notifications (#26217)
* [MM-56629] rendered markdown in batched email (#26116) * [MM-56629] added unit test for GenerateHyperlinkForChannels (#26116) * [MM-56629] refactored code to remove duplicates, updated test (#26116) * [MM-56629] updated landing url and cleared check-style (#26116) * [MM-56629] added app-layesrs and mocks (#26116) * [MM-56629] updated unit tests (#26116) * [MM-56629] reverted changes of removing unused context parameter (#26116) * [MM-56629] removed unused method generateHyperlinkForChannels (#26116) * [MM-56629] fixed check-style error (#26116) * [MM-56629] refactored (#26116) --------- Co-authored-by: Sazzad Hossain <sazzad.hossain@marginedge.com> Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ab029105fd
Коммит
bc887441d0
@@ -615,7 +615,7 @@ func TestGetNotificationEmailBodyPublicChannelMention(t *testing.T) {
|
||||
|
||||
senderName := "user1"
|
||||
teamName := "testteam"
|
||||
teamURL := "http://localhost:8065/testteam"
|
||||
teamURL := th.App.GetSiteURL() + "/landing#" + "/testteam"
|
||||
emailNotificationContentsType := model.EmailNotificationContentsFull
|
||||
translateFunc := i18n.GetUserTranslations("en")
|
||||
|
||||
@@ -628,6 +628,8 @@ func TestGetNotificationEmailBodyPublicChannelMention(t *testing.T) {
|
||||
channelStoreMock.On("GetByNames", "test", []string{ch.Name}, true).Return([]*model.Channel{ch}, nil)
|
||||
storeMock.On("Channel").Return(&channelStoreMock)
|
||||
|
||||
th.App.Srv().EmailService.SetStore(storeMock)
|
||||
|
||||
body, err := th.App.getNotificationEmailBody(th.Context, recipient, post, ch,
|
||||
ch.Name, senderName, teamName, teamURL,
|
||||
emailNotificationContentsType, true, translateFunc, "user-avatar.png")
|
||||
@@ -681,7 +683,7 @@ func TestGetNotificationEmailBodyMultiPublicChannelMention(t *testing.T) {
|
||||
|
||||
senderName := "user1"
|
||||
teamName := "testteam"
|
||||
teamURL := "http://localhost:8065/testteam"
|
||||
teamURL := th.App.GetSiteURL() + "/landing#" + "/testteam"
|
||||
emailNotificationContentsType := model.EmailNotificationContentsFull
|
||||
translateFunc := i18n.GetUserTranslations("en")
|
||||
|
||||
@@ -694,6 +696,8 @@ func TestGetNotificationEmailBodyMultiPublicChannelMention(t *testing.T) {
|
||||
channelStoreMock.On("GetByNames", "test", []string{ch.Name, ch2.Name, ch3.Name}, true).Return([]*model.Channel{ch, ch2, ch3}, nil)
|
||||
storeMock.On("Channel").Return(&channelStoreMock)
|
||||
|
||||
th.App.Srv().EmailService.SetStore(storeMock)
|
||||
|
||||
body, err := th.App.getNotificationEmailBody(th.Context, recipient, post, ch,
|
||||
ch.Name, senderName, teamName, teamURL,
|
||||
emailNotificationContentsType, true, translateFunc, "user-avatar.png")
|
||||
@@ -743,6 +747,8 @@ func TestGetNotificationEmailBodyPrivateChannelMention(t *testing.T) {
|
||||
channelStoreMock.On("GetByNames", "test", []string{ch.Name}, true).Return([]*model.Channel{ch}, nil)
|
||||
storeMock.On("Channel").Return(&channelStoreMock)
|
||||
|
||||
th.App.Srv().EmailService.SetStore(storeMock)
|
||||
|
||||
body, err := th.App.getNotificationEmailBody(th.Context, recipient, post, ch,
|
||||
ch.Name, senderName, teamName, teamURL,
|
||||
emailNotificationContentsType, true, translateFunc, "user-avatar.png")
|
||||
@@ -776,8 +782,9 @@ func TestGenerateHyperlinkForChannelsPublic(t *testing.T) {
|
||||
channelStoreMock.On("GetByNames", "test", []string{ch.Name}, true).Return([]*model.Channel{ch}, nil)
|
||||
storeMock.On("Channel").Return(&channelStoreMock)
|
||||
|
||||
outMessage, err := th.App.generateHyperlinkForChannels(th.Context, message+mention, teamName, teamURL)
|
||||
require.Nil(t, err)
|
||||
th.App.Srv().EmailService.SetStore(storeMock)
|
||||
outMessage, err := th.App.Srv().EmailService.GenerateHyperlinkForChannels(message+mention, teamName, teamURL)
|
||||
require.NoError(t, err)
|
||||
channelURL := teamURL + "/channels/" + ch.Name
|
||||
assert.Equal(t, message+"<a href='"+channelURL+"'>"+mention+"</a>", outMessage)
|
||||
}
|
||||
@@ -826,8 +833,9 @@ func TestGenerateHyperlinkForChannelsMultiPublic(t *testing.T) {
|
||||
channelStoreMock.On("GetByNames", "test", []string{ch.Name, ch2.Name, ch3.Name}, true).Return([]*model.Channel{ch, ch2, ch3}, nil)
|
||||
storeMock.On("Channel").Return(&channelStoreMock)
|
||||
|
||||
outMessage, err := th.App.generateHyperlinkForChannels(th.Context, message, teamName, teamURL)
|
||||
require.Nil(t, err)
|
||||
th.App.Srv().EmailService.SetStore(storeMock)
|
||||
outMessage, err := th.App.Srv().EmailService.GenerateHyperlinkForChannels(message, teamName, teamURL)
|
||||
require.NoError(t, err)
|
||||
channelURL := teamURL + "/channels/" + ch.Name
|
||||
channelURL2 := teamURL + "/channels/" + ch2.Name
|
||||
channelURL3 := teamURL + "/channels/" + ch3.Name
|
||||
@@ -860,8 +868,9 @@ func TestGenerateHyperlinkForChannelsPrivate(t *testing.T) {
|
||||
channelStoreMock.On("GetByNames", "test", []string{ch.Name}, true).Return([]*model.Channel{ch}, nil)
|
||||
storeMock.On("Channel").Return(&channelStoreMock)
|
||||
|
||||
outMessage, err := th.App.generateHyperlinkForChannels(th.Context, message, teamName, teamURL)
|
||||
require.Nil(t, err)
|
||||
th.App.Srv().EmailService.SetStore(storeMock)
|
||||
outMessage, err := th.App.Srv().EmailService.GenerateHyperlinkForChannels(message, teamName, teamURL)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, message, outMessage)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user