]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import { keyBy } from 'lodash' | |
4 | import { join } from 'path' | |
5 | import 'mocha' | |
6 | import * as chai from 'chai' | |
7 | const expect = chai.expect | |
8 | ||
9 | import { | |
10 | ServerInfo, | |
11 | flushTests, | |
12 | runServer, | |
13 | uploadVideo, | |
14 | getVideosList, | |
15 | rateVideo, | |
16 | removeVideo, | |
17 | wait, | |
18 | setAccessTokensToServers, | |
19 | searchVideo, | |
20 | killallServers, | |
21 | dateIsValid, | |
22 | getVideoCategories, | |
23 | getVideoLicences, | |
24 | getVideoLanguages, | |
25 | testVideoImage, | |
26 | webtorrentAdd, | |
27 | getVideo, | |
28 | readdirPromise, | |
29 | getVideosListPagination, | |
30 | searchVideoWithPagination, | |
31 | getVideosListSort, | |
32 | searchVideoWithSort, | |
33 | updateVideo | |
34 | } from '../utils' | |
35 | ||
36 | describe('Test a single pod', function () { | |
37 | let server: ServerInfo = null | |
38 | let videoId = -1 | |
39 | let videoUUID = '' | |
40 | let videosListBase: any[] = null | |
41 | ||
42 | before(async function () { | |
43 | this.timeout(120000) | |
44 | ||
45 | await flushTests() | |
46 | ||
47 | server = await runServer(1) | |
48 | ||
49 | await setAccessTokensToServers([ server ]) | |
50 | }) | |
51 | ||
52 | it('Should list video categories', async function () { | |
53 | const res = await getVideoCategories(server.url) | |
54 | ||
55 | const categories = res.body | |
56 | expect(Object.keys(categories)).to.have.length.above(10) | |
57 | ||
58 | expect(categories[11]).to.equal('News') | |
59 | }) | |
60 | ||
61 | it('Should list video licences', async function () { | |
62 | const res = await getVideoLicences(server.url) | |
63 | ||
64 | const licences = res.body | |
65 | expect(Object.keys(licences)).to.have.length.above(5) | |
66 | ||
67 | expect(licences[3]).to.equal('Attribution - No Derivatives') | |
68 | }) | |
69 | ||
70 | it('Should list video languages', async function () { | |
71 | const res = await getVideoLanguages(server.url) | |
72 | ||
73 | const languages = res.body | |
74 | expect(Object.keys(languages)).to.have.length.above(5) | |
75 | ||
76 | expect(languages[3]).to.equal('Mandarin') | |
77 | }) | |
78 | ||
79 | it('Should not have videos', async function () { | |
80 | const res = await getVideosList(server.url) | |
81 | ||
82 | expect(res.body.total).to.equal(0) | |
83 | expect(res.body.data).to.be.an('array') | |
84 | expect(res.body.data.length).to.equal(0) | |
85 | }) | |
86 | ||
87 | it('Should upload the video', async function () { | |
88 | const videoAttributes = { | |
89 | name: 'my super name', | |
90 | category: 2, | |
91 | nsfw: true, | |
92 | licence: 6, | |
93 | tags: [ 'tag1', 'tag2', 'tag3' ] | |
94 | } | |
95 | await uploadVideo(server.url, server.accessToken, videoAttributes) | |
96 | }) | |
97 | ||
98 | it('Should seed the uploaded video', async function () { | |
99 | // Yes, this could be long | |
100 | this.timeout(60000) | |
101 | ||
102 | const res = await getVideosList(server.url) | |
103 | ||
104 | expect(res.body.total).to.equal(1) | |
105 | expect(res.body.data).to.be.an('array') | |
106 | expect(res.body.data.length).to.equal(1) | |
107 | ||
108 | const video = res.body.data[0] | |
109 | expect(video.name).to.equal('my super name') | |
110 | expect(video.category).to.equal(2) | |
111 | expect(video.categoryLabel).to.equal('Films') | |
112 | expect(video.licence).to.equal(6) | |
113 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
114 | expect(video.language).to.equal(3) | |
115 | expect(video.languageLabel).to.equal('Mandarin') | |
116 | expect(video.nsfw).to.be.ok | |
117 | expect(video.description).to.equal('my super description') | |
118 | expect(video.podHost).to.equal('localhost:9001') | |
119 | expect(video.author).to.equal('root') | |
120 | expect(video.isLocal).to.be.true | |
121 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
122 | expect(dateIsValid(video.createdAt)).to.be.true | |
123 | expect(dateIsValid(video.updatedAt)).to.be.true | |
124 | ||
125 | expect(video.files).to.have.lengthOf(1) | |
126 | ||
127 | const file = video.files[0] | |
128 | const magnetUri = file.magnetUri | |
129 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
a96aed15 C |
130 | expect(file.torrentUrl).to.equal(`${server.url}/static/torrents/${video.uuid}-${file.resolution}.torrent`) |
131 | expect(file.fileUrl).to.equal(`${server.url}/static/webseed/${video.uuid}-${file.resolution}.webm`) | |
14d3270f C |
132 | expect(file.resolution).to.equal(720) |
133 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
134 | expect(file.size).to.equal(218910) |
135 | ||
136 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
137 | expect(test).to.equal(true) | |
138 | ||
139 | videoId = video.id | |
140 | videoUUID = video.uuid | |
141 | ||
142 | const torrent = await webtorrentAdd(magnetUri) | |
143 | expect(torrent.files).to.be.an('array') | |
144 | expect(torrent.files.length).to.equal(1) | |
145 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
146 | }) | |
147 | ||
148 | it('Should get the video', async function () { | |
149 | // Yes, this could be long | |
150 | this.timeout(60000) | |
151 | ||
152 | const res = await getVideo(server.url, videoId) | |
153 | ||
154 | const video = res.body | |
155 | expect(video.name).to.equal('my super name') | |
156 | expect(video.category).to.equal(2) | |
157 | expect(video.categoryLabel).to.equal('Films') | |
158 | expect(video.licence).to.equal(6) | |
159 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
160 | expect(video.language).to.equal(3) | |
161 | expect(video.languageLabel).to.equal('Mandarin') | |
162 | expect(video.nsfw).to.be.ok | |
163 | expect(video.description).to.equal('my super description') | |
164 | expect(video.podHost).to.equal('localhost:9001') | |
165 | expect(video.author).to.equal('root') | |
166 | expect(video.isLocal).to.be.true | |
167 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
168 | expect(dateIsValid(video.createdAt)).to.be.true | |
169 | expect(dateIsValid(video.updatedAt)).to.be.true | |
170 | ||
171 | expect(video.files).to.have.lengthOf(1) | |
172 | ||
173 | const file = video.files[0] | |
174 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
175 | expect(file.resolution).to.equal(720) |
176 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
177 | expect(file.size).to.equal(218910) |
178 | ||
179 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
180 | expect(test).to.equal(true) | |
181 | ||
182 | // Wait the async views increment | |
183 | await wait(500) | |
184 | }) | |
185 | ||
186 | it('Should get the video by UUID', async function () { | |
187 | // Yes, this could be long | |
188 | this.timeout(60000) | |
189 | ||
190 | const res = await getVideo(server.url, videoUUID) | |
191 | ||
192 | const video = res.body | |
193 | expect(video.name).to.equal('my super name') | |
194 | ||
195 | // Wait the async views increment | |
196 | await wait(500) | |
197 | }) | |
198 | ||
199 | it('Should have the views updated', async function () { | |
200 | const res = await getVideo(server.url, videoId) | |
201 | ||
202 | const video = res.body | |
203 | expect(video.views).to.equal(2) | |
204 | }) | |
205 | ||
206 | it('Should search the video by name by default', async function () { | |
207 | const res = await searchVideo(server.url, 'my') | |
208 | ||
209 | expect(res.body.total).to.equal(1) | |
210 | expect(res.body.data).to.be.an('array') | |
211 | expect(res.body.data.length).to.equal(1) | |
212 | ||
213 | const video = res.body.data[0] | |
214 | expect(video.name).to.equal('my super name') | |
215 | expect(video.category).to.equal(2) | |
216 | expect(video.categoryLabel).to.equal('Films') | |
217 | expect(video.licence).to.equal(6) | |
218 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
219 | expect(video.language).to.equal(3) | |
220 | expect(video.languageLabel).to.equal('Mandarin') | |
221 | expect(video.nsfw).to.be.ok | |
222 | expect(video.description).to.equal('my super description') | |
223 | expect(video.podHost).to.equal('localhost:9001') | |
224 | expect(video.author).to.equal('root') | |
225 | expect(video.isLocal).to.be.true | |
226 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
227 | expect(dateIsValid(video.createdAt)).to.be.true | |
228 | expect(dateIsValid(video.updatedAt)).to.be.true | |
229 | ||
230 | expect(video.files).to.have.lengthOf(1) | |
231 | ||
232 | const file = video.files[0] | |
233 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
234 | expect(file.resolution).to.equal(720) |
235 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
236 | expect(file.size).to.equal(218910) |
237 | ||
238 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
239 | expect(test).to.equal(true) | |
240 | }) | |
241 | ||
242 | // Not implemented yet | |
243 | // it('Should search the video by podHost', async function () { | |
244 | // const res = await videosUtils.searchVideo(server.url, '9001', 'host') | |
245 | ||
246 | // expect(res.body.total).to.equal(1) | |
247 | // expect(res.body.data).to.be.an('array') | |
248 | // expect(res.body.data.length).to.equal(1) | |
249 | ||
250 | // const video = res.body.data[0] | |
251 | // expect(video.name).to.equal('my super name') | |
252 | // expect(video.description).to.equal('my super description') | |
253 | // expect(video.podHost).to.equal('localhost:9001') | |
254 | // expect(video.author).to.equal('root') | |
255 | // expect(video.isLocal).to.be.true | |
256 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
257 | // expect(dateIsValid(video.createdAt)).to.be.true | |
258 | // expect(dateIsValid(video.updatedAt)).to.be.true | |
259 | ||
260 | // const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
261 | // expect(test).to.equal(true) | |
262 | ||
263 | // done() | |
264 | // }) | |
265 | // }) | |
266 | // }) | |
267 | ||
268 | it('Should search the video by tag', async function () { | |
269 | const res = await searchVideo(server.url, 'tag1', 'tags') | |
270 | ||
271 | expect(res.body.total).to.equal(1) | |
272 | expect(res.body.data).to.be.an('array') | |
273 | expect(res.body.data.length).to.equal(1) | |
274 | ||
275 | const video = res.body.data[0] | |
276 | expect(video.name).to.equal('my super name') | |
277 | expect(video.category).to.equal(2) | |
278 | expect(video.categoryLabel).to.equal('Films') | |
279 | expect(video.licence).to.equal(6) | |
280 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
281 | expect(video.language).to.equal(3) | |
282 | expect(video.languageLabel).to.equal('Mandarin') | |
283 | expect(video.nsfw).to.be.ok | |
284 | expect(video.description).to.equal('my super description') | |
285 | expect(video.podHost).to.equal('localhost:9001') | |
286 | expect(video.author).to.equal('root') | |
287 | expect(video.isLocal).to.be.true | |
288 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
289 | expect(dateIsValid(video.createdAt)).to.be.true | |
290 | expect(dateIsValid(video.updatedAt)).to.be.true | |
291 | ||
292 | expect(video.files).to.have.lengthOf(1) | |
293 | ||
294 | const file = video.files[0] | |
295 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
296 | expect(file.resolution).to.equal(720) |
297 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
298 | expect(file.size).to.equal(218910) |
299 | ||
300 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
301 | expect(test).to.equal(true) | |
302 | }) | |
303 | ||
304 | it('Should not find a search by name by default', async function () { | |
305 | const res = await searchVideo(server.url, 'hello') | |
306 | ||
307 | expect(res.body.total).to.equal(0) | |
308 | expect(res.body.data).to.be.an('array') | |
309 | expect(res.body.data.length).to.equal(0) | |
310 | }) | |
311 | ||
312 | it('Should not find a search by author', async function () { | |
313 | const res = await searchVideo(server.url, 'hello', 'author') | |
314 | ||
315 | expect(res.body.total).to.equal(0) | |
316 | expect(res.body.data).to.be.an('array') | |
317 | expect(res.body.data.length).to.equal(0) | |
318 | }) | |
319 | ||
320 | it('Should not find a search by tag', async function () { | |
321 | const res = await searchVideo(server.url, 'hello', 'tags') | |
322 | ||
323 | expect(res.body.total).to.equal(0) | |
324 | expect(res.body.data).to.be.an('array') | |
325 | expect(res.body.data.length).to.equal(0) | |
326 | }) | |
327 | ||
328 | it('Should remove the video', async function () { | |
329 | await removeVideo(server.url, server.accessToken, videoId) | |
330 | ||
331 | const files1 = await readdirPromise(join(__dirname, '..', '..', '..', 'test1/videos/')) | |
332 | expect(files1).to.have.lengthOf(0) | |
333 | ||
334 | const files2 = await readdirPromise(join(__dirname, '..', '..', '..', 'test1/thumbnails/')) | |
335 | expect(files2).to.have.lengthOf(0) | |
336 | }) | |
337 | ||
338 | it('Should not have videos', async function () { | |
339 | const res = await getVideosList(server.url) | |
340 | ||
341 | expect(res.body.total).to.equal(0) | |
342 | expect(res.body.data).to.be.an('array') | |
343 | expect(res.body.data).to.have.lengthOf(0) | |
344 | }) | |
345 | ||
346 | it('Should upload 6 videos', async function () { | |
347 | this.timeout(25000) | |
348 | ||
349 | const videos = [ | |
350 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', | |
351 | 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' | |
352 | ] | |
353 | ||
354 | const tasks: Promise<any>[] = [] | |
355 | for (const video of videos) { | |
356 | const videoAttributes = { | |
357 | name: video + ' name', | |
358 | description: video + ' description', | |
359 | category: 2, | |
360 | licence: 1, | |
361 | language: 1, | |
362 | nsfw: true, | |
363 | tags: [ 'tag1', 'tag2', 'tag3' ], | |
364 | fixture: video | |
365 | } | |
366 | ||
367 | const p = uploadVideo(server.url, server.accessToken, videoAttributes) | |
368 | tasks.push(p) | |
369 | } | |
370 | ||
371 | await Promise.all(tasks) | |
372 | }) | |
373 | ||
374 | it('Should have the correct durations', async function () { | |
375 | const res = await getVideosList(server.url) | |
376 | ||
377 | expect(res.body.total).to.equal(6) | |
378 | const videos = res.body.data | |
379 | expect(videos).to.be.an('array') | |
380 | expect(videos).to.have.lengthOf(6) | |
381 | ||
382 | const videosByName = keyBy<{ duration: number }>(videos, 'name') | |
383 | expect(videosByName['video_short.mp4 name'].duration).to.equal(5) | |
384 | expect(videosByName['video_short.ogv name'].duration).to.equal(5) | |
385 | expect(videosByName['video_short.webm name'].duration).to.equal(5) | |
386 | expect(videosByName['video_short1.webm name'].duration).to.equal(10) | |
387 | expect(videosByName['video_short2.webm name'].duration).to.equal(5) | |
388 | expect(videosByName['video_short3.webm name'].duration).to.equal(5) | |
389 | }) | |
390 | ||
391 | it('Should have the correct thumbnails', async function () { | |
392 | const res = await getVideosList(server.url) | |
393 | ||
394 | const videos = res.body.data | |
395 | // For the next test | |
396 | videosListBase = videos | |
397 | ||
398 | for (const video of videos) { | |
399 | const videoName = video.name.replace(' name', '') | |
400 | const test = await testVideoImage(server.url, videoName, video.thumbnailPath) | |
401 | ||
402 | expect(test).to.equal(true) | |
403 | } | |
404 | }) | |
405 | ||
406 | it('Should list only the two first videos', async function () { | |
407 | const res = await getVideosListPagination(server.url, 0, 2, 'name') | |
408 | ||
409 | const videos = res.body.data | |
410 | expect(res.body.total).to.equal(6) | |
411 | expect(videos.length).to.equal(2) | |
412 | expect(videos[0].name).to.equal(videosListBase[0].name) | |
413 | expect(videos[1].name).to.equal(videosListBase[1].name) | |
414 | }) | |
415 | ||
416 | it('Should list only the next three videos', async function () { | |
417 | const res = await getVideosListPagination(server.url, 2, 3, 'name') | |
418 | ||
419 | const videos = res.body.data | |
420 | expect(res.body.total).to.equal(6) | |
421 | expect(videos.length).to.equal(3) | |
422 | expect(videos[0].name).to.equal(videosListBase[2].name) | |
423 | expect(videos[1].name).to.equal(videosListBase[3].name) | |
424 | expect(videos[2].name).to.equal(videosListBase[4].name) | |
425 | }) | |
426 | ||
427 | it('Should list the last video', async function () { | |
428 | const res = await getVideosListPagination(server.url, 5, 6, 'name') | |
429 | ||
430 | const videos = res.body.data | |
431 | expect(res.body.total).to.equal(6) | |
432 | expect(videos.length).to.equal(1) | |
433 | expect(videos[0].name).to.equal(videosListBase[5].name) | |
434 | }) | |
435 | ||
436 | it('Should search the first video', async function () { | |
437 | const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 1, 'name') | |
438 | ||
439 | const videos = res.body.data | |
440 | expect(res.body.total).to.equal(4) | |
441 | expect(videos.length).to.equal(1) | |
442 | expect(videos[0].name).to.equal('video_short1.webm name') | |
443 | }) | |
444 | ||
445 | it('Should search the last two videos', async function () { | |
446 | const res = await searchVideoWithPagination(server.url, 'webm', 'name', 2, 2, 'name') | |
447 | ||
448 | const videos = res.body.data | |
449 | expect(res.body.total).to.equal(4) | |
450 | expect(videos.length).to.equal(2) | |
451 | expect(videos[0].name).to.equal('video_short3.webm name') | |
452 | expect(videos[1].name).to.equal('video_short.webm name') | |
453 | }) | |
454 | ||
455 | it('Should search all the webm videos', async function () { | |
456 | const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 15) | |
457 | ||
458 | const videos = res.body.data | |
459 | expect(res.body.total).to.equal(4) | |
460 | expect(videos.length).to.equal(4) | |
461 | }) | |
462 | ||
463 | it('Should search all the root author videos', async function () { | |
464 | const res = await searchVideoWithPagination(server.url, 'root', 'author', 0, 15) | |
465 | ||
466 | const videos = res.body.data | |
467 | expect(res.body.total).to.equal(6) | |
468 | expect(videos.length).to.equal(6) | |
469 | }) | |
470 | ||
471 | // Not implemented yet | |
472 | // it('Should search all the 9001 port videos', async function () { | |
473 | // const res = await videosUtils.searchVideoWithPagination(server.url, '9001', 'host', 0, 15) | |
474 | ||
475 | // const videos = res.body.data | |
476 | // expect(res.body.total).to.equal(6) | |
477 | // expect(videos.length).to.equal(6) | |
478 | ||
479 | // done() | |
480 | // }) | |
481 | // }) | |
482 | ||
483 | // it('Should search all the localhost videos', async function () { | |
484 | // const res = await videosUtils.searchVideoWithPagination(server.url, 'localhost', 'host', 0, 15) | |
485 | ||
486 | // const videos = res.body.data | |
487 | // expect(res.body.total).to.equal(6) | |
488 | // expect(videos.length).to.equal(6) | |
489 | ||
490 | // done() | |
491 | // }) | |
492 | // }) | |
493 | ||
494 | it('Should search the right magnetUri video', async function () { | |
495 | const video = videosListBase[0] | |
496 | const res = await searchVideoWithPagination(server.url, encodeURIComponent(video.files[0].magnetUri), 'magnetUri', 0, 15) | |
497 | ||
498 | const videos = res.body.data | |
499 | expect(res.body.total).to.equal(1) | |
500 | expect(videos.length).to.equal(1) | |
501 | expect(videos[0].name).to.equal(video.name) | |
502 | }) | |
503 | ||
504 | it('Should list and sort by name in descending order', async function () { | |
505 | const res = await getVideosListSort(server.url, '-name') | |
506 | ||
507 | const videos = res.body.data | |
508 | expect(res.body.total).to.equal(6) | |
509 | expect(videos.length).to.equal(6) | |
510 | expect(videos[0].name).to.equal('video_short.webm name') | |
511 | expect(videos[1].name).to.equal('video_short.ogv name') | |
512 | expect(videos[2].name).to.equal('video_short.mp4 name') | |
513 | expect(videos[3].name).to.equal('video_short3.webm name') | |
514 | expect(videos[4].name).to.equal('video_short2.webm name') | |
515 | expect(videos[5].name).to.equal('video_short1.webm name') | |
516 | }) | |
517 | ||
518 | it('Should search and sort by name in ascending order', async function () { | |
519 | const res = await searchVideoWithSort(server.url, 'webm', 'name') | |
520 | ||
521 | const videos = res.body.data | |
522 | expect(res.body.total).to.equal(4) | |
523 | expect(videos.length).to.equal(4) | |
524 | ||
525 | expect(videos[0].name).to.equal('video_short1.webm name') | |
526 | expect(videos[1].name).to.equal('video_short2.webm name') | |
527 | expect(videos[2].name).to.equal('video_short3.webm name') | |
528 | expect(videos[3].name).to.equal('video_short.webm name') | |
529 | ||
530 | videoId = videos[2].id | |
531 | }) | |
532 | ||
533 | it('Should update a video', async function () { | |
534 | const attributes = { | |
535 | name: 'my super video updated', | |
536 | category: 4, | |
537 | licence: 2, | |
538 | language: 5, | |
539 | nsfw: false, | |
540 | description: 'my super description updated', | |
541 | tags: [ 'tagup1', 'tagup2' ] | |
542 | } | |
543 | await updateVideo(server.url, server.accessToken, videoId, attributes) | |
544 | }) | |
545 | ||
546 | it('Should have the video updated', async function () { | |
547 | this.timeout(60000) | |
548 | ||
549 | const res = await getVideo(server.url, videoId) | |
550 | ||
551 | const video = res.body | |
552 | ||
553 | expect(video.name).to.equal('my super video updated') | |
554 | expect(video.category).to.equal(4) | |
555 | expect(video.categoryLabel).to.equal('Art') | |
556 | expect(video.licence).to.equal(2) | |
557 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | |
558 | expect(video.language).to.equal(5) | |
559 | expect(video.languageLabel).to.equal('Arabic') | |
560 | expect(video.nsfw).to.be.ok | |
561 | expect(video.description).to.equal('my super description updated') | |
562 | expect(video.podHost).to.equal('localhost:9001') | |
563 | expect(video.author).to.equal('root') | |
564 | expect(video.isLocal).to.be.true | |
565 | expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | |
566 | expect(dateIsValid(video.createdAt)).to.be.true | |
567 | expect(dateIsValid(video.updatedAt)).to.be.true | |
568 | ||
569 | expect(video.files).to.have.lengthOf(1) | |
570 | ||
571 | const file = video.files[0] | |
572 | const magnetUri = file.magnetUri | |
573 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
574 | expect(file.resolution).to.equal(720) |
575 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
576 | expect(file.size).to.equal(292677) |
577 | ||
578 | const test = await testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath) | |
579 | expect(test).to.equal(true) | |
580 | ||
581 | const torrent = await webtorrentAdd(magnetUri) | |
582 | expect(torrent.files).to.be.an('array') | |
583 | expect(torrent.files.length).to.equal(1) | |
584 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
585 | }) | |
586 | ||
587 | it('Should update only the tags of a video', async function () { | |
588 | const attributes = { | |
589 | tags: [ 'tag1', 'tag2', 'supertag' ] | |
590 | } | |
591 | ||
592 | await updateVideo(server.url, server.accessToken, videoId, attributes) | |
593 | ||
594 | const res = await getVideo(server.url, videoId) | |
595 | const video = res.body | |
596 | ||
597 | expect(video.name).to.equal('my super video updated') | |
598 | expect(video.category).to.equal(4) | |
599 | expect(video.categoryLabel).to.equal('Art') | |
600 | expect(video.licence).to.equal(2) | |
601 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | |
602 | expect(video.language).to.equal(5) | |
603 | expect(video.languageLabel).to.equal('Arabic') | |
604 | expect(video.nsfw).to.be.ok | |
605 | expect(video.description).to.equal('my super description updated') | |
606 | expect(video.podHost).to.equal('localhost:9001') | |
607 | expect(video.author).to.equal('root') | |
608 | expect(video.isLocal).to.be.true | |
609 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | |
610 | expect(dateIsValid(video.createdAt)).to.be.true | |
611 | expect(dateIsValid(video.updatedAt)).to.be.true | |
612 | ||
613 | expect(video.files).to.have.lengthOf(1) | |
614 | ||
615 | const file = video.files[0] | |
616 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
617 | expect(file.resolution).to.equal(720) |
618 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
619 | expect(file.size).to.equal(292677) |
620 | }) | |
621 | ||
622 | it('Should update only the description of a video', async function () { | |
623 | const attributes = { | |
624 | description: 'hello everybody' | |
625 | } | |
626 | ||
627 | await updateVideo(server.url, server.accessToken, videoId, attributes) | |
628 | ||
629 | const res = await getVideo(server.url, videoId) | |
630 | const video = res.body | |
631 | ||
632 | expect(video.name).to.equal('my super video updated') | |
633 | expect(video.category).to.equal(4) | |
634 | expect(video.categoryLabel).to.equal('Art') | |
635 | expect(video.licence).to.equal(2) | |
636 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | |
637 | expect(video.language).to.equal(5) | |
638 | expect(video.languageLabel).to.equal('Arabic') | |
639 | expect(video.nsfw).to.be.ok | |
640 | expect(video.description).to.equal('hello everybody') | |
641 | expect(video.podHost).to.equal('localhost:9001') | |
642 | expect(video.author).to.equal('root') | |
643 | expect(video.isLocal).to.be.true | |
644 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | |
645 | expect(dateIsValid(video.createdAt)).to.be.true | |
646 | expect(dateIsValid(video.updatedAt)).to.be.true | |
647 | ||
648 | expect(video.files).to.have.lengthOf(1) | |
649 | ||
650 | const file = video.files[0] | |
651 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
652 | expect(file.resolution).to.equal(720) |
653 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
654 | expect(file.size).to.equal(292677) |
655 | }) | |
656 | ||
657 | it('Should like a video', async function () { | |
658 | await rateVideo(server.url, server.accessToken, videoId, 'like') | |
659 | ||
660 | const res = await getVideo(server.url, videoId) | |
661 | const video = res.body | |
662 | ||
663 | expect(video.likes).to.equal(1) | |
664 | expect(video.dislikes).to.equal(0) | |
665 | }) | |
666 | ||
667 | it('Should dislike the same video', async function () { | |
668 | await rateVideo(server.url, server.accessToken, videoId, 'dislike') | |
669 | ||
670 | const res = await getVideo(server.url, videoId) | |
671 | const video = res.body | |
672 | ||
673 | expect(video.likes).to.equal(0) | |
674 | expect(video.dislikes).to.equal(1) | |
675 | }) | |
676 | ||
677 | after(async function () { | |
678 | killallServers([ server ]) | |
679 | ||
680 | // Keep the logs if the test failed | |
681 | if (this['ok']) { | |
682 | await flushTests() | |
683 | } | |
684 | }) | |
685 | }) |