command_help_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
  2. // See LICENSE.txt for license information.
  3. package api4
  4. import (
  5. "testing"
  6. "github.com/mattermost/mattermost-server/v5/model"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestHelpCommand(t *testing.T) {
  10. th := Setup(t).InitBasic()
  11. defer th.TearDown()
  12. Client := th.Client
  13. channel := th.BasicChannel
  14. HelpLink := *th.App.Config().SupportSettings.HelpLink
  15. defer func() {
  16. th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = HelpLink })
  17. }()
  18. th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = "" })
  19. rs1, _ := Client.ExecuteCommand(channel.Id, "/help ")
  20. assert.Equal(t, rs1.GotoLocation, model.SUPPORT_SETTINGS_DEFAULT_HELP_LINK, "failed to default help link")
  21. th.App.UpdateConfig(func(cfg *model.Config) {
  22. *cfg.SupportSettings.HelpLink = "https://docs.mattermost.com/guides/user.html"
  23. })
  24. rs2, _ := Client.ExecuteCommand(channel.Id, "/help ")
  25. assert.Equal(t, rs2.GotoLocation, "https://docs.mattermost.com/guides/user.html", "failed to help link")
  26. }