System Console: Email notification content setting (#7122)
* PLT-7195: Added new config option, new license feature, and config UI to system console. Still need to implement behaviour change in email batching code * PLT-7195: Modified batch emails to respect email notification content type setting * PLT-7195: Tweaking the colours a bit * PLT-7195: Added support for email notification content type setting in immediate (non-batched) notification messages. Attempted to clean up the code somewhat. Unit tests coming in a future commit * PLT-7195: Added unit tests for non-batched emails * Checked license when applying email content settings * Changed return type of getFormattedPostTime
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
9f3713aa98
Коммит
178ccd16cb
@@ -4,6 +4,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -271,3 +272,53 @@ func TestCheckPendingNotificationsCantParseInterval(t *testing.T) {
|
||||
t.Fatal("should have sent queued post")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensures that post contents are not included in notification email when email notification content type is set to generic
|
||||
*/
|
||||
func TestRenderBatchedPostGeneric(t *testing.T) {
|
||||
Setup()
|
||||
var post = &model.Post{}
|
||||
post.Message = "This is the message"
|
||||
var notification = &batchedNotification{}
|
||||
notification.post = post
|
||||
var channel = &model.Channel{}
|
||||
channel.DisplayName = "Some Test Channel"
|
||||
var sender = &model.User{}
|
||||
sender.Email = "sender@test.com"
|
||||
|
||||
translateFunc := func(translationID string, args ...interface{}) string {
|
||||
// mock translateFunc just returns the translation id - this is good enough for our purposes
|
||||
return translationID
|
||||
}
|
||||
|
||||
var rendered = renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_GENERIC)
|
||||
if strings.Contains(rendered, post.Message) {
|
||||
t.Fatal("Rendered email should not contain post contents when email notification contents type is set to Generic.")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensures that post contents included in notification email when email notification content type is set to full
|
||||
*/
|
||||
func TestRenderBatchedPostFull(t *testing.T) {
|
||||
Setup()
|
||||
var post = &model.Post{}
|
||||
post.Message = "This is the message"
|
||||
var notification = &batchedNotification{}
|
||||
notification.post = post
|
||||
var channel = &model.Channel{}
|
||||
channel.DisplayName = "Some Test Channel"
|
||||
var sender = &model.User{}
|
||||
sender.Email = "sender@test.com"
|
||||
|
||||
translateFunc := func(translationID string, args ...interface{}) string {
|
||||
// mock translateFunc just returns the translation id - this is good enough for our purposes
|
||||
return translationID
|
||||
}
|
||||
|
||||
var rendered = renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_FULL)
|
||||
if !strings.Contains(rendered, post.Message) {
|
||||
t.Fatal("Rendered email should contain post contents when email notification contents type is set to Full.")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user