aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/follows.ts186
-rw-r--r--server/tests/api/videos/multiple-servers.ts440
-rw-r--r--server/tests/api/videos/single-server.ts4
3 files changed, 294 insertions, 336 deletions
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 6c815ace8..311631aae 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -2,7 +2,9 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { Video, VideoPrivacy } from '../../../../shared/models/videos'
5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 6import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
7import { completeVideoCheck } from '../../utils'
6 8
7import { 9import {
8 flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, 10 flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
@@ -163,111 +165,109 @@ describe('Test follows', function () {
163 expect(res.body.data[0].name).to.equal('server3') 165 expect(res.body.data[0].name).to.equal('server3')
164 }) 166 })
165 167
166 it('Should propagate previous uploaded videos on a new following', async function () { 168 describe('Should propagate data on a new following', async function () {
167 this.timeout(20000) 169 let video4: Video
168
169 const video4Attributes = {
170 name: 'server3-4',
171 category: 2,
172 nsfw: true,
173 licence: 6,
174 tags: [ 'tag1', 'tag2', 'tag3' ]
175 }
176 170
177 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' }) 171 before(async function () {
178 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' }) 172 this.timeout(20000)
179 await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes)
180 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' })
181 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' })
182 173
183 { 174 const video4Attributes = {
184 const user = { username: 'captain', password: 'password' } 175 name: 'server3-4',
185 await createUser(servers[2].url, servers[2].accessToken, user.username, user.password) 176 category: 2,
186 const userAccessToken = await userLogin(servers[2], user) 177 nsfw: true,
178 licence: 6,
179 tags: [ 'tag1', 'tag2', 'tag3' ]
180 }
187 181
188 const resVideos = await getVideosList(servers[ 2 ].url) 182 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-2' })
189 const video4 = resVideos.body.data.find(v => v.name === 'server3-4') 183 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-3' })
184 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4Attributes)
185 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-5' })
186 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-6' })
190 187
191 { 188 {
192 await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like') 189 const user = { username: 'captain', password: 'password' }
193 await rateVideo(servers[ 2 ].url, userAccessToken, video4.id, 'dislike') 190 await createUser(servers[ 2 ].url, servers[ 2 ].accessToken, user.username, user.password)
194 } 191 const userAccessToken = await userLogin(servers[ 2 ], user)
195 192
196 { 193 const resVideos = await getVideosList(servers[ 2 ].url)
197 const text = 'my super first comment' 194 video4 = resVideos.body.data.find(v => v.name === 'server3-4')
198 const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
199 const threadId = res.body.comment.id
200 195
201 const text1 = 'my super answer to thread 1' 196 {
202 const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1) 197 await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like')
203 const childCommentId = childCommentRes.body.comment.id 198 await rateVideo(servers[ 2 ].url, userAccessToken, video4.id, 'dislike')
199 }
204 200
205 const text2 = 'my super answer to answer of thread 1' 201 {
206 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text2) 202 const text = 'my super first comment'
203 const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
204 const threadId = res.body.comment.id
207 205
208 const text3 = 'my second answer to thread 1' 206 const text1 = 'my super answer to thread 1'
209 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text3) 207 const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1)
210 } 208 const childCommentId = childCommentRes.body.comment.id
211 }
212 209
213 await wait(5000) 210 const text2 = 'my super answer to answer of thread 1'
211 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text2)
214 212
215 // Server 1 follows server 3 213 const text3 = 'my second answer to thread 1'
216 await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken) 214 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text3)
215 }
216 }
217 217
218 await wait(7000) 218 await wait(5000)
219
220 // Server 1 follows server 3
221 await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken)
222
223 await wait(7000)
224 })
225
226 it('Should propagate videos', async function () {
227 const res = await getVideosList(servers[ 0 ].url)
228 expect(res.body.total).to.equal(7)
229
230 const video2 = res.body.data.find(v => v.name === 'server3-2')
231 video4 = res.body.data.find(v => v.name === 'server3-4')
232 const video6 = res.body.data.find(v => v.name === 'server3-6')
233
234 expect(video2).to.not.be.undefined
235 expect(video4).to.not.be.undefined
236 expect(video6).to.not.be.undefined
237
238 const isLocal = false
239 const checkAttributes = {
240 name: 'server3-4',
241 category: 2,
242 licence: 6,
243 language: 3,
244 nsfw: true,
245 description: 'my super description',
246 host: 'localhost:9003',
247 account: 'root',
248 isLocal,
249 duration: 5,
250 tags: [ 'tag1', 'tag2', 'tag3' ],
251 privacy: VideoPrivacy.PUBLIC,
252 likes: 1,
253 dislikes: 1,
254 channel: {
255 name: 'Default root channel',
256 description: '',
257 isLocal
258 },
259 fixture: 'video_short.webm',
260 files: [
261 {
262 resolution: 720,
263 size: 218910
264 }
265 ]
266 }
267 await completeVideoCheck(servers[ 0 ].url, video4, checkAttributes)
268 })
219 269
220 let res = await getVideosList(servers[0].url) 270 it('Should propagate comments', async function () {
221 expect(res.body.total).to.equal(7)
222
223 const video2 = res.body.data.find(v => v.name === 'server3-2')
224 const video4 = res.body.data.find(v => v.name === 'server3-4')
225 const video6 = res.body.data.find(v => v.name === 'server3-6')
226
227 expect(video2).to.not.be.undefined
228 expect(video4).to.not.be.undefined
229 expect(video6).to.not.be.undefined
230
231 const res2 = await getVideo(servers[0].url, video4.id)
232 const videoDetails = res2.body
233
234 expect(videoDetails.name).to.equal('server3-4')
235 expect(videoDetails.category).to.equal(2)
236 expect(videoDetails.categoryLabel).to.equal('Films')
237 expect(videoDetails.licence).to.equal(6)
238 expect(videoDetails.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
239 expect(videoDetails.language).to.equal(3)
240 expect(videoDetails.languageLabel).to.equal('Mandarin')
241 expect(videoDetails.nsfw).to.be.ok
242 expect(videoDetails.description).to.equal('my super description')
243 expect(videoDetails.serverHost).to.equal('localhost:9003')
244 expect(videoDetails.accountName).to.equal('root')
245 expect(videoDetails.likes).to.equal(1)
246 expect(videoDetails.dislikes).to.equal(1)
247 expect(videoDetails.isLocal).to.be.false
248 expect(videoDetails.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
249 expect(dateIsValid(videoDetails.createdAt)).to.be.true
250 expect(dateIsValid(videoDetails.updatedAt)).to.be.true
251 expect(videoDetails.files).to.have.lengthOf(1)
252
253 const file = videoDetails.files[0]
254 const magnetUri = file.magnetUri
255 expect(file.magnetUri).to.have.lengthOf.above(2)
256 expect(file.torrentUrl).to.equal(`${servers[2].url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
257 expect(file.fileUrl).to.equal(`${servers[2].url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
258 expect(file.resolution).to.equal(720)
259 expect(file.resolutionLabel).to.equal('720p')
260 expect(file.size).to.equal(218910)
261
262 const test = await testVideoImage(servers[2].url, 'video_short.webm', videoDetails.thumbnailPath)
263 expect(test).to.equal(true)
264
265 const torrent = await webtorrentAdd(magnetUri)
266 expect(torrent.files).to.be.an('array')
267 expect(torrent.files.length).to.equal(1)
268 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
269
270 {
271 const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5) 271 const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5)
272 272
273 expect(res1.body.total).to.equal(1) 273 expect(res1.body.total).to.equal(1)
@@ -304,7 +304,7 @@ describe('Test follows', function () {
304 const secondChild = tree.children[1] 304 const secondChild = tree.children[1]
305 expect(secondChild.comment.text).to.equal('my second answer to thread 1') 305 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
306 expect(secondChild.children).to.have.lengthOf(0) 306 expect(secondChild.children).to.have.lengthOf(0)
307 } 307 })
308 }) 308 })
309 309
310 after(async function () { 310 after(async function () {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 2a943fe45..d35d1204a 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -4,19 +4,18 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { join } from 'path' 5import { join } from 'path'
6import * as request from 'supertest' 6import * as request from 'supertest'
7import { VideoPrivacy } from '../../../../shared/models/videos'
7import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 8import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
8 9
9import { 10import {
10 addVideoChannel, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, userLogin, getVideo, 11 addVideoChannel, completeVideoCheck, createUser, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, getVideo,
11 getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage, 12 getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage,
12 updateVideo, uploadVideo, wait, webtorrentAdd 13 updateVideo, uploadVideo, userLogin, viewVideo, wait, webtorrentAdd
13} from '../../utils/index' 14} from '../../utils'
14import { createUser } from '../../utils/users/users'
15import { 15import {
16 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, 16 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
17 getVideoThreadComments 17 getVideoThreadComments
18} from '../../utils/videos/video-comments' 18} from '../../utils/videos/video-comments'
19import { viewVideo } from '../../utils/videos/videos'
20 19
21const expect = chai.expect 20const expect = chai.expect
22 21
@@ -80,67 +79,41 @@ describe('Test multiple servers', function () {
80 79
81 // All servers should have this video 80 // All servers should have this video
82 for (const server of servers) { 81 for (const server of servers) {
83 let baseMagnet = null 82 const isLocal = server.url === 'http://localhost:9001'
83 const checkAttributes = {
84 name: 'my super name for server 1',
85 category: 5,
86 licence: 4,
87 language: 9,
88 nsfw: true,
89 description: 'my super description for server 1',
90 host: 'localhost:9001',
91 account: 'root',
92 isLocal,
93 duration: 10,
94 tags: [ 'tag1p1', 'tag2p1' ],
95 privacy: VideoPrivacy.PUBLIC,
96 channel: {
97 name: 'my channel',
98 description: 'super channel',
99 isLocal
100 },
101 fixture: 'video_short.webm',
102 files: [
103 {
104 resolution: 720,
105 size: 572456
106 }
107 ]
108 }
84 109
85 const res = await getVideosList(server.url) 110 const res = await getVideosList(server.url)
86
87 const videos = res.body.data 111 const videos = res.body.data
88 expect(videos).to.be.an('array') 112 expect(videos).to.be.an('array')
89 expect(videos.length).to.equal(1) 113 expect(videos.length).to.equal(1)
90 const video = videos[0] 114 const video = videos[0]
91 expect(video.name).to.equal('my super name for server 1')
92 expect(video.category).to.equal(5)
93 expect(video.categoryLabel).to.equal('Sports')
94 expect(video.licence).to.equal(4)
95 expect(video.licenceLabel).to.equal('Attribution - Non Commercial')
96 expect(video.language).to.equal(9)
97 expect(video.languageLabel).to.equal('Japanese')
98 expect(video.nsfw).to.be.ok
99 expect(video.description).to.equal('my super description for server 1')
100 expect(video.serverHost).to.equal('localhost:9001')
101 expect(video.duration).to.equal(10)
102 expect(dateIsValid(video.createdAt)).to.be.true
103 expect(dateIsValid(video.updatedAt)).to.be.true
104 expect(video.accountName).to.equal('root')
105
106 const res2 = await getVideo(server.url, video.uuid)
107 const videoDetails = res2.body
108
109 expect(videoDetails.channel.name).to.equal('my channel')
110 expect(videoDetails.channel.description).to.equal('super channel')
111 expect(videoDetails.account.name).to.equal('root')
112 expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true
113 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
114 expect(videoDetails.files).to.have.lengthOf(1)
115 expect(videoDetails.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
116
117 const file = videoDetails.files[0]
118 const magnetUri = file.magnetUri
119 expect(file.magnetUri).to.have.lengthOf.above(2)
120 expect(file.torrentUrl).to
121 .equal(`http://${videoDetails.serverHost}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
122 expect(file.fileUrl).to.equal(`http://${videoDetails.serverHost}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
123 expect(file.resolution).to.equal(720)
124 expect(file.resolutionLabel).to.equal('720p')
125 expect(file.size).to.equal(572456)
126
127 if (server.url !== 'http://localhost:9001') {
128 expect(video.isLocal).to.be.false
129 expect(videoDetails.channel.isLocal).to.be.false
130 } else {
131 expect(video.isLocal).to.be.true
132 expect(videoDetails.channel.isLocal).to.be.true
133 }
134 115
135 // All servers should have the same magnet Uri 116 await completeVideoCheck(server.url, video, checkAttributes)
136 if (baseMagnet === null) {
137 baseMagnet = magnetUri
138 } else {
139 expect(baseMagnet).to.equal(magnetUri)
140 }
141
142 const test = await testVideoImage(server.url, 'video_short1.webm', video.thumbnailPath)
143 expect(test).to.equal(true)
144 } 117 }
145 }) 118 })
146 119
@@ -171,79 +144,53 @@ describe('Test multiple servers', function () {
171 144
172 // All servers should have this video 145 // All servers should have this video
173 for (const server of servers) { 146 for (const server of servers) {
174 let baseMagnet = {} 147 const isLocal = server.url === 'http://localhost:9002'
148 const checkAttributes = {
149 name: 'my super name for server 2',
150 category: 4,
151 licence: 3,
152 language: 11,
153 nsfw: true,
154 description: 'my super description for server 2',
155 host: 'localhost:9002',
156 account: 'user1',
157 isLocal,
158 duration: 5,
159 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
160 privacy: VideoPrivacy.PUBLIC,
161 channel: {
162 name: 'Default user1 channel',
163 description: 'super channel',
164 isLocal
165 },
166 fixture: 'video_short2.webm',
167 files: [
168 {
169 resolution: 240,
170 size: 190000
171 },
172 {
173 resolution: 360,
174 size: 280000
175 },
176 {
177 resolution: 480,
178 size: 390000
179 },
180 {
181 resolution: 720,
182 size: 710000
183 }
184 ]
185 }
175 186
176 const res = await getVideosList(server.url) 187 const res = await getVideosList(server.url)
177
178 const videos = res.body.data 188 const videos = res.body.data
179 expect(videos).to.be.an('array') 189 expect(videos).to.be.an('array')
180 expect(videos.length).to.equal(2) 190 expect(videos.length).to.equal(2)
181 const video = videos[1] 191 const video = videos[1]
182 expect(video.name).to.equal('my super name for server 2')
183 expect(video.category).to.equal(4)
184 expect(video.categoryLabel).to.equal('Art')
185 expect(video.licence).to.equal(3)
186 expect(video.licenceLabel).to.equal('Attribution - No Derivatives')
187 expect(video.language).to.equal(11)
188 expect(video.languageLabel).to.equal('German')
189 expect(video.nsfw).to.be.true
190 expect(video.description).to.equal('my super description for server 2')
191 expect(video.serverHost).to.equal('localhost:9002')
192 expect(video.duration).to.equal(5)
193 expect(dateIsValid(video.createdAt)).to.be.true
194 expect(dateIsValid(video.updatedAt)).to.be.true
195 expect(video.accountName).to.equal('user1')
196
197 if (server.url !== 'http://localhost:9002') {
198 expect(video.isLocal).to.be.false
199 } else {
200 expect(video.isLocal).to.be.true
201 }
202
203 const res2 = await getVideo(server.url, video.uuid)
204 const videoDetails = res2.body
205
206 expect(videoDetails.channel.name).to.equal('Default user1 channel')
207 expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true
208 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
209 expect(videoDetails.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
210
211 expect(videoDetails.files).to.have.lengthOf(4)
212
213 // Check common attributes
214 for (const file of videoDetails.files) {
215 expect(file.magnetUri).to.have.lengthOf.above(2)
216
217 // All servers should have the same magnet Uri
218 if (baseMagnet[file.resolution] === undefined) {
219 baseMagnet[file.resolution] = file.magnet
220 } else {
221 expect(baseMagnet[file.resolution]).to.equal(file.magnet)
222 }
223 }
224 192
225 const file240p = videoDetails.files.find(f => f.resolution === 240) 193 await completeVideoCheck(server.url, video, checkAttributes)
226 expect(file240p).not.to.be.undefined
227 expect(file240p.resolutionLabel).to.equal('240p')
228 expect(file240p.size).to.be.above(180000).and.below(200000)
229
230 const file360p = videoDetails.files.find(f => f.resolution === 360)
231 expect(file360p).not.to.be.undefined
232 expect(file360p.resolutionLabel).to.equal('360p')
233 expect(file360p.size).to.be.above(270000).and.below(290000)
234
235 const file480p = videoDetails.files.find(f => f.resolution === 480)
236 expect(file480p).not.to.be.undefined
237 expect(file480p.resolutionLabel).to.equal('480p')
238 expect(file480p.size).to.be.above(380000).and.below(400000)
239
240 const file720p = videoDetails.files.find(f => f.resolution === 720)
241 expect(file720p).not.to.be.undefined
242 expect(file720p.resolutionLabel).to.equal('720p')
243 expect(file720p.size).to.be.above(700000).and.below(7200000)
244
245 const test = await testVideoImage(server.url, 'video_short2.webm', videoDetails.thumbnailPath)
246 expect(test).to.equal(true)
247 } 194 }
248 }) 195 })
249 196
@@ -276,9 +223,9 @@ describe('Test multiple servers', function () {
276 223
277 await wait(10000) 224 await wait(10000)
278 225
279 let baseMagnet = null
280 // All servers should have this video 226 // All servers should have this video
281 for (const server of servers) { 227 for (const server of servers) {
228 const isLocal = server.url === 'http://localhost:9003'
282 const res = await getVideosList(server.url) 229 const res = await getVideosList(server.url)
283 230
284 const videos = res.body.data 231 const videos = res.body.data
@@ -296,80 +243,61 @@ describe('Test multiple servers', function () {
296 video2 = videos[2] 243 video2 = videos[2]
297 } 244 }
298 245
299 expect(video1.name).to.equal('my super name for server 3') 246 const checkAttributesVideo1 = {
300 expect(video1.category).to.equal(6) 247 name: 'my super name for server 3',
301 expect(video1.categoryLabel).to.equal('Travels') 248 category: 6,
302 expect(video1.licence).to.equal(5) 249 licence: 5,
303 expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike') 250 language: 11,
304 expect(video1.language).to.equal(11) 251 nsfw: true,
305 expect(video1.languageLabel).to.equal('German') 252 description: 'my super description for server 3',
306 expect(video1.nsfw).to.be.ok 253 host: 'localhost:9003',
307 expect(video1.description).to.equal('my super description for server 3') 254 account: 'root',
308 expect(video1.serverHost).to.equal('localhost:9003') 255 isLocal,
309 expect(video1.duration).to.equal(5) 256 duration: 5,
310 expect(video1.accountName).to.equal('root') 257 tags: [ 'tag1p3' ],
311 expect(dateIsValid(video1.createdAt)).to.be.true 258 privacy: VideoPrivacy.PUBLIC,
312 expect(dateIsValid(video1.updatedAt)).to.be.true 259 channel: {
313 260 name: 'Default root channel',
314 const res2 = await getVideo(server.url, video1.id) 261 description: '',
315 const video1Details = res2.body 262 isLocal
316 expect(video1Details.files).to.have.lengthOf(1) 263 },
317 expect(video1Details.tags).to.deep.equal([ 'tag1p3' ]) 264 fixture: 'video_short3.webm',
318 265 files: [
319 const file1 = video1Details.files[0] 266 {
320 expect(file1.magnetUri).to.have.lengthOf.above(2) 267 resolution: 720,
321 expect(file1.resolution).to.equal(720) 268 size: 292677
322 expect(file1.resolutionLabel).to.equal('720p') 269 }
323 expect(file1.size).to.equal(292677) 270 ]
324
325 expect(video2.name).to.equal('my super name for server 3-2')
326 expect(video2.category).to.equal(7)
327 expect(video2.categoryLabel).to.equal('Gaming')
328 expect(video2.licence).to.equal(6)
329 expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
330 expect(video2.language).to.equal(12)
331 expect(video2.languageLabel).to.equal('Korean')
332 expect(video2.nsfw).to.be.false
333 expect(video2.description).to.equal('my super description for server 3-2')
334 expect(video2.serverHost).to.equal('localhost:9003')
335 expect(video2.duration).to.equal(5)
336 expect(video2.accountName).to.equal('root')
337 expect(dateIsValid(video2.createdAt)).to.be.true
338 expect(dateIsValid(video2.updatedAt)).to.be.true
339
340 const res3 = await getVideo(server.url, video2.id)
341 const video2Details = res3.body
342 expect(video2Details.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
343
344 expect(video2Details.files).to.have.lengthOf(1)
345
346 const file2 = video2Details.files[0]
347 const magnetUri2 = file2.magnetUri
348 expect(file2.magnetUri).to.have.lengthOf.above(2)
349 expect(file2.resolution).to.equal(720)
350 expect(file2.resolutionLabel).to.equal('720p')
351 expect(file2.size).to.equal(218910)
352
353 if (server.url !== 'http://localhost:9003') {
354 expect(video1.isLocal).to.be.false
355 expect(video2.isLocal).to.be.false
356 } else {
357 expect(video1.isLocal).to.be.true
358 expect(video2.isLocal).to.be.true
359 } 271 }
360 272 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
361 // All servers should have the same magnet Uri 273
362 if (baseMagnet === null) { 274 const checkAttributesVideo2 = {
363 baseMagnet = magnetUri2 275 name: 'my super name for server 3-2',
364 } else { 276 category: 7,
365 expect(baseMagnet).to.equal(magnetUri2) 277 licence: 6,
278 language: 12,
279 nsfw: false,
280 description: 'my super description for server 3-2',
281 host: 'localhost:9003',
282 account: 'root',
283 isLocal,
284 duration: 5,
285 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
286 privacy: VideoPrivacy.PUBLIC,
287 channel: {
288 name: 'Default root channel',
289 description: '',
290 isLocal
291 },
292 fixture: 'video_short3.webm',
293 files: [
294 {
295 resolution: 720,
296 size: 218910
297 }
298 ]
366 } 299 }
367 300 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
368 const test1 = await testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath)
369 expect(test1).to.equal(true)
370
371 const test2 = await testVideoImage(server.url, 'video_short.webm', video2.thumbnailPath)
372 expect(test2).to.equal(true)
373 } 301 }
374 }) 302 })
375 }) 303 })
@@ -387,7 +315,7 @@ describe('Test multiple servers', function () {
387 const res2 = await getVideo(servers[2].url, video.id) 315 const res2 = await getVideo(servers[2].url, video.id)
388 const videoDetails = res2.body 316 const videoDetails = res2.body
389 317
390 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) 318 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
391 expect(torrent.files).to.be.an('array') 319 expect(torrent.files).to.be.an('array')
392 expect(torrent.files.length).to.equal(1) 320 expect(torrent.files.length).to.equal(1)
393 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 321 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
@@ -402,7 +330,7 @@ describe('Test multiple servers', function () {
402 const res2 = await getVideo(servers[0].url, video.id) 330 const res2 = await getVideo(servers[0].url, video.id)
403 const videoDetails = res2.body 331 const videoDetails = res2.body
404 332
405 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) 333 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
406 expect(torrent.files).to.be.an('array') 334 expect(torrent.files).to.be.an('array')
407 expect(torrent.files.length).to.equal(1) 335 expect(torrent.files.length).to.equal(1)
408 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 336 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
@@ -417,7 +345,7 @@ describe('Test multiple servers', function () {
417 const res2 = await getVideo(servers[1].url, video.id) 345 const res2 = await getVideo(servers[1].url, video.id)
418 const videoDetails = res2.body 346 const videoDetails = res2.body
419 347
420 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) 348 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
421 expect(torrent.files).to.be.an('array') 349 expect(torrent.files).to.be.an('array')
422 expect(torrent.files.length).to.equal(1) 350 expect(torrent.files.length).to.equal(1)
423 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 351 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
@@ -603,37 +531,36 @@ describe('Test multiple servers', function () {
603 531
604 const videos = res.body.data 532 const videos = res.body.data
605 const videoUpdated = videos.find(video => video.name === 'my super video updated') 533 const videoUpdated = videos.find(video => video.name === 'my super video updated')
606
607 expect(!!videoUpdated).to.be.true 534 expect(!!videoUpdated).to.be.true
608 expect(videoUpdated.category).to.equal(10)
609 expect(videoUpdated.categoryLabel).to.equal('Entertainment')
610 expect(videoUpdated.licence).to.equal(7)
611 expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication')
612 expect(videoUpdated.language).to.equal(13)
613 expect(videoUpdated.languageLabel).to.equal('French')
614 expect(videoUpdated.nsfw).to.be.ok
615 expect(videoUpdated.description).to.equal('my super description updated')
616 expect(dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
617
618 const res2 = await getVideo(server.url, videoUpdated.uuid)
619 const videoUpdatedDetails = res2.body
620 expect(videoUpdatedDetails.tags).to.deep.equal([ 'tag_up_1', 'tag_up_2' ])
621
622 const file = videoUpdatedDetails.files[0]
623 expect(file.magnetUri).to.have.lengthOf.above(2)
624 expect(file.resolution).to.equal(720)
625 expect(file.resolutionLabel).to.equal('720p')
626 expect(file.size).to.equal(292677)
627
628 const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath)
629 expect(test).to.equal(true)
630 535
631 // Avoid "duplicate torrent" errors 536 const isLocal = server.url === 'http://localhost:9003'
632 const refreshWebTorrent = true 537 const checkAttributes = {
633 const torrent = await webtorrentAdd(videoUpdatedDetails .files[0].magnetUri, refreshWebTorrent) 538 name: 'my super video updated',
634 expect(torrent.files).to.be.an('array') 539 category: 10,
635 expect(torrent.files.length).to.equal(1) 540 licence: 7,
636 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 541 language: 13,
542 nsfw: true,
543 description: 'my super description updated',
544 host: 'localhost:9003',
545 account: 'root',
546 isLocal,
547 duration: 5,
548 tags: [ 'tag_up_1', 'tag_up_2' ],
549 privacy: VideoPrivacy.PUBLIC,
550 channel: {
551 name: 'Default root channel',
552 description: '',
553 isLocal
554 },
555 fixture: 'video_short3.webm',
556 files: [
557 {
558 resolution: 720,
559 size: 292677
560 }
561 ]
562 }
563 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
637 } 564 }
638 }) 565 })
639 566
@@ -833,19 +760,46 @@ describe('Test multiple servers', function () {
833 const res = await getVideosList(server.url) 760 const res = await getVideosList(server.url)
834 const video = res.body.data.find(v => v.name === 'minimum parameters') 761 const video = res.body.data.find(v => v.name === 'minimum parameters')
835 762
836 expect(video.name).to.equal('minimum parameters') 763 const isLocal = server.url === 'http://localhost:9002'
837 expect(video.category).to.equal(null) 764 const checkAttributes = {
838 expect(video.categoryLabel).to.equal('Misc') 765 name: 'minimum parameters',
839 expect(video.licence).to.equal(null) 766 category: null,
840 expect(video.licenceLabel).to.equal('Unknown') 767 licence: null,
841 expect(video.language).to.equal(null) 768 language: null,
842 expect(video.languageLabel).to.equal('Unknown') 769 nsfw: false,
843 expect(video.nsfw).to.not.be.ok 770 description: null,
844 expect(video.description).to.equal(null) 771 host: 'localhost:9002',
845 expect(video.serverHost).to.equal('localhost:9002') 772 account: 'root',
846 expect(video.accountName).to.equal('root') 773 isLocal,
847 expect(dateIsValid(video.createdAt)).to.be.true 774 duration: 5,
848 expect(dateIsValid(video.updatedAt)).to.be.true 775 tags: [ ],
776 privacy: VideoPrivacy.PUBLIC,
777 channel: {
778 name: 'Default root channel',
779 description: '',
780 isLocal
781 },
782 fixture: 'video_short.webm',
783 files: [
784 {
785 resolution: 720,
786 size: 40315
787 },
788 {
789 resolution: 480,
790 size: 22808
791 },
792 {
793 resolution: 360,
794 size: 18617
795 },
796 {
797 resolution: 240,
798 size: 15217
799 }
800 ]
801 }
802 await completeVideoCheck(server.url, video, checkAttributes)
849 } 803 }
850 }) 804 })
851 }) 805 })
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 831be3422..934c653b1 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -52,10 +52,12 @@ describe('Test a single server', function () {
52 host: 'localhost:9001', 52 host: 'localhost:9001',
53 account: 'root', 53 account: 'root',
54 isLocal: true, 54 isLocal: true,
55 duration: 5,
55 tags: [ 'tag1', 'tag2', 'tag3' ], 56 tags: [ 'tag1', 'tag2', 'tag3' ],
56 privacy: VideoPrivacy.PUBLIC, 57 privacy: VideoPrivacy.PUBLIC,
57 channel: { 58 channel: {
58 name: 'Default root channel', 59 name: 'Default root channel',
60 description: '',
59 isLocal: true 61 isLocal: true
60 }, 62 },
61 fixture: 'video_short.webm', 63 fixture: 'video_short.webm',
@@ -79,8 +81,10 @@ describe('Test a single server', function () {
79 isLocal: true, 81 isLocal: true,
80 tags: [ 'tagup1', 'tagup2' ], 82 tags: [ 'tagup1', 'tagup2' ],
81 privacy: VideoPrivacy.PUBLIC, 83 privacy: VideoPrivacy.PUBLIC,
84 duration: 5,
82 channel: { 85 channel: {
83 name: 'Default root channel', 86 name: 'Default root channel',
87 description: '',
84 isLocal: true 88 isLocal: true
85 }, 89 },
86 fixture: 'video_short3.webm', 90 fixture: 'video_short3.webm',