diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/video-captions.ts | 35 | ||||
-rw-r--r-- | server/tests/api/videos/video-captions.ts | 53 |
2 files changed, 86 insertions, 2 deletions
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 12f890db8..a3d7ac35d 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { | 4 | import { |
6 | createUser, | 5 | createUser, |
@@ -127,6 +126,40 @@ describe('Test video captions API validator', function () { | |||
127 | }) | 126 | }) |
128 | }) | 127 | }) |
129 | 128 | ||
129 | it('Should fail with an invalid captionfile extension', async function () { | ||
130 | const attaches = { | ||
131 | 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt') | ||
132 | } | ||
133 | |||
134 | const captionPath = path + videoUUID + '/captions/fr' | ||
135 | await makeUploadRequest({ | ||
136 | method: 'PUT', | ||
137 | url: server.url, | ||
138 | path: captionPath, | ||
139 | token: server.accessToken, | ||
140 | fields, | ||
141 | attaches, | ||
142 | statusCodeExpected: 400 | ||
143 | }) | ||
144 | }) | ||
145 | |||
146 | // it('Should fail with an invalid captionfile srt', async function () { | ||
147 | // const attaches = { | ||
148 | // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.srt') | ||
149 | // } | ||
150 | // | ||
151 | // const captionPath = path + videoUUID + '/captions/fr' | ||
152 | // await makeUploadRequest({ | ||
153 | // method: 'PUT', | ||
154 | // url: server.url, | ||
155 | // path: captionPath, | ||
156 | // token: server.accessToken, | ||
157 | // fields, | ||
158 | // attaches, | ||
159 | // statusCodeExpected: 500 | ||
160 | // }) | ||
161 | // }) | ||
162 | |||
130 | it('Should success with the correct parameters', async function () { | 163 | it('Should success with the correct parameters', async function () { |
131 | const captionPath = path + videoUUID + '/captions/fr' | 164 | const captionPath = path + videoUUID + '/captions/fr' |
132 | await makeUploadRequest({ | 165 | await makeUploadRequest({ |
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index cbf5268f0..eb73c5baf 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.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 { doubleFollow, flushAndRunMultipleServers, uploadVideo } from '../../utils' | 5 | import { checkVideoFilesWereRemoved, doubleFollow, flushAndRunMultipleServers, removeVideo, uploadVideo, wait } from '../../utils' |
6 | import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' | 6 | import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' |
7 | import { waitJobs } from '../../utils/server/jobs' | 7 | import { waitJobs } from '../../utils/server/jobs' |
8 | import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions' | 8 | import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions' |
@@ -110,6 +110,51 @@ describe('Test video captions', function () { | |||
110 | } | 110 | } |
111 | }) | 111 | }) |
112 | 112 | ||
113 | it('Should replace an existing caption with a srt file and convert it', async function () { | ||
114 | this.timeout(30000) | ||
115 | |||
116 | await createVideoCaption({ | ||
117 | url: servers[0].url, | ||
118 | accessToken: servers[0].accessToken, | ||
119 | language: 'ar', | ||
120 | videoId: videoUUID, | ||
121 | fixture: 'subtitle-good.srt' | ||
122 | }) | ||
123 | |||
124 | await waitJobs(servers) | ||
125 | |||
126 | // Cache invalidation | ||
127 | await wait(3000) | ||
128 | }) | ||
129 | |||
130 | it('Should have this caption updated and converted', async function () { | ||
131 | for (const server of servers) { | ||
132 | const res = await listVideoCaptions(server.url, videoUUID) | ||
133 | expect(res.body.total).to.equal(2) | ||
134 | expect(res.body.data).to.have.lengthOf(2) | ||
135 | |||
136 | const caption1: VideoCaption = res.body.data[0] | ||
137 | expect(caption1.language.id).to.equal('ar') | ||
138 | expect(caption1.language.label).to.equal('Arabic') | ||
139 | expect(caption1.captionPath).to.equal('/static/video-captions/' + videoUUID + '-ar.vtt') | ||
140 | |||
141 | const expected = 'WEBVTT FILE\r\n' + | ||
142 | '\r\n' + | ||
143 | '1\r\n' + | ||
144 | '00:00:01.600 --> 00:00:04.200\r\n' + | ||
145 | 'English (US)\r\n' + | ||
146 | '\r\n' + | ||
147 | '2\r\n' + | ||
148 | '00:00:05.900 --> 00:00:07.999\r\n' + | ||
149 | 'This is a subtitle in American English\r\n' + | ||
150 | '\r\n' + | ||
151 | '3\r\n' + | ||
152 | '00:00:10.000 --> 00:00:14.000\r\n' + | ||
153 | 'Adding subtitles is very easy to do\r\n' | ||
154 | await testCaptionFile(server.url, caption1.captionPath, expected) | ||
155 | } | ||
156 | }) | ||
157 | |||
113 | it('Should remove one caption', async function () { | 158 | it('Should remove one caption', async function () { |
114 | this.timeout(30000) | 159 | this.timeout(30000) |
115 | 160 | ||
@@ -133,6 +178,12 @@ describe('Test video captions', function () { | |||
133 | } | 178 | } |
134 | }) | 179 | }) |
135 | 180 | ||
181 | it('Should remove the video, and thus all video captions', async function () { | ||
182 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) | ||
183 | |||
184 | await checkVideoFilesWereRemoved(videoUUID, 1) | ||
185 | }) | ||
186 | |||
136 | after(async function () { | 187 | after(async function () { |
137 | killallServers(servers) | 188 | killallServers(servers) |
138 | }) | 189 | }) |