diff options
Diffstat (limited to 'server/tests/api/moderation/blocklist.ts')
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 100 |
1 files changed, 44 insertions, 56 deletions
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index c253b5c11..3c3b2d6fd 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -8,28 +8,23 @@ import { | |||
8 | CommentsCommand, | 8 | CommentsCommand, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
11 | getVideosList, | ||
12 | getVideosListWithToken, | ||
13 | ServerInfo, | 11 | ServerInfo, |
14 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
15 | uploadVideo, | ||
16 | waitJobs | 13 | waitJobs |
17 | } from '@shared/extra-utils' | 14 | } from '@shared/extra-utils' |
18 | import { UserNotificationType, Video } from '@shared/models' | 15 | import { UserNotificationType } from '@shared/models' |
19 | 16 | ||
20 | const expect = chai.expect | 17 | const expect = chai.expect |
21 | 18 | ||
22 | async function checkAllVideos (server: ServerInfo, token: string) { | 19 | async function checkAllVideos (server: ServerInfo, token: string) { |
23 | { | 20 | { |
24 | const res = await getVideosListWithToken(server.url, token) | 21 | const { data } = await server.videosCommand.listWithToken({ token }) |
25 | 22 | expect(data).to.have.lengthOf(5) | |
26 | expect(res.body.data).to.have.lengthOf(5) | ||
27 | } | 23 | } |
28 | 24 | ||
29 | { | 25 | { |
30 | const res = await getVideosList(server.url) | 26 | const { data } = await server.videosCommand.list() |
31 | 27 | expect(data).to.have.lengthOf(5) | |
32 | expect(res.body.data).to.have.lengthOf(5) | ||
33 | } | 28 | } |
34 | } | 29 | } |
35 | 30 | ||
@@ -93,7 +88,7 @@ describe('Test blocklist', function () { | |||
93 | await servers[0].usersCommand.create({ username: user.username, password: user.password }) | 88 | await servers[0].usersCommand.create({ username: user.username, password: user.password }) |
94 | 89 | ||
95 | userToken1 = await servers[0].loginCommand.getAccessToken(user) | 90 | userToken1 = await servers[0].loginCommand.getAccessToken(user) |
96 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) | 91 | await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } }) |
97 | } | 92 | } |
98 | 93 | ||
99 | { | 94 | { |
@@ -108,22 +103,22 @@ describe('Test blocklist', function () { | |||
108 | await servers[1].usersCommand.create({ username: user.username, password: user.password }) | 103 | await servers[1].usersCommand.create({ username: user.username, password: user.password }) |
109 | 104 | ||
110 | userToken2 = await servers[1].loginCommand.getAccessToken(user) | 105 | userToken2 = await servers[1].loginCommand.getAccessToken(user) |
111 | await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' }) | 106 | await servers[1].videosCommand.upload({ token: userToken2, attributes: { name: 'video user 2' } }) |
112 | } | 107 | } |
113 | 108 | ||
114 | { | 109 | { |
115 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video server 1' }) | 110 | const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } }) |
116 | videoUUID1 = res.body.video.uuid | 111 | videoUUID1 = uuid |
117 | } | 112 | } |
118 | 113 | ||
119 | { | 114 | { |
120 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video server 2' }) | 115 | const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } }) |
121 | videoUUID2 = res.body.video.uuid | 116 | videoUUID2 = uuid |
122 | } | 117 | } |
123 | 118 | ||
124 | { | 119 | { |
125 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 2 server 1' }) | 120 | const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } }) |
126 | videoUUID3 = res.body.video.uuid | 121 | videoUUID3 = uuid |
127 | } | 122 | } |
128 | 123 | ||
129 | await doubleFollow(servers[0], servers[1]) | 124 | await doubleFollow(servers[0], servers[1]) |
@@ -164,12 +159,11 @@ describe('Test blocklist', function () { | |||
164 | }) | 159 | }) |
165 | 160 | ||
166 | it('Should hide its videos', async function () { | 161 | it('Should hide its videos', async function () { |
167 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) | 162 | const { data } = await servers[0].videosCommand.listWithToken() |
168 | 163 | ||
169 | const videos: Video[] = res.body.data | 164 | expect(data).to.have.lengthOf(4) |
170 | expect(videos).to.have.lengthOf(4) | ||
171 | 165 | ||
172 | const v = videos.find(v => v.name === 'video user 2') | 166 | const v = data.find(v => v.name === 'video user 2') |
173 | expect(v).to.be.undefined | 167 | expect(v).to.be.undefined |
174 | }) | 168 | }) |
175 | 169 | ||
@@ -178,12 +172,11 @@ describe('Test blocklist', function () { | |||
178 | }) | 172 | }) |
179 | 173 | ||
180 | it('Should hide its videos', async function () { | 174 | it('Should hide its videos', async function () { |
181 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) | 175 | const { data } = await servers[0].videosCommand.listWithToken() |
182 | 176 | ||
183 | const videos: Video[] = res.body.data | 177 | expect(data).to.have.lengthOf(3) |
184 | expect(videos).to.have.lengthOf(3) | ||
185 | 178 | ||
186 | const v = videos.find(v => v.name === 'video user 1') | 179 | const v = data.find(v => v.name === 'video user 1') |
187 | expect(v).to.be.undefined | 180 | expect(v).to.be.undefined |
188 | }) | 181 | }) |
189 | 182 | ||
@@ -313,12 +306,10 @@ describe('Test blocklist', function () { | |||
313 | }) | 306 | }) |
314 | 307 | ||
315 | it('Should display its videos', async function () { | 308 | it('Should display its videos', async function () { |
316 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) | 309 | const { data } = await servers[0].videosCommand.listWithToken() |
310 | expect(data).to.have.lengthOf(4) | ||
317 | 311 | ||
318 | const videos: Video[] = res.body.data | 312 | const v = data.find(v => v.name === 'video user 2') |
319 | expect(videos).to.have.lengthOf(4) | ||
320 | |||
321 | const v = videos.find(v => v.name === 'video user 2') | ||
322 | expect(v).not.to.be.undefined | 313 | expect(v).not.to.be.undefined |
323 | }) | 314 | }) |
324 | 315 | ||
@@ -387,13 +378,12 @@ describe('Test blocklist', function () { | |||
387 | }) | 378 | }) |
388 | 379 | ||
389 | it('Should hide its videos', async function () { | 380 | it('Should hide its videos', async function () { |
390 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) | 381 | const { data } = await servers[0].videosCommand.listWithToken() |
391 | 382 | ||
392 | const videos: Video[] = res.body.data | 383 | expect(data).to.have.lengthOf(3) |
393 | expect(videos).to.have.lengthOf(3) | ||
394 | 384 | ||
395 | const v1 = videos.find(v => v.name === 'video user 2') | 385 | const v1 = data.find(v => v.name === 'video user 2') |
396 | const v2 = videos.find(v => v.name === 'video server 2') | 386 | const v2 = data.find(v => v.name === 'video server 2') |
397 | 387 | ||
398 | expect(v1).to.be.undefined | 388 | expect(v1).to.be.undefined |
399 | expect(v2).to.be.undefined | 389 | expect(v2).to.be.undefined |
@@ -498,12 +488,11 @@ describe('Test blocklist', function () { | |||
498 | 488 | ||
499 | it('Should hide its videos', async function () { | 489 | it('Should hide its videos', async function () { |
500 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { | 490 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { |
501 | const res = await getVideosListWithToken(servers[0].url, token) | 491 | const { data } = await servers[0].videosCommand.listWithToken({ token }) |
502 | 492 | ||
503 | const videos: Video[] = res.body.data | 493 | expect(data).to.have.lengthOf(4) |
504 | expect(videos).to.have.lengthOf(4) | ||
505 | 494 | ||
506 | const v = videos.find(v => v.name === 'video user 2') | 495 | const v = data.find(v => v.name === 'video user 2') |
507 | expect(v).to.be.undefined | 496 | expect(v).to.be.undefined |
508 | } | 497 | } |
509 | }) | 498 | }) |
@@ -514,12 +503,11 @@ describe('Test blocklist', function () { | |||
514 | 503 | ||
515 | it('Should hide its videos', async function () { | 504 | it('Should hide its videos', async function () { |
516 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { | 505 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { |
517 | const res = await getVideosListWithToken(servers[0].url, token) | 506 | const { data } = await servers[0].videosCommand.listWithToken({ token }) |
518 | 507 | ||
519 | const videos: Video[] = res.body.data | 508 | expect(data).to.have.lengthOf(3) |
520 | expect(videos).to.have.lengthOf(3) | ||
521 | 509 | ||
522 | const v = videos.find(v => v.name === 'video user 1') | 510 | const v = data.find(v => v.name === 'video user 1') |
523 | expect(v).to.be.undefined | 511 | expect(v).to.be.undefined |
524 | } | 512 | } |
525 | }) | 513 | }) |
@@ -593,12 +581,10 @@ describe('Test blocklist', function () { | |||
593 | 581 | ||
594 | it('Should display its videos', async function () { | 582 | it('Should display its videos', async function () { |
595 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { | 583 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { |
596 | const res = await getVideosListWithToken(servers[0].url, token) | 584 | const { data } = await servers[0].videosCommand.listWithToken({ token }) |
597 | 585 | expect(data).to.have.lengthOf(4) | |
598 | const videos: Video[] = res.body.data | ||
599 | expect(videos).to.have.lengthOf(4) | ||
600 | 586 | ||
601 | const v = videos.find(v => v.name === 'video user 2') | 587 | const v = data.find(v => v.name === 'video user 2') |
602 | expect(v).not.to.be.undefined | 588 | expect(v).not.to.be.undefined |
603 | } | 589 | } |
604 | }) | 590 | }) |
@@ -652,15 +638,17 @@ describe('Test blocklist', function () { | |||
652 | 638 | ||
653 | it('Should hide its videos', async function () { | 639 | it('Should hide its videos', async function () { |
654 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { | 640 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { |
655 | const res1 = await getVideosList(servers[0].url) | 641 | const requests = [ |
656 | const res2 = await getVideosListWithToken(servers[0].url, token) | 642 | servers[0].videosCommand.list(), |
643 | servers[0].videosCommand.listWithToken({ token }) | ||
644 | ] | ||
657 | 645 | ||
658 | for (const res of [ res1, res2 ]) { | 646 | for (const req of requests) { |
659 | const videos: Video[] = res.body.data | 647 | const { data } = await req |
660 | expect(videos).to.have.lengthOf(3) | 648 | expect(data).to.have.lengthOf(3) |
661 | 649 | ||
662 | const v1 = videos.find(v => v.name === 'video user 2') | 650 | const v1 = data.find(v => v.name === 'video user 2') |
663 | const v2 = videos.find(v => v.name === 'video server 2') | 651 | const v2 = data.find(v => v.name === 'video server 2') |
664 | 652 | ||
665 | expect(v1).to.be.undefined | 653 | expect(v1).to.be.undefined |
666 | expect(v2).to.be.undefined | 654 | expect(v2).to.be.undefined |