aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/single-server.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-20 14:35:18 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 14:04:05 +0200
commitd525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9 (patch)
tree4305044c4a97bdf1275b241c63cb0e85151cfb6a /server/tests/api/videos/single-server.ts
parent57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6 (diff)
downloadPeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.gz
PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.tar.zst
PeerTube-d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9.zip
Add videos list filters
Diffstat (limited to 'server/tests/api/videos/single-server.ts')
-rw-r--r--server/tests/api/videos/single-server.ts153
1 files changed, 11 insertions, 142 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