summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorJesús Espino <jespinog@gmail.com>2018-08-29 15:07:37 +0200
committerGitHub <noreply@github.com>2018-08-29 15:07:37 +0200
commit0291730c2f2841e8181a2284f852a58294b28c51 (patch)
tree7044547c40dc8aefc2fbe154f5ddef69079f8194 /api4
parent7a3cf112c526cf8832d5a044ac590fb6c7ff8686 (diff)
downloadchat-0291730c2f2841e8181a2284f852a58294b28c51.tar.gz
chat-0291730c2f2841e8181a2284f852a58294b28c51.tar.bz2
chat-0291730c2f2841e8181a2284f852a58294b28c51.zip
MM-11270: Forbid react/de-react in archived channels (#9323)
Diffstat (limited to 'api4')
-rw-r--r--api4/reaction_test.go61
1 files changed, 57 insertions, 4 deletions
diff --git a/api4/reaction_test.go b/api4/reaction_test.go
index ca2c49808..aa7e3fdb8 100644
--- a/api4/reaction_test.go
+++ b/api4/reaction_test.go
@@ -192,13 +192,36 @@ func TestSaveReaction(t *testing.T) {
_, 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")
+ if reactions, err := th.App.GetReactionsForPost(post.Id); err != nil || len(reactions) != 0 {
+ t.Fatal("should have not created a reaction")
}
th.App.RemoveLicense()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
})
+
+ t.Run("unable-to-react-in-an-archived-channel", func(t *testing.T) {
+ th.LoginBasic()
+
+ channel := th.CreatePublicChannel()
+ post := th.CreatePostWithClient(th.Client, channel)
+
+ reaction := &model.Reaction{
+ UserId: userId,
+ PostId: post.Id,
+ EmojiName: "smile",
+ }
+
+ err := th.App.DeleteChannel(channel, userId)
+ assert.Nil(t, err)
+
+ _, resp := Client.SaveReaction(reaction)
+ CheckForbiddenStatus(t, resp)
+
+ if reactions, err := th.App.GetReactionsForPost(post.Id); err != nil || len(reactions) != 0 {
+ t.Fatal("should have not created a reaction")
+ }
+ })
}
func TestGetReactions(t *testing.T) {
@@ -498,7 +521,7 @@ func TestDeleteReaction(t *testing.T) {
CheckNoError(t, resp)
if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 1 {
- t.Fatal("should have created a reactions")
+ t.Fatal("should have created a reaction")
}
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
@@ -507,10 +530,40 @@ func TestDeleteReaction(t *testing.T) {
CheckForbiddenStatus(t, resp)
if reactions, err := th.App.GetReactionsForPost(postId); err != nil || len(reactions) != 1 {
- t.Fatal("should have not deleted a reactions")
+ t.Fatal("should have not deleted a reaction")
}
th.App.RemoveLicense()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
})
+
+ t.Run("unable-to-delete-reactions-in-an-archived-channel", func(t *testing.T) {
+ th.LoginBasic()
+
+ channel := th.CreatePublicChannel()
+ post := th.CreatePostWithClient(th.Client, channel)
+
+ 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 reaction")
+ }
+
+ err := th.App.DeleteChannel(channel, userId)
+ assert.Nil(t, err)
+
+ _, resp = Client.SaveReaction(r1)
+ CheckForbiddenStatus(t, resp)
+
+ if reactions, err := th.App.GetReactionsForPost(post.Id); err != nil || len(reactions) != 1 {
+ t.Fatal("should have not deleted a reaction")
+ }
+ })
}