1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
8 checkPlaylistFilesWereRemoved,
15 doVideosExistInMyPlaylist,
16 flushAndRunMultipleServers,
17 getAccountPlaylistsList,
18 getAccountPlaylistsListWithToken,
21 getVideoChannelPlaylistsList,
23 getVideoPlaylistPrivacies,
24 getVideoPlaylistsList,
25 getVideoPlaylistWithToken,
27 removeVideoFromPlaylist,
28 reorderVideosPlaylist,
30 setAccessTokensToServers,
31 setDefaultVideoChannel,
35 updateVideoPlaylistElement,
40 } from '../../../../shared/extra-utils'
41 import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
42 import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model'
43 import { Video } from '../../../../shared/models/videos'
44 import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
45 import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
46 import { User } from '../../../../shared/models/users'
48 const expect = chai.expect
50 describe('Test video playlists', function () {
51 let servers: ServerInfo[] = []
53 let playlistServer2Id1: number
54 let playlistServer2Id2: number
55 let playlistServer2UUID2: number
57 let playlistServer1Id: number
58 let playlistServer1UUID: string
60 let nsfwVideoServer1: number
62 before(async function () {
65 servers = await flushAndRunMultipleServers(3, { transcoding: { enabled: false } })
67 // Get the access tokens
68 await setAccessTokensToServers(servers)
69 await setDefaultVideoChannel(servers)
71 // Server 1 and server 2 follow each other
72 await doubleFollow(servers[0], servers[1])
73 // Server 1 and server 3 follow each other
74 await doubleFollow(servers[0], servers[2])
77 const serverPromises: Promise<any>[][] = []
79 for (const server of servers) {
80 const videoPromises: Promise<any>[] = []
82 for (let i = 0; i < 7; i++) {
84 uploadVideo(server.url, server.accessToken, { name: `video ${i} server ${server.serverNumber}`, nsfw: false })
85 .then(res => res.body.video)
89 serverPromises.push(videoPromises)
92 servers[0].videos = await Promise.all(serverPromises[0])
93 servers[1].videos = await Promise.all(serverPromises[1])
94 servers[2].videos = await Promise.all(serverPromises[2])
97 nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[ 0 ], videoName: 'NSFW video', nsfw: true })).id
99 await waitJobs(servers)
102 it('Should list video playlist privacies', async function () {
103 const res = await getVideoPlaylistPrivacies(servers[0].url)
105 const privacies = res.body
106 expect(Object.keys(privacies)).to.have.length.at.least(3)
108 expect(privacies[3]).to.equal('Private')
111 it('Should list watch later playlist', async function () {
112 const url = servers[ 0 ].url
113 const accessToken = servers[ 0 ].accessToken
116 const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER)
118 expect(res.body.total).to.equal(1)
119 expect(res.body.data).to.have.lengthOf(1)
121 const playlist: VideoPlaylist = res.body.data[ 0 ]
122 expect(playlist.displayName).to.equal('Watch later')
123 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
124 expect(playlist.type.label).to.equal('Watch later')
128 const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.REGULAR)
130 expect(res.body.total).to.equal(0)
131 expect(res.body.data).to.have.lengthOf(0)
135 const res = await getAccountPlaylistsList(url, 'root', 0, 5)
136 expect(res.body.total).to.equal(0)
137 expect(res.body.data).to.have.lengthOf(0)
141 it('Should create a playlist on server 1 and have the playlist on server 2 and 3', async function () {
144 await createVideoPlaylist({
146 token: servers[0].accessToken,
148 displayName: 'my super playlist',
149 privacy: VideoPlaylistPrivacy.PUBLIC,
150 description: 'my super description',
151 thumbnailfile: 'thumbnail.jpg',
152 videoChannelId: servers[0].videoChannel.id
156 await waitJobs(servers)
158 for (const server of servers) {
159 const res = await getVideoPlaylistsList(server.url, 0, 5)
160 expect(res.body.total).to.equal(1)
161 expect(res.body.data).to.have.lengthOf(1)
163 const playlistFromList = res.body.data[0] as VideoPlaylist
165 const res2 = await getVideoPlaylist(server.url, playlistFromList.uuid)
166 const playlistFromGet = res2.body
168 for (const playlist of [ playlistFromGet, playlistFromList ]) {
169 expect(playlist.id).to.be.a('number')
170 expect(playlist.uuid).to.be.a('string')
172 expect(playlist.isLocal).to.equal(server.serverNumber === 1)
174 expect(playlist.displayName).to.equal('my super playlist')
175 expect(playlist.description).to.equal('my super description')
176 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
177 expect(playlist.privacy.label).to.equal('Public')
178 expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
179 expect(playlist.type.label).to.equal('Regular')
181 expect(playlist.videosLength).to.equal(0)
183 expect(playlist.ownerAccount.name).to.equal('root')
184 expect(playlist.ownerAccount.displayName).to.equal('root')
185 expect(playlist.videoChannel.name).to.equal('root_channel')
186 expect(playlist.videoChannel.displayName).to.equal('Main root channel')
191 it('Should create a playlist on server 2 and have the playlist on server 1 but not on server 3', async function () {
195 const res = await createVideoPlaylist({
197 token: servers[1].accessToken,
199 displayName: 'playlist 2',
200 privacy: VideoPlaylistPrivacy.PUBLIC,
201 videoChannelId: servers[1].videoChannel.id
204 playlistServer2Id1 = res.body.videoPlaylist.id
208 const res = await createVideoPlaylist({
209 url: servers[ 1 ].url,
210 token: servers[ 1 ].accessToken,
212 displayName: 'playlist 3',
213 privacy: VideoPlaylistPrivacy.PUBLIC,
214 thumbnailfile: 'thumbnail.jpg',
215 videoChannelId: servers[1].videoChannel.id
219 playlistServer2Id2 = res.body.videoPlaylist.id
220 playlistServer2UUID2 = res.body.videoPlaylist.uuid
223 for (let id of [ playlistServer2Id1, playlistServer2Id2 ]) {
224 await addVideoInPlaylist({
225 url: servers[ 1 ].url,
226 token: servers[ 1 ].accessToken,
228 elementAttrs: { videoId: servers[ 1 ].videos[ 0 ].id, startTimestamp: 1, stopTimestamp: 2 }
230 await addVideoInPlaylist({
231 url: servers[ 1 ].url,
232 token: servers[ 1 ].accessToken,
234 elementAttrs: { videoId: servers[ 1 ].videos[ 1 ].id }
238 await waitJobs(servers)
240 for (const server of [ servers[0], servers[1] ]) {
241 const res = await getVideoPlaylistsList(server.url, 0, 5)
243 const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2')
244 expect(playlist2).to.not.be.undefined
245 await testImage(server.url, 'thumbnail-playlist', playlist2.thumbnailPath)
247 const playlist3 = res.body.data.find(p => p.displayName === 'playlist 3')
248 expect(playlist3).to.not.be.undefined
249 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
252 const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
253 expect(res.body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
254 expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
257 it('Should have the playlist on server 3 after a new follow', async function () {
260 // Server 2 and server 3 follow each other
261 await doubleFollow(servers[1], servers[2])
263 const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
265 const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2')
266 expect(playlist2).to.not.be.undefined
267 await testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath)
269 expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined
272 it('Should correctly list the playlists', async function () {
276 const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, 'createdAt')
278 expect(res.body.total).to.equal(3)
280 const data: VideoPlaylist[] = res.body.data
281 expect(data).to.have.lengthOf(2)
282 expect(data[ 0 ].displayName).to.equal('playlist 2')
283 expect(data[ 1 ].displayName).to.equal('playlist 3')
287 const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, '-createdAt')
289 expect(res.body.total).to.equal(3)
291 const data: VideoPlaylist[] = res.body.data
292 expect(data).to.have.lengthOf(2)
293 expect(data[ 0 ].displayName).to.equal('playlist 2')
294 expect(data[ 1 ].displayName).to.equal('my super playlist')
298 it('Should list video channel playlists', async function () {
302 const res = await getVideoChannelPlaylistsList(servers[ 0 ].url, 'root_channel', 0, 2, '-createdAt')
304 expect(res.body.total).to.equal(1)
306 const data: VideoPlaylist[] = res.body.data
307 expect(data).to.have.lengthOf(1)
308 expect(data[ 0 ].displayName).to.equal('my super playlist')
312 it('Should list account playlists', async function () {
316 const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, '-createdAt')
318 expect(res.body.total).to.equal(2)
320 const data: VideoPlaylist[] = res.body.data
321 expect(data).to.have.lengthOf(1)
322 expect(data[ 0 ].displayName).to.equal('playlist 2')
326 const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, 'createdAt')
328 expect(res.body.total).to.equal(2)
330 const data: VideoPlaylist[] = res.body.data
331 expect(data).to.have.lengthOf(1)
332 expect(data[ 0 ].displayName).to.equal('playlist 3')
336 it('Should not list unlisted or private playlists', async function () {
339 await createVideoPlaylist({
340 url: servers[ 1 ].url,
341 token: servers[ 1 ].accessToken,
343 displayName: 'playlist unlisted',
344 privacy: VideoPlaylistPrivacy.UNLISTED
348 await createVideoPlaylist({
349 url: servers[ 1 ].url,
350 token: servers[ 1 ].accessToken,
352 displayName: 'playlist private',
353 privacy: VideoPlaylistPrivacy.PRIVATE
357 await waitJobs(servers)
359 for (const server of servers) {
361 await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'),
362 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
365 expect(results[0].body.total).to.equal(2)
366 expect(results[1].body.total).to.equal(3)
368 for (const res of results) {
369 const data: VideoPlaylist[] = res.body.data
370 expect(data).to.have.lengthOf(2)
371 expect(data[ 0 ].displayName).to.equal('playlist 3')
372 expect(data[ 1 ].displayName).to.equal('playlist 2')
377 it('Should update a playlist', async function () {
380 await updateVideoPlaylist({
382 token: servers[1].accessToken,
384 displayName: 'playlist 3 updated',
385 description: 'description updated',
386 privacy: VideoPlaylistPrivacy.UNLISTED,
387 thumbnailfile: 'thumbnail.jpg',
388 videoChannelId: servers[1].videoChannel.id
390 playlistId: playlistServer2Id2
393 await waitJobs(servers)
395 for (const server of servers) {
396 const res = await getVideoPlaylist(server.url, playlistServer2UUID2)
397 const playlist: VideoPlaylist = res.body
399 expect(playlist.displayName).to.equal('playlist 3 updated')
400 expect(playlist.description).to.equal('description updated')
402 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.UNLISTED)
403 expect(playlist.privacy.label).to.equal('Unlisted')
405 expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
406 expect(playlist.type.label).to.equal('Regular')
408 expect(playlist.videosLength).to.equal(2)
410 expect(playlist.ownerAccount.name).to.equal('root')
411 expect(playlist.ownerAccount.displayName).to.equal('root')
412 expect(playlist.videoChannel.name).to.equal('root_channel')
413 expect(playlist.videoChannel.displayName).to.equal('Main root channel')
417 it('Should create a playlist containing different startTimestamp/endTimestamp videos', async function () {
420 const addVideo = (elementAttrs: any) => {
421 return addVideoInPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: playlistServer1Id, elementAttrs })
424 const res = await createVideoPlaylist({
425 url: servers[ 0 ].url,
426 token: servers[ 0 ].accessToken,
428 displayName: 'playlist 4',
429 privacy: VideoPlaylistPrivacy.PUBLIC,
430 videoChannelId: servers[0].videoChannel.id
434 playlistServer1Id = res.body.videoPlaylist.id
435 playlistServer1UUID = res.body.videoPlaylist.uuid
437 await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
438 await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 })
439 await addVideo({ videoId: servers[2].videos[2].uuid })
440 await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 })
441 await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
442 await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 5 })
444 await waitJobs(servers)
447 it('Should correctly list playlist videos', async function () {
450 for (const server of servers) {
451 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
453 expect(res.body.total).to.equal(6)
455 const videos: Video[] = res.body.data
456 expect(videos).to.have.lengthOf(6)
458 expect(videos[0].name).to.equal('video 0 server 1')
459 expect(videos[0].playlistElement.position).to.equal(1)
460 expect(videos[0].playlistElement.startTimestamp).to.equal(15)
461 expect(videos[0].playlistElement.stopTimestamp).to.equal(28)
463 expect(videos[1].name).to.equal('video 1 server 3')
464 expect(videos[1].playlistElement.position).to.equal(2)
465 expect(videos[1].playlistElement.startTimestamp).to.equal(35)
466 expect(videos[1].playlistElement.stopTimestamp).to.be.null
468 expect(videos[2].name).to.equal('video 2 server 3')
469 expect(videos[2].playlistElement.position).to.equal(3)
470 expect(videos[2].playlistElement.startTimestamp).to.be.null
471 expect(videos[2].playlistElement.stopTimestamp).to.be.null
473 expect(videos[3].name).to.equal('video 3 server 1')
474 expect(videos[3].playlistElement.position).to.equal(4)
475 expect(videos[3].playlistElement.startTimestamp).to.be.null
476 expect(videos[3].playlistElement.stopTimestamp).to.equal(35)
478 expect(videos[4].name).to.equal('video 4 server 1')
479 expect(videos[4].playlistElement.position).to.equal(5)
480 expect(videos[4].playlistElement.startTimestamp).to.equal(45)
481 expect(videos[4].playlistElement.stopTimestamp).to.equal(60)
483 expect(videos[5].name).to.equal('NSFW video')
484 expect(videos[5].playlistElement.position).to.equal(6)
485 expect(videos[5].playlistElement.startTimestamp).to.equal(5)
486 expect(videos[5].playlistElement.stopTimestamp).to.be.null
488 const res2 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10, { nsfw: false })
489 expect(res2.body.total).to.equal(5)
490 expect(res2.body.data.find(v => v.name === 'NSFW video')).to.be.undefined
492 const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2)
493 expect(res3.body.data).to.have.lengthOf(2)
497 it('Should reorder the playlist', async function () {
501 await reorderVideosPlaylist({
502 url: servers[ 0 ].url,
503 token: servers[ 0 ].accessToken,
504 playlistId: playlistServer1Id,
507 insertAfterPosition: 3
511 await waitJobs(servers)
513 for (const server of servers) {
514 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
515 const names = res.body.data.map(v => v.name)
517 expect(names).to.deep.equal([
529 await reorderVideosPlaylist({
531 token: servers[0].accessToken,
532 playlistId: playlistServer1Id,
536 insertAfterPosition: 4
540 await waitJobs(servers)
542 for (const server of servers) {
543 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
544 const names = res.body.data.map(v => v.name)
546 expect(names).to.deep.equal([
558 await reorderVideosPlaylist({
560 token: servers[0].accessToken,
561 playlistId: playlistServer1Id,
564 insertAfterPosition: 3
568 await waitJobs(servers)
570 for (const server of servers) {
571 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
572 const videos: Video[] = res.body.data
574 const names = videos.map(v => v.name)
576 expect(names).to.deep.equal([
585 for (let i = 1; i <= videos.length; i++) {
586 expect(videos[i - 1].playlistElement.position).to.equal(i)
592 it('Should update startTimestamp/endTimestamp of some elements', async function () {
595 await updateVideoPlaylistElement({
597 token: servers[0].accessToken,
598 playlistId: playlistServer1Id,
599 videoId: servers[0].videos[3].uuid,
605 await updateVideoPlaylistElement({
607 token: servers[0].accessToken,
608 playlistId: playlistServer1Id,
609 videoId: servers[0].videos[4].uuid,
615 await waitJobs(servers)
617 for (const server of servers) {
618 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
619 const videos: Video[] = res.body.data
621 expect(videos[0].name).to.equal('video 3 server 1')
622 expect(videos[0].playlistElement.position).to.equal(1)
623 expect(videos[0].playlistElement.startTimestamp).to.equal(1)
624 expect(videos[0].playlistElement.stopTimestamp).to.equal(35)
626 expect(videos[5].name).to.equal('video 4 server 1')
627 expect(videos[5].playlistElement.position).to.equal(6)
628 expect(videos[5].playlistElement.startTimestamp).to.equal(45)
629 expect(videos[5].playlistElement.stopTimestamp).to.be.null
633 it('Should check videos existence in my playlist', async function () {
635 servers[0].videos[0].id,
637 servers[0].videos[3].id,
639 servers[0].videos[4].id
641 const res = await doVideosExistInMyPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, videoIds)
642 const obj = res.body as VideoExistInPlaylist
645 const elem = obj[servers[0].videos[0].id]
646 expect(elem).to.have.lengthOf(1)
647 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
648 expect(elem[ 0 ].startTimestamp).to.equal(15)
649 expect(elem[ 0 ].stopTimestamp).to.equal(28)
653 const elem = obj[servers[0].videos[3].id]
654 expect(elem).to.have.lengthOf(1)
655 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
656 expect(elem[ 0 ].startTimestamp).to.equal(1)
657 expect(elem[ 0 ].stopTimestamp).to.equal(35)
661 const elem = obj[servers[0].videos[4].id]
662 expect(elem).to.have.lengthOf(1)
663 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
664 expect(elem[ 0 ].startTimestamp).to.equal(45)
665 expect(elem[ 0 ].stopTimestamp).to.equal(null)
668 expect(obj[42000]).to.have.lengthOf(0)
669 expect(obj[43000]).to.have.lengthOf(0)
672 it('Should automatically update updatedAt field of playlists', async function () {
673 const server = servers[1]
674 const videoId = servers[1].videos[5].id
676 async function getPlaylistNames () {
677 const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt')
679 return (res.body.data as VideoPlaylist[]).map(p => p.displayName)
682 const elementAttrs = { videoId }
683 await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, elementAttrs })
684 await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, elementAttrs })
686 const names1 = await getPlaylistNames()
687 expect(names1[0]).to.equal('playlist 3 updated')
688 expect(names1[1]).to.equal('playlist 2')
690 await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, videoId })
692 const names2 = await getPlaylistNames()
693 expect(names2[0]).to.equal('playlist 2')
694 expect(names2[1]).to.equal('playlist 3 updated')
696 await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, videoId })
698 const names3 = await getPlaylistNames()
699 expect(names3[0]).to.equal('playlist 3 updated')
700 expect(names3[1]).to.equal('playlist 2')
703 it('Should delete some elements', async function () {
706 await removeVideoFromPlaylist({
708 token: servers[0].accessToken,
709 playlistId: playlistServer1Id,
710 videoId: servers[0].videos[3].uuid
713 await removeVideoFromPlaylist({
715 token: servers[0].accessToken,
716 playlistId: playlistServer1Id,
717 videoId: nsfwVideoServer1
720 await waitJobs(servers)
722 for (const server of servers) {
723 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
725 expect(res.body.total).to.equal(4)
727 const videos: Video[] = res.body.data
728 expect(videos).to.have.lengthOf(4)
730 expect(videos[ 0 ].name).to.equal('video 0 server 1')
731 expect(videos[ 0 ].playlistElement.position).to.equal(1)
733 expect(videos[ 1 ].name).to.equal('video 2 server 3')
734 expect(videos[ 1 ].playlistElement.position).to.equal(2)
736 expect(videos[ 2 ].name).to.equal('video 1 server 3')
737 expect(videos[ 2 ].playlistElement.position).to.equal(3)
739 expect(videos[ 3 ].name).to.equal('video 4 server 1')
740 expect(videos[ 3 ].playlistElement.position).to.equal(4)
744 it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () {
747 await deleteVideoPlaylist(servers[0].url, servers[0].accessToken, playlistServer1Id)
749 await waitJobs(servers)
751 for (const server of servers) {
752 await getVideoPlaylist(server.url, playlistServer1UUID, 404)
756 it('Should have deleted the thumbnail on server 1, 2 and 3', async function () {
759 for (const server of servers) {
760 await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber)
764 it('Should unfollow servers 1 and 2 and hide their playlists', async function () {
767 const finder = data => data.find(p => p.displayName === 'my super playlist')
770 const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
771 expect(res.body.total).to.equal(2)
772 expect(finder(res.body.data)).to.not.be.undefined
775 await unfollow(servers[2].url, servers[2].accessToken, servers[0])
778 const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
779 expect(res.body.total).to.equal(1)
781 expect(finder(res.body.data)).to.be.undefined
785 it('Should delete a channel and put the associated playlist in private mode', async function () {
788 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, { name: 'super_channel', displayName: 'super channel' })
789 const videoChannelId = res.body.videoChannel.id
791 const res2 = await createVideoPlaylist({
793 token: servers[0].accessToken,
795 displayName: 'channel playlist',
796 privacy: VideoPlaylistPrivacy.PUBLIC,
800 const videoPlaylistUUID = res2.body.videoPlaylist.uuid
802 await waitJobs(servers)
804 await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'super_channel')
806 await waitJobs(servers)
808 const res3 = await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistUUID)
809 expect(res3.body.displayName).to.equal('channel playlist')
810 expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
812 await getVideoPlaylist(servers[1].url, videoPlaylistUUID, 404)
815 it('Should delete an account and delete its playlists', async function () {
818 const user = { username: 'user_1', password: 'password' }
819 const res = await createUser({
820 url: servers[ 0 ].url,
821 accessToken: servers[ 0 ].accessToken,
822 username: user.username,
823 password: user.password
826 const userId = res.body.user.id
827 const userAccessToken = await userLogin(servers[0], user)
829 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
830 const userChannel = (resChannel.body as User).videoChannels[0]
832 await createVideoPlaylist({
834 token: userAccessToken,
836 displayName: 'playlist to be deleted',
837 privacy: VideoPlaylistPrivacy.PUBLIC,
838 videoChannelId: userChannel.id
842 await waitJobs(servers)
844 const finder = data => data.find(p => p.displayName === 'playlist to be deleted')
847 for (const server of [ servers[0], servers[1] ]) {
848 const res = await getVideoPlaylistsList(server.url, 0, 15)
849 expect(finder(res.body.data)).to.not.be.undefined
853 await removeUser(servers[0].url, userId, servers[0].accessToken)
854 await waitJobs(servers)
857 for (const server of [ servers[0], servers[1] ]) {
858 const res = await getVideoPlaylistsList(server.url, 0, 15)
859 expect(finder(res.body.data)).to.be.undefined
864 after(async function () {
865 await cleanupTests(servers)