update for adding multiple members (#25128)
* update for adding multiple members
* fix unit test
* more test fixes
* add another unit test
* fix object passed by client4
* revert package-lock.json
* revert package-lock.json
* add length check
* limit size of lists in API requests
* revert package-lock
* add batching to front end
* add batching to front end
* fix bad merge
* update return type
* remove unnecessary permisssion check, add unit test
* fixes and add tests from review
* revert changes adding limits to other apis
* fixes
* clean-up from code review
* fix unit test call
* revert back to interface{}, fix unit test
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4f68dbb96e
Коммит
6fd894953c
@@ -3294,6 +3294,36 @@ func TestAddChannelMember(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAddChannelMembers(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
client := th.Client
|
||||
user := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
team := th.BasicTeam
|
||||
publicChannel := th.CreatePublicChannel()
|
||||
privateChannel := th.CreatePrivateChannel()
|
||||
|
||||
user3 := th.CreateUserWithClient(th.SystemAdminClient)
|
||||
_, _, err := th.SystemAdminClient.AddTeamMember(context.Background(), team.Id, user3.Id)
|
||||
require.NoError(t, err)
|
||||
|
||||
cm, resp, err := client.AddChannelMembers(context.Background(), publicChannel.Id, "", []string{user.Id, user2.Id, user3.Id})
|
||||
require.NoError(t, err)
|
||||
CheckCreatedStatus(t, resp)
|
||||
require.Equal(t, publicChannel.Id, cm[0].ChannelId, "should have returned exact channel")
|
||||
require.Equal(t, user.Id, cm[0].UserId, "should have returned exact user added to public channel")
|
||||
require.Equal(t, user2.Id, cm[1].UserId, "should have returned exact user added to public channel")
|
||||
require.Equal(t, user3.Id, cm[2].UserId, "should have returned exact user added to public channel")
|
||||
|
||||
cm, _, err = client.AddChannelMembers(context.Background(), privateChannel.Id, "", []string{user.Id, user2.Id, user3.Id})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, privateChannel.Id, cm[0].ChannelId, "should have returned exact channel")
|
||||
require.Equal(t, user.Id, cm[0].UserId, "should have returned exact user added to public channel")
|
||||
require.Equal(t, user2.Id, cm[1].UserId, "should have returned exact user added to public channel")
|
||||
require.Equal(t, user3.Id, cm[2].UserId, "should have returned exact user added to public channel")
|
||||
}
|
||||
|
||||
func TestAddChannelMemberFromThread(t *testing.T) {
|
||||
t.Skip("MM-41285")
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -4784,6 +4814,13 @@ func TestGetChannelsMemberCount(t *testing.T) {
|
||||
_, _, err := client.GetChannelsMemberCount(context.Background(), channelIDs)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Should fail for private channels that the user is not a member of", func(t *testing.T) {
|
||||
th.LoginBasic2()
|
||||
channelIDs := []string{channel2.Id}
|
||||
_, _, err := client.GetChannelsMemberCount(context.Background(), channelIDs)
|
||||
require.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestMoveChannel(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user