-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
+ cleanupTests,
createUser,
- flushTests,
- killallServers,
+ flushAndRunServer,
makeDeleteRequest,
makeGetRequest,
makeUploadRequest,
- runServer,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin
-} from '../../utils'
+} from '../../../../shared/extra-utils'
import { join } from 'path'
+import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions'
describe('Test video captions API validator', function () {
const path = '/api/v1/videos/'
before(async function () {
this.timeout(30000)
- await flushTests()
-
- server = await runServer(1)
+ server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
username: 'user1',
password: 'my super password'
}
- await createUser(server.url, server.accessToken, user.username, user.password)
+ await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
userAccessToken = await userLogin(server, user)
}
})
describe('When adding video caption', function () {
const fields = { }
const attaches = {
- 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt')
+ captionfile: join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt')
}
it('Should fail without a valid uuid', async function () {
})
})
- it('Should fail with an invalid captionfile extension', async function () {
- const attaches = {
- 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt')
- }
+ // We accept any file now
+ // 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
+ // })
+ // })
- const captionPath = path + videoUUID + '/captions/fr'
- await makeUploadRequest({
- method: 'PUT',
+ // 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,
- path: captionPath,
- token: server.accessToken,
- fields,
- attaches,
- statusCodeExpected: 400
+ 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')
})
after(async function () {
- killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ await cleanupTests([ server ])
})
})