aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/video-playlist.ts2
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts2
-rw-r--r--server/tests/api/videos/video-playlists.ts60
3 files changed, 57 insertions, 7 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index bcb60e265..08b0f971d 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -139,7 +139,7 @@ async function listVideoPlaylists (req: express.Request, res: express.Response)
139 start: req.query.start, 139 start: req.query.start,
140 count: req.query.count, 140 count: req.query.count,
141 sort: req.query.sort, 141 sort: req.query.sort,
142 type: req.query.type 142 type: req.query.playlistType
143 }) 143 })
144 144
145 return res.json(getFormattedObjects(resultList.data, resultList.total)) 145 return res.json(getFormattedObjects(resultList.data, resultList.total))
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index e4b7e5c56..c631a16f8 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -142,7 +142,7 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {
142 142
143 const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary 143 const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary
144 144
145 // Video is unlisted, check we used the uuid to fetch it 145 // Playlist is unlisted, check we used the uuid to fetch it
146 if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) { 146 if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) {
147 if (isUUIDValid(req.params.playlistId)) return next() 147 if (isUUIDValid(req.params.playlistId)) return next()
148 148
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index e8e653382..d9c5bdf16 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -114,7 +114,7 @@ describe('Test video playlists', function () {
114 await waitJobs(servers) 114 await waitJobs(servers)
115 }) 115 })
116 116
117 describe('Get default playlists', function () { 117 describe('Check playlists filters and privacies', function () {
118 118
119 it('Should list video playlist privacies', async function () { 119 it('Should list video playlist privacies', async function () {
120 const privacies = await commands[0].getPrivacies() 120 const privacies = await commands[0].getPrivacies()
@@ -123,9 +123,21 @@ describe('Test video playlists', function () {
123 expect(privacies[3]).to.equal('Private') 123 expect(privacies[3]).to.equal('Private')
124 }) 124 })
125 125
126 it('Should list watch later playlist', async function () { 126 it('Should filter on playlist type', async function () {
127 this.timeout(30000)
128
127 const token = servers[0].accessToken 129 const token = servers[0].accessToken
128 130
131 await commands[0].create({
132 attributes: {
133 displayName: 'my super playlist',
134 privacy: VideoPlaylistPrivacy.PUBLIC,
135 description: 'my super description',
136 thumbnailfile: 'thumbnail.jpg',
137 videoChannelId: servers[0].store.channel.id
138 }
139 })
140
129 { 141 {
130 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER }) 142 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER })
131 143
@@ -136,13 +148,51 @@ describe('Test video playlists', function () {
136 expect(playlist.displayName).to.equal('Watch later') 148 expect(playlist.displayName).to.equal('Watch later')
137 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER) 149 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
138 expect(playlist.type.label).to.equal('Watch later') 150 expect(playlist.type.label).to.equal('Watch later')
151 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
139 } 152 }
140 153
141 { 154 {
142 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.REGULAR }) 155 const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.WATCH_LATER })
156 const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.WATCH_LATER })
143 157
144 expect(body.total).to.equal(0) 158 for (const body of [ bodyList, bodyChannel ]) {
145 expect(body.data).to.have.lengthOf(0) 159 expect(body.total).to.equal(0)
160 expect(body.data).to.have.lengthOf(0)
161 }
162 }
163
164 {
165 const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.REGULAR })
166 const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.REGULAR })
167
168 let playlist: VideoPlaylist = null
169 for (const body of [ bodyList, bodyChannel ]) {
170
171 expect(body.total).to.equal(1)
172 expect(body.data).to.have.lengthOf(1)
173
174 playlist = body.data[0]
175 expect(playlist.displayName).to.equal('my super playlist')
176 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
177 expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
178 }
179
180 await commands[0].update({
181 playlistId: playlist.id,
182 attributes: {
183 privacy: VideoPlaylistPrivacy.PRIVATE
184 }
185 })
186 }
187
188 {
189 const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.REGULAR })
190 const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.REGULAR })
191
192 for (const body of [ bodyList, bodyChannel ]) {
193 expect(body.total).to.equal(0)
194 expect(body.data).to.have.lengthOf(0)
195 }
146 } 196 }
147 197
148 { 198 {