X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-captions.ts;h=e4d36fd4fe7e84c20cc87cbc454167c7ab323075;hb=ae28cdf327d782e629379eee1999096ca2a5d74b;hp=12f890db8114dceca0ce252123cf74fec9751e91;hpb=40e87e9ecc54e3513fb586928330a7855eb192c6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 12f890db8..e4d36fd4f 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts @@ -1,6 +1,5 @@ /* tslint:disable:no-unused-expression */ -import * as chai from 'chai' import 'mocha' import { createUser, @@ -14,8 +13,9 @@ import { setAccessTokensToServers, uploadVideo, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { join } from 'path' +import { createVideoCaption } from '../../../../shared/utils/videos/video-captions' describe('Test video captions API validator', function () { const path = '/api/v1/videos/' @@ -127,6 +127,65 @@ describe('Test video captions API validator', function () { }) }) + it('Should fail with an invalid captionfile extension', async function () { + const attaches = { + 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt') + } + + const captionPath = path + videoUUID + '/captions/fr' + await makeUploadRequest({ + method: 'PUT', + url: server.url, + path: captionPath, + token: server.accessToken, + fields, + attaches, + statusCodeExpected: 400 + }) + }) + + // We don't check the extension yet + // it('Should fail with an invalid captionfile extension and octet-stream mime type', async function () { + // await createVideoCaption({ + // url: server.url, + // accessToken: server.accessToken, + // language: 'zh', + // videoId: videoUUID, + // fixture: 'subtitle-bad.txt', + // mimeType: 'application/octet-stream', + // statusCodeExpected: 400 + // }) + // }) + + it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () { + await createVideoCaption({ + url: server.url, + accessToken: server.accessToken, + language: 'zh', + videoId: videoUUID, + fixture: 'subtitle-good.srt', + mimeType: 'application/octet-stream' + }) + }) + + // We don't check the file validity yet + // it('Should fail with an invalid captionfile srt', async function () { + // const attaches = { + // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.srt') + // } + // + // const captionPath = path + videoUUID + '/captions/fr' + // await makeUploadRequest({ + // method: 'PUT', + // url: server.url, + // path: captionPath, + // token: server.accessToken, + // fields, + // attaches, + // statusCodeExpected: 500 + // }) + // }) + it('Should success with the correct parameters', async function () { const captionPath = path + videoUUID + '/captions/fr' await makeUploadRequest({