[MM-62004] update threads after a channel gets moved (#29624)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2025-02-07 16:20:13 +01:00
коммит произвёл GitHub
родитель 3aaa379687
Коммит a3f22bd349
8 изменённых файлов: 247 добавлений и 0 удалений

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

@@ -247,6 +247,59 @@ func TestMoveChannel(t *testing.T) {
require.Equal(t, model.SidebarCategoryChannels, categories.Categories[1].Type)
assert.Contains(t, categories.Categories[1].Channels, channel.Id)
})
t.Run("should update threads when moving channels between teams", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
sourceTeam := th.CreateTeam()
targetTeam := th.CreateTeam()
channel := th.CreateChannel(th.Context, sourceTeam)
th.LinkUserToTeam(th.BasicUser, sourceTeam)
th.LinkUserToTeam(th.BasicUser, targetTeam)
th.AddUserToChannel(th.BasicUser, channel)
// Create a thread in the channel
post := &model.Post{
UserId: th.BasicUser.Id,
ChannelId: channel.Id,
Message: "test",
}
post, appErr := th.App.CreatePost(th.Context, post, channel, model.CreatePostFlags{})
require.Nil(t, appErr)
// Post a reply to the thread
reply := &model.Post{
UserId: th.BasicUser.Id,
ChannelId: channel.Id,
RootId: post.Id,
Message: "reply",
}
_, appErr = th.App.CreatePost(th.Context, reply, channel, model.CreatePostFlags{})
require.Nil(t, appErr)
// Check that the thread count before move
threads, appErr := th.App.GetThreadsForUser(th.BasicUser.Id, targetTeam.Id, model.GetUserThreadsOpts{})
require.Nil(t, appErr)
require.Zero(t, threads.Total)
// Move the channel to the target team
appErr = th.App.MoveChannel(th.Context, targetTeam, channel, th.BasicUser)
require.Nil(t, appErr)
// Check that the thread was moved
threads, appErr = th.App.GetThreadsForUser(th.BasicUser.Id, targetTeam.Id, model.GetUserThreadsOpts{})
require.Nil(t, appErr)
require.Equal(t, int64(1), threads.Total)
// Check that the thread count after move
threads, appErr = th.App.GetThreadsForUser(th.BasicUser.Id, sourceTeam.Id, model.GetUserThreadsOpts{})
require.Nil(t, appErr)
require.Zero(t, threads.Total)
})
}
func TestRemoveUsersFromChannelNotMemberOfTeam(t *testing.T) {