MM-18818 Prompt admins to set the Support Email (#17296)

* MM-18818 Set default support to empty and handled the same in email templates

* #MM-18818 Admin advisor now warns for inconfigured support email address

* Updated text

* #MM-18818 gofmt'ed files

* #MM-18818 updated text and removed unused i18n strings:

* #MM-18818 updated i18n string ordering

* #MM-18818 Added test for support email advisory

* MM-18818 gofmt'd the file

* MM-18818 separated contextual notifications from configuration notifications in Admin Advisor

* #MM-18818 prevented support email with whitepsaces from being detected as filled

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Harshil Sharma
2021-04-28 12:05:38 +05:30
коммит произвёл GitHub
родитель dc7a425e77
Коммит 79dd9b13dc
12 изменённых файлов: 165 добавлений и 16 удалений

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

@@ -695,3 +695,61 @@ func TestSentry(t *testing.T) {
}
})
}
func TestAdminAdvisor(t *testing.T) {
th := Setup(t)
defer th.TearDown()
// creating a system user to whole admin advisor will send post
user := model.User{
Email: strings.ToLower(model.NewId()) + "success+test@example.com",
Nickname: "Darth Vader",
Username: "vader" + model.NewId(),
Password: "passwd1",
AuthService: "",
Roles: model.SYSTEM_ADMIN_ROLE_ID,
}
ruser, err := th.App.CreateUser(&user)
assert.Nil(t, err, "User should be created")
defer th.App.PermanentDeleteUser(&user)
t.Run("Should notify admin of un-configured support email", func(t *testing.T) {
doCheckAdminSupportStatus(th.App)
bot, err := th.App.GetUserByUsername(model.BOT_WARN_METRIC_BOT_USERNAME)
assert.NotNil(t, bot, "Bot should have been created now")
assert.Nil(t, err, "No error should be generated")
channel, err := th.App.getDirectChannel(bot.Id, ruser.Id)
assert.NotNil(t, channel, "DM channel should exist between Admin Advisor and system admin")
assert.Nil(t, err, "No error should be generated")
})
t.Run("Should NOT notify admin when support email is configured", func(t *testing.T) {
th.App.UpdateConfig(func(m *model.Config) {
email := "success+test@example.com"
m.SupportSettings.SupportEmail = &email
})
bot, err := th.App.GetUserByUsername(model.BOT_WARN_METRIC_BOT_USERNAME)
assert.NotNil(t, bot, "Bot should be already created")
assert.Nil(t, err, "No error should be generated")
channel, err := th.App.getDirectChannel(bot.Id, ruser.Id)
assert.NotNil(t, channel, "DM channel should already exist")
assert.Nil(t, err, "No error should be generated")
err = th.App.PermanentDeleteChannel(channel)
assert.Nil(t, err, "No error should be generated")
doCheckAdminSupportStatus(th.App)
channel, err = th.App.getDirectChannel(bot.Id, ruser.Id)
assert.NotNil(t, channel, "DM channel should exist between Admin Advisor and system admin")
assert.Nil(t, err, "No error should be generated")
posts, err := th.App.GetPosts(channel.Id, 0, 100)
assert.Nil(t, err, "No error should be generated")
assert.Equal(t, 0, len(posts.Posts))
})
}