diff options
author | Julien Maulny <julien.maulny@protonmail.com> | 2019-11-15 19:05:08 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-12-04 09:36:45 +0100 |
commit | 69222afac8f8c41d90295b33f0695bbff352851e (patch) | |
tree | 63fe1faea94dd3bfc54e633631eecb275c969e54 /server/tests/api | |
parent | 69c7f7525ddf13b7ced787d8b72ac74b43665517 (diff) | |
download | PeerTube-69222afac8f8c41d90295b33f0695bbff352851e.tar.gz PeerTube-69222afac8f8c41d90295b33f0695bbff352851e.tar.zst PeerTube-69222afac8f8c41d90295b33f0695bbff352851e.zip |
Soft delete video comments instead of detroy
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 56 | ||||
-rw-r--r-- | server/tests/api/videos/video-comments.ts | 24 |
2 files changed, 66 insertions, 14 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index aeda188c2..e7b57ba1f 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -868,7 +868,7 @@ describe('Test multiple servers', function () { | |||
868 | await waitJobs(servers) | 868 | await waitJobs(servers) |
869 | }) | 869 | }) |
870 | 870 | ||
871 | it('Should not have this comment anymore', async function () { | 871 | it('Should have this comment marked as deleted', async function () { |
872 | for (const server of servers) { | 872 | for (const server of servers) { |
873 | const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 873 | const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5) |
874 | const threadId = res1.body.data.find(c => c.text === 'my super first comment').id | 874 | const threadId = res1.body.data.find(c => c.text === 'my super first comment').id |
@@ -880,7 +880,13 @@ describe('Test multiple servers', function () { | |||
880 | 880 | ||
881 | const firstChild = tree.children[0] | 881 | const firstChild = tree.children[0] |
882 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') | 882 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') |
883 | expect(firstChild.children).to.have.lengthOf(0) | 883 | expect(firstChild.children).to.have.lengthOf(1) |
884 | |||
885 | const deletedComment = firstChild.children[0].comment | ||
886 | expect(deletedComment.isDeleted).to.be.true | ||
887 | expect(deletedComment.deletedAt).to.not.be.null | ||
888 | expect(deletedComment.account).to.be.null | ||
889 | expect(deletedComment.text).to.equal('') | ||
884 | 890 | ||
885 | const secondChild = tree.children[1] | 891 | const secondChild = tree.children[1] |
886 | expect(secondChild.comment.text).to.equal('my second answer to thread 1') | 892 | expect(secondChild.comment.text).to.equal('my second answer to thread 1') |
@@ -897,13 +903,13 @@ describe('Test multiple servers', function () { | |||
897 | await waitJobs(servers) | 903 | await waitJobs(servers) |
898 | }) | 904 | }) |
899 | 905 | ||
900 | it('Should have the threads deleted on other servers too', async function () { | 906 | it('Should have the threads marked as deleted on other servers too', async function () { |
901 | for (const server of servers) { | 907 | for (const server of servers) { |
902 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 908 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) |
903 | 909 | ||
904 | expect(res.body.total).to.equal(1) | 910 | expect(res.body.total).to.equal(2) |
905 | expect(res.body.data).to.be.an('array') | 911 | expect(res.body.data).to.be.an('array') |
906 | expect(res.body.data).to.have.lengthOf(1) | 912 | expect(res.body.data).to.have.lengthOf(2) |
907 | 913 | ||
908 | { | 914 | { |
909 | const comment: VideoComment = res.body.data[0] | 915 | const comment: VideoComment = res.body.data[0] |
@@ -915,6 +921,20 @@ describe('Test multiple servers', function () { | |||
915 | expect(dateIsValid(comment.createdAt as string)).to.be.true | 921 | expect(dateIsValid(comment.createdAt as string)).to.be.true |
916 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | 922 | expect(dateIsValid(comment.updatedAt as string)).to.be.true |
917 | } | 923 | } |
924 | |||
925 | { | ||
926 | const deletedComment: VideoComment = res.body.data[1] | ||
927 | expect(deletedComment).to.not.be.undefined | ||
928 | expect(deletedComment.isDeleted).to.be.true | ||
929 | expect(deletedComment.deletedAt).to.not.be.null | ||
930 | expect(deletedComment.text).to.equal('') | ||
931 | expect(deletedComment.inReplyToCommentId).to.be.null | ||
932 | expect(deletedComment.account).to.be.null | ||
933 | expect(deletedComment.totalReplies).to.equal(3) | ||
934 | expect(dateIsValid(deletedComment.createdAt as string)).to.be.true | ||
935 | expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true | ||
936 | expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true | ||
937 | } | ||
918 | } | 938 | } |
919 | }) | 939 | }) |
920 | 940 | ||
@@ -926,12 +946,32 @@ describe('Test multiple servers', function () { | |||
926 | await waitJobs(servers) | 946 | await waitJobs(servers) |
927 | }) | 947 | }) |
928 | 948 | ||
929 | it('Should have the threads deleted on other servers too', async function () { | 949 | it('Should have the threads marked as deleted on other servers too', async function () { |
930 | for (const server of servers) { | 950 | for (const server of servers) { |
931 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 951 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) |
932 | 952 | ||
933 | expect(res.body.total).to.equal(0) | 953 | expect(res.body.total).to.equal(2) |
934 | expect(res.body.data).to.have.lengthOf(0) | 954 | expect(res.body.data).to.have.lengthOf(2) |
955 | |||
956 | { | ||
957 | const comment: VideoComment = res.body.data[0] | ||
958 | expect(comment.text).to.equal('') | ||
959 | expect(comment.isDeleted).to.be.true | ||
960 | expect(comment.createdAt).to.not.be.null | ||
961 | expect(comment.deletedAt).to.not.be.null | ||
962 | expect(comment.account).to.be.null | ||
963 | expect(comment.totalReplies).to.equal(0) | ||
964 | } | ||
965 | |||
966 | { | ||
967 | const comment: VideoComment = res.body.data[1] | ||
968 | expect(comment.text).to.equal('') | ||
969 | expect(comment.isDeleted).to.be.true | ||
970 | expect(comment.createdAt).to.not.be.null | ||
971 | expect(comment.deletedAt).to.not.be.null | ||
972 | expect(comment.account).to.be.null | ||
973 | expect(comment.totalReplies).to.equal(3) | ||
974 | } | ||
935 | } | 975 | } |
936 | }) | 976 | }) |
937 | 977 | ||
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 82182cc7c..95be14c0e 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts | |||
@@ -172,7 +172,7 @@ describe('Test video comments', function () { | |||
172 | 172 | ||
173 | const tree: VideoCommentThreadTree = res.body | 173 | const tree: VideoCommentThreadTree = res.body |
174 | expect(tree.comment.text).equal('my super first comment') | 174 | expect(tree.comment.text).equal('my super first comment') |
175 | expect(tree.children).to.have.lengthOf(1) | 175 | expect(tree.children).to.have.lengthOf(2) |
176 | 176 | ||
177 | const firstChild = tree.children[0] | 177 | const firstChild = tree.children[0] |
178 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') | 178 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') |
@@ -181,20 +181,32 @@ describe('Test video comments', function () { | |||
181 | const childOfFirstChild = firstChild.children[0] | 181 | const childOfFirstChild = firstChild.children[0] |
182 | expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') | 182 | expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') |
183 | expect(childOfFirstChild.children).to.have.lengthOf(0) | 183 | expect(childOfFirstChild.children).to.have.lengthOf(0) |
184 | |||
185 | const deletedChildOfFirstChild = tree.children[1] | ||
186 | expect(deletedChildOfFirstChild.comment.text).to.equal('') | ||
187 | expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true | ||
188 | expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null | ||
189 | expect(deletedChildOfFirstChild.comment.account).to.be.null | ||
190 | expect(deletedChildOfFirstChild.children).to.have.lengthOf(0) | ||
184 | }) | 191 | }) |
185 | 192 | ||
186 | it('Should delete a complete thread', async function () { | 193 | it('Should delete a complete thread', async function () { |
187 | await deleteVideoComment(server.url, server.accessToken, videoId, threadId) | 194 | await deleteVideoComment(server.url, server.accessToken, videoId, threadId) |
188 | 195 | ||
189 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') | 196 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') |
190 | expect(res.body.total).to.equal(2) | 197 | expect(res.body.total).to.equal(3) |
191 | expect(res.body.data).to.be.an('array') | 198 | expect(res.body.data).to.be.an('array') |
192 | expect(res.body.data).to.have.lengthOf(2) | 199 | expect(res.body.data).to.have.lengthOf(3) |
193 | 200 | ||
194 | expect(res.body.data[0].text).to.equal('super thread 2') | 201 | expect(res.body.data[0].text).to.equal('') |
195 | expect(res.body.data[0].totalReplies).to.equal(0) | 202 | expect(res.body.data[0].isDeleted).to.be.true |
196 | expect(res.body.data[1].text).to.equal('super thread 3') | 203 | expect(res.body.data[0].deletedAt).to.not.be.null |
204 | expect(res.body.data[0].account).to.be.null | ||
205 | expect(res.body.data[0].totalReplies).to.equal(3) | ||
206 | expect(res.body.data[1].text).to.equal('super thread 2') | ||
197 | expect(res.body.data[1].totalReplies).to.equal(0) | 207 | expect(res.body.data[1].totalReplies).to.equal(0) |
208 | expect(res.body.data[2].text).to.equal('super thread 3') | ||
209 | expect(res.body.data[2].totalReplies).to.equal(0) | ||
198 | }) | 210 | }) |
199 | 211 | ||
200 | after(async function () { | 212 | after(async function () { |