aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/videos.ts30
-rw-r--r--server/tests/api/follows.ts2
-rw-r--r--server/tests/api/multiple-servers.ts57
-rw-r--r--server/tests/api/services.ts4
-rw-r--r--server/tests/api/single-server.ts185
-rw-r--r--server/tests/api/users.ts8
6 files changed, 157 insertions, 129 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 2962f5640..0aaa6e7c9 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -189,14 +189,6 @@ describe('Test videos API validator', function () {
189 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 189 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
190 }) 190 })
191 191
192 it('Should fail without a category', async function () {
193 const fields = getCompleteVideoUploadAttributes()
194 delete fields.category
195
196 const attaches = getVideoUploadAttaches
197 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
198 })
199
200 it('Should fail with a bad category', async function () { 192 it('Should fail with a bad category', async function () {
201 const fields = getCompleteVideoUploadAttributes() 193 const fields = getCompleteVideoUploadAttributes()
202 fields.category = 125 194 fields.category = 125
@@ -205,14 +197,6 @@ describe('Test videos API validator', function () {
205 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 197 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
206 }) 198 })
207 199
208 it('Should fail without a licence', async function () {
209 const fields = getCompleteVideoUploadAttributes()
210 delete fields.licence
211
212 const attaches = getVideoUploadAttaches()
213 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
214 })
215
216 it('Should fail with a bad licence', async function () { 200 it('Should fail with a bad licence', async function () {
217 const fields = getCompleteVideoUploadAttributes() 201 const fields = getCompleteVideoUploadAttributes()
218 fields.licence = 125 202 fields.licence = 125
@@ -245,14 +229,6 @@ describe('Test videos API validator', function () {
245 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 229 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
246 }) 230 })
247 231
248 it('Should fail without description', async function () {
249 const fields = getCompleteVideoUploadAttributes()
250 delete fields.description
251
252 const attaches = getVideoUploadAttaches()
253 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
254 })
255
256 it('Should fail with a long description', async function () { 232 it('Should fail with a long description', async function () {
257 const fields = getCompleteVideoUploadAttributes() 233 const fields = getCompleteVideoUploadAttributes()
258 fields.description = 'my super description which is very very very very very very very very very very very very long'.repeat(35) 234 fields.description = 'my super description which is very very very very very very very very very very very very long'.repeat(35)
@@ -345,7 +321,7 @@ describe('Test videos API validator', function () {
345 token: server.accessToken, 321 token: server.accessToken,
346 fields, 322 fields,
347 attaches, 323 attaches,
348 statusCodeExpected: 204 324 statusCodeExpected: 200
349 }) 325 })
350 326
351 attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4') 327 attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4')
@@ -355,7 +331,7 @@ describe('Test videos API validator', function () {
355 token: server.accessToken, 331 token: server.accessToken,
356 fields, 332 fields,
357 attaches, 333 attaches,
358 statusCodeExpected: 204 334 statusCodeExpected: 200
359 }) 335 })
360 336
361 attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv') 337 attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv')
@@ -365,7 +341,7 @@ describe('Test videos API validator', function () {
365 token: server.accessToken, 341 token: server.accessToken,
366 fields, 342 fields,
367 attaches, 343 attaches,
368 statusCodeExpected: 204 344 statusCodeExpected: 200
369 }) 345 })
370 }) 346 })
371 }) 347 })
diff --git a/server/tests/api/follows.ts b/server/tests/api/follows.ts
index aadae3cce..dcb4c8bd9 100644
--- a/server/tests/api/follows.ts
+++ b/server/tests/api/follows.ts
@@ -227,7 +227,7 @@ describe('Test follows', function () {
227 expect(videoDetails.nsfw).to.be.ok 227 expect(videoDetails.nsfw).to.be.ok
228 expect(videoDetails.description).to.equal('my super description') 228 expect(videoDetails.description).to.equal('my super description')
229 expect(videoDetails.serverHost).to.equal('localhost:9003') 229 expect(videoDetails.serverHost).to.equal('localhost:9003')
230 expect(videoDetails.account).to.equal('root') 230 expect(videoDetails.accountName).to.equal('root')
231 expect(videoDetails.likes).to.equal(1) 231 expect(videoDetails.likes).to.equal(1)
232 expect(videoDetails.dislikes).to.equal(1) 232 expect(videoDetails.dislikes).to.equal(1)
233 expect(videoDetails.isLocal).to.be.false 233 expect(videoDetails.isLocal).to.be.false
diff --git a/server/tests/api/multiple-servers.ts b/server/tests/api/multiple-servers.ts
index c80ded862..2f17f017a 100644
--- a/server/tests/api/multiple-servers.ts
+++ b/server/tests/api/multiple-servers.ts
@@ -2,6 +2,8 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path'
6import * as request from 'supertest'
5 7
6import { 8import {
7 dateIsValid, 9 dateIsValid,
@@ -111,13 +113,14 @@ describe('Test multiple servers', function () {
111 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) 113 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
112 expect(dateIsValid(video.createdAt)).to.be.true 114 expect(dateIsValid(video.createdAt)).to.be.true
113 expect(dateIsValid(video.updatedAt)).to.be.true 115 expect(dateIsValid(video.updatedAt)).to.be.true
114 expect(video.account).to.equal('root') 116 expect(video.accountName).to.equal('root')
115 117
116 const res2 = await getVideo(server.url, video.uuid) 118 const res2 = await getVideo(server.url, video.uuid)
117 const videoDetails = res2.body 119 const videoDetails = res2.body
118 120
119 expect(videoDetails.channel.name).to.equal('my channel') 121 expect(videoDetails.channel.name).to.equal('my channel')
120 expect(videoDetails.channel.description).to.equal('super channel') 122 expect(videoDetails.channel.description).to.equal('super channel')
123 expect(videoDetails.account.name).to.equal('root')
121 expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true 124 expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true
122 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true 125 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
123 expect(videoDetails.files).to.have.lengthOf(1) 126 expect(videoDetails.files).to.have.lengthOf(1)
@@ -201,7 +204,7 @@ describe('Test multiple servers', function () {
201 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) 204 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
202 expect(dateIsValid(video.createdAt)).to.be.true 205 expect(dateIsValid(video.createdAt)).to.be.true
203 expect(dateIsValid(video.updatedAt)).to.be.true 206 expect(dateIsValid(video.updatedAt)).to.be.true
204 expect(video.account).to.equal('user1') 207 expect(video.accountName).to.equal('user1')
205 208
206 if (server.url !== 'http://localhost:9002') { 209 if (server.url !== 'http://localhost:9002') {
207 expect(video.isLocal).to.be.false 210 expect(video.isLocal).to.be.false
@@ -316,7 +319,7 @@ describe('Test multiple servers', function () {
316 expect(video1.serverHost).to.equal('localhost:9003') 319 expect(video1.serverHost).to.equal('localhost:9003')
317 expect(video1.duration).to.equal(5) 320 expect(video1.duration).to.equal(5)
318 expect(video1.tags).to.deep.equal([ 'tag1p3' ]) 321 expect(video1.tags).to.deep.equal([ 'tag1p3' ])
319 expect(video1.account).to.equal('root') 322 expect(video1.accountName).to.equal('root')
320 expect(dateIsValid(video1.createdAt)).to.be.true 323 expect(dateIsValid(video1.createdAt)).to.be.true
321 expect(dateIsValid(video1.updatedAt)).to.be.true 324 expect(dateIsValid(video1.updatedAt)).to.be.true
322 325
@@ -342,7 +345,7 @@ describe('Test multiple servers', function () {
342 expect(video2.serverHost).to.equal('localhost:9003') 345 expect(video2.serverHost).to.equal('localhost:9003')
343 expect(video2.duration).to.equal(5) 346 expect(video2.duration).to.equal(5)
344 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) 347 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
345 expect(video2.account).to.equal('root') 348 expect(video2.accountName).to.equal('root')
346 expect(dateIsValid(video2.createdAt)).to.be.true 349 expect(dateIsValid(video2.createdAt)).to.be.true
347 expect(dateIsValid(video2.updatedAt)).to.be.true 350 expect(dateIsValid(video2.updatedAt)).to.be.true
348 351
@@ -690,7 +693,7 @@ describe('Test multiple servers', function () {
690 expect(baseVideo.licence).to.equal(video.licence) 693 expect(baseVideo.licence).to.equal(video.licence)
691 expect(baseVideo.category).to.equal(video.category) 694 expect(baseVideo.category).to.equal(video.category)
692 expect(baseVideo.nsfw).to.equal(video.nsfw) 695 expect(baseVideo.nsfw).to.equal(video.nsfw)
693 expect(baseVideo.account).to.equal(video.account) 696 expect(baseVideo.accountName).to.equal(video.accountName)
694 expect(baseVideo.tags).to.deep.equal(video.tags) 697 expect(baseVideo.tags).to.deep.equal(video.tags)
695 } 698 }
696 }) 699 })
@@ -706,6 +709,50 @@ describe('Test multiple servers', function () {
706 }) 709 })
707 }) 710 })
708 711
712 describe('With minimum parameters', function () {
713 it('Should upload and propagate the video', async function () {
714 this.timeout(50000)
715
716 const path = '/api/v1/videos/upload'
717
718 const req = request(servers[1].url)
719 .post(path)
720 .set('Accept', 'application/json')
721 .set('Authorization', 'Bearer ' + servers[1].accessToken)
722 .field('name', 'minimum parameters')
723 .field('privacy', '1')
724 .field('nsfw', 'false')
725 .field('channelId', '1')
726
727 const filePath = join(__dirname, '..', 'api', 'fixtures', 'video_short.webm')
728
729 await req.attach('videofile', filePath)
730 .expect(200)
731
732 await wait(25000)
733
734 for (const server of servers) {
735 const res = await getVideosList(server.url)
736 const video = res.body.data.find(v => v.name === 'minimum parameters')
737
738 expect(video.name).to.equal('minimum parameters')
739 expect(video.category).to.equal(null)
740 expect(video.categoryLabel).to.equal('Misc')
741 expect(video.licence).to.equal(null)
742 expect(video.licenceLabel).to.equal('Unknown')
743 expect(video.language).to.equal(null)
744 expect(video.languageLabel).to.equal('Unknown')
745 expect(video.nsfw).to.not.be.ok
746 expect(video.description).to.equal(null)
747 expect(video.serverHost).to.equal('localhost:9002')
748 expect(video.accountName).to.equal('root')
749 expect(video.tags).to.deep.equal([ ])
750 expect(dateIsValid(video.createdAt)).to.be.true
751 expect(dateIsValid(video.updatedAt)).to.be.true
752 }
753 })
754 })
755
709 after(async function () { 756 after(async function () {
710 killallServers(servers) 757 killallServers(servers)
711 758
diff --git a/server/tests/api/services.ts b/server/tests/api/services.ts
index 8d96ccc5e..4d480c305 100644
--- a/server/tests/api/services.ts
+++ b/server/tests/api/services.ts
@@ -46,7 +46,7 @@ describe('Test services', function () {
46 46
47 expect(res.body.html).to.equal(expectedHtml) 47 expect(res.body.html).to.equal(expectedHtml)
48 expect(res.body.title).to.equal(server.video.name) 48 expect(res.body.title).to.equal(server.video.name)
49 expect(res.body.author_name).to.equal(server.video.account) 49 expect(res.body.author_name).to.equal(server.video.accountName)
50 expect(res.body.width).to.equal(560) 50 expect(res.body.width).to.equal(560)
51 expect(res.body.height).to.equal(315) 51 expect(res.body.height).to.equal(315)
52 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) 52 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -66,7 +66,7 @@ describe('Test services', function () {
66 66
67 expect(res.body.html).to.equal(expectedHtml) 67 expect(res.body.html).to.equal(expectedHtml)
68 expect(res.body.title).to.equal(server.video.name) 68 expect(res.body.title).to.equal(server.video.name)
69 expect(res.body.author_name).to.equal(server.video.account) 69 expect(res.body.author_name).to.equal(server.video.accountName)
70 expect(res.body.height).to.equal(50) 70 expect(res.body.height).to.equal(50)
71 expect(res.body.width).to.equal(50) 71 expect(res.body.width).to.equal(50)
72 expect(res.body).to.not.have.property('thumbnail_url') 72 expect(res.body).to.not.have.property('thumbnail_url')
diff --git a/server/tests/api/single-server.ts b/server/tests/api/single-server.ts
index 041d13225..174fb480d 100644
--- a/server/tests/api/single-server.ts
+++ b/server/tests/api/single-server.ts
@@ -1,40 +1,40 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import * as chai from 'chai'
3import { keyBy } from 'lodash' 4import { keyBy } from 'lodash'
4import { join } from 'path'
5import 'mocha' 5import 'mocha'
6import * as chai from 'chai' 6import { join } from 'path'
7const expect = chai.expect
8
9import { 7import {
10 ServerInfo,
11 flushTests,
12 runServer,
13 uploadVideo,
14 getVideosList,
15 rateVideo,
16 removeVideo,
17 wait,
18 setAccessTokensToServers,
19 searchVideo,
20 killallServers,
21 dateIsValid, 8 dateIsValid,
9 flushTests,
10 getVideo,
22 getVideoCategories, 11 getVideoCategories,
23 getVideoLicences,
24 getVideoLanguages, 12 getVideoLanguages,
13 getVideoLicences,
25 getVideoPrivacies, 14 getVideoPrivacies,
26 testVideoImage, 15 getVideosList,
27 webtorrentAdd,
28 getVideo,
29 readdirPromise,
30 getVideosListPagination, 16 getVideosListPagination,
31 searchVideoWithPagination,
32 getVideosListSort, 17 getVideosListSort,
18 killallServers,
19 rateVideo,
20 readdirPromise,
21 removeVideo,
22 runServer,
23 searchVideo,
24 searchVideoWithPagination,
33 searchVideoWithSort, 25 searchVideoWithSort,
34 updateVideo 26 ServerInfo,
27 setAccessTokensToServers,
28 testVideoImage,
29 updateVideo,
30 uploadVideo,
31 wait,
32 webtorrentAdd
35} from '../utils' 33} from '../utils'
36import { viewVideo } from '../utils/videos' 34import { viewVideo } from '../utils/videos'
37 35
36const expect = chai.expect
37
38describe('Test a single server', function () { 38describe('Test a single server', function () {
39 let server: ServerInfo = null 39 let server: ServerInfo = null
40 let videoId = -1 40 let videoId = -1
@@ -103,7 +103,10 @@ describe('Test a single server', function () {
103 licence: 6, 103 licence: 6,
104 tags: [ 'tag1', 'tag2', 'tag3' ] 104 tags: [ 'tag1', 'tag2', 'tag3' ]
105 } 105 }
106 await uploadVideo(server.url, server.accessToken, videoAttributes) 106 const res = await uploadVideo(server.url, server.accessToken, videoAttributes)
107 expect(res.body.video).to.not.be.undefined
108 expect(res.body.video.id).to.equal(1)
109 expect(res.body.video.uuid).to.have.length.above(5)
107 }) 110 })
108 111
109 it('Should seed the uploaded video', async function () { 112 it('Should seed the uploaded video', async function () {
@@ -127,7 +130,7 @@ describe('Test a single server', function () {
127 expect(video.nsfw).to.be.ok 130 expect(video.nsfw).to.be.ok
128 expect(video.description).to.equal('my super description') 131 expect(video.description).to.equal('my super description')
129 expect(video.serverHost).to.equal('localhost:9001') 132 expect(video.serverHost).to.equal('localhost:9001')
130 expect(video.account).to.equal('root') 133 expect(video.accountName).to.equal('root')
131 expect(video.isLocal).to.be.true 134 expect(video.isLocal).to.be.true
132 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 135 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
133 expect(dateIsValid(video.createdAt)).to.be.true 136 expect(dateIsValid(video.createdAt)).to.be.true
@@ -176,7 +179,7 @@ describe('Test a single server', function () {
176 expect(video.nsfw).to.be.ok 179 expect(video.nsfw).to.be.ok
177 expect(video.description).to.equal('my super description') 180 expect(video.description).to.equal('my super description')
178 expect(video.serverHost).to.equal('localhost:9001') 181 expect(video.serverHost).to.equal('localhost:9001')
179 expect(video.account).to.equal('root') 182 expect(video.accountName).to.equal('root')
180 expect(video.isLocal).to.be.true 183 expect(video.isLocal).to.be.true
181 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 184 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
182 expect(dateIsValid(video.createdAt)).to.be.true 185 expect(dateIsValid(video.createdAt)).to.be.true
@@ -225,7 +228,7 @@ describe('Test a single server', function () {
225 expect(video.views).to.equal(3) 228 expect(video.views).to.equal(3)
226 }) 229 })
227 230
228 it('Should search the video by name by default', async function () { 231 it('Should search the video by name', async function () {
229 const res = await searchVideo(server.url, 'my') 232 const res = await searchVideo(server.url, 'my')
230 233
231 expect(res.body.total).to.equal(1) 234 expect(res.body.total).to.equal(1)
@@ -243,7 +246,7 @@ describe('Test a single server', function () {
243 expect(video.nsfw).to.be.ok 246 expect(video.nsfw).to.be.ok
244 expect(video.description).to.equal('my super description') 247 expect(video.description).to.equal('my super description')
245 expect(video.serverHost).to.equal('localhost:9001') 248 expect(video.serverHost).to.equal('localhost:9001')
246 expect(video.account).to.equal('root') 249 expect(video.accountName).to.equal('root')
247 expect(video.isLocal).to.be.true 250 expect(video.isLocal).to.be.true
248 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 251 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
249 expect(dateIsValid(video.createdAt)).to.be.true 252 expect(dateIsValid(video.createdAt)).to.be.true
@@ -279,35 +282,36 @@ describe('Test a single server', function () {
279 // }) 282 // })
280 // }) 283 // })
281 284
282 it('Should search the video by tag', async function () { 285 // Not implemented yet
283 const res = await searchVideo(server.url, 'tag1', 'tags') 286 // it('Should search the video by tag', async function () {
284 287 // const res = await searchVideo(server.url, 'tag1')
285 expect(res.body.total).to.equal(1) 288 //
286 expect(res.body.data).to.be.an('array') 289 // expect(res.body.total).to.equal(1)
287 expect(res.body.data.length).to.equal(1) 290 // expect(res.body.data).to.be.an('array')
288 291 // expect(res.body.data.length).to.equal(1)
289 const video = res.body.data[0] 292 //
290 expect(video.name).to.equal('my super name') 293 // const video = res.body.data[0]
291 expect(video.category).to.equal(2) 294 // expect(video.name).to.equal('my super name')
292 expect(video.categoryLabel).to.equal('Films') 295 // expect(video.category).to.equal(2)
293 expect(video.licence).to.equal(6) 296 // expect(video.categoryLabel).to.equal('Films')
294 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') 297 // expect(video.licence).to.equal(6)
295 expect(video.language).to.equal(3) 298 // expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
296 expect(video.languageLabel).to.equal('Mandarin') 299 // expect(video.language).to.equal(3)
297 expect(video.nsfw).to.be.ok 300 // expect(video.languageLabel).to.equal('Mandarin')
298 expect(video.description).to.equal('my super description') 301 // expect(video.nsfw).to.be.ok
299 expect(video.serverHost).to.equal('localhost:9001') 302 // expect(video.description).to.equal('my super description')
300 expect(video.account).to.equal('root') 303 // expect(video.serverHost).to.equal('localhost:9001')
301 expect(video.isLocal).to.be.true 304 // expect(video.accountName).to.equal('root')
302 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 305 // expect(video.isLocal).to.be.true
303 expect(dateIsValid(video.createdAt)).to.be.true 306 // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
304 expect(dateIsValid(video.updatedAt)).to.be.true 307 // expect(dateIsValid(video.createdAt)).to.be.true
305 308 // expect(dateIsValid(video.updatedAt)).to.be.true
306 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) 309 //
307 expect(test).to.equal(true) 310 // const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
308 }) 311 // expect(test).to.equal(true)
312 // })
309 313
310 it('Should not find a search by name by default', async function () { 314 it('Should not find a search by name', async function () {
311 const res = await searchVideo(server.url, 'hello') 315 const res = await searchVideo(server.url, 'hello')
312 316
313 expect(res.body.total).to.equal(0) 317 expect(res.body.total).to.equal(0)
@@ -315,21 +319,23 @@ describe('Test a single server', function () {
315 expect(res.body.data.length).to.equal(0) 319 expect(res.body.data.length).to.equal(0)
316 }) 320 })
317 321
318 it('Should not find a search by author', async function () { 322 // Not implemented yet
319 const res = await searchVideo(server.url, 'hello', 'account') 323 // it('Should not find a search by author', async function () {
320 324 // const res = await searchVideo(server.url, 'hello')
321 expect(res.body.total).to.equal(0) 325 //
322 expect(res.body.data).to.be.an('array') 326 // expect(res.body.total).to.equal(0)
323 expect(res.body.data.length).to.equal(0) 327 // expect(res.body.data).to.be.an('array')
324 }) 328 // expect(res.body.data.length).to.equal(0)
325 329 // })
326 it('Should not find a search by tag', async function () { 330 //
327 const res = await searchVideo(server.url, 'hello', 'tags') 331 // Not implemented yet
328 332 // it('Should not find a search by tag', async function () {
329 expect(res.body.total).to.equal(0) 333 // const res = await searchVideo(server.url, 'hello')
330 expect(res.body.data).to.be.an('array') 334 //
331 expect(res.body.data.length).to.equal(0) 335 // expect(res.body.total).to.equal(0)
332 }) 336 // expect(res.body.data).to.be.an('array')
337 // expect(res.body.data.length).to.equal(0)
338 // })
333 339
334 it('Should remove the video', async function () { 340 it('Should remove the video', async function () {
335 await removeVideo(server.url, server.accessToken, videoId) 341 await removeVideo(server.url, server.accessToken, videoId)
@@ -357,7 +363,7 @@ describe('Test a single server', function () {
357 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' 363 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
358 ] 364 ]
359 365
360 // const tasks: Promise<any>[] = [] 366 const tasks: Promise<any>[] = []
361 for (const video of videos) { 367 for (const video of videos) {
362 const videoAttributes = { 368 const videoAttributes = {
363 name: video + ' name', 369 name: video + ' name',
@@ -371,13 +377,10 @@ describe('Test a single server', function () {
371 } 377 }
372 378
373 const p = uploadVideo(server.url, server.accessToken, videoAttributes) 379 const p = uploadVideo(server.url, server.accessToken, videoAttributes)
374 await p 380 tasks.push(p)
375 } 381 }
376 // FIXME: concurrent uploads does not work :( 382
377 // tasks.push(p) 383 await Promise.all(tasks)
378 // }
379 //
380 // await Promise.all(tasks)
381 }) 384 })
382 385
383 it('Should have the correct durations', async function () { 386 it('Should have the correct durations', async function () {
@@ -443,7 +446,7 @@ describe('Test a single server', function () {
443 }) 446 })
444 447
445 it('Should search the first video', async function () { 448 it('Should search the first video', async function () {
446 const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 1, 'name') 449 const res = await searchVideoWithPagination(server.url, 'webm', 0, 1, 'name')
447 450
448 const videos = res.body.data 451 const videos = res.body.data
449 expect(res.body.total).to.equal(4) 452 expect(res.body.total).to.equal(4)
@@ -452,7 +455,7 @@ describe('Test a single server', function () {
452 }) 455 })
453 456
454 it('Should search the last two videos', async function () { 457 it('Should search the last two videos', async function () {
455 const res = await searchVideoWithPagination(server.url, 'webm', 'name', 2, 2, 'name') 458 const res = await searchVideoWithPagination(server.url, 'webm', 2, 2, 'name')
456 459
457 const videos = res.body.data 460 const videos = res.body.data
458 expect(res.body.total).to.equal(4) 461 expect(res.body.total).to.equal(4)
@@ -462,20 +465,21 @@ describe('Test a single server', function () {
462 }) 465 })
463 466
464 it('Should search all the webm videos', async function () { 467 it('Should search all the webm videos', async function () {
465 const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 15) 468 const res = await searchVideoWithPagination(server.url, 'webm', 0, 15)
466 469
467 const videos = res.body.data 470 const videos = res.body.data
468 expect(res.body.total).to.equal(4) 471 expect(res.body.total).to.equal(4)
469 expect(videos.length).to.equal(4) 472 expect(videos.length).to.equal(4)
470 }) 473 })
471 474
472 it('Should search all the root author videos', async function () { 475 // Not implemented yet
473 const res = await searchVideoWithPagination(server.url, 'root', 'account', 0, 15) 476 // it('Should search all the root author videos', async function () {
474 477 // const res = await searchVideoWithPagination(server.url, 'root', 0, 15)
475 const videos = res.body.data 478 //
476 expect(res.body.total).to.equal(6) 479 // const videos = res.body.data
477 expect(videos.length).to.equal(6) 480 // expect(res.body.total).to.equal(6)
478 }) 481 // expect(videos.length).to.equal(6)
482 // })
479 483
480 // Not implemented yet 484 // Not implemented yet
481 // it('Should search all the 9001 port videos', async function () { 485 // it('Should search all the 9001 port videos', async function () {
@@ -559,7 +563,8 @@ describe('Test a single server', function () {
559 expect(video.nsfw).to.be.ok 563 expect(video.nsfw).to.be.ok
560 expect(video.description).to.equal('my super description updated') 564 expect(video.description).to.equal('my super description updated')
561 expect(video.serverHost).to.equal('localhost:9001') 565 expect(video.serverHost).to.equal('localhost:9001')
562 expect(video.account).to.equal('root') 566 expect(video.accountName).to.equal('root')
567 expect(video.account.name).to.equal('root')
563 expect(video.isLocal).to.be.true 568 expect(video.isLocal).to.be.true
564 expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) 569 expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
565 expect(dateIsValid(video.createdAt)).to.be.true 570 expect(dateIsValid(video.createdAt)).to.be.true
@@ -608,7 +613,7 @@ describe('Test a single server', function () {
608 expect(video.nsfw).to.be.ok 613 expect(video.nsfw).to.be.ok
609 expect(video.description).to.equal('my super description updated') 614 expect(video.description).to.equal('my super description updated')
610 expect(video.serverHost).to.equal('localhost:9001') 615 expect(video.serverHost).to.equal('localhost:9001')
611 expect(video.account).to.equal('root') 616 expect(video.accountName).to.equal('root')
612 expect(video.isLocal).to.be.true 617 expect(video.isLocal).to.be.true
613 expect(video.tags).to.deep.equal([ 'supertag', 'tag1', 'tag2' ]) 618 expect(video.tags).to.deep.equal([ 'supertag', 'tag1', 'tag2' ])
614 expect(dateIsValid(video.createdAt)).to.be.true 619 expect(dateIsValid(video.createdAt)).to.be.true
@@ -648,7 +653,7 @@ describe('Test a single server', function () {
648 expect(video.nsfw).to.be.ok 653 expect(video.nsfw).to.be.ok
649 expect(video.description).to.equal('hello everybody') 654 expect(video.description).to.equal('hello everybody')
650 expect(video.serverHost).to.equal('localhost:9001') 655 expect(video.serverHost).to.equal('localhost:9001')
651 expect(video.account).to.equal('root') 656 expect(video.accountName).to.equal('root')
652 expect(video.isLocal).to.be.true 657 expect(video.isLocal).to.be.true
653 expect(video.tags).to.deep.equal([ 'supertag', 'tag1', 'tag2' ]) 658 expect(video.tags).to.deep.equal([ 'supertag', 'tag1', 'tag2' ])
654 expect(dateIsValid(video.createdAt)).to.be.true 659 expect(dateIsValid(video.createdAt)).to.be.true
diff --git a/server/tests/api/users.ts b/server/tests/api/users.ts
index 33646e84f..b3163b1e1 100644
--- a/server/tests/api/users.ts
+++ b/server/tests/api/users.ts
@@ -113,11 +113,11 @@ describe('Test users', function () {
113 113
114 it('Should upload the video with the correct token', async function () { 114 it('Should upload the video with the correct token', async function () {
115 const videoAttributes = {} 115 const videoAttributes = {}
116 await uploadVideo(server.url, accessToken, videoAttributes, 204) 116 await uploadVideo(server.url, accessToken, videoAttributes)
117 const res = await getVideosList(server.url) 117 const res = await getVideosList(server.url)
118 const video = res.body.data[ 0 ] 118 const video = res.body.data[ 0 ]
119 119
120 expect(video.account) 120 expect(video.accountName)
121 .to 121 .to
122 .equal('root') 122 .equal('root')
123 videoId = video.id 123 videoId = video.id
@@ -125,7 +125,7 @@ describe('Test users', function () {
125 125
126 it('Should upload the video again with the correct token', async function () { 126 it('Should upload the video again with the correct token', async function () {
127 const videoAttributes = {} 127 const videoAttributes = {}
128 await uploadVideo(server.url, accessToken, videoAttributes, 204) 128 await uploadVideo(server.url, accessToken, videoAttributes)
129 }) 129 })
130 130
131 it('Should retrieve a video rating', async function () { 131 it('Should retrieve a video rating', async function () {
@@ -487,7 +487,7 @@ describe('Test users', function () {
487 .equal(1) 487 .equal(1)
488 488
489 const video = res.body.data[ 0 ] 489 const video = res.body.data[ 0 ]
490 expect(video.account) 490 expect(video.accountName)
491 .to 491 .to
492 .equal('root') 492 .equal('root')
493 }) 493 })