diff options
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 440 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 4 |
2 files changed, 201 insertions, 243 deletions
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' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import * as request from 'supertest' | 6 | import * as request from 'supertest' |
7 | import { VideoPrivacy } from '../../../../shared/models/videos' | ||
7 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' | 8 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' |
8 | 9 | ||
9 | import { | 10 | import { |
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' |
14 | import { createUser } from '../../utils/users/users' | ||
15 | import { | 15 | import { |
16 | addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, | 16 | addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, |
17 | getVideoThreadComments | 17 | getVideoThreadComments |
18 | } from '../../utils/videos/video-comments' | 18 | } from '../../utils/videos/video-comments' |
19 | import { viewVideo } from '../../utils/videos/videos' | ||
20 | 19 | ||
21 | const expect = chai.expect | 20 | const 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', |