aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-imports.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-imports.ts')
-rw-r--r--server/tests/api/videos/video-imports.ts54
1 files changed, 22 insertions, 32 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 052c052b4..31fdfe12e 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -7,9 +7,6 @@ import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getMyVideos,
11 getVideo,
12 getVideosList,
13 ImportsCommand, 10 ImportsCommand,
14 ServerInfo, 11 ServerInfo,
15 setAccessTokensToServers, 12 setAccessTokensToServers,
@@ -17,7 +14,7 @@ import {
17 testImage, 14 testImage,
18 waitJobs 15 waitJobs
19} from '@shared/extra-utils' 16} from '@shared/extra-utils'
20import { VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models' 17import { VideoPrivacy, VideoResolution } from '@shared/models'
21 18
22const expect = chai.expect 19const expect = chai.expect
23 20
@@ -29,8 +26,7 @@ describe('Test video imports', function () {
29 if (areHttpImportTestsDisabled()) return 26 if (areHttpImportTestsDisabled()) return
30 27
31 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) { 28 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
32 const resHttp = await getVideo(server.url, idHttp) 29 const videoHttp = await server.videosCommand.get({ id: idHttp })
33 const videoHttp: VideoDetails = resHttp.body
34 30
35 expect(videoHttp.name).to.equal('small video - youtube') 31 expect(videoHttp.name).to.equal('small video - youtube')
36 // FIXME: youtube-dl seems broken 32 // FIXME: youtube-dl seems broken
@@ -47,10 +43,8 @@ describe('Test video imports', function () {
47 expect(originallyPublishedAt.getMonth()).to.equal(0) 43 expect(originallyPublishedAt.getMonth()).to.equal(0)
48 expect(originallyPublishedAt.getFullYear()).to.equal(2019) 44 expect(originallyPublishedAt.getFullYear()).to.equal(2019)
49 45
50 const resMagnet = await getVideo(server.url, idMagnet) 46 const videoMagnet = await server.videosCommand.get({ id: idMagnet })
51 const videoMagnet: VideoDetails = resMagnet.body 47 const videoTorrent = await server.videosCommand.get({ id: idTorrent })
52 const resTorrent = await getVideo(server.url, idTorrent)
53 const videoTorrent: VideoDetails = resTorrent.body
54 48
55 for (const video of [ videoMagnet, videoTorrent ]) { 49 for (const video of [ videoMagnet, videoTorrent ]) {
56 expect(video.category.label).to.equal('Misc') 50 expect(video.category.label).to.equal('Misc')
@@ -70,8 +64,7 @@ describe('Test video imports', function () {
70 } 64 }
71 65
72 async function checkVideoServer2 (server: ServerInfo, id: number | string) { 66 async function checkVideoServer2 (server: ServerInfo, id: number | string) {
73 const res = await getVideo(server.url, id) 67 const video = await server.videosCommand.get({ id })
74 const video: VideoDetails = res.body
75 68
76 expect(video.name).to.equal('my super name') 69 expect(video.name).to.equal('my super name')
77 expect(video.category.label).to.equal('Entertainment') 70 expect(video.category.label).to.equal('Entertainment')
@@ -190,15 +183,14 @@ Ajouter un sous-titre est vraiment facile`)
190 }) 183 })
191 184
192 it('Should list the videos to import in my videos on server 1', async function () { 185 it('Should list the videos to import in my videos on server 1', async function () {
193 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5, 'createdAt') 186 const { total, data } = await servers[0].videosCommand.listMyVideos({ sort: 'createdAt' })
194 187
195 expect(res.body.total).to.equal(3) 188 expect(total).to.equal(3)
196 189
197 const videos = res.body.data 190 expect(data).to.have.lengthOf(3)
198 expect(videos).to.have.lengthOf(3) 191 expect(data[0].name).to.equal('small video - youtube')
199 expect(videos[0].name).to.equal('small video - youtube') 192 expect(data[1].name).to.equal('super peertube2 video')
200 expect(videos[1].name).to.equal('super peertube2 video') 193 expect(data[2].name).to.equal('你好 世界 720p.mp4')
201 expect(videos[2].name).to.equal('你好 世界 720p.mp4')
202 }) 194 })
203 195
204 it('Should list the videos to import in my imports on server 1', async function () { 196 it('Should list the videos to import in my imports on server 1', async function () {
@@ -229,11 +221,11 @@ Ajouter un sous-titre est vraiment facile`)
229 await waitJobs(servers) 221 await waitJobs(servers)
230 222
231 for (const server of servers) { 223 for (const server of servers) {
232 const res = await getVideosList(server.url) 224 const { total, data } = await server.videosCommand.list()
233 expect(res.body.total).to.equal(3) 225 expect(total).to.equal(3)
234 expect(res.body.data).to.have.lengthOf(3) 226 expect(data).to.have.lengthOf(3)
235 227
236 const [ videoHttp, videoMagnet, videoTorrent ] = res.body.data 228 const [ videoHttp, videoMagnet, videoTorrent ] = data
237 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) 229 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
238 } 230 }
239 }) 231 })
@@ -262,13 +254,13 @@ Ajouter un sous-titre est vraiment facile`)
262 await waitJobs(servers) 254 await waitJobs(servers)
263 255
264 for (const server of servers) { 256 for (const server of servers) {
265 const res = await getVideosList(server.url) 257 const { total, data } = await server.videosCommand.list()
266 expect(res.body.total).to.equal(4) 258 expect(total).to.equal(4)
267 expect(res.body.data).to.have.lengthOf(4) 259 expect(data).to.have.lengthOf(4)
268 260
269 await checkVideoServer2(server, res.body.data[0].uuid) 261 await checkVideoServer2(server, data[0].uuid)
270 262
271 const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data 263 const [ , videoHttp, videoMagnet, videoTorrent ] = data
272 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) 264 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
273 } 265 }
274 }) 266 })
@@ -288,8 +280,7 @@ Ajouter un sous-titre est vraiment facile`)
288 await waitJobs(servers) 280 await waitJobs(servers)
289 281
290 for (const server of servers) { 282 for (const server of servers) {
291 const res = await getVideo(server.url, videoUUID) 283 const video = await server.videosCommand.get({ id: videoUUID })
292 const video: VideoDetails = res.body
293 284
294 expect(video.name).to.equal('transcoded video') 285 expect(video.name).to.equal('transcoded video')
295 expect(video.files).to.have.lengthOf(4) 286 expect(video.files).to.have.lengthOf(4)
@@ -339,8 +330,7 @@ Ajouter un sous-titre est vraiment facile`)
339 await waitJobs(servers) 330 await waitJobs(servers)
340 331
341 // test resolution 332 // test resolution
342 const res2 = await getVideo(servers[0].url, videoUUID) 333 const video = await servers[0].videosCommand.get({ id: videoUUID })
343 const video: VideoDetails = res2.body
344 expect(video.name).to.equal('hdr video') 334 expect(video.name).to.equal('hdr video')
345 const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id })) 335 const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id }))
346 expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) 336 expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P)