aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/videos-overview.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/videos-overview.ts')
-rw-r--r--server/tests/api/videos/videos-overview.ts85
1 files changed, 57 insertions, 28 deletions
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index ca08ab5b1..d38bcb6eb 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils' 5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '../../../../shared/extra-utils'
6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
7import { VideosOverview } from '../../../../shared/models/overviews' 7import { VideosOverview } from '../../../../shared/models/overviews'
8 8
@@ -20,7 +20,7 @@ describe('Test a videos overview', function () {
20 }) 20 })
21 21
22 it('Should send empty overview', async function () { 22 it('Should send empty overview', async function () {
23 const res = await getVideosOverview(server.url) 23 const res = await getVideosOverview(server.url, 1)
24 24
25 const overview: VideosOverview = res.body 25 const overview: VideosOverview = res.body
26 expect(overview.tags).to.have.lengthOf(0) 26 expect(overview.tags).to.have.lengthOf(0)
@@ -31,15 +31,15 @@ describe('Test a videos overview', function () {
31 it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', async function () { 31 it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', async function () {
32 this.timeout(15000) 32 this.timeout(15000)
33 33
34 for (let i = 0; i < 5; i++) { 34 await wait(3000)
35 await uploadVideo(server.url, server.accessToken, { 35
36 name: 'video ' + i, 36 await uploadVideo(server.url, server.accessToken, {
37 category: 3, 37 name: 'video 0',
38 tags: [ 'coucou1', 'coucou2' ] 38 category: 3,
39 }) 39 tags: [ 'coucou1', 'coucou2' ]
40 } 40 })
41 41
42 const res = await getVideosOverview(server.url) 42 const res = await getVideosOverview(server.url, 1)
43 43
44 const overview: VideosOverview = res.body 44 const overview: VideosOverview = res.body
45 expect(overview.tags).to.have.lengthOf(0) 45 expect(overview.tags).to.have.lengthOf(0)
@@ -48,27 +48,55 @@ describe('Test a videos overview', function () {
48 }) 48 })
49 49
50 it('Should upload another video and include all videos in the overview', async function () { 50 it('Should upload another video and include all videos in the overview', async function () {
51 await uploadVideo(server.url, server.accessToken, { 51 this.timeout(15000)
52 name: 'video 5',
53 category: 3,
54 tags: [ 'coucou1', 'coucou2' ]
55 })
56 52
57 const res = await getVideosOverview(server.url) 53 for (let i = 1; i < 6; i++) {
54 await uploadVideo(server.url, server.accessToken, {
55 name: 'video ' + i,
56 category: 3,
57 tags: [ 'coucou1', 'coucou2' ]
58 })
59 }
58 60
59 const overview: VideosOverview = res.body 61 await wait(3000)
60 expect(overview.tags).to.have.lengthOf(2) 62
61 expect(overview.categories).to.have.lengthOf(1) 63 {
62 expect(overview.channels).to.have.lengthOf(1) 64 const res = await getVideosOverview(server.url, 1)
65
66 const overview: VideosOverview = res.body
67 expect(overview.tags).to.have.lengthOf(1)
68 expect(overview.categories).to.have.lengthOf(1)
69 expect(overview.channels).to.have.lengthOf(1)
70 }
71
72 {
73 const res = await getVideosOverview(server.url, 2)
74
75 const overview: VideosOverview = res.body
76 expect(overview.tags).to.have.lengthOf(1)
77 expect(overview.categories).to.have.lengthOf(0)
78 expect(overview.channels).to.have.lengthOf(0)
79 }
63 }) 80 })
64 81
65 it('Should have the correct overview', async function () { 82 it('Should have the correct overview', async function () {
66 const res = await getVideosOverview(server.url) 83 const res1 = await getVideosOverview(server.url, 1)
84 const res2 = await getVideosOverview(server.url, 2)
67 85
68 const overview: VideosOverview = res.body 86 const overview1: VideosOverview = res1.body
87 const overview2: VideosOverview = res2.body
88
89 const tmp = [
90 overview1.tags,
91 overview1.categories,
92 overview1.channels,
93 overview2.tags
94 ]
95
96 for (const arr of tmp) {
97 expect(arr).to.have.lengthOf(1)
69 98
70 for (const attr of [ 'tags', 'categories', 'channels' ]) { 99 const obj = arr[0]
71 const obj = overview[attr][0]
72 100
73 expect(obj.videos).to.have.lengthOf(6) 101 expect(obj.videos).to.have.lengthOf(6)
74 expect(obj.videos[0].name).to.equal('video 5') 102 expect(obj.videos[0].name).to.equal('video 5')
@@ -79,12 +107,13 @@ describe('Test a videos overview', function () {
79 expect(obj.videos[5].name).to.equal('video 0') 107 expect(obj.videos[5].name).to.equal('video 0')
80 } 108 }
81 109
82 expect(overview.tags.find(t => t.tag === 'coucou1')).to.not.be.undefined 110 const tags = [ overview1.tags[0].tag, overview2.tags[0].tag ]
83 expect(overview.tags.find(t => t.tag === 'coucou2')).to.not.be.undefined 111 expect(tags.find(t => t === 'coucou1')).to.not.be.undefined
112 expect(tags.find(t => t === 'coucou2')).to.not.be.undefined
84 113
85 expect(overview.categories[0].category.id).to.equal(3) 114 expect(overview1.categories[0].category.id).to.equal(3)
86 115
87 expect(overview.channels[0].channel.name).to.equal('root_channel') 116 expect(overview1.channels[0].channel.name).to.equal('root_channel')
88 }) 117 })
89 118
90 after(async function () { 119 after(async function () {