2019-11-29 06:59:40 -05:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
2017-06-29 10:38:56 -04:00
|
|
|
|
|
|
|
|
package api4
|
|
|
|
|
|
|
|
|
|
import (
|
2023-06-06 17:29:29 -04:00
|
|
|
"context"
|
2017-09-06 18:12:54 -04:00
|
|
|
"testing"
|
|
|
|
|
|
2019-10-28 11:52:51 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
2022-10-06 04:04:21 -04:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-01-07 12:12:43 -05:00
|
|
|
|
2023-06-11 01:24:35 -04:00
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
2017-06-29 10:38:56 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestHelpCommand(t *testing.T) {
|
2025-05-30 07:58:26 -04:00
|
|
|
mainHelper.Parallel(t)
|
2025-11-12 07:00:51 -05:00
|
|
|
th := Setup(t).InitBasic(t)
|
2017-10-02 04:50:56 -04:00
|
|
|
|
2021-08-13 07:12:16 -04:00
|
|
|
client := th.Client
|
2017-06-29 10:38:56 -04:00
|
|
|
channel := th.BasicChannel
|
|
|
|
|
|
2017-10-18 18:36:43 -04:00
|
|
|
HelpLink := *th.App.Config().SupportSettings.HelpLink
|
2017-06-29 10:38:56 -04:00
|
|
|
defer func() {
|
2017-10-18 18:36:43 -04:00
|
|
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = HelpLink })
|
2017-06-29 10:38:56 -04:00
|
|
|
}()
|
|
|
|
|
|
2017-10-18 18:36:43 -04:00
|
|
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = "" })
|
2023-06-06 17:29:29 -04:00
|
|
|
rs1, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/help ")
|
2022-10-06 04:04:21 -04:00
|
|
|
require.NoError(t, err)
|
2022-08-23 11:37:06 -04:00
|
|
|
assert.Contains(t, rs1.Text, model.SupportSettingsDefaultHelpLink, "failed to default help link")
|
2017-06-29 10:38:56 -04:00
|
|
|
|
2017-10-18 18:36:43 -04:00
|
|
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
|
|
|
|
*cfg.SupportSettings.HelpLink = "https://docs.mattermost.com/guides/user.html"
|
|
|
|
|
})
|
2023-06-06 17:29:29 -04:00
|
|
|
rs2, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/help ")
|
2022-10-06 04:04:21 -04:00
|
|
|
require.NoError(t, err)
|
2022-08-23 11:37:06 -04:00
|
|
|
assert.Contains(t, rs2.Text, "https://docs.mattermost.com/guides/user.html", "failed to help link")
|
2017-06-29 10:38:56 -04:00
|
|
|
}
|