aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/cli/create-import-video-file-job.ts31
1 files changed, 19 insertions, 12 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index d486db600..251088882 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -3,29 +3,31 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails, VideoFile } from '../../../shared/models/videos' 5import { VideoDetails, VideoFile } from '../../../shared/models/videos'
6const expect = chai.expect
7
8import { 6import {
7 doubleFollow,
9 execCLI, 8 execCLI,
9 flushAndRunMultipleServers,
10 flushTests, 10 flushTests,
11 getEnvCli, 11 getEnvCli,
12 getVideo,
12 getVideosList, 13 getVideosList,
13 killallServers, 14 killallServers,
14 parseTorrentVideo,
15 runServer,
16 ServerInfo, 15 ServerInfo,
17 setAccessTokensToServers, 16 setAccessTokensToServers,
18 uploadVideo, 17 uploadVideo,
19 wait, 18 wait
20 getVideo, flushAndRunMultipleServers, doubleFollow
21} from '../utils' 19} from '../utils'
22 20
23function assertVideoProperties (video: VideoFile, resolution: number, extname: string) { 21const expect = chai.expect
22
23function assertVideoProperties (video: VideoFile, resolution: number, extname: string, size?: number) {
24 expect(video).to.have.nested.property('resolution.id', resolution) 24 expect(video).to.have.nested.property('resolution.id', resolution)
25 expect(video).to.have.property('magnetUri').that.includes(`.${extname}`) 25 expect(video).to.have.property('magnetUri').that.includes(`.${extname}`)
26 expect(video).to.have.property('torrentUrl').that.includes(`-${resolution}.torrent`) 26 expect(video).to.have.property('torrentUrl').that.includes(`-${resolution}.torrent`)
27 expect(video).to.have.property('fileUrl').that.includes(`.${extname}`) 27 expect(video).to.have.property('fileUrl').that.includes(`.${extname}`)
28 expect(video).to.have.property('size').that.is.above(0) 28 expect(video).to.have.property('size').that.is.above(0)
29
30 if (size) expect(video.size).to.equal(size)
29} 31}
30 32
31describe('Test create import video jobs', function () { 33describe('Test create import video jobs', function () {
@@ -51,6 +53,7 @@ describe('Test create import video jobs', function () {
51 const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) 53 const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
52 video2UUID = res2.body.video.uuid 54 video2UUID = res2.body.video.uuid
53 55
56 // Transcoding
54 await wait(40000) 57 await wait(40000)
55 }) 58 })
56 59
@@ -60,12 +63,11 @@ describe('Test create import video jobs', function () {
60 63
61 await wait(30000) 64 await wait(30000)
62 65
66 let magnetUri: string
63 for (const server of servers) { 67 for (const server of servers) {
64 const { data: videos } = (await getVideosList(server.url)).body 68 const { data: videos } = (await getVideosList(server.url)).body
65 expect(videos).to.have.lengthOf(2) 69 expect(videos).to.have.lengthOf(2)
66 70
67 let infoHashes: { [ id: number ]: string } = {}
68
69 const video = videos.find(({ uuid }) => uuid === video1UUID) 71 const video = videos.find(({ uuid }) => uuid === video1UUID)
70 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body 72 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body
71 73
@@ -73,6 +75,9 @@ describe('Test create import video jobs', function () {
73 const [originalVideo, transcodedVideo] = videoDetail.files 75 const [originalVideo, transcodedVideo] = videoDetail.files
74 assertVideoProperties(originalVideo, 720, 'webm') 76 assertVideoProperties(originalVideo, 720, 'webm')
75 assertVideoProperties(transcodedVideo, 480, 'webm') 77 assertVideoProperties(transcodedVideo, 480, 'webm')
78
79 if (!magnetUri) magnetUri = transcodedVideo.magnetUri
80 else expect(transcodedVideo.magnetUri).to.equal(magnetUri)
76 } 81 }
77 }) 82 })
78 83
@@ -82,21 +87,23 @@ describe('Test create import video jobs', function () {
82 87
83 await wait(30000) 88 await wait(30000)
84 89
90 let magnetUri: string
85 for (const server of servers.reverse()) { 91 for (const server of servers.reverse()) {
86 const { data: videos } = (await getVideosList(server.url)).body 92 const { data: videos } = (await getVideosList(server.url)).body
87 expect(videos).to.have.lengthOf(2) 93 expect(videos).to.have.lengthOf(2)
88 94
89 let infoHashes: { [ id: number ]: string }
90
91 const video = videos.find(({ uuid }) => uuid === video2UUID) 95 const video = videos.find(({ uuid }) => uuid === video2UUID)
92 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body 96 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body
93 97
94 expect(videoDetail.files).to.have.lengthOf(4) 98 expect(videoDetail.files).to.have.lengthOf(4)
95 const [originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240] = videoDetail.files 99 const [originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240] = videoDetail.files
96 assertVideoProperties(originalVideo, 720, 'ogv') 100 assertVideoProperties(originalVideo, 720, 'ogv', 140849)
97 assertVideoProperties(transcodedVideo420, 480, 'mp4') 101 assertVideoProperties(transcodedVideo420, 480, 'mp4')
98 assertVideoProperties(transcodedVideo320, 360, 'mp4') 102 assertVideoProperties(transcodedVideo320, 360, 'mp4')
99 assertVideoProperties(transcodedVideo240, 240, 'mp4') 103 assertVideoProperties(transcodedVideo240, 240, 'mp4')
104
105 if (!magnetUri) magnetUri = originalVideo.magnetUri
106 else expect(originalVideo.magnetUri).to.equal(magnetUri)
100 } 107 }
101 }) 108 })
102 109