2019-11-29 12:59:40 +01:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
2017-06-29 23:38:56 +09:00
|
|
|
|
|
|
|
|
package api4
|
|
|
|
|
|
|
|
|
|
import (
|
2017-09-06 17:12:54 -05:00
|
|
|
"testing"
|
|
|
|
|
|
2019-10-29 00:52:51 +09:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-01-07 22:42:43 +05:30
|
|
|
|
|
|
|
|
"github.com/mattermost/mattermost-server/v5/model"
|
2017-06-29 23:38:56 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestHelpCommand(t *testing.T) {
|
2020-02-10 19:31:41 +01:00
|
|
|
th := Setup(t).InitBasic()
|
2017-10-02 03:50:56 -05:00
|
|
|
defer th.TearDown()
|
|
|
|
|
|
2017-06-29 23:38:56 +09:00
|
|
|
Client := th.Client
|
|
|
|
|
channel := th.BasicChannel
|
|
|
|
|
|
2017-10-18 15:36:43 -07:00
|
|
|
HelpLink := *th.App.Config().SupportSettings.HelpLink
|
2017-06-29 23:38:56 +09:00
|
|
|
defer func() {
|
2017-10-18 15:36:43 -07:00
|
|
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = HelpLink })
|
2017-06-29 23:38:56 +09:00
|
|
|
}()
|
|
|
|
|
|
2017-10-18 15:36:43 -07:00
|
|
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = "" })
|
2017-06-29 23:38:56 +09:00
|
|
|
rs1, _ := Client.ExecuteCommand(channel.Id, "/help ")
|
2019-10-29 00:52:51 +09:00
|
|
|
assert.Equal(t, rs1.GotoLocation, model.SUPPORT_SETTINGS_DEFAULT_HELP_LINK, "failed to default help link")
|
2017-06-29 23:38:56 +09:00
|
|
|
|
2017-10-18 15:36:43 -07:00
|
|
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
|
|
|
|
*cfg.SupportSettings.HelpLink = "https://docs.mattermost.com/guides/user.html"
|
|
|
|
|
})
|
2017-06-29 23:38:56 +09:00
|
|
|
rs2, _ := Client.ExecuteCommand(channel.Id, "/help ")
|
2019-10-29 00:52:51 +09:00
|
|
|
assert.Equal(t, rs2.GotoLocation, "https://docs.mattermost.com/guides/user.html", "failed to help link")
|
2017-06-29 23:38:56 +09:00
|
|
|
}
|