aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-08 15:54:39 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commite6346d59e63135cf012ed18c102d3b0179ef565f (patch)
treee65259adb50daa6376c9878abeef051d99191328 /server/tests/api/videos
parent72cbfc5695ec5ebdb9721d3648218f63feeaeac5 (diff)
downloadPeerTube-e6346d59e63135cf012ed18c102d3b0179ef565f.tar.gz
PeerTube-e6346d59e63135cf012ed18c102d3b0179ef565f.tar.zst
PeerTube-e6346d59e63135cf012ed18c102d3b0179ef565f.zip
Introduce playlist command
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-playlist-thumbnails.ts123
-rw-r--r--server/tests/api/videos/video-playlists.ts564
2 files changed, 287 insertions, 400 deletions
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts
index a93a0b7de..af5df8d90 100644
--- a/server/tests/api/videos/video-playlist-thumbnails.ts
+++ b/server/tests/api/videos/video-playlist-thumbnails.ts
@@ -1,16 +1,11 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { 5import {
6 addVideoInPlaylist,
7 cleanupTests, 6 cleanupTests,
8 createVideoPlaylist,
9 doubleFollow, 7 doubleFollow,
10 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
11 getVideoPlaylistsList,
12 removeVideoFromPlaylist,
13 reorderVideosPlaylist,
14 ServerInfo, 9 ServerInfo,
15 setAccessTokensToServers, 10 setAccessTokensToServers,
16 setDefaultVideoChannel, 11 setDefaultVideoChannel,
@@ -25,8 +20,8 @@ const expect = chai.expect
25describe('Playlist thumbnail', function () { 20describe('Playlist thumbnail', function () {
26 let servers: ServerInfo[] = [] 21 let servers: ServerInfo[] = []
27 22
28 let playlistWithoutThumbnail: number 23 let playlistWithoutThumbnailId: number
29 let playlistWithThumbnail: number 24 let playlistWithThumbnailId: number
30 25
31 let withThumbnailE1: number 26 let withThumbnailE1: number
32 let withThumbnailE2: number 27 let withThumbnailE2: number
@@ -37,15 +32,15 @@ describe('Playlist thumbnail', function () {
37 let video2: number 32 let video2: number
38 33
39 async function getPlaylistWithoutThumbnail (server: ServerInfo) { 34 async function getPlaylistWithoutThumbnail (server: ServerInfo) {
40 const res = await getVideoPlaylistsList(server.url, 0, 10) 35 const body = await server.playlistsCommand.list({ start: 0, count: 10 })
41 36
42 return res.body.data.find(p => p.displayName === 'playlist without thumbnail') 37 return body.data.find(p => p.displayName === 'playlist without thumbnail')
43 } 38 }
44 39
45 async function getPlaylistWithThumbnail (server: ServerInfo) { 40 async function getPlaylistWithThumbnail (server: ServerInfo) {
46 const res = await getVideoPlaylistsList(server.url, 0, 10) 41 const body = await server.playlistsCommand.list({ start: 0, count: 10 })
47 42
48 return res.body.data.find(p => p.displayName === 'playlist with thumbnail') 43 return body.data.find(p => p.displayName === 'playlist with thumbnail')
49 } 44 }
50 45
51 before(async function () { 46 before(async function () {
@@ -69,24 +64,20 @@ describe('Playlist thumbnail', function () {
69 it('Should automatically update the thumbnail when adding an element', async function () { 64 it('Should automatically update the thumbnail when adding an element', async function () {
70 this.timeout(30000) 65 this.timeout(30000)
71 66
72 const res = await createVideoPlaylist({ 67 const created = await servers[1].playlistsCommand.create({
73 url: servers[1].url, 68 attributes: {
74 token: servers[1].accessToken,
75 playlistAttrs: {
76 displayName: 'playlist without thumbnail', 69 displayName: 'playlist without thumbnail',
77 privacy: VideoPlaylistPrivacy.PUBLIC, 70 privacy: VideoPlaylistPrivacy.PUBLIC,
78 videoChannelId: servers[1].videoChannel.id 71 videoChannelId: servers[1].videoChannel.id
79 } 72 }
80 }) 73 })
81 playlistWithoutThumbnail = res.body.videoPlaylist.id 74 playlistWithoutThumbnailId = created.id
82 75
83 const res2 = await addVideoInPlaylist({ 76 const added = await servers[1].playlistsCommand.addElement({
84 url: servers[1].url, 77 playlistId: playlistWithoutThumbnailId,
85 token: servers[1].accessToken, 78 attributes: { videoId: video1 }
86 playlistId: playlistWithoutThumbnail,
87 elementAttrs: { videoId: video1 }
88 }) 79 })
89 withoutThumbnailE1 = res2.body.videoPlaylistElement.id 80 withoutThumbnailE1 = added.id
90 81
91 await waitJobs(servers) 82 await waitJobs(servers)
92 83
@@ -99,25 +90,21 @@ describe('Playlist thumbnail', function () {
99 it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () { 90 it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () {
100 this.timeout(30000) 91 this.timeout(30000)
101 92
102 const res = await createVideoPlaylist({ 93 const created = await servers[1].playlistsCommand.create({
103 url: servers[1].url, 94 attributes: {
104 token: servers[1].accessToken,
105 playlistAttrs: {
106 displayName: 'playlist with thumbnail', 95 displayName: 'playlist with thumbnail',
107 privacy: VideoPlaylistPrivacy.PUBLIC, 96 privacy: VideoPlaylistPrivacy.PUBLIC,
108 videoChannelId: servers[1].videoChannel.id, 97 videoChannelId: servers[1].videoChannel.id,
109 thumbnailfile: 'thumbnail.jpg' 98 thumbnailfile: 'thumbnail.jpg'
110 } 99 }
111 }) 100 })
112 playlistWithThumbnail = res.body.videoPlaylist.id 101 playlistWithThumbnailId = created.id
113 102
114 const res2 = await addVideoInPlaylist({ 103 const added = await servers[1].playlistsCommand.addElement({
115 url: servers[1].url, 104 playlistId: playlistWithThumbnailId,
116 token: servers[1].accessToken, 105 attributes: { videoId: video1 }
117 playlistId: playlistWithThumbnail,
118 elementAttrs: { videoId: video1 }
119 }) 106 })
120 withThumbnailE1 = res2.body.videoPlaylistElement.id 107 withThumbnailE1 = added.id
121 108
122 await waitJobs(servers) 109 await waitJobs(servers)
123 110
@@ -130,19 +117,15 @@ describe('Playlist thumbnail', function () {
130 it('Should automatically update the thumbnail when moving the first element', async function () { 117 it('Should automatically update the thumbnail when moving the first element', async function () {
131 this.timeout(30000) 118 this.timeout(30000)
132 119
133 const res = await addVideoInPlaylist({ 120 const added = await servers[1].playlistsCommand.addElement({
134 url: servers[1].url, 121 playlistId: playlistWithoutThumbnailId,
135 token: servers[1].accessToken, 122 attributes: { videoId: video2 }
136 playlistId: playlistWithoutThumbnail,
137 elementAttrs: { videoId: video2 }
138 }) 123 })
139 withoutThumbnailE2 = res.body.videoPlaylistElement.id 124 withoutThumbnailE2 = added.id
140 125
141 await reorderVideosPlaylist({ 126 await servers[1].playlistsCommand.reorderElements({
142 url: servers[1].url, 127 playlistId: playlistWithoutThumbnailId,
143 token: servers[1].accessToken, 128 attributes: {
144 playlistId: playlistWithoutThumbnail,
145 elementAttrs: {
146 startPosition: 1, 129 startPosition: 1,
147 insertAfterPosition: 2 130 insertAfterPosition: 2
148 } 131 }
@@ -159,19 +142,15 @@ describe('Playlist thumbnail', function () {
159 it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () { 142 it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () {
160 this.timeout(30000) 143 this.timeout(30000)
161 144
162 const res = await addVideoInPlaylist({ 145 const added = await servers[1].playlistsCommand.addElement({
163 url: servers[1].url, 146 playlistId: playlistWithThumbnailId,
164 token: servers[1].accessToken, 147 attributes: { videoId: video2 }
165 playlistId: playlistWithThumbnail,
166 elementAttrs: { videoId: video2 }
167 }) 148 })
168 withThumbnailE2 = res.body.videoPlaylistElement.id 149 withThumbnailE2 = added.id
169 150
170 await reorderVideosPlaylist({ 151 await servers[1].playlistsCommand.reorderElements({
171 url: servers[1].url, 152 playlistId: playlistWithThumbnailId,
172 token: servers[1].accessToken, 153 attributes: {
173 playlistId: playlistWithThumbnail,
174 elementAttrs: {
175 startPosition: 1, 154 startPosition: 1,
176 insertAfterPosition: 2 155 insertAfterPosition: 2
177 } 156 }
@@ -188,11 +167,9 @@ describe('Playlist thumbnail', function () {
188 it('Should automatically update the thumbnail when deleting the first element', async function () { 167 it('Should automatically update the thumbnail when deleting the first element', async function () {
189 this.timeout(30000) 168 this.timeout(30000)
190 169
191 await removeVideoFromPlaylist({ 170 await servers[1].playlistsCommand.removeElement({
192 url: servers[1].url, 171 playlistId: playlistWithoutThumbnailId,
193 token: servers[1].accessToken, 172 elementId: withoutThumbnailE1
194 playlistId: playlistWithoutThumbnail,
195 playlistElementId: withoutThumbnailE1
196 }) 173 })
197 174
198 await waitJobs(servers) 175 await waitJobs(servers)
@@ -206,11 +183,9 @@ describe('Playlist thumbnail', function () {
206 it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () { 183 it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () {
207 this.timeout(30000) 184 this.timeout(30000)
208 185
209 await removeVideoFromPlaylist({ 186 await servers[1].playlistsCommand.removeElement({
210 url: servers[1].url, 187 playlistId: playlistWithThumbnailId,
211 token: servers[1].accessToken, 188 elementId: withThumbnailE1
212 playlistId: playlistWithThumbnail,
213 playlistElementId: withThumbnailE1
214 }) 189 })
215 190
216 await waitJobs(servers) 191 await waitJobs(servers)
@@ -224,11 +199,9 @@ describe('Playlist thumbnail', function () {
224 it('Should the thumbnail when we delete the last element', async function () { 199 it('Should the thumbnail when we delete the last element', async function () {
225 this.timeout(30000) 200 this.timeout(30000)
226 201
227 await removeVideoFromPlaylist({ 202 await servers[1].playlistsCommand.removeElement({
228 url: servers[1].url, 203 playlistId: playlistWithoutThumbnailId,
229 token: servers[1].accessToken, 204 elementId: withoutThumbnailE2
230 playlistId: playlistWithoutThumbnail,
231 playlistElementId: withoutThumbnailE2
232 }) 205 })
233 206
234 await waitJobs(servers) 207 await waitJobs(servers)
@@ -242,11 +215,9 @@ describe('Playlist thumbnail', function () {
242 it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () { 215 it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () {
243 this.timeout(30000) 216 this.timeout(30000)
244 217
245 await removeVideoFromPlaylist({ 218 await servers[1].playlistsCommand.removeElement({
246 url: servers[1].url, 219 playlistId: playlistWithThumbnailId,
247 token: servers[1].accessToken, 220 elementId: withThumbnailE2
248 playlistId: playlistWithThumbnail,
249 playlistElementId: withThumbnailE2
250 }) 221 })
251 222
252 await waitJobs(servers) 223 await waitJobs(servers)
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 069450453..4de6b3abf 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -5,37 +5,22 @@ import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 addVideoChannel, 7 addVideoChannel,
8 addVideoInPlaylist,
9 checkPlaylistFilesWereRemoved, 8 checkPlaylistFilesWereRemoved,
10 cleanupTests, 9 cleanupTests,
11 createUser, 10 createUser,
12 createVideoPlaylist,
13 deleteVideoChannel, 11 deleteVideoChannel,
14 deleteVideoPlaylist,
15 doubleFollow, 12 doubleFollow,
16 doVideosExistInMyPlaylist,
17 flushAndRunMultipleServers, 13 flushAndRunMultipleServers,
18 generateUserAccessToken, 14 generateUserAccessToken,
19 getAccessToken, 15 getAccessToken,
20 getAccountPlaylistsList,
21 getAccountPlaylistsListWithToken,
22 getMyUserInformation, 16 getMyUserInformation,
23 getPlaylistVideos, 17 PlaylistsCommand,
24 getVideoChannelPlaylistsList,
25 getVideoPlaylist,
26 getVideoPlaylistPrivacies,
27 getVideoPlaylistsList,
28 getVideoPlaylistWithToken,
29 removeUser, 18 removeUser,
30 removeVideoFromPlaylist,
31 reorderVideosPlaylist,
32 ServerInfo, 19 ServerInfo,
33 setAccessTokensToServers, 20 setAccessTokensToServers,
34 setDefaultVideoChannel, 21 setDefaultVideoChannel,
35 testImage, 22 testImage,
36 updateVideo, 23 updateVideo,
37 updateVideoPlaylist,
38 updateVideoPlaylistElement,
39 uploadVideo, 24 uploadVideo,
40 uploadVideoAndGetId, 25 uploadVideoAndGetId,
41 userLogin, 26 userLogin,
@@ -44,10 +29,8 @@ import {
44} from '@shared/extra-utils' 29} from '@shared/extra-utils'
45import { 30import {
46 User, 31 User,
47 VideoExistInPlaylist,
48 VideoPlaylist, 32 VideoPlaylist,
49 VideoPlaylistCreateResult, 33 VideoPlaylistCreateResult,
50 VideoPlaylistElement,
51 VideoPlaylistElementType, 34 VideoPlaylistElementType,
52 VideoPlaylistPrivacy, 35 VideoPlaylistPrivacy,
53 VideoPlaylistType, 36 VideoPlaylistType,
@@ -65,10 +48,10 @@ async function checkPlaylistElementType (
65 total: number 48 total: number
66) { 49) {
67 for (const server of servers) { 50 for (const server of servers) {
68 const res = await getPlaylistVideos(server.url, server.accessToken, playlistId, 0, 10) 51 const body = await server.playlistsCommand.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 })
69 expect(res.body.total).to.equal(total) 52 expect(body.total).to.equal(total)
70 53
71 const videoElement: VideoPlaylistElement = res.body.data.find((e: VideoPlaylistElement) => e.position === position) 54 const videoElement = body.data.find(e => e.position === position)
72 expect(videoElement.type).to.equal(type, 'On server ' + server.url) 55 expect(videoElement.type).to.equal(type, 'On server ' + server.url)
73 56
74 if (type === VideoPlaylistElementType.REGULAR) { 57 if (type === VideoPlaylistElementType.REGULAR) {
@@ -85,7 +68,7 @@ describe('Test video playlists', function () {
85 68
86 let playlistServer2Id1: number 69 let playlistServer2Id1: number
87 let playlistServer2Id2: number 70 let playlistServer2Id2: number
88 let playlistServer2UUID2: number 71 let playlistServer2UUID2: string
89 72
90 let playlistServer1Id: number 73 let playlistServer1Id: number
91 let playlistServer1UUID: string 74 let playlistServer1UUID: string
@@ -97,7 +80,9 @@ describe('Test video playlists', function () {
97 80
98 let nsfwVideoServer1: number 81 let nsfwVideoServer1: number
99 82
100 let userAccessTokenServer1: string 83 let userTokenServer1: string
84
85 let commands: PlaylistsCommand[]
101 86
102 before(async function () { 87 before(async function () {
103 this.timeout(120000) 88 this.timeout(120000)
@@ -113,6 +98,8 @@ describe('Test video playlists', function () {
113 // Server 1 and server 3 follow each other 98 // Server 1 and server 3 follow each other
114 await doubleFollow(servers[0], servers[2]) 99 await doubleFollow(servers[0], servers[2])
115 100
101 commands = servers.map(s => s.playlistsCommand)
102
116 { 103 {
117 servers[0].videos = [] 104 servers[0].videos = []
118 servers[1].videos = [] 105 servers[1].videos = []
@@ -137,62 +124,60 @@ describe('Test video playlists', function () {
137 username: 'user1', 124 username: 'user1',
138 password: 'password' 125 password: 'password'
139 }) 126 })
140 userAccessTokenServer1 = await getAccessToken(servers[0].url, 'user1', 'password') 127 userTokenServer1 = await getAccessToken(servers[0].url, 'user1', 'password')
141 } 128 }
142 129
143 await waitJobs(servers) 130 await waitJobs(servers)
144 }) 131 })
145 132
146 describe('Get default playlists', function () { 133 describe('Get default playlists', function () {
134
147 it('Should list video playlist privacies', async function () { 135 it('Should list video playlist privacies', async function () {
148 const res = await getVideoPlaylistPrivacies(servers[0].url) 136 const privacies = await commands[0].getPrivacies()
149 137
150 const privacies = res.body
151 expect(Object.keys(privacies)).to.have.length.at.least(3) 138 expect(Object.keys(privacies)).to.have.length.at.least(3)
152
153 expect(privacies[3]).to.equal('Private') 139 expect(privacies[3]).to.equal('Private')
154 }) 140 })
155 141
156 it('Should list watch later playlist', async function () { 142 it('Should list watch later playlist', async function () {
157 const url = servers[0].url 143 const token = servers[0].accessToken
158 const accessToken = servers[0].accessToken
159 144
160 { 145 {
161 const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER) 146 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER })
162 147
163 expect(res.body.total).to.equal(1) 148 expect(body.total).to.equal(1)
164 expect(res.body.data).to.have.lengthOf(1) 149 expect(body.data).to.have.lengthOf(1)
165 150
166 const playlist: VideoPlaylist = res.body.data[0] 151 const playlist = body.data[0]
167 expect(playlist.displayName).to.equal('Watch later') 152 expect(playlist.displayName).to.equal('Watch later')
168 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER) 153 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
169 expect(playlist.type.label).to.equal('Watch later') 154 expect(playlist.type.label).to.equal('Watch later')
170 } 155 }
171 156
172 { 157 {
173 const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.REGULAR) 158 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.REGULAR })
174 159
175 expect(res.body.total).to.equal(0) 160 expect(body.total).to.equal(0)
176 expect(res.body.data).to.have.lengthOf(0) 161 expect(body.data).to.have.lengthOf(0)
177 } 162 }
178 163
179 { 164 {
180 const res = await getAccountPlaylistsList(url, 'root', 0, 5) 165 const body = await commands[0].listByAccount({ handle: 'root' })
181 expect(res.body.total).to.equal(0) 166 expect(body.total).to.equal(0)
182 expect(res.body.data).to.have.lengthOf(0) 167 expect(body.data).to.have.lengthOf(0)
183 } 168 }
184 }) 169 })
185 170
186 it('Should get private playlist for a classic user', async function () { 171 it('Should get private playlist for a classic user', async function () {
187 const token = await generateUserAccessToken(servers[0], 'toto') 172 const token = await generateUserAccessToken(servers[0], 'toto')
188 173
189 const res = await getAccountPlaylistsListWithToken(servers[0].url, token, 'toto', 0, 5) 174 const body = await commands[0].listByAccount({ token, handle: 'toto' })
190 175
191 expect(res.body.total).to.equal(1) 176 expect(body.total).to.equal(1)
192 expect(res.body.data).to.have.lengthOf(1) 177 expect(body.data).to.have.lengthOf(1)
193 178
194 const playlistId = res.body.data[0].id 179 const playlistId = body.data[0].id
195 await getPlaylistVideos(servers[0].url, token, playlistId, 0, 5) 180 await commands[0].listVideos({ token, playlistId })
196 }) 181 })
197 }) 182 })
198 183
@@ -201,10 +186,8 @@ describe('Test video playlists', function () {
201 it('Should create a playlist on server 1 and have the playlist on server 2 and 3', async function () { 186 it('Should create a playlist on server 1 and have the playlist on server 2 and 3', async function () {
202 this.timeout(30000) 187 this.timeout(30000)
203 188
204 await createVideoPlaylist({ 189 await commands[0].create({
205 url: servers[0].url, 190 attributes: {
206 token: servers[0].accessToken,
207 playlistAttrs: {
208 displayName: 'my super playlist', 191 displayName: 'my super playlist',
209 privacy: VideoPlaylistPrivacy.PUBLIC, 192 privacy: VideoPlaylistPrivacy.PUBLIC,
210 description: 'my super description', 193 description: 'my super description',
@@ -218,14 +201,13 @@ describe('Test video playlists', function () {
218 await wait(3000) 201 await wait(3000)
219 202
220 for (const server of servers) { 203 for (const server of servers) {
221 const res = await getVideoPlaylistsList(server.url, 0, 5) 204 const body = await server.playlistsCommand.list({ start: 0, count: 5 })
222 expect(res.body.total).to.equal(1) 205 expect(body.total).to.equal(1)
223 expect(res.body.data).to.have.lengthOf(1) 206 expect(body.data).to.have.lengthOf(1)
224 207
225 const playlistFromList = res.body.data[0] as VideoPlaylist 208 const playlistFromList = body.data[0]
226 209
227 const res2 = await getVideoPlaylist(server.url, playlistFromList.uuid) 210 const playlistFromGet = await server.playlistsCommand.get({ playlistId: playlistFromList.uuid })
228 const playlistFromGet = res2.body as VideoPlaylist
229 211
230 for (const playlist of [ playlistFromGet, playlistFromList ]) { 212 for (const playlist of [ playlistFromGet, playlistFromList ]) {
231 expect(playlist.id).to.be.a('number') 213 expect(playlist.id).to.be.a('number')
@@ -255,23 +237,19 @@ describe('Test video playlists', function () {
255 this.timeout(30000) 237 this.timeout(30000)
256 238
257 { 239 {
258 const res = await createVideoPlaylist({ 240 const playlist = await servers[1].playlistsCommand.create({
259 url: servers[1].url, 241 attributes: {
260 token: servers[1].accessToken,
261 playlistAttrs: {
262 displayName: 'playlist 2', 242 displayName: 'playlist 2',
263 privacy: VideoPlaylistPrivacy.PUBLIC, 243 privacy: VideoPlaylistPrivacy.PUBLIC,
264 videoChannelId: servers[1].videoChannel.id 244 videoChannelId: servers[1].videoChannel.id
265 } 245 }
266 }) 246 })
267 playlistServer2Id1 = res.body.videoPlaylist.id 247 playlistServer2Id1 = playlist.id
268 } 248 }
269 249
270 { 250 {
271 const res = await createVideoPlaylist({ 251 const playlist = await servers[1].playlistsCommand.create({
272 url: servers[1].url, 252 attributes: {
273 token: servers[1].accessToken,
274 playlistAttrs: {
275 displayName: 'playlist 3', 253 displayName: 'playlist 3',
276 privacy: VideoPlaylistPrivacy.PUBLIC, 254 privacy: VideoPlaylistPrivacy.PUBLIC,
277 thumbnailfile: 'thumbnail.jpg', 255 thumbnailfile: 'thumbnail.jpg',
@@ -279,22 +257,18 @@ describe('Test video playlists', function () {
279 } 257 }
280 }) 258 })
281 259
282 playlistServer2Id2 = res.body.videoPlaylist.id 260 playlistServer2Id2 = playlist.id
283 playlistServer2UUID2 = res.body.videoPlaylist.uuid 261 playlistServer2UUID2 = playlist.uuid
284 } 262 }
285 263
286 for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) { 264 for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) {
287 await addVideoInPlaylist({ 265 await servers[1].playlistsCommand.addElement({
288 url: servers[1].url,
289 token: servers[1].accessToken,
290 playlistId: id, 266 playlistId: id,
291 elementAttrs: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 } 267 attributes: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 }
292 }) 268 })
293 await addVideoInPlaylist({ 269 await servers[1].playlistsCommand.addElement({
294 url: servers[1].url,
295 token: servers[1].accessToken,
296 playlistId: id, 270 playlistId: id,
297 elementAttrs: { videoId: servers[1].videos[1].id } 271 attributes: { videoId: servers[1].videos[1].id }
298 }) 272 })
299 } 273 }
300 274
@@ -302,20 +276,20 @@ describe('Test video playlists', function () {
302 await wait(3000) 276 await wait(3000)
303 277
304 for (const server of [ servers[0], servers[1] ]) { 278 for (const server of [ servers[0], servers[1] ]) {
305 const res = await getVideoPlaylistsList(server.url, 0, 5) 279 const body = await server.playlistsCommand.list({ start: 0, count: 5 })
306 280
307 const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2') 281 const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
308 expect(playlist2).to.not.be.undefined 282 expect(playlist2).to.not.be.undefined
309 await testImage(server.url, 'thumbnail-playlist', playlist2.thumbnailPath) 283 await testImage(server.url, 'thumbnail-playlist', playlist2.thumbnailPath)
310 284
311 const playlist3 = res.body.data.find(p => p.displayName === 'playlist 3') 285 const playlist3 = body.data.find(p => p.displayName === 'playlist 3')
312 expect(playlist3).to.not.be.undefined 286 expect(playlist3).to.not.be.undefined
313 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) 287 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
314 } 288 }
315 289
316 const res = await getVideoPlaylistsList(servers[2].url, 0, 5) 290 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
317 expect(res.body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined 291 expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
318 expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined 292 expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
319 }) 293 })
320 294
321 it('Should have the playlist on server 3 after a new follow', async function () { 295 it('Should have the playlist on server 3 after a new follow', async function () {
@@ -324,13 +298,13 @@ describe('Test video playlists', function () {
324 // Server 2 and server 3 follow each other 298 // Server 2 and server 3 follow each other
325 await doubleFollow(servers[1], servers[2]) 299 await doubleFollow(servers[1], servers[2])
326 300
327 const res = await getVideoPlaylistsList(servers[2].url, 0, 5) 301 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
328 302
329 const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2') 303 const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
330 expect(playlist2).to.not.be.undefined 304 expect(playlist2).to.not.be.undefined
331 await testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath) 305 await testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath)
332 306
333 expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined 307 expect(body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined
334 }) 308 })
335 }) 309 })
336 310
@@ -340,22 +314,20 @@ describe('Test video playlists', function () {
340 this.timeout(30000) 314 this.timeout(30000)
341 315
342 { 316 {
343 const res = await getVideoPlaylistsList(servers[2].url, 1, 2, 'createdAt') 317 const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: 'createdAt' })
318 expect(body.total).to.equal(3)
344 319
345 expect(res.body.total).to.equal(3) 320 const data = body.data
346
347 const data: VideoPlaylist[] = res.body.data
348 expect(data).to.have.lengthOf(2) 321 expect(data).to.have.lengthOf(2)
349 expect(data[0].displayName).to.equal('playlist 2') 322 expect(data[0].displayName).to.equal('playlist 2')
350 expect(data[1].displayName).to.equal('playlist 3') 323 expect(data[1].displayName).to.equal('playlist 3')
351 } 324 }
352 325
353 { 326 {
354 const res = await getVideoPlaylistsList(servers[2].url, 1, 2, '-createdAt') 327 const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: '-createdAt' })
355 328 expect(body.total).to.equal(3)
356 expect(res.body.total).to.equal(3)
357 329
358 const data: VideoPlaylist[] = res.body.data 330 const data = body.data
359 expect(data).to.have.lengthOf(2) 331 expect(data).to.have.lengthOf(2)
360 expect(data[0].displayName).to.equal('playlist 2') 332 expect(data[0].displayName).to.equal('playlist 2')
361 expect(data[1].displayName).to.equal('my super playlist') 333 expect(data[1].displayName).to.equal('my super playlist')
@@ -366,11 +338,10 @@ describe('Test video playlists', function () {
366 this.timeout(30000) 338 this.timeout(30000)
367 339
368 { 340 {
369 const res = await getVideoChannelPlaylistsList(servers[0].url, 'root_channel', 0, 2, '-createdAt') 341 const body = await commands[0].listByChannel({ handle: 'root_channel', start: 0, count: 2, sort: '-createdAt' })
342 expect(body.total).to.equal(1)
370 343
371 expect(res.body.total).to.equal(1) 344 const data = body.data
372
373 const data: VideoPlaylist[] = res.body.data
374 expect(data).to.have.lengthOf(1) 345 expect(data).to.have.lengthOf(1)
375 expect(data[0].displayName).to.equal('my super playlist') 346 expect(data[0].displayName).to.equal('my super playlist')
376 } 347 }
@@ -380,41 +351,37 @@ describe('Test video playlists', function () {
380 this.timeout(30000) 351 this.timeout(30000)
381 352
382 { 353 {
383 const res = await getAccountPlaylistsList(servers[1].url, 'root', 1, 2, '-createdAt') 354 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' })
384 355 expect(body.total).to.equal(2)
385 expect(res.body.total).to.equal(2)
386 356
387 const data: VideoPlaylist[] = res.body.data 357 const data = body.data
388 expect(data).to.have.lengthOf(1) 358 expect(data).to.have.lengthOf(1)
389 expect(data[0].displayName).to.equal('playlist 2') 359 expect(data[0].displayName).to.equal('playlist 2')
390 } 360 }
391 361
392 { 362 {
393 const res = await getAccountPlaylistsList(servers[1].url, 'root', 1, 2, 'createdAt') 363 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' })
364 expect(body.total).to.equal(2)
394 365
395 expect(res.body.total).to.equal(2) 366 const data = body.data
396
397 const data: VideoPlaylist[] = res.body.data
398 expect(data).to.have.lengthOf(1) 367 expect(data).to.have.lengthOf(1)
399 expect(data[0].displayName).to.equal('playlist 3') 368 expect(data[0].displayName).to.equal('playlist 3')
400 } 369 }
401 370
402 { 371 {
403 const res = await getAccountPlaylistsList(servers[1].url, 'root', 0, 10, 'createdAt', '3') 372 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' })
404 373 expect(body.total).to.equal(1)
405 expect(res.body.total).to.equal(1)
406 374
407 const data: VideoPlaylist[] = res.body.data 375 const data = body.data
408 expect(data).to.have.lengthOf(1) 376 expect(data).to.have.lengthOf(1)
409 expect(data[0].displayName).to.equal('playlist 3') 377 expect(data[0].displayName).to.equal('playlist 3')
410 } 378 }
411 379
412 { 380 {
413 const res = await getAccountPlaylistsList(servers[1].url, 'root', 0, 10, 'createdAt', '4') 381 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' })
414 382 expect(body.total).to.equal(0)
415 expect(res.body.total).to.equal(0)
416 383
417 const data: VideoPlaylist[] = res.body.data 384 const data = body.data
418 expect(data).to.have.lengthOf(0) 385 expect(data).to.have.lengthOf(0)
419 } 386 }
420 }) 387 })
@@ -428,28 +395,22 @@ describe('Test video playlists', function () {
428 this.timeout(30000) 395 this.timeout(30000)
429 396
430 { 397 {
431 const res = await createVideoPlaylist({ 398 unlistedPlaylist = await servers[1].playlistsCommand.create({
432 url: servers[1].url, 399 attributes: {
433 token: servers[1].accessToken,
434 playlistAttrs: {
435 displayName: 'playlist unlisted', 400 displayName: 'playlist unlisted',
436 privacy: VideoPlaylistPrivacy.UNLISTED, 401 privacy: VideoPlaylistPrivacy.UNLISTED,
437 videoChannelId: servers[1].videoChannel.id 402 videoChannelId: servers[1].videoChannel.id
438 } 403 }
439 }) 404 })
440 unlistedPlaylist = res.body.videoPlaylist
441 } 405 }
442 406
443 { 407 {
444 const res = await createVideoPlaylist({ 408 privatePlaylist = await servers[1].playlistsCommand.create({
445 url: servers[1].url, 409 attributes: {
446 token: servers[1].accessToken,
447 playlistAttrs: {
448 displayName: 'playlist private', 410 displayName: 'playlist private',
449 privacy: VideoPlaylistPrivacy.PRIVATE 411 privacy: VideoPlaylistPrivacy.PRIVATE
450 } 412 }
451 }) 413 })
452 privatePlaylist = res.body.videoPlaylist
453 } 414 }
454 415
455 await waitJobs(servers) 416 await waitJobs(servers)
@@ -459,15 +420,15 @@ describe('Test video playlists', function () {
459 it('Should not list unlisted or private playlists', async function () { 420 it('Should not list unlisted or private playlists', async function () {
460 for (const server of servers) { 421 for (const server of servers) {
461 const results = [ 422 const results = [
462 await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), 423 await server.playlistsCommand.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }),
463 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') 424 await server.playlistsCommand.list({ start: 0, count: 2, sort: '-createdAt' })
464 ] 425 ]
465 426
466 expect(results[0].body.total).to.equal(2) 427 expect(results[0].total).to.equal(2)
467 expect(results[1].body.total).to.equal(3) 428 expect(results[1].total).to.equal(3)
468 429
469 for (const res of results) { 430 for (const body of results) {
470 const data: VideoPlaylist[] = res.body.data 431 const data = body.data
471 expect(data).to.have.lengthOf(2) 432 expect(data).to.have.lengthOf(2)
472 expect(data[0].displayName).to.equal('playlist 3') 433 expect(data[0].displayName).to.equal('playlist 3')
473 expect(data[1].displayName).to.equal('playlist 2') 434 expect(data[1].displayName).to.equal('playlist 2')
@@ -476,23 +437,23 @@ describe('Test video playlists', function () {
476 }) 437 })
477 438
478 it('Should not get unlisted playlist using only the id', async function () { 439 it('Should not get unlisted playlist using only the id', async function () {
479 await getVideoPlaylist(servers[1].url, unlistedPlaylist.id, 404) 440 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 })
480 }) 441 })
481 442
482 it('Should get unlisted plyaylist using uuid or shortUUID', async function () { 443 it('Should get unlisted plyaylist using uuid or shortUUID', async function () {
483 await getVideoPlaylist(servers[1].url, unlistedPlaylist.uuid) 444 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.uuid })
484 await getVideoPlaylist(servers[1].url, unlistedPlaylist.shortUUID) 445 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.shortUUID })
485 }) 446 })
486 447
487 it('Should not get private playlist without token', async function () { 448 it('Should not get private playlist without token', async function () {
488 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { 449 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
489 await getVideoPlaylist(servers[1].url, id, 401) 450 await servers[1].playlistsCommand.get({ playlistId: id, expectedStatus: 401 })
490 } 451 }
491 }) 452 })
492 453
493 it('Should get private playlist with a token', async function () { 454 it('Should get private playlist with a token', async function () {
494 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { 455 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
495 await getVideoPlaylistWithToken(servers[1].url, servers[1].accessToken, id) 456 await servers[1].playlistsCommand.get({ token: servers[1].accessToken, playlistId: id })
496 } 457 }
497 }) 458 })
498 }) 459 })
@@ -502,10 +463,8 @@ describe('Test video playlists', function () {
502 it('Should update a playlist', async function () { 463 it('Should update a playlist', async function () {
503 this.timeout(30000) 464 this.timeout(30000)
504 465
505 await updateVideoPlaylist({ 466 await servers[1].playlistsCommand.update({
506 url: servers[1].url, 467 attributes: {
507 token: servers[1].accessToken,
508 playlistAttrs: {
509 displayName: 'playlist 3 updated', 468 displayName: 'playlist 3 updated',
510 description: 'description updated', 469 description: 'description updated',
511 privacy: VideoPlaylistPrivacy.UNLISTED, 470 privacy: VideoPlaylistPrivacy.UNLISTED,
@@ -518,8 +477,7 @@ describe('Test video playlists', function () {
518 await waitJobs(servers) 477 await waitJobs(servers)
519 478
520 for (const server of servers) { 479 for (const server of servers) {
521 const res = await getVideoPlaylist(server.url, playlistServer2UUID2) 480 const playlist = await server.playlistsCommand.get({ playlistId: playlistServer2UUID2 })
522 const playlist: VideoPlaylist = res.body
523 481
524 expect(playlist.displayName).to.equal('playlist 3 updated') 482 expect(playlist.displayName).to.equal('playlist 3 updated')
525 expect(playlist.description).to.equal('description updated') 483 expect(playlist.description).to.equal('description updated')
@@ -545,39 +503,37 @@ describe('Test video playlists', function () {
545 it('Should create a playlist containing different startTimestamp/endTimestamp videos', async function () { 503 it('Should create a playlist containing different startTimestamp/endTimestamp videos', async function () {
546 this.timeout(30000) 504 this.timeout(30000)
547 505
548 const addVideo = (elementAttrs: any) => { 506 const addVideo = (attributes: any) => {
549 return addVideoInPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: playlistServer1Id, elementAttrs }) 507 return commands[0].addElement({ playlistId: playlistServer1Id, attributes })
550 } 508 }
551 509
552 const res = await createVideoPlaylist({ 510 const playlist = await commands[0].create({
553 url: servers[0].url, 511 attributes: {
554 token: servers[0].accessToken,
555 playlistAttrs: {
556 displayName: 'playlist 4', 512 displayName: 'playlist 4',
557 privacy: VideoPlaylistPrivacy.PUBLIC, 513 privacy: VideoPlaylistPrivacy.PUBLIC,
558 videoChannelId: servers[0].videoChannel.id 514 videoChannelId: servers[0].videoChannel.id
559 } 515 }
560 }) 516 })
561 517
562 playlistServer1Id = res.body.videoPlaylist.id 518 playlistServer1Id = playlist.id
563 playlistServer1UUID = res.body.videoPlaylist.uuid 519 playlistServer1UUID = playlist.uuid
564 520
565 await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) 521 await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
566 await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 }) 522 await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 })
567 await addVideo({ videoId: servers[2].videos[2].uuid }) 523 await addVideo({ videoId: servers[2].videos[2].uuid })
568 { 524 {
569 const res = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 }) 525 const element = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 })
570 playlistElementServer1Video4 = res.body.videoPlaylistElement.id 526 playlistElementServer1Video4 = element.id
571 } 527 }
572 528
573 { 529 {
574 const res = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) 530 const element = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
575 playlistElementServer1Video5 = res.body.videoPlaylistElement.id 531 playlistElementServer1Video5 = element.id
576 } 532 }
577 533
578 { 534 {
579 const res = await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 5 }) 535 const element = await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 5 })
580 playlistElementNSFW = res.body.videoPlaylistElement.id 536 playlistElementNSFW = element.id
581 537
582 await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 4 }) 538 await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 4 })
583 await addVideo({ videoId: nsfwVideoServer1 }) 539 await addVideo({ videoId: nsfwVideoServer1 })
@@ -590,55 +546,59 @@ describe('Test video playlists', function () {
590 this.timeout(30000) 546 this.timeout(30000)
591 547
592 for (const server of servers) { 548 for (const server of servers) {
593 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 549 {
594 550 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
595 expect(res.body.total).to.equal(8) 551
596 552 expect(body.total).to.equal(8)
597 const videoElements: VideoPlaylistElement[] = res.body.data 553
598 expect(videoElements).to.have.lengthOf(8) 554 const videoElements = body.data
599 555 expect(videoElements).to.have.lengthOf(8)
600 expect(videoElements[0].video.name).to.equal('video 0 server 1') 556
601 expect(videoElements[0].position).to.equal(1) 557 expect(videoElements[0].video.name).to.equal('video 0 server 1')
602 expect(videoElements[0].startTimestamp).to.equal(15) 558 expect(videoElements[0].position).to.equal(1)
603 expect(videoElements[0].stopTimestamp).to.equal(28) 559 expect(videoElements[0].startTimestamp).to.equal(15)
604 560 expect(videoElements[0].stopTimestamp).to.equal(28)
605 expect(videoElements[1].video.name).to.equal('video 1 server 3') 561
606 expect(videoElements[1].position).to.equal(2) 562 expect(videoElements[1].video.name).to.equal('video 1 server 3')
607 expect(videoElements[1].startTimestamp).to.equal(35) 563 expect(videoElements[1].position).to.equal(2)
608 expect(videoElements[1].stopTimestamp).to.be.null 564 expect(videoElements[1].startTimestamp).to.equal(35)
609 565 expect(videoElements[1].stopTimestamp).to.be.null
610 expect(videoElements[2].video.name).to.equal('video 2 server 3') 566
611 expect(videoElements[2].position).to.equal(3) 567 expect(videoElements[2].video.name).to.equal('video 2 server 3')
612 expect(videoElements[2].startTimestamp).to.be.null 568 expect(videoElements[2].position).to.equal(3)
613 expect(videoElements[2].stopTimestamp).to.be.null 569 expect(videoElements[2].startTimestamp).to.be.null
614 570 expect(videoElements[2].stopTimestamp).to.be.null
615 expect(videoElements[3].video.name).to.equal('video 3 server 1') 571
616 expect(videoElements[3].position).to.equal(4) 572 expect(videoElements[3].video.name).to.equal('video 3 server 1')
617 expect(videoElements[3].startTimestamp).to.be.null 573 expect(videoElements[3].position).to.equal(4)
618 expect(videoElements[3].stopTimestamp).to.equal(35) 574 expect(videoElements[3].startTimestamp).to.be.null
619 575 expect(videoElements[3].stopTimestamp).to.equal(35)
620 expect(videoElements[4].video.name).to.equal('video 4 server 1') 576
621 expect(videoElements[4].position).to.equal(5) 577 expect(videoElements[4].video.name).to.equal('video 4 server 1')
622 expect(videoElements[4].startTimestamp).to.equal(45) 578 expect(videoElements[4].position).to.equal(5)
623 expect(videoElements[4].stopTimestamp).to.equal(60) 579 expect(videoElements[4].startTimestamp).to.equal(45)
624 580 expect(videoElements[4].stopTimestamp).to.equal(60)
625 expect(videoElements[5].video.name).to.equal('NSFW video') 581
626 expect(videoElements[5].position).to.equal(6) 582 expect(videoElements[5].video.name).to.equal('NSFW video')
627 expect(videoElements[5].startTimestamp).to.equal(5) 583 expect(videoElements[5].position).to.equal(6)
628 expect(videoElements[5].stopTimestamp).to.be.null 584 expect(videoElements[5].startTimestamp).to.equal(5)
629 585 expect(videoElements[5].stopTimestamp).to.be.null
630 expect(videoElements[6].video.name).to.equal('NSFW video') 586
631 expect(videoElements[6].position).to.equal(7) 587 expect(videoElements[6].video.name).to.equal('NSFW video')
632 expect(videoElements[6].startTimestamp).to.equal(4) 588 expect(videoElements[6].position).to.equal(7)
633 expect(videoElements[6].stopTimestamp).to.be.null 589 expect(videoElements[6].startTimestamp).to.equal(4)
634 590 expect(videoElements[6].stopTimestamp).to.be.null
635 expect(videoElements[7].video.name).to.equal('NSFW video') 591
636 expect(videoElements[7].position).to.equal(8) 592 expect(videoElements[7].video.name).to.equal('NSFW video')
637 expect(videoElements[7].startTimestamp).to.be.null 593 expect(videoElements[7].position).to.equal(8)
638 expect(videoElements[7].stopTimestamp).to.be.null 594 expect(videoElements[7].startTimestamp).to.be.null
639 595 expect(videoElements[7].stopTimestamp).to.be.null
640 const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2) 596 }
641 expect(res3.body.data).to.have.lengthOf(2) 597
598 {
599 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 })
600 expect(body.data).to.have.lengthOf(2)
601 }
642 } 602 }
643 }) 603 })
644 }) 604 })
@@ -656,29 +616,28 @@ describe('Test video playlists', function () {
656 before(async function () { 616 before(async function () {
657 this.timeout(60000) 617 this.timeout(60000)
658 618
659 groupUser1 = [ Object.assign({}, servers[0], { accessToken: userAccessTokenServer1 }) ] 619 groupUser1 = [ Object.assign({}, servers[0], { accessToken: userTokenServer1 }) ]
660 groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ] 620 groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ]
661 group1 = [ servers[0] ] 621 group1 = [ servers[0] ]
662 group2 = [ servers[1], servers[2] ] 622 group2 = [ servers[1], servers[2] ]
663 623
664 const res = await createVideoPlaylist({ 624 const playlist = await commands[0].create({
665 url: servers[0].url, 625 token: userTokenServer1,
666 token: userAccessTokenServer1, 626 attributes: {
667 playlistAttrs: {
668 displayName: 'playlist 56', 627 displayName: 'playlist 56',
669 privacy: VideoPlaylistPrivacy.PUBLIC, 628 privacy: VideoPlaylistPrivacy.PUBLIC,
670 videoChannelId: servers[0].videoChannel.id 629 videoChannelId: servers[0].videoChannel.id
671 } 630 }
672 }) 631 })
673 632
674 const playlistServer1Id2 = res.body.videoPlaylist.id 633 const playlistServer1Id2 = playlist.id
675 playlistServer1UUID2 = res.body.videoPlaylist.uuid 634 playlistServer1UUID2 = playlist.uuid
676 635
677 const addVideo = (elementAttrs: any) => { 636 const addVideo = (attributes: any) => {
678 return addVideoInPlaylist({ url: servers[0].url, token: userAccessTokenServer1, playlistId: playlistServer1Id2, elementAttrs }) 637 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes })
679 } 638 }
680 639
681 video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userAccessTokenServer1 })).uuid 640 video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userTokenServer1 })).uuid
682 video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid 641 video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid
683 video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid 642 video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid
684 643
@@ -756,26 +715,26 @@ describe('Test video playlists', function () {
756 const position = 2 715 const position = 2
757 716
758 { 717 {
759 await command.addToMyBlocklist({ token: userAccessTokenServer1, account: 'root@localhost:' + servers[1].port }) 718 await command.addToMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port })
760 await waitJobs(servers) 719 await waitJobs(servers)
761 720
762 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) 721 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
763 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 722 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
764 723
765 await command.removeFromMyBlocklist({ token: userAccessTokenServer1, account: 'root@localhost:' + servers[1].port }) 724 await command.removeFromMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port })
766 await waitJobs(servers) 725 await waitJobs(servers)
767 726
768 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 727 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
769 } 728 }
770 729
771 { 730 {
772 await command.addToMyBlocklist({ token: userAccessTokenServer1, server: 'localhost:' + servers[1].port }) 731 await command.addToMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port })
773 await waitJobs(servers) 732 await waitJobs(servers)
774 733
775 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) 734 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
776 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 735 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
777 736
778 await command.removeFromMyBlocklist({ token: userAccessTokenServer1, server: 'localhost:' + servers[1].port }) 737 await command.removeFromMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port })
779 await waitJobs(servers) 738 await waitJobs(servers)
780 739
781 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 740 await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -809,10 +768,10 @@ describe('Test video playlists', function () {
809 }) 768 })
810 769
811 it('Should hide the video if it is NSFW', async function () { 770 it('Should hide the video if it is NSFW', async function () {
812 const res = await getPlaylistVideos(servers[0].url, userAccessTokenServer1, playlistServer1UUID2, 0, 10, { nsfw: false }) 771 const body = await commands[0].listVideos({ token: userTokenServer1, playlistId: playlistServer1UUID2, query: { nsfw: 'false' } })
813 expect(res.body.total).to.equal(3) 772 expect(body.total).to.equal(3)
814 773
815 const elements: VideoPlaylistElement[] = res.body.data 774 const elements = body.data
816 const element = elements.find(e => e.position === 3) 775 const element = elements.find(e => e.position === 3)
817 776
818 expect(element).to.exist 777 expect(element).to.exist
@@ -828,11 +787,9 @@ describe('Test video playlists', function () {
828 this.timeout(30000) 787 this.timeout(30000)
829 788
830 { 789 {
831 await reorderVideosPlaylist({ 790 await commands[0].reorderElements({
832 url: servers[0].url,
833 token: servers[0].accessToken,
834 playlistId: playlistServer1Id, 791 playlistId: playlistServer1Id,
835 elementAttrs: { 792 attributes: {
836 startPosition: 2, 793 startPosition: 2,
837 insertAfterPosition: 3 794 insertAfterPosition: 3
838 } 795 }
@@ -841,8 +798,8 @@ describe('Test video playlists', function () {
841 await waitJobs(servers) 798 await waitJobs(servers)
842 799
843 for (const server of servers) { 800 for (const server of servers) {
844 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 801 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
845 const names = (res.body.data as VideoPlaylistElement[]).map(v => v.video.name) 802 const names = body.data.map(v => v.video.name)
846 803
847 expect(names).to.deep.equal([ 804 expect(names).to.deep.equal([
848 'video 0 server 1', 805 'video 0 server 1',
@@ -858,11 +815,9 @@ describe('Test video playlists', function () {
858 } 815 }
859 816
860 { 817 {
861 await reorderVideosPlaylist({ 818 await commands[0].reorderElements({
862 url: servers[0].url,
863 token: servers[0].accessToken,
864 playlistId: playlistServer1Id, 819 playlistId: playlistServer1Id,
865 elementAttrs: { 820 attributes: {
866 startPosition: 1, 821 startPosition: 1,
867 reorderLength: 3, 822 reorderLength: 3,
868 insertAfterPosition: 4 823 insertAfterPosition: 4
@@ -872,8 +827,8 @@ describe('Test video playlists', function () {
872 await waitJobs(servers) 827 await waitJobs(servers)
873 828
874 for (const server of servers) { 829 for (const server of servers) {
875 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 830 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
876 const names = (res.body.data as VideoPlaylistElement[]).map(v => v.video.name) 831 const names = body.data.map(v => v.video.name)
877 832
878 expect(names).to.deep.equal([ 833 expect(names).to.deep.equal([
879 'video 3 server 1', 834 'video 3 server 1',
@@ -889,11 +844,9 @@ describe('Test video playlists', function () {
889 } 844 }
890 845
891 { 846 {
892 await reorderVideosPlaylist({ 847 await commands[0].reorderElements({
893 url: servers[0].url,
894 token: servers[0].accessToken,
895 playlistId: playlistServer1Id, 848 playlistId: playlistServer1Id,
896 elementAttrs: { 849 attributes: {
897 startPosition: 6, 850 startPosition: 6,
898 insertAfterPosition: 3 851 insertAfterPosition: 3
899 } 852 }
@@ -902,8 +855,7 @@ describe('Test video playlists', function () {
902 await waitJobs(servers) 855 await waitJobs(servers)
903 856
904 for (const server of servers) { 857 for (const server of servers) {
905 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 858 const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
906 const elements: VideoPlaylistElement[] = res.body.data
907 const names = elements.map(v => v.video.name) 859 const names = elements.map(v => v.video.name)
908 860
909 expect(names).to.deep.equal([ 861 expect(names).to.deep.equal([
@@ -927,22 +879,18 @@ describe('Test video playlists', function () {
927 it('Should update startTimestamp/endTimestamp of some elements', async function () { 879 it('Should update startTimestamp/endTimestamp of some elements', async function () {
928 this.timeout(30000) 880 this.timeout(30000)
929 881
930 await updateVideoPlaylistElement({ 882 await commands[0].updateElement({
931 url: servers[0].url,
932 token: servers[0].accessToken,
933 playlistId: playlistServer1Id, 883 playlistId: playlistServer1Id,
934 playlistElementId: playlistElementServer1Video4, 884 elementId: playlistElementServer1Video4,
935 elementAttrs: { 885 attributes: {
936 startTimestamp: 1 886 startTimestamp: 1
937 } 887 }
938 }) 888 })
939 889
940 await updateVideoPlaylistElement({ 890 await commands[0].updateElement({
941 url: servers[0].url,
942 token: servers[0].accessToken,
943 playlistId: playlistServer1Id, 891 playlistId: playlistServer1Id,
944 playlistElementId: playlistElementServer1Video5, 892 elementId: playlistElementServer1Video5,
945 elementAttrs: { 893 attributes: {
946 stopTimestamp: null 894 stopTimestamp: null
947 } 895 }
948 }) 896 })
@@ -950,8 +898,7 @@ describe('Test video playlists', function () {
950 await waitJobs(servers) 898 await waitJobs(servers)
951 899
952 for (const server of servers) { 900 for (const server of servers) {
953 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 901 const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
954 const elements: VideoPlaylistElement[] = res.body.data
955 902
956 expect(elements[0].video.name).to.equal('video 3 server 1') 903 expect(elements[0].video.name).to.equal('video 3 server 1')
957 expect(elements[0].position).to.equal(1) 904 expect(elements[0].position).to.equal(1)
@@ -973,8 +920,7 @@ describe('Test video playlists', function () {
973 43000, 920 43000,
974 servers[0].videos[4].id 921 servers[0].videos[4].id
975 ] 922 ]
976 const res = await doVideosExistInMyPlaylist(servers[0].url, servers[0].accessToken, videoIds) 923 const obj = await commands[0].videosExist({ videoIds })
977 const obj = res.body as VideoExistInPlaylist
978 924
979 { 925 {
980 const elem = obj[servers[0].videos[0].id] 926 const elem = obj[servers[0].videos[0].id]
@@ -1011,39 +957,26 @@ describe('Test video playlists', function () {
1011 const videoId = servers[1].videos[5].id 957 const videoId = servers[1].videos[5].id
1012 958
1013 async function getPlaylistNames () { 959 async function getPlaylistNames () {
1014 const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt') 960 const { data } = await server.playlistsCommand.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' })
1015 961
1016 return (res.body.data as VideoPlaylist[]).map(p => p.displayName) 962 return data.map(p => p.displayName)
1017 } 963 }
1018 964
1019 const elementAttrs = { videoId } 965 const attributes = { videoId }
1020 const res1 = await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, elementAttrs }) 966 const element1 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id1, attributes })
1021 const res2 = await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, elementAttrs }) 967 const element2 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id2, attributes })
1022
1023 const element1 = res1.body.videoPlaylistElement.id
1024 const element2 = res2.body.videoPlaylistElement.id
1025 968
1026 const names1 = await getPlaylistNames() 969 const names1 = await getPlaylistNames()
1027 expect(names1[0]).to.equal('playlist 3 updated') 970 expect(names1[0]).to.equal('playlist 3 updated')
1028 expect(names1[1]).to.equal('playlist 2') 971 expect(names1[1]).to.equal('playlist 2')
1029 972
1030 await removeVideoFromPlaylist({ 973 await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id })
1031 url: server.url,
1032 token: server.accessToken,
1033 playlistId: playlistServer2Id1,
1034 playlistElementId: element1
1035 })
1036 974
1037 const names2 = await getPlaylistNames() 975 const names2 = await getPlaylistNames()
1038 expect(names2[0]).to.equal('playlist 2') 976 expect(names2[0]).to.equal('playlist 2')
1039 expect(names2[1]).to.equal('playlist 3 updated') 977 expect(names2[1]).to.equal('playlist 3 updated')
1040 978
1041 await removeVideoFromPlaylist({ 979 await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id })
1042 url: server.url,
1043 token: server.accessToken,
1044 playlistId: playlistServer2Id2,
1045 playlistElementId: element2
1046 })
1047 980
1048 const names3 = await getPlaylistNames() 981 const names3 = await getPlaylistNames()
1049 expect(names3[0]).to.equal('playlist 3 updated') 982 expect(names3[0]).to.equal('playlist 3 updated')
@@ -1053,28 +986,16 @@ describe('Test video playlists', function () {
1053 it('Should delete some elements', async function () { 986 it('Should delete some elements', async function () {
1054 this.timeout(30000) 987 this.timeout(30000)
1055 988
1056 await removeVideoFromPlaylist({ 989 await commands[0].removeElement({ playlistId: playlistServer1Id, elementId: playlistElementServer1Video4 })
1057 url: servers[0].url, 990 await commands[0].removeElement({ playlistId: playlistServer1Id, elementId: playlistElementNSFW })
1058 token: servers[0].accessToken,
1059 playlistId: playlistServer1Id,
1060 playlistElementId: playlistElementServer1Video4
1061 })
1062
1063 await removeVideoFromPlaylist({
1064 url: servers[0].url,
1065 token: servers[0].accessToken,
1066 playlistId: playlistServer1Id,
1067 playlistElementId: playlistElementNSFW
1068 })
1069 991
1070 await waitJobs(servers) 992 await waitJobs(servers)
1071 993
1072 for (const server of servers) { 994 for (const server of servers) {
1073 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 995 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
1074 996 expect(body.total).to.equal(6)
1075 expect(res.body.total).to.equal(6)
1076 997
1077 const elements: VideoPlaylistElement[] = res.body.data 998 const elements = body.data
1078 expect(elements).to.have.lengthOf(6) 999 expect(elements).to.have.lengthOf(6)
1079 1000
1080 expect(elements[0].video.name).to.equal('video 0 server 1') 1001 expect(elements[0].video.name).to.equal('video 0 server 1')
@@ -1100,34 +1021,31 @@ describe('Test video playlists', function () {
1100 it('Should be able to create a public playlist, and set it to private', async function () { 1021 it('Should be able to create a public playlist, and set it to private', async function () {
1101 this.timeout(30000) 1022 this.timeout(30000)
1102 1023
1103 const res = await createVideoPlaylist({ 1024 const videoPlaylistIds = await commands[0].create({
1104 url: servers[0].url, 1025 attributes: {
1105 token: servers[0].accessToken,
1106 playlistAttrs: {
1107 displayName: 'my super public playlist', 1026 displayName: 'my super public playlist',
1108 privacy: VideoPlaylistPrivacy.PUBLIC, 1027 privacy: VideoPlaylistPrivacy.PUBLIC,
1109 videoChannelId: servers[0].videoChannel.id 1028 videoChannelId: servers[0].videoChannel.id
1110 } 1029 }
1111 }) 1030 })
1112 const videoPlaylistIds = res.body.videoPlaylist
1113 1031
1114 await waitJobs(servers) 1032 await waitJobs(servers)
1115 1033
1116 for (const server of servers) { 1034 for (const server of servers) {
1117 await getVideoPlaylist(server.url, videoPlaylistIds.uuid, HttpStatusCode.OK_200) 1035 await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 })
1118 } 1036 }
1119 1037
1120 const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE } 1038 const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE }
1121 await updateVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: videoPlaylistIds.id, playlistAttrs }) 1039 await commands[0].update({ playlistId: videoPlaylistIds.id, attributes })
1122 1040
1123 await waitJobs(servers) 1041 await waitJobs(servers)
1124 1042
1125 for (const server of [ servers[1], servers[2] ]) { 1043 for (const server of [ servers[1], servers[2] ]) {
1126 await getVideoPlaylist(server.url, videoPlaylistIds.uuid, HttpStatusCode.NOT_FOUND_404) 1044 await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1127 } 1045 }
1128 await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, HttpStatusCode.UNAUTHORIZED_401)
1129 1046
1130 await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, HttpStatusCode.OK_200) 1047 await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
1048 await commands[0].get({ token: servers[0].accessToken, playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 })
1131 }) 1049 })
1132 }) 1050 })
1133 1051
@@ -1136,12 +1054,12 @@ describe('Test video playlists', function () {
1136 it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () { 1054 it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () {
1137 this.timeout(30000) 1055 this.timeout(30000)
1138 1056
1139 await deleteVideoPlaylist(servers[0].url, servers[0].accessToken, playlistServer1Id) 1057 await commands[0].delete({ playlistId: playlistServer1Id })
1140 1058
1141 await waitJobs(servers) 1059 await waitJobs(servers)
1142 1060
1143 for (const server of servers) { 1061 for (const server of servers) {
1144 await getVideoPlaylist(server.url, playlistServer1UUID, HttpStatusCode.NOT_FOUND_404) 1062 await server.playlistsCommand.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1145 } 1063 }
1146 }) 1064 })
1147 1065
@@ -1156,21 +1074,22 @@ describe('Test video playlists', function () {
1156 it('Should unfollow servers 1 and 2 and hide their playlists', async function () { 1074 it('Should unfollow servers 1 and 2 and hide their playlists', async function () {
1157 this.timeout(30000) 1075 this.timeout(30000)
1158 1076
1159 const finder = data => data.find(p => p.displayName === 'my super playlist') 1077 const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist')
1160 1078
1161 { 1079 {
1162 const res = await getVideoPlaylistsList(servers[2].url, 0, 5) 1080 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
1163 expect(res.body.total).to.equal(3) 1081 expect(body.total).to.equal(3)
1164 expect(finder(res.body.data)).to.not.be.undefined 1082
1083 expect(finder(body.data)).to.not.be.undefined
1165 } 1084 }
1166 1085
1167 await servers[2].followsCommand.unfollow({ target: servers[0] }) 1086 await servers[2].followsCommand.unfollow({ target: servers[0] })
1168 1087
1169 { 1088 {
1170 const res = await getVideoPlaylistsList(servers[2].url, 0, 5) 1089 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
1171 expect(res.body.total).to.equal(1) 1090 expect(body.total).to.equal(1)
1172 1091
1173 expect(finder(res.body.data)).to.be.undefined 1092 expect(finder(body.data)).to.be.undefined
1174 } 1093 }
1175 }) 1094 })
1176 1095
@@ -1180,16 +1099,13 @@ describe('Test video playlists', function () {
1180 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, { name: 'super_channel', displayName: 'super channel' }) 1099 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, { name: 'super_channel', displayName: 'super channel' })
1181 const videoChannelId = res.body.videoChannel.id 1100 const videoChannelId = res.body.videoChannel.id
1182 1101
1183 const res2 = await createVideoPlaylist({ 1102 const playlistCreated = await commands[0].create({
1184 url: servers[0].url, 1103 attributes: {
1185 token: servers[0].accessToken,
1186 playlistAttrs: {
1187 displayName: 'channel playlist', 1104 displayName: 'channel playlist',
1188 privacy: VideoPlaylistPrivacy.PUBLIC, 1105 privacy: VideoPlaylistPrivacy.PUBLIC,
1189 videoChannelId 1106 videoChannelId
1190 } 1107 }
1191 }) 1108 })
1192 const videoPlaylistUUID = res2.body.videoPlaylist.uuid
1193 1109
1194 await waitJobs(servers) 1110 await waitJobs(servers)
1195 1111
@@ -1197,11 +1113,11 @@ describe('Test video playlists', function () {
1197 1113
1198 await waitJobs(servers) 1114 await waitJobs(servers)
1199 1115
1200 const res3 = await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistUUID) 1116 const body = await commands[0].get({ token: servers[0].accessToken, playlistId: playlistCreated.uuid })
1201 expect(res3.body.displayName).to.equal('channel playlist') 1117 expect(body.displayName).to.equal('channel playlist')
1202 expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) 1118 expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
1203 1119
1204 await getVideoPlaylist(servers[1].url, videoPlaylistUUID, HttpStatusCode.NOT_FOUND_404) 1120 await servers[1].playlistsCommand.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1205 }) 1121 })
1206 1122
1207 it('Should delete an account and delete its playlists', async function () { 1123 it('Should delete an account and delete its playlists', async function () {
@@ -1221,10 +1137,8 @@ describe('Test video playlists', function () {
1221 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken) 1137 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
1222 const userChannel = (resChannel.body as User).videoChannels[0] 1138 const userChannel = (resChannel.body as User).videoChannels[0]
1223 1139
1224 await createVideoPlaylist({ 1140 await commands[0].create({
1225 url: servers[0].url, 1141 attributes: {
1226 token: userAccessToken,
1227 playlistAttrs: {
1228 displayName: 'playlist to be deleted', 1142 displayName: 'playlist to be deleted',
1229 privacy: VideoPlaylistPrivacy.PUBLIC, 1143 privacy: VideoPlaylistPrivacy.PUBLIC,
1230 videoChannelId: userChannel.id 1144 videoChannelId: userChannel.id
@@ -1233,12 +1147,13 @@ describe('Test video playlists', function () {
1233 1147
1234 await waitJobs(servers) 1148 await waitJobs(servers)
1235 1149
1236 const finder = data => data.find(p => p.displayName === 'playlist to be deleted') 1150 const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'playlist to be deleted')
1237 1151
1238 { 1152 {
1239 for (const server of [ servers[0], servers[1] ]) { 1153 for (const server of [ servers[0], servers[1] ]) {
1240 const res = await getVideoPlaylistsList(server.url, 0, 15) 1154 const body = await server.playlistsCommand.list({ start: 0, count: 15 })
1241 expect(finder(res.body.data)).to.not.be.undefined 1155
1156 expect(finder(body.data)).to.not.be.undefined
1242 } 1157 }
1243 } 1158 }
1244 1159
@@ -1247,8 +1162,9 @@ describe('Test video playlists', function () {
1247 1162
1248 { 1163 {
1249 for (const server of [ servers[0], servers[1] ]) { 1164 for (const server of [ servers[0], servers[1] ]) {
1250 const res = await getVideoPlaylistsList(server.url, 0, 15) 1165 const body = await server.playlistsCommand.list({ start: 0, count: 15 })
1251 expect(finder(res.body.data)).to.be.undefined 1166
1167 expect(finder(body.data)).to.be.undefined
1252 } 1168 }
1253 } 1169 }
1254 }) 1170 })