MM-11227: Fix group msg slash command. (#9070)
Этот коммит содержится в:
коммит произвёл
Carlos Tadeu Panato Junior
родитель
74e5d8ae66
Коммит
2df818b9c6
@@ -2,6 +2,11 @@ package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nicksnyder/go-i18n/i18n"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
func TestGroupMsgUsernames(t *testing.T) {
|
||||
@@ -35,3 +40,58 @@ func TestGroupMsgUsernames(t *testing.T) {
|
||||
t.Fatal("error parsing different types of users")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGroupMsgProvider(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user3 := th.CreateUser()
|
||||
targetUsers := "@" + th.BasicUser2.Username + ",@" + user3.Username + " "
|
||||
|
||||
team := th.CreateTeam()
|
||||
th.LinkUserToTeam(th.BasicUser, team)
|
||||
cmd := &groupmsgProvider{}
|
||||
|
||||
// Check without permission to create a GM channel.
|
||||
resp := cmd.DoCommand(th.App, &model.CommandArgs{
|
||||
T: i18n.IdentityTfunc(),
|
||||
SiteURL: "http://test.url",
|
||||
TeamId: team.Id,
|
||||
UserId: th.BasicUser.Id,
|
||||
Session: model.Session{
|
||||
Roles: "",
|
||||
},
|
||||
}, targetUsers+"hello")
|
||||
|
||||
channelName := model.GetGroupNameFromUserIds([]string{th.BasicUser.Id, th.BasicUser2.Id, user3.Id})
|
||||
assert.Equal(t, "api.command_groupmsg.permission.app_error", resp.Text)
|
||||
assert.Equal(t, "", resp.GotoLocation)
|
||||
|
||||
// Check with permission to create a GM channel.
|
||||
resp = cmd.DoCommand(th.App, &model.CommandArgs{
|
||||
T: i18n.IdentityTfunc(),
|
||||
SiteURL: "http://test.url",
|
||||
TeamId: team.Id,
|
||||
UserId: th.BasicUser.Id,
|
||||
Session: model.Session{
|
||||
Roles: model.SYSTEM_USER_ROLE_ID,
|
||||
},
|
||||
}, targetUsers+"hello")
|
||||
|
||||
assert.Equal(t, "", resp.Text)
|
||||
assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation)
|
||||
|
||||
// Check without permission to post to an existing GM channel.
|
||||
resp = cmd.DoCommand(th.App, &model.CommandArgs{
|
||||
T: i18n.IdentityTfunc(),
|
||||
SiteURL: "http://test.url",
|
||||
TeamId: team.Id,
|
||||
UserId: th.BasicUser.Id,
|
||||
Session: model.Session{
|
||||
Roles: "",
|
||||
},
|
||||
}, targetUsers+"hello")
|
||||
|
||||
assert.Equal(t, "", resp.Text)
|
||||
assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user