MM-11172: Don't allow reacting in read-only town square. (#9106)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
10f571784b
Коммит
9d9fcd9ac5
@@ -172,6 +172,33 @@ func TestSaveReaction(t *testing.T) {
|
||||
}
|
||||
th.AddPermissionToRole(model.PERMISSION_ADD_REACTION.Id, model.CHANNEL_USER_ROLE_ID)
|
||||
})
|
||||
|
||||
t.Run("unable-to-react-in-read-only-town-square", func(t *testing.T) {
|
||||
th.LoginBasic()
|
||||
|
||||
channel, err := th.App.GetChannelByName("town-square", th.BasicTeam.Id)
|
||||
assert.Nil(t, err)
|
||||
post := th.CreatePostWithClient(th.Client, channel)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
|
||||
|
||||
reaction := &model.Reaction{
|
||||
UserId: userId,
|
||||
PostId: post.Id,
|
||||
EmojiName: "smile",
|
||||
}
|
||||
|
||||
_, resp := Client.SaveReaction(reaction)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 3 {
|
||||
t.Fatal("should have not created a reactions")
|
||||
}
|
||||
|
||||
th.App.RemoveLicense()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetReactions(t *testing.T) {
|
||||
@@ -451,4 +478,39 @@ func TestDeleteReaction(t *testing.T) {
|
||||
}
|
||||
th.AddPermissionToRole(model.PERMISSION_REMOVE_OTHERS_REACTIONS.Id, model.SYSTEM_ADMIN_ROLE_ID)
|
||||
})
|
||||
|
||||
t.Run("unable-to-delete-reactions-in-read-only-town-square", func(t *testing.T) {
|
||||
th.LoginBasic()
|
||||
|
||||
channel, err := th.App.GetChannelByName("town-square", th.BasicTeam.Id)
|
||||
assert.Nil(t, err)
|
||||
post := th.CreatePostWithClient(th.Client, channel)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
|
||||
reaction := &model.Reaction{
|
||||
UserId: userId,
|
||||
PostId: post.Id,
|
||||
EmojiName: "smile",
|
||||
}
|
||||
|
||||
r1, resp := Client.SaveReaction(reaction)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 1 {
|
||||
t.Fatal("should have created a reactions")
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
|
||||
|
||||
_, resp = th.SystemAdminClient.DeleteReaction(r1)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 1 {
|
||||
t.Fatal("should have not deleted a reactions")
|
||||
}
|
||||
|
||||
th.App.RemoveLicense()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user