[MM-51089] Fix sorting value of category in CreateSidebarCategoryForTeamForUser (#22455)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9a5c4fc736
Коммит
1f57819054
@@ -335,7 +335,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
|
|||||||
Id: newCategoryId,
|
Id: newCategoryId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
Sorting: model.SidebarCategorySortDefault,
|
Sorting: newCategory.Sorting,
|
||||||
SortOrder: int64(model.MinimalSidebarSortDistance * len(newOrder)), // first we place it at the end of the list
|
SortOrder: int64(model.MinimalSidebarSortDistance * len(newOrder)), // first we place it at the end of the list
|
||||||
Type: model.SidebarCategoryCustom,
|
Type: model.SidebarCategoryCustom,
|
||||||
Muted: newCategory.Muted,
|
Muted: newCategory.Muted,
|
||||||
|
|||||||
@@ -672,6 +672,38 @@ func testCreateSidebarCategory(t *testing.T, ss store.Store) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, []string{}, res2.Channels)
|
assert.Equal(t, []string{}, res2.Channels)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("should store the correct sorting value", func(t *testing.T) {
|
||||||
|
userId := model.NewId()
|
||||||
|
|
||||||
|
team := setupTeam(t, ss, userId)
|
||||||
|
|
||||||
|
opts := &store.SidebarCategorySearchOpts{
|
||||||
|
TeamID: team.Id,
|
||||||
|
ExcludeTeam: false,
|
||||||
|
}
|
||||||
|
res, nErr := ss.Channel().CreateInitialSidebarCategories(userId, opts)
|
||||||
|
require.NoError(t, nErr)
|
||||||
|
require.NotEmpty(t, res)
|
||||||
|
// Create the category
|
||||||
|
created, err := ss.Channel().CreateSidebarCategory(userId, team.Id, &model.SidebarCategoryWithChannels{
|
||||||
|
SidebarCategory: model.SidebarCategory{
|
||||||
|
DisplayName: model.NewId(),
|
||||||
|
Sorting: model.SidebarCategorySortManual,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Confirm that sorting value is correct
|
||||||
|
res, err = ss.Channel().GetSidebarCategoriesForTeamForUser(userId, team.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, res.Categories, 4)
|
||||||
|
// first category will be favorites and second will be newly created
|
||||||
|
assert.Equal(t, model.SidebarCategoryCustom, res.Categories[1].Type)
|
||||||
|
assert.Equal(t, created.Id, res.Categories[1].Id)
|
||||||
|
assert.Equal(t, model.SidebarCategorySortManual, res.Categories[1].Sorting)
|
||||||
|
assert.Equal(t, model.SidebarCategorySortManual, created.Sorting)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetSidebarCategory(t *testing.T, ss store.Store, s SqlStore) {
|
func testGetSidebarCategory(t *testing.T, ss store.Store, s SqlStore) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user