1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
8 checkPlaylistFilesWereRemoved,
13 doubleFollow, doVideosExistInMyPlaylist,
14 flushAndRunMultipleServers,
16 getAccountPlaylistsList,
17 getAccountPlaylistsListWithToken, getMyUserInformation,
19 getVideoChannelPlaylistsList,
21 getVideoPlaylistPrivacies,
22 getVideoPlaylistsList,
23 getVideoPlaylistWithToken,
26 removeVideoFromPlaylist,
27 reorderVideosPlaylist,
29 setAccessTokensToServers,
30 setDefaultVideoChannel,
34 updateVideoPlaylistElement,
39 } from '../../../../shared/utils'
40 import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
41 import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model'
42 import { Video } from '../../../../shared/models/videos'
43 import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
44 import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
45 import { User } from '../../../../shared/models/users'
47 const expect = chai.expect
49 describe('Test video playlists', function () {
50 let servers: ServerInfo[] = []
52 let playlistServer2Id1: number
53 let playlistServer2Id2: number
54 let playlistServer2UUID2: number
56 let playlistServer1Id: number
57 let playlistServer1UUID: string
59 let nsfwVideoServer1: number
61 before(async function () {
64 servers = await flushAndRunMultipleServers(3, { transcoding: { enabled: false } })
66 // Get the access tokens
67 await setAccessTokensToServers(servers)
68 await setDefaultVideoChannel(servers)
70 // Server 1 and server 2 follow each other
71 await doubleFollow(servers[0], servers[1])
72 // Server 1 and server 3 follow each other
73 await doubleFollow(servers[0], servers[2])
76 const serverPromises: Promise<any>[][] = []
78 for (const server of servers) {
79 const videoPromises: Promise<any>[] = []
81 for (let i = 0; i < 7; i++) {
83 uploadVideo(server.url, server.accessToken, { name: `video ${i} server ${server.serverNumber}`, nsfw: false })
84 .then(res => res.body.video)
88 serverPromises.push(videoPromises)
91 servers[0].videos = await Promise.all(serverPromises[0])
92 servers[1].videos = await Promise.all(serverPromises[1])
93 servers[2].videos = await Promise.all(serverPromises[2])
96 nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[ 0 ], videoName: 'NSFW video', nsfw: true })).id
98 await waitJobs(servers)
101 it('Should list video playlist privacies', async function () {
102 const res = await getVideoPlaylistPrivacies(servers[0].url)
104 const privacies = res.body
105 expect(Object.keys(privacies)).to.have.length.at.least(3)
107 expect(privacies[3]).to.equal('Private')
110 it('Should list watch later playlist', async function () {
111 const url = servers[ 0 ].url
112 const accessToken = servers[ 0 ].accessToken
115 const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER)
117 expect(res.body.total).to.equal(1)
118 expect(res.body.data).to.have.lengthOf(1)
120 const playlist: VideoPlaylist = res.body.data[ 0 ]
121 expect(playlist.displayName).to.equal('Watch later')
122 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
123 expect(playlist.type.label).to.equal('Watch later')
127 const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.REGULAR)
129 expect(res.body.total).to.equal(0)
130 expect(res.body.data).to.have.lengthOf(0)
134 const res = await getAccountPlaylistsList(url, 'root', 0, 5)
135 expect(res.body.total).to.equal(0)
136 expect(res.body.data).to.have.lengthOf(0)
140 it('Should create a playlist on server 1 and have the playlist on server 2 and 3', async function () {
143 await createVideoPlaylist({
145 token: servers[0].accessToken,
147 displayName: 'my super playlist',
148 privacy: VideoPlaylistPrivacy.PUBLIC,
149 description: 'my super description',
150 thumbnailfile: 'thumbnail.jpg',
151 videoChannelId: servers[0].videoChannel.id
155 await waitJobs(servers)
157 for (const server of servers) {
158 const res = await getVideoPlaylistsList(server.url, 0, 5)
159 expect(res.body.total).to.equal(1)
160 expect(res.body.data).to.have.lengthOf(1)
162 const playlistFromList = res.body.data[0] as VideoPlaylist
164 const res2 = await getVideoPlaylist(server.url, playlistFromList.uuid)
165 const playlistFromGet = res2.body
167 for (const playlist of [ playlistFromGet, playlistFromList ]) {
168 expect(playlist.id).to.be.a('number')
169 expect(playlist.uuid).to.be.a('string')
171 expect(playlist.isLocal).to.equal(server.serverNumber === 1)
173 expect(playlist.displayName).to.equal('my super playlist')
174 expect(playlist.description).to.equal('my super description')
175 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
176 expect(playlist.privacy.label).to.equal('Public')
177 expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
178 expect(playlist.type.label).to.equal('Regular')
180 expect(playlist.videosLength).to.equal(0)
182 expect(playlist.ownerAccount.name).to.equal('root')
183 expect(playlist.ownerAccount.displayName).to.equal('root')
184 expect(playlist.videoChannel.name).to.equal('root_channel')
185 expect(playlist.videoChannel.displayName).to.equal('Main root channel')
190 it('Should create a playlist on server 2 and have the playlist on server 1 but not on server 3', async function () {
194 const res = await createVideoPlaylist({
196 token: servers[1].accessToken,
198 displayName: 'playlist 2',
199 privacy: VideoPlaylistPrivacy.PUBLIC,
200 videoChannelId: servers[1].videoChannel.id
203 playlistServer2Id1 = res.body.videoPlaylist.id
207 const res = await createVideoPlaylist({
208 url: servers[ 1 ].url,
209 token: servers[ 1 ].accessToken,
211 displayName: 'playlist 3',
212 privacy: VideoPlaylistPrivacy.PUBLIC,
213 thumbnailfile: 'thumbnail.jpg',
214 videoChannelId: servers[1].videoChannel.id
218 playlistServer2Id2 = res.body.videoPlaylist.id
219 playlistServer2UUID2 = res.body.videoPlaylist.uuid
222 for (let id of [ playlistServer2Id1, playlistServer2Id2 ]) {
223 await addVideoInPlaylist({
224 url: servers[ 1 ].url,
225 token: servers[ 1 ].accessToken,
227 elementAttrs: { videoId: servers[ 1 ].videos[ 0 ].id, startTimestamp: 1, stopTimestamp: 2 }
229 await addVideoInPlaylist({
230 url: servers[ 1 ].url,
231 token: servers[ 1 ].accessToken,
233 elementAttrs: { videoId: servers[ 1 ].videos[ 1 ].id }
237 await waitJobs(servers)
239 for (const server of [ servers[0], servers[1] ]) {
240 const res = await getVideoPlaylistsList(server.url, 0, 5)
242 const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2')
243 expect(playlist2).to.not.be.undefined
244 await testImage(server.url, 'thumbnail-playlist', playlist2.thumbnailPath)
246 const playlist3 = res.body.data.find(p => p.displayName === 'playlist 3')
247 expect(playlist3).to.not.be.undefined
248 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
251 const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
252 expect(res.body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
253 expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
256 it('Should have the playlist on server 3 after a new follow', async function () {
259 // Server 2 and server 3 follow each other
260 await doubleFollow(servers[1], servers[2])
262 const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
264 const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2')
265 expect(playlist2).to.not.be.undefined
266 await testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath)
268 expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined
271 it('Should correctly list the playlists', async function () {
275 const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, 'createdAt')
277 expect(res.body.total).to.equal(3)
279 const data: VideoPlaylist[] = res.body.data
280 expect(data).to.have.lengthOf(2)
281 expect(data[ 0 ].displayName).to.equal('playlist 2')
282 expect(data[ 1 ].displayName).to.equal('playlist 3')
286 const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, '-createdAt')
288 expect(res.body.total).to.equal(3)
290 const data: VideoPlaylist[] = res.body.data
291 expect(data).to.have.lengthOf(2)
292 expect(data[ 0 ].displayName).to.equal('playlist 2')
293 expect(data[ 1 ].displayName).to.equal('my super playlist')
297 it('Should list video channel playlists', async function () {
301 const res = await getVideoChannelPlaylistsList(servers[ 0 ].url, 'root_channel', 0, 2, '-createdAt')
303 expect(res.body.total).to.equal(1)
305 const data: VideoPlaylist[] = res.body.data
306 expect(data).to.have.lengthOf(1)
307 expect(data[ 0 ].displayName).to.equal('my super playlist')
311 it('Should list account playlists', async function () {
315 const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, '-createdAt')
317 expect(res.body.total).to.equal(2)
319 const data: VideoPlaylist[] = res.body.data
320 expect(data).to.have.lengthOf(1)
321 expect(data[ 0 ].displayName).to.equal('playlist 2')
325 const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, 'createdAt')
327 expect(res.body.total).to.equal(2)
329 const data: VideoPlaylist[] = res.body.data
330 expect(data).to.have.lengthOf(1)
331 expect(data[ 0 ].displayName).to.equal('playlist 3')
335 it('Should not list unlisted or private playlists', async function () {
338 await createVideoPlaylist({
339 url: servers[ 1 ].url,
340 token: servers[ 1 ].accessToken,
342 displayName: 'playlist unlisted',
343 privacy: VideoPlaylistPrivacy.UNLISTED
347 await createVideoPlaylist({
348 url: servers[ 1 ].url,
349 token: servers[ 1 ].accessToken,
351 displayName: 'playlist private',
352 privacy: VideoPlaylistPrivacy.PRIVATE
356 await waitJobs(servers)
358 for (const server of servers) {
360 await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'),
361 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
364 expect(results[0].body.total).to.equal(2)
365 expect(results[1].body.total).to.equal(3)
367 for (const res of results) {
368 const data: VideoPlaylist[] = res.body.data
369 expect(data).to.have.lengthOf(2)
370 expect(data[ 0 ].displayName).to.equal('playlist 3')
371 expect(data[ 1 ].displayName).to.equal('playlist 2')
376 it('Should update a playlist', async function () {
379 await updateVideoPlaylist({
381 token: servers[1].accessToken,
383 displayName: 'playlist 3 updated',
384 description: 'description updated',
385 privacy: VideoPlaylistPrivacy.UNLISTED,
386 thumbnailfile: 'thumbnail.jpg',
387 videoChannelId: servers[1].videoChannel.id
389 playlistId: playlistServer2Id2
392 await waitJobs(servers)
394 for (const server of servers) {
395 const res = await getVideoPlaylist(server.url, playlistServer2UUID2)
396 const playlist: VideoPlaylist = res.body
398 expect(playlist.displayName).to.equal('playlist 3 updated')
399 expect(playlist.description).to.equal('description updated')
401 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.UNLISTED)
402 expect(playlist.privacy.label).to.equal('Unlisted')
404 expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
405 expect(playlist.type.label).to.equal('Regular')
407 expect(playlist.videosLength).to.equal(2)
409 expect(playlist.ownerAccount.name).to.equal('root')
410 expect(playlist.ownerAccount.displayName).to.equal('root')
411 expect(playlist.videoChannel.name).to.equal('root_channel')
412 expect(playlist.videoChannel.displayName).to.equal('Main root channel')
416 it('Should create a playlist containing different startTimestamp/endTimestamp videos', async function () {
419 const addVideo = (elementAttrs: any) => {
420 return addVideoInPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: playlistServer1Id, elementAttrs })
423 const res = await createVideoPlaylist({
424 url: servers[ 0 ].url,
425 token: servers[ 0 ].accessToken,
427 displayName: 'playlist 4',
428 privacy: VideoPlaylistPrivacy.PUBLIC,
429 videoChannelId: servers[0].videoChannel.id
433 playlistServer1Id = res.body.videoPlaylist.id
434 playlistServer1UUID = res.body.videoPlaylist.uuid
436 await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
437 await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 })
438 await addVideo({ videoId: servers[2].videos[2].uuid })
439 await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 })
440 await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
441 await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 5 })
443 await waitJobs(servers)
446 it('Should correctly list playlist videos', async function () {
449 for (const server of servers) {
450 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
452 expect(res.body.total).to.equal(6)
454 const videos: Video[] = res.body.data
455 expect(videos).to.have.lengthOf(6)
457 expect(videos[0].name).to.equal('video 0 server 1')
458 expect(videos[0].playlistElement.position).to.equal(1)
459 expect(videos[0].playlistElement.startTimestamp).to.equal(15)
460 expect(videos[0].playlistElement.stopTimestamp).to.equal(28)
462 expect(videos[1].name).to.equal('video 1 server 3')
463 expect(videos[1].playlistElement.position).to.equal(2)
464 expect(videos[1].playlistElement.startTimestamp).to.equal(35)
465 expect(videos[1].playlistElement.stopTimestamp).to.be.null
467 expect(videos[2].name).to.equal('video 2 server 3')
468 expect(videos[2].playlistElement.position).to.equal(3)
469 expect(videos[2].playlistElement.startTimestamp).to.be.null
470 expect(videos[2].playlistElement.stopTimestamp).to.be.null
472 expect(videos[3].name).to.equal('video 3 server 1')
473 expect(videos[3].playlistElement.position).to.equal(4)
474 expect(videos[3].playlistElement.startTimestamp).to.be.null
475 expect(videos[3].playlistElement.stopTimestamp).to.equal(35)
477 expect(videos[4].name).to.equal('video 4 server 1')
478 expect(videos[4].playlistElement.position).to.equal(5)
479 expect(videos[4].playlistElement.startTimestamp).to.equal(45)
480 expect(videos[4].playlistElement.stopTimestamp).to.equal(60)
482 expect(videos[5].name).to.equal('NSFW video')
483 expect(videos[5].playlistElement.position).to.equal(6)
484 expect(videos[5].playlistElement.startTimestamp).to.equal(5)
485 expect(videos[5].playlistElement.stopTimestamp).to.be.null
487 const res2 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10, { nsfw: false })
488 expect(res2.body.total).to.equal(5)
489 expect(res2.body.data.find(v => v.name === 'NSFW video')).to.be.undefined
491 const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2)
492 expect(res3.body.data).to.have.lengthOf(2)
496 it('Should reorder the playlist', async function () {
500 await reorderVideosPlaylist({
501 url: servers[ 0 ].url,
502 token: servers[ 0 ].accessToken,
503 playlistId: playlistServer1Id,
506 insertAfterPosition: 3
510 await waitJobs(servers)
512 for (const server of servers) {
513 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
514 const names = res.body.data.map(v => v.name)
516 expect(names).to.deep.equal([
528 await reorderVideosPlaylist({
530 token: servers[0].accessToken,
531 playlistId: playlistServer1Id,
535 insertAfterPosition: 4
539 await waitJobs(servers)
541 for (const server of servers) {
542 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
543 const names = res.body.data.map(v => v.name)
545 expect(names).to.deep.equal([
557 await reorderVideosPlaylist({
559 token: servers[0].accessToken,
560 playlistId: playlistServer1Id,
563 insertAfterPosition: 3
567 await waitJobs(servers)
569 for (const server of servers) {
570 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
571 const videos: Video[] = res.body.data
573 const names = videos.map(v => v.name)
575 expect(names).to.deep.equal([
584 for (let i = 1; i <= videos.length; i++) {
585 expect(videos[i - 1].playlistElement.position).to.equal(i)
591 it('Should update startTimestamp/endTimestamp of some elements', async function () {
594 await updateVideoPlaylistElement({
596 token: servers[0].accessToken,
597 playlistId: playlistServer1Id,
598 videoId: servers[0].videos[3].uuid,
604 await updateVideoPlaylistElement({
606 token: servers[0].accessToken,
607 playlistId: playlistServer1Id,
608 videoId: servers[0].videos[4].uuid,
614 await waitJobs(servers)
616 for (const server of servers) {
617 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
618 const videos: Video[] = res.body.data
620 expect(videos[0].name).to.equal('video 3 server 1')
621 expect(videos[0].playlistElement.position).to.equal(1)
622 expect(videos[0].playlistElement.startTimestamp).to.equal(1)
623 expect(videos[0].playlistElement.stopTimestamp).to.equal(35)
625 expect(videos[5].name).to.equal('video 4 server 1')
626 expect(videos[5].playlistElement.position).to.equal(6)
627 expect(videos[5].playlistElement.startTimestamp).to.equal(45)
628 expect(videos[5].playlistElement.stopTimestamp).to.be.null
632 it('Should check videos existence in my playlist', async function () {
634 servers[0].videos[0].id,
636 servers[0].videos[3].id,
638 servers[0].videos[4].id
640 const res = await doVideosExistInMyPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, videoIds)
641 const obj = res.body as VideoExistInPlaylist
644 const elem = obj[servers[0].videos[0].id]
645 expect(elem).to.have.lengthOf(1)
646 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
647 expect(elem[ 0 ].startTimestamp).to.equal(15)
648 expect(elem[ 0 ].stopTimestamp).to.equal(28)
652 const elem = obj[servers[0].videos[3].id]
653 expect(elem).to.have.lengthOf(1)
654 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
655 expect(elem[ 0 ].startTimestamp).to.equal(1)
656 expect(elem[ 0 ].stopTimestamp).to.equal(35)
660 const elem = obj[servers[0].videos[4].id]
661 expect(elem).to.have.lengthOf(1)
662 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
663 expect(elem[ 0 ].startTimestamp).to.equal(45)
664 expect(elem[ 0 ].stopTimestamp).to.equal(null)
667 expect(obj[42000]).to.have.lengthOf(0)
668 expect(obj[43000]).to.have.lengthOf(0)
671 it('Should automatically update updatedAt field of playlists', async function () {
672 const server = servers[1]
673 const videoId = servers[1].videos[5].id
675 async function getPlaylistNames () {
676 const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt')
678 return (res.body.data as VideoPlaylist[]).map(p => p.displayName)
681 const elementAttrs = { videoId }
682 await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, elementAttrs })
683 await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, elementAttrs })
685 const names1 = await getPlaylistNames()
686 expect(names1[0]).to.equal('playlist 3 updated')
687 expect(names1[1]).to.equal('playlist 2')
689 await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, videoId })
691 const names2 = await getPlaylistNames()
692 expect(names2[0]).to.equal('playlist 2')
693 expect(names2[1]).to.equal('playlist 3 updated')
695 await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, videoId })
697 const names3 = await getPlaylistNames()
698 expect(names3[0]).to.equal('playlist 3 updated')
699 expect(names3[1]).to.equal('playlist 2')
702 it('Should delete some elements', async function () {
705 await removeVideoFromPlaylist({
707 token: servers[0].accessToken,
708 playlistId: playlistServer1Id,
709 videoId: servers[0].videos[3].uuid
712 await removeVideoFromPlaylist({
714 token: servers[0].accessToken,
715 playlistId: playlistServer1Id,
716 videoId: nsfwVideoServer1
719 await waitJobs(servers)
721 for (const server of servers) {
722 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
724 expect(res.body.total).to.equal(4)
726 const videos: Video[] = res.body.data
727 expect(videos).to.have.lengthOf(4)
729 expect(videos[ 0 ].name).to.equal('video 0 server 1')
730 expect(videos[ 0 ].playlistElement.position).to.equal(1)
732 expect(videos[ 1 ].name).to.equal('video 2 server 3')
733 expect(videos[ 1 ].playlistElement.position).to.equal(2)
735 expect(videos[ 2 ].name).to.equal('video 1 server 3')
736 expect(videos[ 2 ].playlistElement.position).to.equal(3)
738 expect(videos[ 3 ].name).to.equal('video 4 server 1')
739 expect(videos[ 3 ].playlistElement.position).to.equal(4)
743 it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () {
746 await deleteVideoPlaylist(servers[0].url, servers[0].accessToken, playlistServer1Id)
748 await waitJobs(servers)
750 for (const server of servers) {
751 await getVideoPlaylist(server.url, playlistServer1UUID, 404)
755 it('Should have deleted the thumbnail on server 1, 2 and 3', async function () {
758 for (const server of servers) {
759 await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber)
763 it('Should unfollow servers 1 and 2 and hide their playlists', async function () {
766 const finder = data => data.find(p => p.displayName === 'my super playlist')
769 const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
770 expect(res.body.total).to.equal(2)
771 expect(finder(res.body.data)).to.not.be.undefined
774 await unfollow(servers[2].url, servers[2].accessToken, servers[0])
777 const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
778 expect(res.body.total).to.equal(1)
780 expect(finder(res.body.data)).to.be.undefined
784 it('Should delete a channel and put the associated playlist in private mode', async function () {
787 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, { name: 'super_channel', displayName: 'super channel' })
788 const videoChannelId = res.body.videoChannel.id
790 const res2 = await createVideoPlaylist({
792 token: servers[0].accessToken,
794 displayName: 'channel playlist',
795 privacy: VideoPlaylistPrivacy.PUBLIC,
799 const videoPlaylistUUID = res2.body.videoPlaylist.uuid
801 await waitJobs(servers)
803 await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'super_channel')
805 await waitJobs(servers)
807 const res3 = await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistUUID)
808 expect(res3.body.displayName).to.equal('channel playlist')
809 expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
811 await getVideoPlaylist(servers[1].url, videoPlaylistUUID, 404)
814 it('Should delete an account and delete its playlists', async function () {
817 const user = { username: 'user_1', password: 'password' }
818 const res = await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
820 const userId = res.body.user.id
821 const userAccessToken = await userLogin(servers[0], user)
823 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
824 const userChannel = (resChannel.body as User).videoChannels[0]
826 await createVideoPlaylist({
828 token: userAccessToken,
830 displayName: 'playlist to be deleted',
831 privacy: VideoPlaylistPrivacy.PUBLIC,
832 videoChannelId: userChannel.id
836 await waitJobs(servers)
838 const finder = data => data.find(p => p.displayName === 'playlist to be deleted')
841 for (const server of [ servers[0], servers[1] ]) {
842 const res = await getVideoPlaylistsList(server.url, 0, 15)
843 expect(finder(res.body.data)).to.not.be.undefined
847 await removeUser(servers[0].url, userId, servers[0].accessToken)
848 await waitJobs(servers)
851 for (const server of [ servers[0], servers[1] ]) {
852 const res = await getVideoPlaylistsList(server.url, 0, 15)
853 expect(finder(res.body.data)).to.be.undefined
858 after(async function () {
859 killallServers(servers)
861 // Keep the logs if the test failed