aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-playlists.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-playlists.ts')
-rw-r--r--server/tests/api/videos/video-playlists.ts184
1 files changed, 92 insertions, 92 deletions
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 40f61ca19..0dc53d4c0 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -36,7 +36,7 @@ async function checkPlaylistElementType (
36 total: number 36 total: number
37) { 37) {
38 for (const server of servers) { 38 for (const server of servers) {
39 const body = await server.playlistsCommand.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }) 39 const body = await server.playlists.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 })
40 expect(body.total).to.equal(total) 40 expect(body.total).to.equal(total)
41 41
42 const videoElement = body.data.find(e => e.position === position) 42 const videoElement = body.data.find(e => e.position === position)
@@ -86,26 +86,26 @@ describe('Test video playlists', function () {
86 // Server 1 and server 3 follow each other 86 // Server 1 and server 3 follow each other
87 await doubleFollow(servers[0], servers[2]) 87 await doubleFollow(servers[0], servers[2])
88 88
89 commands = servers.map(s => s.playlistsCommand) 89 commands = servers.map(s => s.playlists)
90 90
91 { 91 {
92 servers[0].videos = [] 92 servers[0].store.videos = []
93 servers[1].videos = [] 93 servers[1].store.videos = []
94 servers[2].videos = [] 94 servers[2].store.videos = []
95 95
96 for (const server of servers) { 96 for (const server of servers) {
97 for (let i = 0; i < 7; i++) { 97 for (let i = 0; i < 7; i++) {
98 const name = `video ${i} server ${server.serverNumber}` 98 const name = `video ${i} server ${server.serverNumber}`
99 const video = await server.videosCommand.upload({ attributes: { name, nsfw: false } }) 99 const video = await server.videos.upload({ attributes: { name, nsfw: false } })
100 100
101 server.videos.push(video) 101 server.store.videos.push(video)
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 nsfwVideoServer1 = (await servers[0].videosCommand.quickUpload({ name: 'NSFW video', nsfw: true })).id 106 nsfwVideoServer1 = (await servers[0].videos.quickUpload({ name: 'NSFW video', nsfw: true })).id
107 107
108 userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1') 108 userTokenServer1 = await servers[0].users.generateUserAndToken('user1')
109 109
110 await waitJobs(servers) 110 await waitJobs(servers)
111 }) 111 })
@@ -149,7 +149,7 @@ describe('Test video playlists', function () {
149 }) 149 })
150 150
151 it('Should get private playlist for a classic user', async function () { 151 it('Should get private playlist for a classic user', async function () {
152 const token = await servers[0].usersCommand.generateUserAndToken('toto') 152 const token = await servers[0].users.generateUserAndToken('toto')
153 153
154 const body = await commands[0].listByAccount({ token, handle: 'toto' }) 154 const body = await commands[0].listByAccount({ token, handle: 'toto' })
155 155
@@ -172,7 +172,7 @@ describe('Test video playlists', function () {
172 privacy: VideoPlaylistPrivacy.PUBLIC, 172 privacy: VideoPlaylistPrivacy.PUBLIC,
173 description: 'my super description', 173 description: 'my super description',
174 thumbnailfile: 'thumbnail.jpg', 174 thumbnailfile: 'thumbnail.jpg',
175 videoChannelId: servers[0].videoChannel.id 175 videoChannelId: servers[0].store.channel.id
176 } 176 }
177 }) 177 })
178 178
@@ -181,13 +181,13 @@ describe('Test video playlists', function () {
181 await wait(3000) 181 await wait(3000)
182 182
183 for (const server of servers) { 183 for (const server of servers) {
184 const body = await server.playlistsCommand.list({ start: 0, count: 5 }) 184 const body = await server.playlists.list({ start: 0, count: 5 })
185 expect(body.total).to.equal(1) 185 expect(body.total).to.equal(1)
186 expect(body.data).to.have.lengthOf(1) 186 expect(body.data).to.have.lengthOf(1)
187 187
188 const playlistFromList = body.data[0] 188 const playlistFromList = body.data[0]
189 189
190 const playlistFromGet = await server.playlistsCommand.get({ playlistId: playlistFromList.uuid }) 190 const playlistFromGet = await server.playlists.get({ playlistId: playlistFromList.uuid })
191 191
192 for (const playlist of [ playlistFromGet, playlistFromList ]) { 192 for (const playlist of [ playlistFromGet, playlistFromList ]) {
193 expect(playlist.id).to.be.a('number') 193 expect(playlist.id).to.be.a('number')
@@ -217,23 +217,23 @@ describe('Test video playlists', function () {
217 this.timeout(30000) 217 this.timeout(30000)
218 218
219 { 219 {
220 const playlist = await servers[1].playlistsCommand.create({ 220 const playlist = await servers[1].playlists.create({
221 attributes: { 221 attributes: {
222 displayName: 'playlist 2', 222 displayName: 'playlist 2',
223 privacy: VideoPlaylistPrivacy.PUBLIC, 223 privacy: VideoPlaylistPrivacy.PUBLIC,
224 videoChannelId: servers[1].videoChannel.id 224 videoChannelId: servers[1].store.channel.id
225 } 225 }
226 }) 226 })
227 playlistServer2Id1 = playlist.id 227 playlistServer2Id1 = playlist.id
228 } 228 }
229 229
230 { 230 {
231 const playlist = await servers[1].playlistsCommand.create({ 231 const playlist = await servers[1].playlists.create({
232 attributes: { 232 attributes: {
233 displayName: 'playlist 3', 233 displayName: 'playlist 3',
234 privacy: VideoPlaylistPrivacy.PUBLIC, 234 privacy: VideoPlaylistPrivacy.PUBLIC,
235 thumbnailfile: 'thumbnail.jpg', 235 thumbnailfile: 'thumbnail.jpg',
236 videoChannelId: servers[1].videoChannel.id 236 videoChannelId: servers[1].store.channel.id
237 } 237 }
238 }) 238 })
239 239
@@ -242,13 +242,13 @@ describe('Test video playlists', function () {
242 } 242 }
243 243
244 for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) { 244 for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) {
245 await servers[1].playlistsCommand.addElement({ 245 await servers[1].playlists.addElement({
246 playlistId: id, 246 playlistId: id,
247 attributes: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 } 247 attributes: { videoId: servers[1].store.videos[0].id, startTimestamp: 1, stopTimestamp: 2 }
248 }) 248 })
249 await servers[1].playlistsCommand.addElement({ 249 await servers[1].playlists.addElement({
250 playlistId: id, 250 playlistId: id,
251 attributes: { videoId: servers[1].videos[1].id } 251 attributes: { videoId: servers[1].store.videos[1].id }
252 }) 252 })
253 } 253 }
254 254
@@ -256,7 +256,7 @@ describe('Test video playlists', function () {
256 await wait(3000) 256 await wait(3000)
257 257
258 for (const server of [ servers[0], servers[1] ]) { 258 for (const server of [ servers[0], servers[1] ]) {
259 const body = await server.playlistsCommand.list({ start: 0, count: 5 }) 259 const body = await server.playlists.list({ start: 0, count: 5 })
260 260
261 const playlist2 = body.data.find(p => p.displayName === 'playlist 2') 261 const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
262 expect(playlist2).to.not.be.undefined 262 expect(playlist2).to.not.be.undefined
@@ -267,7 +267,7 @@ describe('Test video playlists', function () {
267 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) 267 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
268 } 268 }
269 269
270 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 270 const body = await servers[2].playlists.list({ start: 0, count: 5 })
271 expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined 271 expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
272 expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined 272 expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
273 }) 273 })
@@ -278,7 +278,7 @@ describe('Test video playlists', function () {
278 // Server 2 and server 3 follow each other 278 // Server 2 and server 3 follow each other
279 await doubleFollow(servers[1], servers[2]) 279 await doubleFollow(servers[1], servers[2])
280 280
281 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 281 const body = await servers[2].playlists.list({ start: 0, count: 5 })
282 282
283 const playlist2 = body.data.find(p => p.displayName === 'playlist 2') 283 const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
284 expect(playlist2).to.not.be.undefined 284 expect(playlist2).to.not.be.undefined
@@ -294,7 +294,7 @@ describe('Test video playlists', function () {
294 this.timeout(30000) 294 this.timeout(30000)
295 295
296 { 296 {
297 const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: 'createdAt' }) 297 const body = await servers[2].playlists.list({ start: 1, count: 2, sort: 'createdAt' })
298 expect(body.total).to.equal(3) 298 expect(body.total).to.equal(3)
299 299
300 const data = body.data 300 const data = body.data
@@ -304,7 +304,7 @@ describe('Test video playlists', function () {
304 } 304 }
305 305
306 { 306 {
307 const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: '-createdAt' }) 307 const body = await servers[2].playlists.list({ start: 1, count: 2, sort: '-createdAt' })
308 expect(body.total).to.equal(3) 308 expect(body.total).to.equal(3)
309 309
310 const data = body.data 310 const data = body.data
@@ -331,7 +331,7 @@ describe('Test video playlists', function () {
331 this.timeout(30000) 331 this.timeout(30000)
332 332
333 { 333 {
334 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }) 334 const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' })
335 expect(body.total).to.equal(2) 335 expect(body.total).to.equal(2)
336 336
337 const data = body.data 337 const data = body.data
@@ -340,7 +340,7 @@ describe('Test video playlists', function () {
340 } 340 }
341 341
342 { 342 {
343 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' }) 343 const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' })
344 expect(body.total).to.equal(2) 344 expect(body.total).to.equal(2)
345 345
346 const data = body.data 346 const data = body.data
@@ -349,7 +349,7 @@ describe('Test video playlists', function () {
349 } 349 }
350 350
351 { 351 {
352 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' }) 352 const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' })
353 expect(body.total).to.equal(1) 353 expect(body.total).to.equal(1)
354 354
355 const data = body.data 355 const data = body.data
@@ -358,7 +358,7 @@ describe('Test video playlists', function () {
358 } 358 }
359 359
360 { 360 {
361 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' }) 361 const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' })
362 expect(body.total).to.equal(0) 362 expect(body.total).to.equal(0)
363 363
364 const data = body.data 364 const data = body.data
@@ -375,17 +375,17 @@ describe('Test video playlists', function () {
375 this.timeout(30000) 375 this.timeout(30000)
376 376
377 { 377 {
378 unlistedPlaylist = await servers[1].playlistsCommand.create({ 378 unlistedPlaylist = await servers[1].playlists.create({
379 attributes: { 379 attributes: {
380 displayName: 'playlist unlisted', 380 displayName: 'playlist unlisted',
381 privacy: VideoPlaylistPrivacy.UNLISTED, 381 privacy: VideoPlaylistPrivacy.UNLISTED,
382 videoChannelId: servers[1].videoChannel.id 382 videoChannelId: servers[1].store.channel.id
383 } 383 }
384 }) 384 })
385 } 385 }
386 386
387 { 387 {
388 privatePlaylist = await servers[1].playlistsCommand.create({ 388 privatePlaylist = await servers[1].playlists.create({
389 attributes: { 389 attributes: {
390 displayName: 'playlist private', 390 displayName: 'playlist private',
391 privacy: VideoPlaylistPrivacy.PRIVATE 391 privacy: VideoPlaylistPrivacy.PRIVATE
@@ -400,8 +400,8 @@ describe('Test video playlists', function () {
400 it('Should not list unlisted or private playlists', async function () { 400 it('Should not list unlisted or private playlists', async function () {
401 for (const server of servers) { 401 for (const server of servers) {
402 const results = [ 402 const results = [
403 await server.playlistsCommand.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), 403 await server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }),
404 await server.playlistsCommand.list({ start: 0, count: 2, sort: '-createdAt' }) 404 await server.playlists.list({ start: 0, count: 2, sort: '-createdAt' })
405 ] 405 ]
406 406
407 expect(results[0].total).to.equal(2) 407 expect(results[0].total).to.equal(2)
@@ -417,23 +417,23 @@ describe('Test video playlists', function () {
417 }) 417 })
418 418
419 it('Should not get unlisted playlist using only the id', async function () { 419 it('Should not get unlisted playlist using only the id', async function () {
420 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }) 420 await servers[1].playlists.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 })
421 }) 421 })
422 422
423 it('Should get unlisted plyaylist using uuid or shortUUID', async function () { 423 it('Should get unlisted plyaylist using uuid or shortUUID', async function () {
424 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.uuid }) 424 await servers[1].playlists.get({ playlistId: unlistedPlaylist.uuid })
425 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.shortUUID }) 425 await servers[1].playlists.get({ playlistId: unlistedPlaylist.shortUUID })
426 }) 426 })
427 427
428 it('Should not get private playlist without token', async function () { 428 it('Should not get private playlist without token', async function () {
429 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { 429 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
430 await servers[1].playlistsCommand.get({ playlistId: id, expectedStatus: 401 }) 430 await servers[1].playlists.get({ playlistId: id, expectedStatus: 401 })
431 } 431 }
432 }) 432 })
433 433
434 it('Should get private playlist with a token', async function () { 434 it('Should get private playlist with a token', async function () {
435 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { 435 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
436 await servers[1].playlistsCommand.get({ token: servers[1].accessToken, playlistId: id }) 436 await servers[1].playlists.get({ token: servers[1].accessToken, playlistId: id })
437 } 437 }
438 }) 438 })
439 }) 439 })
@@ -443,13 +443,13 @@ describe('Test video playlists', function () {
443 it('Should update a playlist', async function () { 443 it('Should update a playlist', async function () {
444 this.timeout(30000) 444 this.timeout(30000)
445 445
446 await servers[1].playlistsCommand.update({ 446 await servers[1].playlists.update({
447 attributes: { 447 attributes: {
448 displayName: 'playlist 3 updated', 448 displayName: 'playlist 3 updated',
449 description: 'description updated', 449 description: 'description updated',
450 privacy: VideoPlaylistPrivacy.UNLISTED, 450 privacy: VideoPlaylistPrivacy.UNLISTED,
451 thumbnailfile: 'thumbnail.jpg', 451 thumbnailfile: 'thumbnail.jpg',
452 videoChannelId: servers[1].videoChannel.id 452 videoChannelId: servers[1].store.channel.id
453 }, 453 },
454 playlistId: playlistServer2Id2 454 playlistId: playlistServer2Id2
455 }) 455 })
@@ -457,7 +457,7 @@ describe('Test video playlists', function () {
457 await waitJobs(servers) 457 await waitJobs(servers)
458 458
459 for (const server of servers) { 459 for (const server of servers) {
460 const playlist = await server.playlistsCommand.get({ playlistId: playlistServer2UUID2 }) 460 const playlist = await server.playlists.get({ playlistId: playlistServer2UUID2 })
461 461
462 expect(playlist.displayName).to.equal('playlist 3 updated') 462 expect(playlist.displayName).to.equal('playlist 3 updated')
463 expect(playlist.description).to.equal('description updated') 463 expect(playlist.description).to.equal('description updated')
@@ -491,23 +491,23 @@ describe('Test video playlists', function () {
491 attributes: { 491 attributes: {
492 displayName: 'playlist 4', 492 displayName: 'playlist 4',
493 privacy: VideoPlaylistPrivacy.PUBLIC, 493 privacy: VideoPlaylistPrivacy.PUBLIC,
494 videoChannelId: servers[0].videoChannel.id 494 videoChannelId: servers[0].store.channel.id
495 } 495 }
496 }) 496 })
497 497
498 playlistServer1Id = playlist.id 498 playlistServer1Id = playlist.id
499 playlistServer1UUID = playlist.uuid 499 playlistServer1UUID = playlist.uuid
500 500
501 await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) 501 await addVideo({ videoId: servers[0].store.videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
502 await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 }) 502 await addVideo({ videoId: servers[2].store.videos[1].uuid, startTimestamp: 35 })
503 await addVideo({ videoId: servers[2].videos[2].uuid }) 503 await addVideo({ videoId: servers[2].store.videos[2].uuid })
504 { 504 {
505 const element = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 }) 505 const element = await addVideo({ videoId: servers[0].store.videos[3].uuid, stopTimestamp: 35 })
506 playlistElementServer1Video4 = element.id 506 playlistElementServer1Video4 = element.id
507 } 507 }
508 508
509 { 509 {
510 const element = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) 510 const element = await addVideo({ videoId: servers[0].store.videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
511 playlistElementServer1Video5 = element.id 511 playlistElementServer1Video5 = element.id
512 } 512 }
513 513
@@ -527,7 +527,7 @@ describe('Test video playlists', function () {
527 527
528 for (const server of servers) { 528 for (const server of servers) {
529 { 529 {
530 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 530 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
531 531
532 expect(body.total).to.equal(8) 532 expect(body.total).to.equal(8)
533 533
@@ -576,7 +576,7 @@ describe('Test video playlists', function () {
576 } 576 }
577 577
578 { 578 {
579 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 }) 579 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 })
580 expect(body.data).to.have.lengthOf(2) 580 expect(body.data).to.have.lengthOf(2)
581 } 581 }
582 } 582 }
@@ -606,7 +606,7 @@ describe('Test video playlists', function () {
606 attributes: { 606 attributes: {
607 displayName: 'playlist 56', 607 displayName: 'playlist 56',
608 privacy: VideoPlaylistPrivacy.PUBLIC, 608 privacy: VideoPlaylistPrivacy.PUBLIC,
609 videoChannelId: servers[0].videoChannel.id 609 videoChannelId: servers[0].store.channel.id
610 } 610 }
611 }) 611 })
612 612
@@ -617,9 +617,9 @@ describe('Test video playlists', function () {
617 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes }) 617 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes })
618 } 618 }
619 619
620 video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid 620 video1 = (await servers[0].videos.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid
621 video2 = (await servers[1].videosCommand.quickUpload({ name: 'video 90' })).uuid 621 video2 = (await servers[1].videos.quickUpload({ name: 'video 90' })).uuid
622 video3 = (await servers[0].videosCommand.quickUpload({ name: 'video 91', nsfw: true })).uuid 622 video3 = (await servers[0].videos.quickUpload({ name: 'video 91', nsfw: true })).uuid
623 623
624 await waitJobs(servers) 624 await waitJobs(servers)
625 625
@@ -637,7 +637,7 @@ describe('Test video playlists', function () {
637 const position = 1 637 const position = 1
638 638
639 { 639 {
640 await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } }) 640 await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } })
641 await waitJobs(servers) 641 await waitJobs(servers)
642 642
643 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 643 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -647,7 +647,7 @@ describe('Test video playlists', function () {
647 } 647 }
648 648
649 { 649 {
650 await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } }) 650 await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } })
651 await waitJobs(servers) 651 await waitJobs(servers)
652 652
653 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 653 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -665,7 +665,7 @@ describe('Test video playlists', function () {
665 const position = 1 665 const position = 1
666 666
667 { 667 {
668 await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true }) 668 await servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true })
669 await waitJobs(servers) 669 await waitJobs(servers)
670 670
671 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 671 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -675,7 +675,7 @@ describe('Test video playlists', function () {
675 } 675 }
676 676
677 { 677 {
678 await servers[0].blacklistCommand.remove({ videoId: video1 }) 678 await servers[0].blacklist.remove({ videoId: video1 })
679 await waitJobs(servers) 679 await waitJobs(servers)
680 680
681 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 681 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -689,7 +689,7 @@ describe('Test video playlists', function () {
689 it('Should update the element type if the account or server of the video is blocked', async function () { 689 it('Should update the element type if the account or server of the video is blocked', async function () {
690 this.timeout(90000) 690 this.timeout(90000)
691 691
692 const command = servers[0].blocklistCommand 692 const command = servers[0].blocklist
693 693
694 const name = 'video 90' 694 const name = 'video 90'
695 const position = 2 695 const position = 2
@@ -778,7 +778,7 @@ describe('Test video playlists', function () {
778 await waitJobs(servers) 778 await waitJobs(servers)
779 779
780 for (const server of servers) { 780 for (const server of servers) {
781 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 781 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
782 const names = body.data.map(v => v.video.name) 782 const names = body.data.map(v => v.video.name)
783 783
784 expect(names).to.deep.equal([ 784 expect(names).to.deep.equal([
@@ -807,7 +807,7 @@ describe('Test video playlists', function () {
807 await waitJobs(servers) 807 await waitJobs(servers)
808 808
809 for (const server of servers) { 809 for (const server of servers) {
810 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 810 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
811 const names = body.data.map(v => v.video.name) 811 const names = body.data.map(v => v.video.name)
812 812
813 expect(names).to.deep.equal([ 813 expect(names).to.deep.equal([
@@ -835,7 +835,7 @@ describe('Test video playlists', function () {
835 await waitJobs(servers) 835 await waitJobs(servers)
836 836
837 for (const server of servers) { 837 for (const server of servers) {
838 const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 838 const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
839 const names = elements.map(v => v.video.name) 839 const names = elements.map(v => v.video.name)
840 840
841 expect(names).to.deep.equal([ 841 expect(names).to.deep.equal([
@@ -878,7 +878,7 @@ describe('Test video playlists', function () {
878 await waitJobs(servers) 878 await waitJobs(servers)
879 879
880 for (const server of servers) { 880 for (const server of servers) {
881 const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 881 const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
882 882
883 expect(elements[0].video.name).to.equal('video 3 server 1') 883 expect(elements[0].video.name).to.equal('video 3 server 1')
884 expect(elements[0].position).to.equal(1) 884 expect(elements[0].position).to.equal(1)
@@ -894,16 +894,16 @@ describe('Test video playlists', function () {
894 894
895 it('Should check videos existence in my playlist', async function () { 895 it('Should check videos existence in my playlist', async function () {
896 const videoIds = [ 896 const videoIds = [
897 servers[0].videos[0].id, 897 servers[0].store.videos[0].id,
898 42000, 898 42000,
899 servers[0].videos[3].id, 899 servers[0].store.videos[3].id,
900 43000, 900 43000,
901 servers[0].videos[4].id 901 servers[0].store.videos[4].id
902 ] 902 ]
903 const obj = await commands[0].videosExist({ videoIds }) 903 const obj = await commands[0].videosExist({ videoIds })
904 904
905 { 905 {
906 const elem = obj[servers[0].videos[0].id] 906 const elem = obj[servers[0].store.videos[0].id]
907 expect(elem).to.have.lengthOf(1) 907 expect(elem).to.have.lengthOf(1)
908 expect(elem[0].playlistElementId).to.exist 908 expect(elem[0].playlistElementId).to.exist
909 expect(elem[0].playlistId).to.equal(playlistServer1Id) 909 expect(elem[0].playlistId).to.equal(playlistServer1Id)
@@ -912,7 +912,7 @@ describe('Test video playlists', function () {
912 } 912 }
913 913
914 { 914 {
915 const elem = obj[servers[0].videos[3].id] 915 const elem = obj[servers[0].store.videos[3].id]
916 expect(elem).to.have.lengthOf(1) 916 expect(elem).to.have.lengthOf(1)
917 expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4) 917 expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4)
918 expect(elem[0].playlistId).to.equal(playlistServer1Id) 918 expect(elem[0].playlistId).to.equal(playlistServer1Id)
@@ -921,7 +921,7 @@ describe('Test video playlists', function () {
921 } 921 }
922 922
923 { 923 {
924 const elem = obj[servers[0].videos[4].id] 924 const elem = obj[servers[0].store.videos[4].id]
925 expect(elem).to.have.lengthOf(1) 925 expect(elem).to.have.lengthOf(1)
926 expect(elem[0].playlistId).to.equal(playlistServer1Id) 926 expect(elem[0].playlistId).to.equal(playlistServer1Id)
927 expect(elem[0].startTimestamp).to.equal(45) 927 expect(elem[0].startTimestamp).to.equal(45)
@@ -934,29 +934,29 @@ describe('Test video playlists', function () {
934 934
935 it('Should automatically update updatedAt field of playlists', async function () { 935 it('Should automatically update updatedAt field of playlists', async function () {
936 const server = servers[1] 936 const server = servers[1]
937 const videoId = servers[1].videos[5].id 937 const videoId = servers[1].store.videos[5].id
938 938
939 async function getPlaylistNames () { 939 async function getPlaylistNames () {
940 const { data } = await server.playlistsCommand.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }) 940 const { data } = await server.playlists.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' })
941 941
942 return data.map(p => p.displayName) 942 return data.map(p => p.displayName)
943 } 943 }
944 944
945 const attributes = { videoId } 945 const attributes = { videoId }
946 const element1 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id1, attributes }) 946 const element1 = await server.playlists.addElement({ playlistId: playlistServer2Id1, attributes })
947 const element2 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id2, attributes }) 947 const element2 = await server.playlists.addElement({ playlistId: playlistServer2Id2, attributes })
948 948
949 const names1 = await getPlaylistNames() 949 const names1 = await getPlaylistNames()
950 expect(names1[0]).to.equal('playlist 3 updated') 950 expect(names1[0]).to.equal('playlist 3 updated')
951 expect(names1[1]).to.equal('playlist 2') 951 expect(names1[1]).to.equal('playlist 2')
952 952
953 await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id }) 953 await server.playlists.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id })
954 954
955 const names2 = await getPlaylistNames() 955 const names2 = await getPlaylistNames()
956 expect(names2[0]).to.equal('playlist 2') 956 expect(names2[0]).to.equal('playlist 2')
957 expect(names2[1]).to.equal('playlist 3 updated') 957 expect(names2[1]).to.equal('playlist 3 updated')
958 958
959 await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id }) 959 await server.playlists.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id })
960 960
961 const names3 = await getPlaylistNames() 961 const names3 = await getPlaylistNames()
962 expect(names3[0]).to.equal('playlist 3 updated') 962 expect(names3[0]).to.equal('playlist 3 updated')
@@ -972,7 +972,7 @@ describe('Test video playlists', function () {
972 await waitJobs(servers) 972 await waitJobs(servers)
973 973
974 for (const server of servers) { 974 for (const server of servers) {
975 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 975 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
976 expect(body.total).to.equal(6) 976 expect(body.total).to.equal(6)
977 977
978 const elements = body.data 978 const elements = body.data
@@ -1005,14 +1005,14 @@ describe('Test video playlists', function () {
1005 attributes: { 1005 attributes: {
1006 displayName: 'my super public playlist', 1006 displayName: 'my super public playlist',
1007 privacy: VideoPlaylistPrivacy.PUBLIC, 1007 privacy: VideoPlaylistPrivacy.PUBLIC,
1008 videoChannelId: servers[0].videoChannel.id 1008 videoChannelId: servers[0].store.channel.id
1009 } 1009 }
1010 }) 1010 })
1011 1011
1012 await waitJobs(servers) 1012 await waitJobs(servers)
1013 1013
1014 for (const server of servers) { 1014 for (const server of servers) {
1015 await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 }) 1015 await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 })
1016 } 1016 }
1017 1017
1018 const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE } 1018 const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE }
@@ -1021,7 +1021,7 @@ describe('Test video playlists', function () {
1021 await waitJobs(servers) 1021 await waitJobs(servers)
1022 1022
1023 for (const server of [ servers[1], servers[2] ]) { 1023 for (const server of [ servers[1], servers[2] ]) {
1024 await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 1024 await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1025 } 1025 }
1026 1026
1027 await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 1027 await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
@@ -1039,7 +1039,7 @@ describe('Test video playlists', function () {
1039 await waitJobs(servers) 1039 await waitJobs(servers)
1040 1040
1041 for (const server of servers) { 1041 for (const server of servers) {
1042 await server.playlistsCommand.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 1042 await server.playlists.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1043 } 1043 }
1044 }) 1044 })
1045 1045
@@ -1057,16 +1057,16 @@ describe('Test video playlists', function () {
1057 const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist') 1057 const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist')
1058 1058
1059 { 1059 {
1060 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 1060 const body = await servers[2].playlists.list({ start: 0, count: 5 })
1061 expect(body.total).to.equal(3) 1061 expect(body.total).to.equal(3)
1062 1062
1063 expect(finder(body.data)).to.not.be.undefined 1063 expect(finder(body.data)).to.not.be.undefined
1064 } 1064 }
1065 1065
1066 await servers[2].followsCommand.unfollow({ target: servers[0] }) 1066 await servers[2].follows.unfollow({ target: servers[0] })
1067 1067
1068 { 1068 {
1069 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 1069 const body = await servers[2].playlists.list({ start: 0, count: 5 })
1070 expect(body.total).to.equal(1) 1070 expect(body.total).to.equal(1)
1071 1071
1072 expect(finder(body.data)).to.be.undefined 1072 expect(finder(body.data)).to.be.undefined
@@ -1076,7 +1076,7 @@ describe('Test video playlists', function () {
1076 it('Should delete a channel and put the associated playlist in private mode', async function () { 1076 it('Should delete a channel and put the associated playlist in private mode', async function () {
1077 this.timeout(30000) 1077 this.timeout(30000)
1078 1078
1079 const channel = await servers[0].channelsCommand.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }) 1079 const channel = await servers[0].channels.create({ attributes: { name: 'super_channel', displayName: 'super channel' } })
1080 1080
1081 const playlistCreated = await commands[0].create({ 1081 const playlistCreated = await commands[0].create({
1082 attributes: { 1082 attributes: {
@@ -1088,7 +1088,7 @@ describe('Test video playlists', function () {
1088 1088
1089 await waitJobs(servers) 1089 await waitJobs(servers)
1090 1090
1091 await servers[0].channelsCommand.delete({ channelName: 'super_channel' }) 1091 await servers[0].channels.delete({ channelName: 'super_channel' })
1092 1092
1093 await waitJobs(servers) 1093 await waitJobs(servers)
1094 1094
@@ -1096,15 +1096,15 @@ describe('Test video playlists', function () {
1096 expect(body.displayName).to.equal('channel playlist') 1096 expect(body.displayName).to.equal('channel playlist')
1097 expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) 1097 expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
1098 1098
1099 await servers[1].playlistsCommand.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 1099 await servers[1].playlists.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1100 }) 1100 })
1101 1101
1102 it('Should delete an account and delete its playlists', async function () { 1102 it('Should delete an account and delete its playlists', async function () {
1103 this.timeout(30000) 1103 this.timeout(30000)
1104 1104
1105 const { userId, token } = await servers[0].usersCommand.generate('user_1') 1105 const { userId, token } = await servers[0].users.generate('user_1')
1106 1106
1107 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token }) 1107 const { videoChannels } = await servers[0].users.getMyInfo({ token })
1108 const userChannel = videoChannels[0] 1108 const userChannel = videoChannels[0]
1109 1109
1110 await commands[0].create({ 1110 await commands[0].create({
@@ -1121,18 +1121,18 @@ describe('Test video playlists', function () {
1121 1121
1122 { 1122 {
1123 for (const server of [ servers[0], servers[1] ]) { 1123 for (const server of [ servers[0], servers[1] ]) {
1124 const body = await server.playlistsCommand.list({ start: 0, count: 15 }) 1124 const body = await server.playlists.list({ start: 0, count: 15 })
1125 1125
1126 expect(finder(body.data)).to.not.be.undefined 1126 expect(finder(body.data)).to.not.be.undefined
1127 } 1127 }
1128 } 1128 }
1129 1129
1130 await servers[0].usersCommand.remove({ userId }) 1130 await servers[0].users.remove({ userId })
1131 await waitJobs(servers) 1131 await waitJobs(servers)
1132 1132
1133 { 1133 {
1134 for (const server of [ servers[0], servers[1] ]) { 1134 for (const server of [ servers[0], servers[1] ]) {
1135 const body = await server.playlistsCommand.list({ start: 0, count: 15 }) 1135 const body = await server.playlists.list({ start: 0, count: 15 })
1136 1136
1137 expect(finder(body.data)).to.be.undefined 1137 expect(finder(body.data)).to.be.undefined
1138 } 1138 }