aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/single-server.ts49
1 files changed, 42 insertions, 7 deletions
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 596fff996..0ae405950 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -34,6 +34,7 @@ const expect = chai.expect
34describe('Test a single server', function () { 34describe('Test a single server', function () {
35 let server: ServerInfo = null 35 let server: ServerInfo = null
36 let videoId = -1 36 let videoId = -1
37 let videoId2 = -1
37 let videoUUID = '' 38 let videoUUID = ''
38 let videosListBase: any[] = null 39 let videosListBase: any[] = null
39 40
@@ -237,12 +238,11 @@ describe('Test a single server', function () {
237 it('Should upload 6 videos', async function () { 238 it('Should upload 6 videos', async function () {
238 this.timeout(25000) 239 this.timeout(25000)
239 240
240 const videos = [ 241 const videos = new Set([
241 'video_short.mp4', 'video_short.ogv', 'video_short.webm', 242 'video_short.mp4', 'video_short.ogv', 'video_short.webm',
242 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' 243 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
243 ] 244 ])
244 245
245 const tasks: Promise<any>[] = []
246 for (const video of videos) { 246 for (const video of videos) {
247 const videoAttributes = { 247 const videoAttributes = {
248 name: video + ' name', 248 name: video + ' name',
@@ -255,11 +255,8 @@ describe('Test a single server', function () {
255 fixture: video 255 fixture: video
256 } 256 }
257 257
258 const p = uploadVideo(server.url, server.accessToken, videoAttributes) 258 await uploadVideo(server.url, server.accessToken, videoAttributes)
259 tasks.push(p)
260 } 259 }
261
262 await Promise.all(tasks)
263 }) 260 })
264 261
265 it('Should have the correct durations', async function () { 262 it('Should have the correct durations', async function () {
@@ -345,6 +342,7 @@ describe('Test a single server', function () {
345 expect(videos[5].name).to.equal('video_short1.webm name') 342 expect(videos[5].name).to.equal('video_short1.webm name')
346 343
347 videoId = videos[3].uuid 344 videoId = videos[3].uuid
345 videoId2 = videos[5].uuid
348 }) 346 })
349 347
350 it('Should list and sort by trending in descending order', async function () { 348 it('Should list and sort by trending in descending order', async function () {
@@ -433,6 +431,43 @@ describe('Test a single server', function () {
433 expect(video.dislikes).to.equal(1) 431 expect(video.dislikes).to.equal(1)
434 }) 432 })
435 433
434 it('Should sort by originallyPublishedAt', async function () {
435 {
436
437 {
438 const now = new Date()
439 const attributes = { originallyPublishedAt: now.toISOString() }
440 await updateVideo(server.url, server.accessToken, videoId, attributes)
441
442 const res = await getVideosListSort(server.url, '-originallyPublishedAt')
443 const names = res.body.data.map(v => v.name)
444
445 expect(names[0]).to.equal('my super video updated')
446 expect(names[1]).to.equal('video_short2.webm name')
447 expect(names[2]).to.equal('video_short1.webm name')
448 expect(names[3]).to.equal('video_short.webm name')
449 expect(names[4]).to.equal('video_short.ogv name')
450 expect(names[5]).to.equal('video_short.mp4 name')
451 }
452
453 {
454 const now = new Date()
455 const attributes = { originallyPublishedAt: now.toISOString() }
456 await updateVideo(server.url, server.accessToken, videoId2, attributes)
457
458 const res = await getVideosListSort(server.url, '-originallyPublishedAt')
459 const names = res.body.data.map(v => v.name)
460
461 expect(names[0]).to.equal('video_short1.webm name')
462 expect(names[1]).to.equal('my super video updated')
463 expect(names[2]).to.equal('video_short2.webm name')
464 expect(names[3]).to.equal('video_short.webm name')
465 expect(names[4]).to.equal('video_short.ogv name')
466 expect(names[5]).to.equal('video_short.mp4 name')
467 }
468 }
469 })
470
436 after(async function () { 471 after(async function () {
437 await cleanupTests([ server ]) 472 await cleanupTests([ server ])
438 }) 473 })