diff options
Diffstat (limited to 'server/tests/api/videos/video-imports.ts')
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 50 |
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 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos' | 5 | import { VideoDetails, VideoImport, VideoPrivacy, VideoCaption } from '../../../../shared/models/videos' |
6 | import { | 6 | import { |
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 | ||
131 | Kind: captions | ||
132 | Language: en | ||
133 | |||
134 | 00:00:01.600 --> 00:00:04.200 | ||
135 | English (US) | ||
136 | |||
137 | 00:00:05.900 --> 00:00:07.999 | ||
138 | This is a subtitle in American English | ||
139 | |||
140 | 00:00:10.000 --> 00:00:14.000 | ||
141 | Adding 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 | ||
148 | Kind: captions | ||
149 | Language: fr | ||
150 | |||
151 | 00:00:01.600 --> 00:00:04.200 | ||
152 | Français (FR) | ||
153 | |||
154 | 00:00:05.900 --> 00:00:07.999 | ||
155 | C'est un sous-titre français | ||
156 | |||
157 | 00:00:10.000 --> 00:00:14.000 | ||
158 | Ajouter un sous-titre est vraiment facile`) | ||
113 | } | 159 | } |
114 | 160 | ||
115 | { | 161 | { |