X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-playlists.ts;h=34327334f183a06982cc91f4a675bf4baa1f2bc3;hb=d511df28906f84c7d25ecb24e41515ed549ff276;hp=e57d86c14dac8d3c28db4865eb97f6f944cbb923;hpb=7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index e57d86c14..34327334f 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts @@ -2,24 +2,10 @@ import 'mocha' import * as chai from 'chai' -import { HttpStatusCode } from '@shared/core-utils' -import { - checkPlaylistFilesWereRemoved, - cleanupTests, - doubleFollow, - flushAndRunMultipleServers, - PlaylistsCommand, - ServerInfo, - setAccessTokensToServers, - setDefaultVideoChannel, - testImage, - updateVideo, - uploadVideo, - uploadVideoAndGetId, - wait, - waitJobs -} from '@shared/extra-utils' +import { checkPlaylistFilesWereRemoved, testImage } from '@server/tests/shared' +import { wait } from '@shared/core-utils' import { + HttpStatusCode, VideoPlaylist, VideoPlaylistCreateResult, VideoPlaylistElementType, @@ -27,11 +13,21 @@ import { VideoPlaylistType, VideoPrivacy } from '@shared/models' +import { + cleanupTests, + createMultipleServers, + doubleFollow, + PeerTubeServer, + PlaylistsCommand, + setAccessTokensToServers, + setDefaultVideoChannel, + waitJobs +} from '@shared/server-commands' const expect = chai.expect async function checkPlaylistElementType ( - servers: ServerInfo[], + servers: PeerTubeServer[], playlistId: string, type: VideoPlaylistElementType, position: number, @@ -39,7 +35,7 @@ async function checkPlaylistElementType ( total: number ) { for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }) expect(body.total).to.equal(total) const videoElement = body.data.find(e => e.position === position) @@ -55,7 +51,7 @@ async function checkPlaylistElementType ( } describe('Test video playlists', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let playlistServer2Id1: number let playlistServer2Id2: number @@ -78,7 +74,7 @@ describe('Test video playlists', function () { before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(3, { transcoding: { enabled: false } }) + servers = await createMultipleServers(3, { transcoding: { enabled: false } }) // Get the access tokens await setAccessTokensToServers(servers) @@ -89,26 +85,26 @@ describe('Test video playlists', function () { // Server 1 and server 3 follow each other await doubleFollow(servers[0], servers[2]) - commands = servers.map(s => s.playlistsCommand) + commands = servers.map(s => s.playlists) { - servers[0].videos = [] - servers[1].videos = [] - servers[2].videos = [] + servers[0].store.videos = [] + servers[1].store.videos = [] + servers[2].store.videos = [] for (const server of servers) { for (let i = 0; i < 7; i++) { const name = `video ${i} server ${server.serverNumber}` - const resVideo = await uploadVideo(server.url, server.accessToken, { name, nsfw: false }) + const video = await server.videos.upload({ attributes: { name, nsfw: false } }) - server.videos.push(resVideo.body.video) + server.store.videos.push(video) } } } - nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id + nsfwVideoServer1 = (await servers[0].videos.quickUpload({ name: 'NSFW video', nsfw: true })).id - userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1') + userTokenServer1 = await servers[0].users.generateUserAndToken('user1') await waitJobs(servers) }) @@ -152,7 +148,7 @@ describe('Test video playlists', function () { }) it('Should get private playlist for a classic user', async function () { - const token = await servers[0].usersCommand.generateUserAndToken('toto') + const token = await servers[0].users.generateUserAndToken('toto') const body = await commands[0].listByAccount({ token, handle: 'toto' }) @@ -175,7 +171,7 @@ describe('Test video playlists', function () { privacy: VideoPlaylistPrivacy.PUBLIC, description: 'my super description', thumbnailfile: 'thumbnail.jpg', - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) @@ -184,13 +180,13 @@ describe('Test video playlists', function () { await wait(3000) for (const server of servers) { - const body = await server.playlistsCommand.list({ start: 0, count: 5 }) + const body = await server.playlists.list({ start: 0, count: 5 }) expect(body.total).to.equal(1) expect(body.data).to.have.lengthOf(1) const playlistFromList = body.data[0] - const playlistFromGet = await server.playlistsCommand.get({ playlistId: playlistFromList.uuid }) + const playlistFromGet = await server.playlists.get({ playlistId: playlistFromList.uuid }) for (const playlist of [ playlistFromGet, playlistFromList ]) { expect(playlist.id).to.be.a('number') @@ -220,23 +216,23 @@ describe('Test video playlists', function () { this.timeout(30000) { - const playlist = await servers[1].playlistsCommand.create({ + const playlist = await servers[1].playlists.create({ attributes: { displayName: 'playlist 2', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) playlistServer2Id1 = playlist.id } { - const playlist = await servers[1].playlistsCommand.create({ + const playlist = await servers[1].playlists.create({ attributes: { displayName: 'playlist 3', privacy: VideoPlaylistPrivacy.PUBLIC, thumbnailfile: 'thumbnail.jpg', - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) @@ -245,13 +241,13 @@ describe('Test video playlists', function () { } for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) { - await servers[1].playlistsCommand.addElement({ + await servers[1].playlists.addElement({ playlistId: id, - attributes: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 } + attributes: { videoId: servers[1].store.videos[0].id, startTimestamp: 1, stopTimestamp: 2 } }) - await servers[1].playlistsCommand.addElement({ + await servers[1].playlists.addElement({ playlistId: id, - attributes: { videoId: servers[1].videos[1].id } + attributes: { videoId: servers[1].store.videos[1].id } }) } @@ -259,7 +255,7 @@ describe('Test video playlists', function () { await wait(3000) for (const server of [ servers[0], servers[1] ]) { - const body = await server.playlistsCommand.list({ start: 0, count: 5 }) + const body = await server.playlists.list({ start: 0, count: 5 }) const playlist2 = body.data.find(p => p.displayName === 'playlist 2') expect(playlist2).to.not.be.undefined @@ -270,7 +266,7 @@ describe('Test video playlists', function () { await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) } - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined }) @@ -281,7 +277,7 @@ describe('Test video playlists', function () { // Server 2 and server 3 follow each other await doubleFollow(servers[1], servers[2]) - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) const playlist2 = body.data.find(p => p.displayName === 'playlist 2') expect(playlist2).to.not.be.undefined @@ -297,7 +293,7 @@ describe('Test video playlists', function () { this.timeout(30000) { - const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: 'createdAt' }) + const body = await servers[2].playlists.list({ start: 1, count: 2, sort: 'createdAt' }) expect(body.total).to.equal(3) const data = body.data @@ -307,7 +303,7 @@ describe('Test video playlists', function () { } { - const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: '-createdAt' }) + const body = await servers[2].playlists.list({ start: 1, count: 2, sort: '-createdAt' }) expect(body.total).to.equal(3) const data = body.data @@ -334,7 +330,7 @@ describe('Test video playlists', function () { this.timeout(30000) { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }) expect(body.total).to.equal(2) const data = body.data @@ -343,7 +339,7 @@ describe('Test video playlists', function () { } { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' }) expect(body.total).to.equal(2) const data = body.data @@ -352,7 +348,7 @@ describe('Test video playlists', function () { } { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' }) expect(body.total).to.equal(1) const data = body.data @@ -361,7 +357,7 @@ describe('Test video playlists', function () { } { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' }) expect(body.total).to.equal(0) const data = body.data @@ -378,17 +374,17 @@ describe('Test video playlists', function () { this.timeout(30000) { - unlistedPlaylist = await servers[1].playlistsCommand.create({ + unlistedPlaylist = await servers[1].playlists.create({ attributes: { displayName: 'playlist unlisted', privacy: VideoPlaylistPrivacy.UNLISTED, - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) } { - privatePlaylist = await servers[1].playlistsCommand.create({ + privatePlaylist = await servers[1].playlists.create({ attributes: { displayName: 'playlist private', privacy: VideoPlaylistPrivacy.PRIVATE @@ -403,8 +399,8 @@ describe('Test video playlists', function () { it('Should not list unlisted or private playlists', async function () { for (const server of servers) { const results = [ - await server.playlistsCommand.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), - await server.playlistsCommand.list({ start: 0, count: 2, sort: '-createdAt' }) + await server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), + await server.playlists.list({ start: 0, count: 2, sort: '-createdAt' }) ] expect(results[0].total).to.equal(2) @@ -420,23 +416,23 @@ describe('Test video playlists', function () { }) it('Should not get unlisted playlist using only the id', async function () { - await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }) + await servers[1].playlists.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }) }) it('Should get unlisted plyaylist using uuid or shortUUID', async function () { - await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.uuid }) - await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.shortUUID }) + await servers[1].playlists.get({ playlistId: unlistedPlaylist.uuid }) + await servers[1].playlists.get({ playlistId: unlistedPlaylist.shortUUID }) }) it('Should not get private playlist without token', async function () { for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { - await servers[1].playlistsCommand.get({ playlistId: id, expectedStatus: 401 }) + await servers[1].playlists.get({ playlistId: id, expectedStatus: 401 }) } }) it('Should get private playlist with a token', async function () { for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { - await servers[1].playlistsCommand.get({ token: servers[1].accessToken, playlistId: id }) + await servers[1].playlists.get({ token: servers[1].accessToken, playlistId: id }) } }) }) @@ -446,13 +442,13 @@ describe('Test video playlists', function () { it('Should update a playlist', async function () { this.timeout(30000) - await servers[1].playlistsCommand.update({ + await servers[1].playlists.update({ attributes: { displayName: 'playlist 3 updated', description: 'description updated', privacy: VideoPlaylistPrivacy.UNLISTED, thumbnailfile: 'thumbnail.jpg', - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id }, playlistId: playlistServer2Id2 }) @@ -460,7 +456,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const playlist = await server.playlistsCommand.get({ playlistId: playlistServer2UUID2 }) + const playlist = await server.playlists.get({ playlistId: playlistServer2UUID2 }) expect(playlist.displayName).to.equal('playlist 3 updated') expect(playlist.description).to.equal('description updated') @@ -494,23 +490,23 @@ describe('Test video playlists', function () { attributes: { displayName: 'playlist 4', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) playlistServer1Id = playlist.id playlistServer1UUID = playlist.uuid - await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) - await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 }) - await addVideo({ videoId: servers[2].videos[2].uuid }) + await addVideo({ videoId: servers[0].store.videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) + await addVideo({ videoId: servers[2].store.videos[1].uuid, startTimestamp: 35 }) + await addVideo({ videoId: servers[2].store.videos[2].uuid }) { - const element = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 }) + const element = await addVideo({ videoId: servers[0].store.videos[3].uuid, stopTimestamp: 35 }) playlistElementServer1Video4 = element.id } { - const element = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) + const element = await addVideo({ videoId: servers[0].store.videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) playlistElementServer1Video5 = element.id } @@ -530,7 +526,7 @@ describe('Test video playlists', function () { for (const server of servers) { { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) expect(body.total).to.equal(8) @@ -579,7 +575,7 @@ describe('Test video playlists', function () { } { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 }) expect(body.data).to.have.lengthOf(2) } } @@ -587,10 +583,10 @@ describe('Test video playlists', function () { }) describe('Element type', function () { - let groupUser1: ServerInfo[] - let groupWithoutToken1: ServerInfo[] - let group1: ServerInfo[] - let group2: ServerInfo[] + let groupUser1: PeerTubeServer[] + let groupWithoutToken1: PeerTubeServer[] + let group1: PeerTubeServer[] + let group2: PeerTubeServer[] let video1: string let video2: string @@ -609,7 +605,7 @@ describe('Test video playlists', function () { attributes: { displayName: 'playlist 56', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) @@ -620,9 +616,9 @@ describe('Test video playlists', function () { return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes }) } - video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userTokenServer1 })).uuid - video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid - video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid + video1 = (await servers[0].videos.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid + video2 = (await servers[1].videos.quickUpload({ name: 'video 90' })).uuid + video3 = (await servers[0].videos.quickUpload({ name: 'video 91', nsfw: true })).uuid await waitJobs(servers) @@ -640,7 +636,7 @@ describe('Test video playlists', function () { const position = 1 { - await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PRIVATE }) + await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -650,7 +646,7 @@ describe('Test video playlists', function () { } { - await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PUBLIC }) + await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -668,7 +664,7 @@ describe('Test video playlists', function () { const position = 1 { - await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true }) + await servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -678,7 +674,7 @@ describe('Test video playlists', function () { } { - await servers[0].blacklistCommand.remove({ videoId: video1 }) + await servers[0].blacklist.remove({ videoId: video1 }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -692,7 +688,7 @@ describe('Test video playlists', function () { it('Should update the element type if the account or server of the video is blocked', async function () { this.timeout(90000) - const command = servers[0].blocklistCommand + const command = servers[0].blocklist const name = 'video 90' const position = 2 @@ -781,7 +777,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) const names = body.data.map(v => v.video.name) expect(names).to.deep.equal([ @@ -810,7 +806,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) const names = body.data.map(v => v.video.name) expect(names).to.deep.equal([ @@ -838,7 +834,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) const names = elements.map(v => v.video.name) expect(names).to.deep.equal([ @@ -881,7 +877,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) expect(elements[0].video.name).to.equal('video 3 server 1') expect(elements[0].position).to.equal(1) @@ -897,16 +893,16 @@ describe('Test video playlists', function () { it('Should check videos existence in my playlist', async function () { const videoIds = [ - servers[0].videos[0].id, + servers[0].store.videos[0].id, 42000, - servers[0].videos[3].id, + servers[0].store.videos[3].id, 43000, - servers[0].videos[4].id + servers[0].store.videos[4].id ] const obj = await commands[0].videosExist({ videoIds }) { - const elem = obj[servers[0].videos[0].id] + const elem = obj[servers[0].store.videos[0].id] expect(elem).to.have.lengthOf(1) expect(elem[0].playlistElementId).to.exist expect(elem[0].playlistId).to.equal(playlistServer1Id) @@ -915,7 +911,7 @@ describe('Test video playlists', function () { } { - const elem = obj[servers[0].videos[3].id] + const elem = obj[servers[0].store.videos[3].id] expect(elem).to.have.lengthOf(1) expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4) expect(elem[0].playlistId).to.equal(playlistServer1Id) @@ -924,7 +920,7 @@ describe('Test video playlists', function () { } { - const elem = obj[servers[0].videos[4].id] + const elem = obj[servers[0].store.videos[4].id] expect(elem).to.have.lengthOf(1) expect(elem[0].playlistId).to.equal(playlistServer1Id) expect(elem[0].startTimestamp).to.equal(45) @@ -937,29 +933,29 @@ describe('Test video playlists', function () { it('Should automatically update updatedAt field of playlists', async function () { const server = servers[1] - const videoId = servers[1].videos[5].id + const videoId = servers[1].store.videos[5].id async function getPlaylistNames () { - const { data } = await server.playlistsCommand.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }) + const { data } = await server.playlists.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }) return data.map(p => p.displayName) } const attributes = { videoId } - const element1 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id1, attributes }) - const element2 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id2, attributes }) + const element1 = await server.playlists.addElement({ playlistId: playlistServer2Id1, attributes }) + const element2 = await server.playlists.addElement({ playlistId: playlistServer2Id2, attributes }) const names1 = await getPlaylistNames() expect(names1[0]).to.equal('playlist 3 updated') expect(names1[1]).to.equal('playlist 2') - await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id }) + await server.playlists.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id }) const names2 = await getPlaylistNames() expect(names2[0]).to.equal('playlist 2') expect(names2[1]).to.equal('playlist 3 updated') - await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id }) + await server.playlists.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id }) const names3 = await getPlaylistNames() expect(names3[0]).to.equal('playlist 3 updated') @@ -975,7 +971,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) expect(body.total).to.equal(6) const elements = body.data @@ -1008,14 +1004,14 @@ describe('Test video playlists', function () { attributes: { displayName: 'my super public playlist', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) await waitJobs(servers) for (const server of servers) { - await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 }) + await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 }) } const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE } @@ -1024,7 +1020,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of [ servers[1], servers[2] ]) { - await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -1042,7 +1038,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - await server.playlistsCommand.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.playlists.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) @@ -1060,16 +1056,16 @@ describe('Test video playlists', function () { const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist') { - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) expect(body.total).to.equal(3) expect(finder(body.data)).to.not.be.undefined } - await servers[2].followsCommand.unfollow({ target: servers[0] }) + await servers[2].follows.unfollow({ target: servers[0] }) { - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) expect(body.total).to.equal(1) expect(finder(body.data)).to.be.undefined @@ -1079,7 +1075,7 @@ describe('Test video playlists', function () { it('Should delete a channel and put the associated playlist in private mode', async function () { this.timeout(30000) - const channel = await servers[0].channelsCommand.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }) + const channel = await servers[0].channels.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }) const playlistCreated = await commands[0].create({ attributes: { @@ -1091,7 +1087,7 @@ describe('Test video playlists', function () { await waitJobs(servers) - await servers[0].channelsCommand.delete({ channelName: 'super_channel' }) + await servers[0].channels.delete({ channelName: 'super_channel' }) await waitJobs(servers) @@ -1099,15 +1095,15 @@ describe('Test video playlists', function () { expect(body.displayName).to.equal('channel playlist') expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) - await servers[1].playlistsCommand.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[1].playlists.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) it('Should delete an account and delete its playlists', async function () { this.timeout(30000) - const { userId, token } = await servers[0].usersCommand.generate('user_1') + const { userId, token } = await servers[0].users.generate('user_1') - const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token }) + const { videoChannels } = await servers[0].users.getMyInfo({ token }) const userChannel = videoChannels[0] await commands[0].create({ @@ -1124,18 +1120,18 @@ describe('Test video playlists', function () { { for (const server of [ servers[0], servers[1] ]) { - const body = await server.playlistsCommand.list({ start: 0, count: 15 }) + const body = await server.playlists.list({ start: 0, count: 15 }) expect(finder(body.data)).to.not.be.undefined } } - await servers[0].usersCommand.remove({ userId }) + await servers[0].users.remove({ userId }) await waitJobs(servers) { for (const server of [ servers[0], servers[1] ]) { - const body = await server.playlistsCommand.list({ start: 0, count: 15 }) + const body = await server.playlists.list({ start: 0, count: 15 }) expect(finder(body.data)).to.be.undefined }