diff options
author | kimsible <kimsible@users.noreply.github.com> | 2020-04-14 17:23:01 +0200 |
---|---|---|
committer | kimsible <kimsible@users.noreply.github.com> | 2020-04-14 17:23:01 +0200 |
commit | ba6e9e8f1df29a7f355636d48c2a608bc4cb54ec (patch) | |
tree | ba92cf3b6115a7bf738a799ff1ffbd4066740169 | |
parent | 50ad0a1c1699fb1799c9ba2a99bf888894f88df4 (diff) | |
download | PeerTube-ba6e9e8f1df29a7f355636d48c2a608bc4cb54ec.tar.gz PeerTube-ba6e9e8f1df29a7f355636d48c2a608bc4cb54ec.tar.zst PeerTube-ba6e9e8f1df29a7f355636d48c2a608bc4cb54ec.zip |
Add unit tests for captions via URL import
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 44 | ||||
-rw-r--r-- | shared/extra-utils/index.ts | 1 |
2 files changed, 44 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index a67e528c6..1e97cc6ca 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 |
@@ -110,6 +112,46 @@ describe('Test video imports', function () { | |||
110 | const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) | 112 | const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) |
111 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 113 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) |
112 | expect(res.body.video.name).to.equal('small video - youtube') | 114 | expect(res.body.video.name).to.equal('small video - youtube') |
115 | |||
116 | const resCaptions = await listVideoCaptions(servers[0].url, res.body.video.id) | ||
117 | const videoCaptions: VideoCaption[] = resCaptions.body | ||
118 | expect(videoCaptions).to.have.lengthOf(2) | ||
119 | |||
120 | const enCaption = videoCaptions.filter(caption => caption.language.label === 'en')[0] | ||
121 | expect(enCaption).to.not(undefined) | ||
122 | expect(enCaption.language.label).to.equal('en') | ||
123 | expect(enCaption.captionPath).to.equal(`/static/video-captions/${res.body.video.uuid}-en.vtt`) | ||
124 | await testCaptionFile(servers[0].url, enCaption.captionPath, `WEBVTT | ||
125 | |||
126 | 1 | ||
127 | 00:00:01.600 --> 00:00:04.200 | ||
128 | English (US) | ||
129 | |||
130 | 2 | ||
131 | 00:00:05.900 --> 00:00:07.999 | ||
132 | This is a subtitle in American English | ||
133 | |||
134 | 3 | ||
135 | 00:00:10.000 --> 00:00:14.000 | ||
136 | Adding subtitles is very easy to do`) | ||
137 | |||
138 | const frCaption = videoCaptions.filter(caption => caption.language.label === 'fr')[0] | ||
139 | expect(frCaption).to.not(undefined) | ||
140 | expect(frCaption.language.label).to.equal('fr') | ||
141 | expect(frCaption.captionPath).to.equal(`/static/video-captions/${res.body.video.uuid}-en.vtt`) | ||
142 | await testCaptionFile(servers[0].url, frCaption.captionPath, `WEBVTT | ||
143 | |||
144 | 1 | ||
145 | 00:00:01,600 --> 00:00:04.200 | ||
146 | Français (FR) | ||
147 | |||
148 | 2 | ||
149 | 00:00:05,900 --> 00:00:07.999 | ||
150 | C'est un sous-titre français | ||
151 | |||
152 | 3 | ||
153 | 00:00:10,000 --> 00:00:14.000 | ||
154 | Ajouter un sous-titre est vraiment facile`) | ||
113 | } | 155 | } |
114 | 156 | ||
115 | { | 157 | { |
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 78acf72aa..fd8fef5dc 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -18,6 +18,7 @@ export * from './users/users' | |||
18 | export * from './users/accounts' | 18 | export * from './users/accounts' |
19 | export * from './videos/video-abuses' | 19 | export * from './videos/video-abuses' |
20 | export * from './videos/video-blacklist' | 20 | export * from './videos/video-blacklist' |
21 | export * from './videos/video-captions' | ||
21 | export * from './videos/video-channels' | 22 | export * from './videos/video-channels' |
22 | export * from './videos/video-comments' | 23 | export * from './videos/video-comments' |
23 | export * from './videos/video-streaming-playlists' | 24 | export * from './videos/video-streaming-playlists' |