MM-26056 Add plugin ability to execute slash command. (#14898)

* Add plugin ability to execute slash command.

* A test

* Add site url to command args for plugin API

* Remove unessiary complexity.
Этот коммит содержится в:
Christopher Speller
2020-07-07 09:31:03 -07:00
коммит произвёл GitHub
родитель b977017ca7
Коммит bebff8156b
6 изменённых файлов: 102 добавлений и 0 удалений

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

@@ -1663,6 +1663,27 @@ func TestPluginHTTPUpgradeWebSocket(t *testing.T) {
}
}
func TestPluginExecuteSlashCommand(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
api := th.SetupPluginAPI()
newUser := th.CreateUser()
th.LinkUserToTeam(newUser, th.BasicTeam)
t.Run("run invite command", func(t *testing.T) {
_, err := api.ExecuteSlashCommand(&model.CommandArgs{
Command: "/invite @" + newUser.Username,
TeamId: th.BasicTeam.Id,
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
})
require.NoError(t, err)
_, err2 := th.App.GetChannelMember(th.BasicChannel.Id, newUser.Id)
require.Nil(t, err2)
})
}
func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()