aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-15 14:16:40 +0200
committerChocobozzz <me@florianbigard.com>2020-04-15 14:16:40 +0200
commit62068f4153cb1e67fe30a7f92947c3f2ec058c73 (patch)
tree9253408bc4e96f3dac4afe230eafecc1356c49d8 /server/tests/api
parentf757be65b8dc2d3b286b5d8b22c64637d7bc2fb8 (diff)
parent652c64165b3d8d1c5d5fc646c29e5cd1c82a3330 (diff)
downloadPeerTube-62068f4153cb1e67fe30a7f92947c3f2ec058c73.tar.gz
PeerTube-62068f4153cb1e67fe30a7f92947c3f2ec058c73.tar.zst
PeerTube-62068f4153cb1e67fe30a7f92947c3f2ec058c73.zip
Merge branch 'pr/2629' into develop
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/videos/video-imports.ts50
1 files changed, 48 insertions, 2 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index a67e528c6..8e179b825 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos' 5import { VideoDetails, VideoImport, VideoPrivacy, VideoCaption } from '../../../../shared/models/videos'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
@@ -11,6 +11,8 @@ import {
11 getMyVideos, 11 getMyVideos,
12 getVideo, 12 getVideo,
13 getVideosList, 13 getVideosList,
14 listVideoCaptions,
15 testCaptionFile,
14 immutableAssign, 16 immutableAssign,
15 ServerInfo, 17 ServerInfo,
16 setAccessTokensToServers 18 setAccessTokensToServers
@@ -60,11 +62,14 @@ describe('Test video imports', function () {
60 62
61 expect(videoTorrent.name).to.contain('你好 世界 720p.mp4') 63 expect(videoTorrent.name).to.contain('你好 世界 720p.mp4')
62 expect(videoMagnet.name).to.contain('super peertube2 video') 64 expect(videoMagnet.name).to.contain('super peertube2 video')
65
66 const resCaptions = await listVideoCaptions(url, idHttp)
67 expect(resCaptions.body.total).to.equal(2)
63 } 68 }
64 69
65 async function checkVideoServer2 (url: string, id: number | string) { 70 async function checkVideoServer2 (url: string, id: number | string) {
66 const res = await getVideo(url, id) 71 const res = await getVideo(url, id)
67 const video = res.body 72 const video: VideoDetails = res.body
68 73
69 expect(video.name).to.equal('my super name') 74 expect(video.name).to.equal('my super name')
70 expect(video.category.label).to.equal('Entertainment') 75 expect(video.category.label).to.equal('Entertainment')
@@ -75,6 +80,9 @@ describe('Test video imports', function () {
75 expect(video.tags).to.deep.equal([ 'supertag1', 'supertag2' ]) 80 expect(video.tags).to.deep.equal([ 'supertag1', 'supertag2' ])
76 81
77 expect(video.files).to.have.lengthOf(1) 82 expect(video.files).to.have.lengthOf(1)
83
84 const resCaptions = await listVideoCaptions(url, id)
85 expect(resCaptions.body.total).to.equal(2)
78 } 86 }
79 87
80 before(async function () { 88 before(async function () {
@@ -110,6 +118,44 @@ describe('Test video imports', function () {
110 const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) 118 const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() })
111 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) 119 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
112 expect(res.body.video.name).to.equal('small video - youtube') 120 expect(res.body.video.name).to.equal('small video - youtube')
121
122 const resCaptions = await listVideoCaptions(servers[0].url, res.body.video.id)
123 const videoCaptions: VideoCaption[] = resCaptions.body.data
124 expect(videoCaptions).to.have.lengthOf(2)
125
126 const enCaption = videoCaptions.find(caption => caption.language.id === 'en')
127 expect(enCaption).to.exist
128 expect(enCaption.language.label).to.equal('English')
129 expect(enCaption.captionPath).to.equal(`/static/video-captions/${res.body.video.uuid}-en.vtt`)
130 await testCaptionFile(servers[0].url, enCaption.captionPath, `WEBVTT
131Kind: captions
132Language: en
133
13400:00:01.600 --> 00:00:04.200
135English (US)
136
13700:00:05.900 --> 00:00:07.999
138This is a subtitle in American English
139
14000:00:10.000 --> 00:00:14.000
141Adding subtitles is very easy to do`)
142
143 const frCaption = videoCaptions.find(caption => caption.language.id === 'fr')
144 expect(frCaption).to.exist
145 expect(frCaption.language.label).to.equal('French')
146 expect(frCaption.captionPath).to.equal(`/static/video-captions/${res.body.video.uuid}-fr.vtt`)
147 await testCaptionFile(servers[0].url, frCaption.captionPath, `WEBVTT
148Kind: captions
149Language: fr
150
15100:00:01.600 --> 00:00:04.200
152Français (FR)
153
15400:00:05.900 --> 00:00:07.999
155C'est un sous-titre français
156
15700:00:10.000 --> 00:00:14.000
158Ajouter un sous-titre est vraiment facile`)
113 } 159 }
114 160
115 { 161 {