MM-27258 Cannot update categories with deleted channels (#15109)

Этот коммит содержится в:
Harrison Healey
2020-07-27 17:03:25 -04:00
коммит произвёл GitHub
родитель c511042c0f
Коммит 93dc68873a
2 изменённых файлов: 32 добавлений и 5 удалений

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

@@ -3996,10 +3996,6 @@ func TestUpdateCategoryForTeamForUser(t *testing.T) {
Channels: []string{channelsCategory.Channels[1], channelsCategory.Channels[0], channelsCategory.Channels[4], channelsCategory.Channels[3], channelsCategory.Channels[2]},
}
t.Log("UserId=" + th.BasicUser.Id)
t.Log("TeamId=" + th.BasicTeam.Id)
t.Log("category=" + channelsCategory.Id)
received, resp := th.Client.UpdateSidebarCategoryForTeamForUser(th.BasicUser.Id, th.BasicTeam.Id, channelsCategory.Id, updatedCategory)
assert.Nil(t, resp.Error)
assert.Equal(t, channelsCategory.Id, received.Id)
@@ -4076,4 +4072,33 @@ func TestUpdateCategoryForTeamForUser(t *testing.T) {
assert.Equal(t, customCategory.Id, received.Id)
assert.Equal(t, updatedCategory.DisplayName, received.DisplayName)
})
t.Run("should update the channel order of the category even if it contains archived channels", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
categories, resp := th.Client.GetSidebarCategoriesForTeamForUser(th.BasicUser.Id, th.BasicTeam.Id, "")
require.Nil(t, resp.Error)
require.Len(t, categories.Categories, 3)
require.Len(t, categories.Order, 3)
channelsCategory := categories.Categories[1]
require.Equal(t, model.SidebarCategoryChannels, channelsCategory.Type)
require.Len(t, channelsCategory.Channels, 5) // Town Square, Off Topic, and the 3 channels created by InitBasic
// Delete one of the channels
_, resp = th.Client.DeleteChannel(th.BasicChannel.Id)
require.Nil(t, resp.Error)
// Should still be able to reorder the channels
updatedCategory := &model.SidebarCategoryWithChannels{
SidebarCategory: channelsCategory.SidebarCategory,
Channels: []string{channelsCategory.Channels[1], channelsCategory.Channels[0], channelsCategory.Channels[4], channelsCategory.Channels[3], channelsCategory.Channels[2]},
}
received, resp := th.Client.UpdateSidebarCategoryForTeamForUser(th.BasicUser.Id, th.BasicTeam.Id, channelsCategory.Id, updatedCategory)
require.Nil(t, resp.Error)
assert.Equal(t, channelsCategory.Id, received.Id)
assert.Equal(t, updatedCategory.Channels, received.Channels)
})
}