diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-12 19:02:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-16 11:50:08 +0200 |
commit | 40e87e9ecc54e3513fb586928330a7855eb192c6 (patch) | |
tree | af1111ecba85f9cd8286811ff332a67cf21be2f6 /server/tests/utils | |
parent | d4557fd3ecc8d4ed4fb0e5c868929bc36c959ed2 (diff) | |
download | PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.tar.gz PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.tar.zst PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.zip |
Implement captions/subtitles
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/miscs/miscs.ts | 1 | ||||
-rw-r--r-- | server/tests/utils/videos/video-captions.ts | 66 |
2 files changed, 66 insertions, 1 deletions
diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts index 7ac60a983..5e46004a7 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/server/tests/utils/miscs/miscs.ts | |||
@@ -5,7 +5,6 @@ import { isAbsolute, join } from 'path' | |||
5 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
6 | import * as WebTorrent from 'webtorrent' | 6 | import * as WebTorrent from 'webtorrent' |
7 | import { readFileBufferPromise } from '../../../helpers/core-utils' | 7 | import { readFileBufferPromise } from '../../../helpers/core-utils' |
8 | import { ServerInfo } from '..' | ||
9 | 8 | ||
10 | const expect = chai.expect | 9 | const expect = chai.expect |
11 | let webtorrent = new WebTorrent() | 10 | let webtorrent = new WebTorrent() |
diff --git a/server/tests/utils/videos/video-captions.ts b/server/tests/utils/videos/video-captions.ts new file mode 100644 index 000000000..207e89632 --- /dev/null +++ b/server/tests/utils/videos/video-captions.ts | |||
@@ -0,0 +1,66 @@ | |||
1 | import { makeDeleteRequest, makeGetRequest } from '../' | ||
2 | import { buildAbsoluteFixturePath, makeUploadRequest } from '../index' | ||
3 | import * as request from 'supertest' | ||
4 | import * as chai from 'chai' | ||
5 | |||
6 | const expect = chai.expect | ||
7 | |||
8 | function createVideoCaption (args: { | ||
9 | url: string, | ||
10 | accessToken: string | ||
11 | videoId: string | number | ||
12 | language: string | ||
13 | fixture: string | ||
14 | }) { | ||
15 | const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language | ||
16 | |||
17 | return makeUploadRequest({ | ||
18 | method: 'PUT', | ||
19 | url: args.url, | ||
20 | path, | ||
21 | token: args.accessToken, | ||
22 | fields: {}, | ||
23 | attaches: { | ||
24 | captionfile: buildAbsoluteFixturePath(args.fixture) | ||
25 | }, | ||
26 | statusCodeExpected: 204 | ||
27 | }) | ||
28 | } | ||
29 | |||
30 | function listVideoCaptions (url: string, videoId: string | number) { | ||
31 | const path = '/api/v1/videos/' + videoId + '/captions' | ||
32 | |||
33 | return makeGetRequest({ | ||
34 | url, | ||
35 | path, | ||
36 | statusCodeExpected: 200 | ||
37 | }) | ||
38 | } | ||
39 | |||
40 | function deleteVideoCaption (url: string, token: string, videoId: string | number, language: string) { | ||
41 | const path = '/api/v1/videos/' + videoId + '/captions/' + language | ||
42 | |||
43 | return makeDeleteRequest({ | ||
44 | url, | ||
45 | token, | ||
46 | path, | ||
47 | statusCodeExpected: 204 | ||
48 | }) | ||
49 | } | ||
50 | |||
51 | async function testCaptionFile (url: string, captionPath: string, containsString: string) { | ||
52 | const res = await request(url) | ||
53 | .get(captionPath) | ||
54 | .expect(200) | ||
55 | |||
56 | expect(res.text).to.contain(containsString) | ||
57 | } | ||
58 | |||
59 | // --------------------------------------------------------------------------- | ||
60 | |||
61 | export { | ||
62 | createVideoCaption, | ||
63 | listVideoCaptions, | ||
64 | testCaptionFile, | ||
65 | deleteVideoCaption | ||
66 | } | ||