aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-29 14:31:04 +0200
committerChocobozzz <me@florianbigard.com>2019-08-29 14:31:04 +0200
commitf0a47bc92aa20b91b46197a4d3fc430aea962848 (patch)
tree104bb5dd7facc0d4db09c7deeea9e189f930e72e /server/tests/api
parent3155c8606cff211f495bf71c75c56cae85a5430f (diff)
downloadPeerTube-f0a47bc92aa20b91b46197a4d3fc430aea962848.tar.gz
PeerTube-f0a47bc92aa20b91b46197a4d3fc430aea962848.tar.zst
PeerTube-f0a47bc92aa20b91b46197a4d3fc430aea962848.zip
Hide video abuses from muted accounts
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/videos/video-abuse.ts77
1 files changed, 73 insertions, 4 deletions
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index a2f3ee161..0cd6f22c7 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -17,6 +17,12 @@ import {
17} from '../../../../shared/extra-utils/index' 17} from '../../../../shared/extra-utils/index'
18import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 18import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
20import {
21 addAccountToServerBlocklist,
22 addServerToServerBlocklist,
23 removeAccountFromServerBlocklist,
24 removeServerFromServerBlocklist
25} from '../../../../shared/extra-utils/users/blocklist'
20 26
21const expect = chai.expect 27const expect = chai.expect
22 28
@@ -163,13 +169,76 @@ describe('Test video abuses', function () {
163 expect(res.body.data[0].moderationComment).to.equal('It is valid') 169 expect(res.body.data[0].moderationComment).to.equal('It is valid')
164 }) 170 })
165 171
172 it('Should hide video abuses from blocked accounts', async function () {
173 this.timeout(10000)
174
175 {
176 await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this')
177 await waitJobs(servers)
178
179 const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
180 expect(res.body.total).to.equal(3)
181 }
182
183 const accountToBlock = 'root@localhost:' + servers[1].port
184
185 {
186 await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock)
187
188 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
189 expect(res.body.total).to.equal(2)
190
191 const abuse = res.body.data.find(a => a.reason === 'will mute this')
192 expect(abuse).to.be.undefined
193 }
194
195 {
196 await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock)
197
198 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
199 expect(res.body.total).to.equal(3)
200 }
201 })
202
203 it('Should hide video abuses from blocked servers', async function () {
204 const serverToBlock = servers[1].host
205
206 {
207 await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, servers[1].host)
208
209 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
210 expect(res.body.total).to.equal(2)
211
212 const abuse = res.body.data.find(a => a.reason === 'will mute this')
213 expect(abuse).to.be.undefined
214 }
215
216 {
217 await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, serverToBlock)
218
219 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
220 expect(res.body.total).to.equal(3)
221 }
222 })
223
166 it('Should delete the video abuse', async function () { 224 it('Should delete the video abuse', async function () {
225 this.timeout(10000)
226
167 await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id) 227 await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id)
168 228
169 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) 229 await waitJobs(servers)
170 expect(res.body.total).to.equal(0) 230
171 expect(res.body.data).to.be.an('array') 231 {
172 expect(res.body.data.length).to.equal(0) 232 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
233 expect(res.body.total).to.equal(1)
234 expect(res.body.data.length).to.equal(1)
235 expect(res.body.data[0].id).to.not.equal(abuseServer2.id)
236 }
237
238 {
239 const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
240 expect(res.body.total).to.equal(3)
241 }
173 }) 242 })
174 243
175 after(async function () { 244 after(async function () {