diff options
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-abuse.ts | 64 |
1 files changed, 53 insertions, 11 deletions
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index 8a8290e14..26bc3783b 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts | |||
@@ -14,7 +14,9 @@ import { | |||
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | updateVideoAbuse, | 15 | updateVideoAbuse, |
16 | uploadVideo, | 16 | uploadVideo, |
17 | removeVideo | 17 | removeVideo, |
18 | createUser, | ||
19 | userLogin | ||
18 | } from '../../../../shared/extra-utils/index' | 20 | } from '../../../../shared/extra-utils/index' |
19 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 21 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 22 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
@@ -236,16 +238,56 @@ describe('Test video abuses', function () { | |||
236 | 238 | ||
237 | await waitJobs(servers) | 239 | await waitJobs(servers) |
238 | 240 | ||
239 | { | 241 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
240 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 242 | expect(res.body.total).to.equal(2, "wrong number of videos returned") |
241 | expect(res.body.total).to.equal(2) | 243 | expect(res.body.data.length).to.equal(2, "wrong number of videos returned") |
242 | expect(res.body.data.length).to.equal(2) | 244 | expect(res.body.data[0].id).to.equal(abuseServer2.id, "wrong origin server id for first video") |
243 | expect(res.body.data[0].id).to.equal(abuseServer2.id) | 245 | |
246 | const abuse: VideoAbuse = res.body.data[0] | ||
247 | expect(abuse.video.id).to.equal(abuseServer2.video.id, "wrong video id") | ||
248 | expect(abuse.video.channel).to.exist | ||
249 | expect(abuse.video.deleted).to.be.true | ||
250 | }) | ||
251 | |||
252 | it('Should include counts of reports from reporter and reportee', async function () { | ||
253 | this.timeout(10000) | ||
244 | 254 | ||
245 | const abuse: VideoAbuse = res.body.data[1] | 255 | // register a second user to have two reporters/reportees |
246 | expect(abuse.video.deleted).to.be.true | 256 | const user = { username: 'user2', password: 'password' } |
247 | expect(abuse.video.id).to.equal(abuseServer2.video.id) | 257 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user }) |
248 | expect(abuse.video.channel).to.exist | 258 | const userAccessToken = await userLogin(servers[0], user) |
259 | |||
260 | // upload a third video via this user | ||
261 | const video3Attributes = { | ||
262 | name: 'my second super name for server 1', | ||
263 | description: 'my second super description for server 1' | ||
264 | } | ||
265 | await uploadVideo(servers[0].url, userAccessToken, video3Attributes) | ||
266 | |||
267 | const res1 = await getVideosList(servers[0].url) | ||
268 | const videos = res1.body.data | ||
269 | const video3 = videos.find(video => video.name === 'my second super name for server 1') | ||
270 | |||
271 | // resume with the test | ||
272 | const reason3 = 'my super bad reason 3' | ||
273 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, video3.id, reason3) | ||
274 | const reason4 = 'my super bad reason 4' | ||
275 | await reportVideoAbuse(servers[0].url, userAccessToken, servers[0].video.id, reason4) | ||
276 | |||
277 | const res2 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | ||
278 | |||
279 | { | ||
280 | for (const abuse of res2.body.data as VideoAbuse[]) { | ||
281 | if (abuse.video.id === video3.id) { | ||
282 | expect(abuse.count).to.equal(1, "wrong reports count for video 3") | ||
283 | expect(abuse.nth).to.equal(1, "wrong report position in report list for video 3") | ||
284 | expect(abuse.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse") | ||
285 | expect(abuse.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse") | ||
286 | } | ||
287 | if (abuse.video.id === servers[0].video.id) { | ||
288 | expect(abuse.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") | ||
289 | } | ||
290 | } | ||
249 | } | 291 | } |
250 | }) | 292 | }) |
251 | 293 | ||
@@ -265,7 +307,7 @@ describe('Test video abuses', function () { | |||
265 | 307 | ||
266 | { | 308 | { |
267 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 309 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) |
268 | expect(res.body.total).to.equal(3) | 310 | expect(res.body.total).to.equal(5) |
269 | } | 311 | } |
270 | }) | 312 | }) |
271 | 313 | ||