aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-imports.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-08 11:49:38 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commita2470c9f4bfc7f49f4b94de935bacdd53fd54f29 (patch)
treecb6b6b33d1a404fe31547c004241a7eb9743b64e /server/tests/api/videos/video-imports.ts
parente3d15a6a9aed97a004d9dac1b7a6499d794e080a (diff)
downloadPeerTube-a2470c9f4bfc7f49f4b94de935bacdd53fd54f29.tar.gz
PeerTube-a2470c9f4bfc7f49f4b94de935bacdd53fd54f29.tar.zst
PeerTube-a2470c9f4bfc7f49f4b94de935bacdd53fd54f29.zip
Introduce captions command
Diffstat (limited to 'server/tests/api/videos/video-imports.ts')
-rw-r--r--server/tests/api/videos/video-imports.ts33
1 files changed, 16 insertions, 17 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index a4a9132b4..14aed604f 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -11,7 +11,6 @@ import {
11 getVideo, 11 getVideo,
12 getVideosList, 12 getVideosList,
13 immutableAssign, 13 immutableAssign,
14 listVideoCaptions,
15 ServerInfo, 14 ServerInfo,
16 setAccessTokensToServers, 15 setAccessTokensToServers,
17 testCaptionFile 16 testCaptionFile
@@ -25,7 +24,7 @@ import {
25 getYoutubeVideoUrl, 24 getYoutubeVideoUrl,
26 importVideo 25 importVideo
27} from '../../../../shared/extra-utils/videos/video-imports' 26} from '../../../../shared/extra-utils/videos/video-imports'
28import { VideoCaption, VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos' 27import { VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos'
29 28
30const expect = chai.expect 29const expect = chai.expect
31 30
@@ -36,8 +35,8 @@ describe('Test video imports', function () {
36 35
37 if (areHttpImportTestsDisabled()) return 36 if (areHttpImportTestsDisabled()) return
38 37
39 async function checkVideosServer1 (url: string, idHttp: string, idMagnet: string, idTorrent: string) { 38 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
40 const resHttp = await getVideo(url, idHttp) 39 const resHttp = await getVideo(server.url, idHttp)
41 const videoHttp: VideoDetails = resHttp.body 40 const videoHttp: VideoDetails = resHttp.body
42 41
43 expect(videoHttp.name).to.equal('small video - youtube') 42 expect(videoHttp.name).to.equal('small video - youtube')
@@ -55,9 +54,9 @@ describe('Test video imports', function () {
55 expect(originallyPublishedAt.getMonth()).to.equal(0) 54 expect(originallyPublishedAt.getMonth()).to.equal(0)
56 expect(originallyPublishedAt.getFullYear()).to.equal(2019) 55 expect(originallyPublishedAt.getFullYear()).to.equal(2019)
57 56
58 const resMagnet = await getVideo(url, idMagnet) 57 const resMagnet = await getVideo(server.url, idMagnet)
59 const videoMagnet: VideoDetails = resMagnet.body 58 const videoMagnet: VideoDetails = resMagnet.body
60 const resTorrent = await getVideo(url, idTorrent) 59 const resTorrent = await getVideo(server.url, idTorrent)
61 const videoTorrent: VideoDetails = resTorrent.body 60 const videoTorrent: VideoDetails = resTorrent.body
62 61
63 for (const video of [ videoMagnet, videoTorrent ]) { 62 for (const video of [ videoMagnet, videoTorrent ]) {
@@ -73,12 +72,12 @@ describe('Test video imports', function () {
73 expect(videoTorrent.name).to.contain('你好 世界 720p.mp4') 72 expect(videoTorrent.name).to.contain('你好 世界 720p.mp4')
74 expect(videoMagnet.name).to.contain('super peertube2 video') 73 expect(videoMagnet.name).to.contain('super peertube2 video')
75 74
76 const resCaptions = await listVideoCaptions(url, idHttp) 75 const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: idHttp })
77 expect(resCaptions.body.total).to.equal(2) 76 expect(bodyCaptions.total).to.equal(2)
78 } 77 }
79 78
80 async function checkVideoServer2 (url: string, id: number | string) { 79 async function checkVideoServer2 (server: ServerInfo, id: number | string) {
81 const res = await getVideo(url, id) 80 const res = await getVideo(server.url, id)
82 const video: VideoDetails = res.body 81 const video: VideoDetails = res.body
83 82
84 expect(video.name).to.equal('my super name') 83 expect(video.name).to.equal('my super name')
@@ -91,8 +90,8 @@ describe('Test video imports', function () {
91 90
92 expect(video.files).to.have.lengthOf(1) 91 expect(video.files).to.have.lengthOf(1)
93 92
94 const resCaptions = await listVideoCaptions(url, id) 93 const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: id })
95 expect(resCaptions.body.total).to.equal(2) 94 expect(bodyCaptions.total).to.equal(2)
96 } 95 }
97 96
98 before(async function () { 97 before(async function () {
@@ -135,8 +134,8 @@ describe('Test video imports', function () {
135 await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath) 134 await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath)
136 await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath) 135 await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath)
137 136
138 const resCaptions = await listVideoCaptions(servers[0].url, res.body.video.id) 137 const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: res.body.video.id })
139 const videoCaptions: VideoCaption[] = resCaptions.body.data 138 const videoCaptions = bodyCaptions.data
140 expect(videoCaptions).to.have.lengthOf(2) 139 expect(videoCaptions).to.have.lengthOf(2)
141 140
142 const enCaption = videoCaptions.find(caption => caption.language.id === 'en') 141 const enCaption = videoCaptions.find(caption => caption.language.id === 'en')
@@ -241,7 +240,7 @@ Ajouter un sous-titre est vraiment facile`)
241 expect(res.body.data).to.have.lengthOf(3) 240 expect(res.body.data).to.have.lengthOf(3)
242 241
243 const [ videoHttp, videoMagnet, videoTorrent ] = res.body.data 242 const [ videoHttp, videoMagnet, videoTorrent ] = res.body.data
244 await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) 243 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
245 } 244 }
246 }) 245 })
247 246
@@ -273,10 +272,10 @@ Ajouter un sous-titre est vraiment facile`)
273 expect(res.body.total).to.equal(4) 272 expect(res.body.total).to.equal(4)
274 expect(res.body.data).to.have.lengthOf(4) 273 expect(res.body.data).to.have.lengthOf(4)
275 274
276 await checkVideoServer2(server.url, res.body.data[0].uuid) 275 await checkVideoServer2(server, res.body.data[0].uuid)
277 276
278 const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data 277 const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data
279 await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) 278 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
280 } 279 }
281 }) 280 })
282 281