diff options
Diffstat (limited to 'server/tests/api/users/user-subscriptions.ts')
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index c09a85a32..622cddb7d 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -6,12 +6,9 @@ import { | |||
6 | cleanupTests, | 6 | cleanupTests, |
7 | doubleFollow, | 7 | doubleFollow, |
8 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
9 | getVideosList, | ||
10 | ServerInfo, | 9 | ServerInfo, |
11 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
12 | SubscriptionsCommand, | 11 | SubscriptionsCommand, |
13 | updateVideo, | ||
14 | uploadVideo, | ||
15 | waitJobs | 12 | waitJobs |
16 | } from '@shared/extra-utils' | 13 | } from '@shared/extra-utils' |
17 | 14 | ||
@@ -44,10 +41,10 @@ describe('Test users subscriptions', function () { | |||
44 | users.push({ accessToken }) | 41 | users.push({ accessToken }) |
45 | 42 | ||
46 | const videoName1 = 'video 1-' + server.serverNumber | 43 | const videoName1 = 'video 1-' + server.serverNumber |
47 | await uploadVideo(server.url, accessToken, { name: videoName1 }) | 44 | await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName1 } }) |
48 | 45 | ||
49 | const videoName2 = 'video 2-' + server.serverNumber | 46 | const videoName2 = 'video 2-' + server.serverNumber |
50 | await uploadVideo(server.url, accessToken, { name: videoName2 }) | 47 | await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName2 } }) |
51 | } | 48 | } |
52 | } | 49 | } |
53 | 50 | ||
@@ -57,9 +54,9 @@ describe('Test users subscriptions', function () { | |||
57 | }) | 54 | }) |
58 | 55 | ||
59 | it('Should display videos of server 2 on server 1', async function () { | 56 | it('Should display videos of server 2 on server 1', async function () { |
60 | const res = await getVideosList(servers[0].url) | 57 | const { total } = await servers[0].videosCommand.list() |
61 | 58 | ||
62 | expect(res.body.total).to.equal(4) | 59 | expect(total).to.equal(4) |
63 | }) | 60 | }) |
64 | 61 | ||
65 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { | 62 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { |
@@ -70,17 +67,17 @@ describe('Test users subscriptions', function () { | |||
70 | 67 | ||
71 | await waitJobs(servers) | 68 | await waitJobs(servers) |
72 | 69 | ||
73 | const res = await uploadVideo(servers[2].url, users[2].accessToken, { name: 'video server 3 added after follow' }) | 70 | const { uuid } = await servers[2].videosCommand.upload({ attributes: { name: 'video server 3 added after follow' } }) |
74 | video3UUID = res.body.video.uuid | 71 | video3UUID = uuid |
75 | 72 | ||
76 | await waitJobs(servers) | 73 | await waitJobs(servers) |
77 | }) | 74 | }) |
78 | 75 | ||
79 | it('Should not display videos of server 3 on server 1', async function () { | 76 | it('Should not display videos of server 3 on server 1', async function () { |
80 | const res = await getVideosList(servers[0].url) | 77 | const { total, data } = await servers[0].videosCommand.list() |
78 | expect(total).to.equal(4) | ||
81 | 79 | ||
82 | expect(res.body.total).to.equal(4) | 80 | for (const video of data) { |
83 | for (const video of res.body.data) { | ||
84 | expect(video.name).to.not.contain('1-3') | 81 | expect(video.name).to.not.contain('1-3') |
85 | expect(video.name).to.not.contain('2-3') | 82 | expect(video.name).to.not.contain('2-3') |
86 | expect(video.name).to.not.contain('video server 3 added after follow') | 83 | expect(video.name).to.not.contain('video server 3 added after follow') |
@@ -186,7 +183,7 @@ describe('Test users subscriptions', function () { | |||
186 | this.timeout(60000) | 183 | this.timeout(60000) |
187 | 184 | ||
188 | const videoName = 'video server 1 added after follow' | 185 | const videoName = 'video server 1 added after follow' |
189 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: videoName }) | 186 | await servers[0].videosCommand.upload({ attributes: { name: videoName } }) |
190 | 187 | ||
191 | await waitJobs(servers) | 188 | await waitJobs(servers) |
192 | 189 | ||
@@ -212,10 +209,10 @@ describe('Test users subscriptions', function () { | |||
212 | } | 209 | } |
213 | 210 | ||
214 | { | 211 | { |
215 | const res = await getVideosList(servers[0].url) | 212 | const { data, total } = await servers[0].videosCommand.list() |
213 | expect(total).to.equal(5) | ||
216 | 214 | ||
217 | expect(res.body.total).to.equal(5) | 215 | for (const video of data) { |
218 | for (const video of res.body.data) { | ||
219 | expect(video.name).to.not.contain('1-3') | 216 | expect(video.name).to.not.contain('1-3') |
220 | expect(video.name).to.not.contain('2-3') | 217 | expect(video.name).to.not.contain('2-3') |
221 | expect(video.name).to.not.contain('video server 3 added after follow') | 218 | expect(video.name).to.not.contain('video server 3 added after follow') |
@@ -230,13 +227,12 @@ describe('Test users subscriptions', function () { | |||
230 | 227 | ||
231 | await waitJobs(servers) | 228 | await waitJobs(servers) |
232 | 229 | ||
233 | const res = await getVideosList(servers[0].url) | 230 | const { data, total } = await servers[0].videosCommand.list() |
234 | 231 | expect(total).to.equal(8) | |
235 | expect(res.body.total).to.equal(8) | ||
236 | 232 | ||
237 | const names = [ '1-3', '2-3', 'video server 3 added after follow' ] | 233 | const names = [ '1-3', '2-3', 'video server 3 added after follow' ] |
238 | for (const name of names) { | 234 | for (const name of names) { |
239 | const video = res.body.data.find(v => v.name.indexOf(name) === -1) | 235 | const video = data.find(v => v.name.includes(name)) |
240 | expect(video).to.not.be.undefined | 236 | expect(video).to.not.be.undefined |
241 | } | 237 | } |
242 | }) | 238 | }) |
@@ -248,10 +244,10 @@ describe('Test users subscriptions', function () { | |||
248 | 244 | ||
249 | await waitJobs(servers) | 245 | await waitJobs(servers) |
250 | 246 | ||
251 | const res = await getVideosList(servers[0].url) | 247 | const { total, data } = await servers[0].videosCommand.list() |
248 | expect(total).to.equal(5) | ||
252 | 249 | ||
253 | expect(res.body.total).to.equal(5) | 250 | for (const video of data) { |
254 | for (const video of res.body.data) { | ||
255 | expect(video.name).to.not.contain('1-3') | 251 | expect(video.name).to.not.contain('1-3') |
256 | expect(video.name).to.not.contain('2-3') | 252 | expect(video.name).to.not.contain('2-3') |
257 | expect(video.name).to.not.contain('video server 3 added after follow') | 253 | expect(video.name).to.not.contain('video server 3 added after follow') |
@@ -284,7 +280,7 @@ describe('Test users subscriptions', function () { | |||
284 | it('Should update a video of server 3 and see the updated video on server 1', async function () { | 280 | it('Should update a video of server 3 and see the updated video on server 1', async function () { |
285 | this.timeout(30000) | 281 | this.timeout(30000) |
286 | 282 | ||
287 | await updateVideo(servers[2].url, users[2].accessToken, video3UUID, { name: 'video server 3 added after follow updated' }) | 283 | await servers[2].videosCommand.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) |
288 | 284 | ||
289 | await waitJobs(servers) | 285 | await waitJobs(servers) |
290 | 286 | ||
@@ -329,10 +325,10 @@ describe('Test users subscriptions', function () { | |||
329 | }) | 325 | }) |
330 | 326 | ||
331 | it('Should correctly display public videos on server 1', async function () { | 327 | it('Should correctly display public videos on server 1', async function () { |
332 | const res = await getVideosList(servers[0].url) | 328 | const { total, data } = await servers[0].videosCommand.list() |
329 | expect(total).to.equal(5) | ||
333 | 330 | ||
334 | expect(res.body.total).to.equal(5) | 331 | for (const video of data) { |
335 | for (const video of res.body.data) { | ||
336 | expect(video.name).to.not.contain('1-3') | 332 | expect(video.name).to.not.contain('1-3') |
337 | expect(video.name).to.not.contain('2-3') | 333 | expect(video.name).to.not.contain('2-3') |
338 | expect(video.name).to.not.contain('video server 3 added after follow updated') | 334 | expect(video.name).to.not.contain('video server 3 added after follow updated') |
@@ -360,10 +356,10 @@ describe('Test users subscriptions', function () { | |||
360 | } | 356 | } |
361 | 357 | ||
362 | { | 358 | { |
363 | const res = await getVideosList(servers[0].url) | 359 | const { total, data } = await servers[0].videosCommand.list() |
360 | expect(total).to.equal(5) | ||
364 | 361 | ||
365 | expect(res.body.total).to.equal(5) | 362 | for (const video of data) { |
366 | for (const video of res.body.data) { | ||
367 | expect(video.name).to.not.contain('1-3') | 363 | expect(video.name).to.not.contain('1-3') |
368 | expect(video.name).to.not.contain('2-3') | 364 | expect(video.name).to.not.contain('2-3') |
369 | expect(video.name).to.not.contain('video server 3 added after follow updated') | 365 | expect(video.name).to.not.contain('video server 3 added after follow updated') |