aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-20 15:28:16 +0200
committerRigel Kent <par@rigelk.eu>2020-05-01 16:41:02 +0200
commit197876ea87494f9c8f5262fa371b0f70e3c56fb5 (patch)
treef16db617292c63a7d7385c40d4983d30c6542033 /server/tests/api
parentefa012edad6b9b4c38a21a5c7d06ce0f7089d22c (diff)
downloadPeerTube-197876ea87494f9c8f5262fa371b0f70e3c56fb5.tar.gz
PeerTube-197876ea87494f9c8f5262fa371b0f70e3c56fb5.tar.zst
PeerTube-197876ea87494f9c8f5262fa371b0f70e3c56fb5.zip
Add tests for video-abuse persistence after video deletion
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/videos/video-abuse.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index cd6df7267..8a8290e14 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -13,7 +13,8 @@ import {
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 updateVideoAbuse, 15 updateVideoAbuse,
16 uploadVideo 16 uploadVideo,
17 removeVideo
17} from '../../../../shared/extra-utils/index' 18} from '../../../../shared/extra-utils/index'
18import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 19import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 20import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -97,6 +98,11 @@ describe('Test video abuses', function () {
97 expect(abuse.reporterAccount.name).to.equal('root') 98 expect(abuse.reporterAccount.name).to.equal('root')
98 expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port) 99 expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port)
99 expect(abuse.video.id).to.equal(servers[0].video.id) 100 expect(abuse.video.id).to.equal(servers[0].video.id)
101 expect(abuse.video.channel).to.exist
102 expect(abuse.count).to.equal(1)
103 expect(abuse.nth).to.equal(1)
104 expect(abuse.countReportsForReporter).to.equal(1)
105 expect(abuse.countReportsForReportee).to.equal(1)
100 106
101 const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) 107 const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
102 expect(res2.body.total).to.equal(0) 108 expect(res2.body.total).to.equal(0)
@@ -128,6 +134,8 @@ describe('Test video abuses', function () {
128 expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) 134 expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING)
129 expect(abuse1.state.label).to.equal('Pending') 135 expect(abuse1.state.label).to.equal('Pending')
130 expect(abuse1.moderationComment).to.be.null 136 expect(abuse1.moderationComment).to.be.null
137 expect(abuse1.count).to.equal(1)
138 expect(abuse1.nth).to.equal(1)
131 139
132 const abuse2: VideoAbuse = res1.body.data[1] 140 const abuse2: VideoAbuse = res1.body.data[1]
133 expect(abuse2.reason).to.equal('my super bad reason 2') 141 expect(abuse2.reason).to.equal('my super bad reason 2')
@@ -221,6 +229,26 @@ describe('Test video abuses', function () {
221 } 229 }
222 }) 230 })
223 231
232 it('Should keep the video abuse when deleting the video', async function () {
233 this.timeout(10000)
234
235 await removeVideo(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid)
236
237 await waitJobs(servers)
238
239 {
240 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
241 expect(res.body.total).to.equal(2)
242 expect(res.body.data.length).to.equal(2)
243 expect(res.body.data[0].id).to.equal(abuseServer2.id)
244
245 const abuse: VideoAbuse = res.body.data[1]
246 expect(abuse.video.deleted).to.be.true
247 expect(abuse.video.id).to.equal(abuseServer2.video.id)
248 expect(abuse.video.channel).to.exist
249 }
250 })
251
224 it('Should delete the video abuse', async function () { 252 it('Should delete the video abuse', async function () {
225 this.timeout(10000) 253 this.timeout(10000)
226 254