diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-20 14:35:18 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-24 14:04:05 +0200 |
commit | d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9 (patch) | |
tree | 4305044c4a97bdf1275b241c63cb0e85151cfb6a /server/tests/api/videos | |
parent | 57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6 (diff) | |
download | PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.gz PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.zst PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.zip |
Add videos list filters
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/single-server.ts | 153 | ||||
-rw-r--r-- | server/tests/api/videos/video-nsfw.ts | 30 |
2 files changed, 36 insertions, 147 deletions
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index d8af94e8f..ba4920d1b 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -16,13 +16,11 @@ import { | |||
16 | getVideosList, | 16 | getVideosList, |
17 | getVideosListPagination, | 17 | getVideosListPagination, |
18 | getVideosListSort, | 18 | getVideosListSort, |
19 | getVideosWithFilters, | ||
19 | killallServers, | 20 | killallServers, |
20 | rateVideo, | 21 | rateVideo, |
21 | removeVideo, | 22 | removeVideo, |
22 | runServer, | 23 | runServer, |
23 | searchVideo, | ||
24 | searchVideoWithPagination, | ||
25 | searchVideoWithSort, | ||
26 | ServerInfo, | 24 | ServerInfo, |
27 | setAccessTokensToServers, | 25 | setAccessTokensToServers, |
28 | testImage, | 26 | testImage, |
@@ -218,72 +216,6 @@ describe('Test a single server', function () { | |||
218 | expect(video.views).to.equal(3) | 216 | expect(video.views).to.equal(3) |
219 | }) | 217 | }) |
220 | 218 | ||
221 | it('Should search the video by name', async function () { | ||
222 | const res = await searchVideo(server.url, 'my') | ||
223 | |||
224 | expect(res.body.total).to.equal(1) | ||
225 | expect(res.body.data).to.be.an('array') | ||
226 | expect(res.body.data.length).to.equal(1) | ||
227 | |||
228 | const video = res.body.data[0] | ||
229 | await completeVideoCheck(server.url, video, getCheckAttributes) | ||
230 | }) | ||
231 | |||
232 | // Not implemented yet | ||
233 | // it('Should search the video by tag', async function () { | ||
234 | // const res = await searchVideo(server.url, 'tag1') | ||
235 | // | ||
236 | // expect(res.body.total).to.equal(1) | ||
237 | // expect(res.body.data).to.be.an('array') | ||
238 | // expect(res.body.data.length).to.equal(1) | ||
239 | // | ||
240 | // const video = res.body.data[0] | ||
241 | // expect(video.name).to.equal('my super name') | ||
242 | // expect(video.category).to.equal(2) | ||
243 | // expect(video.categoryLabel).to.equal('Films') | ||
244 | // expect(video.licence).to.equal(6) | ||
245 | // expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | ||
246 | // expect(video.language).to.equal('zh') | ||
247 | // expect(video.languageLabel).to.equal('Chinese') | ||
248 | // expect(video.nsfw).to.be.ok | ||
249 | // expect(video.description).to.equal('my super description') | ||
250 | // expect(video.account.name).to.equal('root') | ||
251 | // expect(video.account.host).to.equal('localhost:9001') | ||
252 | // expect(video.isLocal).to.be.true | ||
253 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | ||
254 | // expect(dateIsValid(video.createdAt)).to.be.true | ||
255 | // expect(dateIsValid(video.updatedAt)).to.be.true | ||
256 | // | ||
257 | // const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | ||
258 | // expect(test).to.equal(true) | ||
259 | // }) | ||
260 | |||
261 | it('Should not find a search by name', async function () { | ||
262 | const res = await searchVideo(server.url, 'hello') | ||
263 | |||
264 | expect(res.body.total).to.equal(0) | ||
265 | expect(res.body.data).to.be.an('array') | ||
266 | expect(res.body.data.length).to.equal(0) | ||
267 | }) | ||
268 | |||
269 | // Not implemented yet | ||
270 | // it('Should not find a search by author', async function () { | ||
271 | // const res = await searchVideo(server.url, 'hello') | ||
272 | // | ||
273 | // expect(res.body.total).to.equal(0) | ||
274 | // expect(res.body.data).to.be.an('array') | ||
275 | // expect(res.body.data.length).to.equal(0) | ||
276 | // }) | ||
277 | // | ||
278 | // Not implemented yet | ||
279 | // it('Should not find a search by tag', async function () { | ||
280 | // const res = await searchVideo(server.url, 'hello') | ||
281 | // | ||
282 | // expect(res.body.total).to.equal(0) | ||
283 | // expect(res.body.data).to.be.an('array') | ||
284 | // expect(res.body.data.length).to.equal(0) | ||
285 | // }) | ||
286 | |||
287 | it('Should remove the video', async function () { | 219 | it('Should remove the video', async function () { |
288 | await removeVideo(server.url, server.accessToken, videoId) | 220 | await removeVideo(server.url, server.accessToken, videoId) |
289 | 221 | ||
@@ -386,65 +318,6 @@ describe('Test a single server', function () { | |||
386 | expect(videos[0].name).to.equal(videosListBase[5].name) | 318 | expect(videos[0].name).to.equal(videosListBase[5].name) |
387 | }) | 319 | }) |
388 | 320 | ||
389 | it('Should search the first video', async function () { | ||
390 | const res = await searchVideoWithPagination(server.url, 'webm', 0, 1, 'name') | ||
391 | |||
392 | const videos = res.body.data | ||
393 | expect(res.body.total).to.equal(4) | ||
394 | expect(videos.length).to.equal(1) | ||
395 | expect(videos[0].name).to.equal('video_short1.webm name') | ||
396 | }) | ||
397 | |||
398 | it('Should search the last two videos', async function () { | ||
399 | const res = await searchVideoWithPagination(server.url, 'webm', 2, 2, 'name') | ||
400 | |||
401 | const videos = res.body.data | ||
402 | expect(res.body.total).to.equal(4) | ||
403 | expect(videos.length).to.equal(2) | ||
404 | expect(videos[0].name).to.equal('video_short3.webm name') | ||
405 | expect(videos[1].name).to.equal('video_short.webm name') | ||
406 | }) | ||
407 | |||
408 | it('Should search all the webm videos', async function () { | ||
409 | const res = await searchVideoWithPagination(server.url, 'webm', 0, 15) | ||
410 | |||
411 | const videos = res.body.data | ||
412 | expect(res.body.total).to.equal(4) | ||
413 | expect(videos.length).to.equal(4) | ||
414 | }) | ||
415 | |||
416 | // Not implemented yet | ||
417 | // it('Should search all the root author videos', async function () { | ||
418 | // const res = await searchVideoWithPagination(server.url, 'root', 0, 15) | ||
419 | // | ||
420 | // const videos = res.body.data | ||
421 | // expect(res.body.total).to.equal(6) | ||
422 | // expect(videos.length).to.equal(6) | ||
423 | // }) | ||
424 | |||
425 | // Not implemented yet | ||
426 | // it('Should search all the 9001 port videos', async function () { | ||
427 | // const res = await videosUtils.searchVideoWithPagination(server.url, '9001', 'host', 0, 15) | ||
428 | |||
429 | // const videos = res.body.data | ||
430 | // expect(res.body.total).to.equal(6) | ||
431 | // expect(videos.length).to.equal(6) | ||
432 | |||
433 | // done() | ||
434 | // }) | ||
435 | // }) | ||
436 | |||
437 | // it('Should search all the localhost videos', async function () { | ||
438 | // const res = await videosUtils.searchVideoWithPagination(server.url, 'localhost', 'host', 0, 15) | ||
439 | |||
440 | // const videos = res.body.data | ||
441 | // expect(res.body.total).to.equal(6) | ||
442 | // expect(videos.length).to.equal(6) | ||
443 | |||
444 | // done() | ||
445 | // }) | ||
446 | // }) | ||
447 | |||
448 | it('Should list and sort by name in descending order', async function () { | 321 | it('Should list and sort by name in descending order', async function () { |
449 | const res = await getVideosListSort(server.url, '-name') | 322 | const res = await getVideosListSort(server.url, '-name') |
450 | 323 | ||
@@ -457,21 +330,8 @@ describe('Test a single server', function () { | |||
457 | expect(videos[3].name).to.equal('video_short3.webm name') | 330 | expect(videos[3].name).to.equal('video_short3.webm name') |
458 | expect(videos[4].name).to.equal('video_short2.webm name') | 331 | expect(videos[4].name).to.equal('video_short2.webm name') |
459 | expect(videos[5].name).to.equal('video_short1.webm name') | 332 | expect(videos[5].name).to.equal('video_short1.webm name') |
460 | }) | ||
461 | |||
462 | it('Should search and sort by name in ascending order', async function () { | ||
463 | const res = await searchVideoWithSort(server.url, 'webm', 'name') | ||
464 | 333 | ||
465 | const videos = res.body.data | 334 | videoId = videos[3].uuid |
466 | expect(res.body.total).to.equal(4) | ||
467 | expect(videos.length).to.equal(4) | ||
468 | |||
469 | expect(videos[0].name).to.equal('video_short1.webm name') | ||
470 | expect(videos[1].name).to.equal('video_short2.webm name') | ||
471 | expect(videos[2].name).to.equal('video_short3.webm name') | ||
472 | expect(videos[3].name).to.equal('video_short.webm name') | ||
473 | |||
474 | videoId = videos[2].id | ||
475 | }) | 335 | }) |
476 | 336 | ||
477 | it('Should update a video', async function () { | 337 | it('Should update a video', async function () { |
@@ -488,6 +348,15 @@ describe('Test a single server', function () { | |||
488 | await updateVideo(server.url, server.accessToken, videoId, attributes) | 348 | await updateVideo(server.url, server.accessToken, videoId, attributes) |
489 | }) | 349 | }) |
490 | 350 | ||
351 | it('Should filter by tags and category', async function () { | ||
352 | const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: 4 }) | ||
353 | expect(res1.body.total).to.equal(1) | ||
354 | expect(res1.body.data[0].name).to.equal('my super video updated') | ||
355 | |||
356 | const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: 3 }) | ||
357 | expect(res2.body.total).to.equal(0) | ||
358 | }) | ||
359 | |||
491 | it('Should have the video updated', async function () { | 360 | it('Should have the video updated', async function () { |
492 | this.timeout(60000) | 361 | this.timeout(60000) |
493 | 362 | ||
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index 6af0ca8af..38bdaa54e 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts | |||
@@ -30,7 +30,7 @@ describe('Test video NSFW policy', function () { | |||
30 | let userAccessToken: string | 30 | let userAccessToken: string |
31 | let customConfig: CustomConfig | 31 | let customConfig: CustomConfig |
32 | 32 | ||
33 | function getVideosFunctions (token?: string) { | 33 | function getVideosFunctions (token?: string, query = {}) { |
34 | return getMyUserInformation(server.url, server.accessToken) | 34 | return getMyUserInformation(server.url, server.accessToken) |
35 | .then(res => { | 35 | .then(res => { |
36 | const user: User = res.body | 36 | const user: User = res.body |
@@ -39,10 +39,10 @@ describe('Test video NSFW policy', function () { | |||
39 | 39 | ||
40 | if (token) { | 40 | if (token) { |
41 | return Promise.all([ | 41 | return Promise.all([ |
42 | getVideosListWithToken(server.url, token), | 42 | getVideosListWithToken(server.url, token, query), |
43 | searchVideoWithToken(server.url, 'n', token), | 43 | searchVideoWithToken(server.url, 'n', token, query), |
44 | getAccountVideos(server.url, token, accountName, 0, 5), | 44 | getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), |
45 | getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5) | 45 | getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5, undefined, query) |
46 | ]) | 46 | ]) |
47 | } | 47 | } |
48 | 48 | ||
@@ -200,6 +200,26 @@ describe('Test video NSFW policy', function () { | |||
200 | expect(videos[ 0 ].name).to.equal('normal') | 200 | expect(videos[ 0 ].name).to.equal('normal') |
201 | expect(videos[ 1 ].name).to.equal('nsfw') | 201 | expect(videos[ 1 ].name).to.equal('nsfw') |
202 | }) | 202 | }) |
203 | |||
204 | it('Should display NSFW videos when the nsfw param === true', async function () { | ||
205 | for (const res of await getVideosFunctions(server.accessToken, { nsfw: true })) { | ||
206 | expect(res.body.total).to.equal(1) | ||
207 | |||
208 | const videos = res.body.data | ||
209 | expect(videos).to.have.lengthOf(1) | ||
210 | expect(videos[ 0 ].name).to.equal('nsfw') | ||
211 | } | ||
212 | }) | ||
213 | |||
214 | it('Should hide NSFW videos when the nsfw param === true', async function () { | ||
215 | for (const res of await getVideosFunctions(server.accessToken, { nsfw: false })) { | ||
216 | expect(res.body.total).to.equal(1) | ||
217 | |||
218 | const videos = res.body.data | ||
219 | expect(videos).to.have.lengthOf(1) | ||
220 | expect(videos[ 0 ].name).to.equal('normal') | ||
221 | } | ||
222 | }) | ||
203 | }) | 223 | }) |
204 | 224 | ||
205 | after(async function () { | 225 | after(async function () { |