import { join } from 'path'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import {
- createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest,
- makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin
-} from '../../../../shared/utils'
+ cleanupTests,
+ createUser,
+ flushAndRunServer,
+ getMyUserInformation,
+ getVideo,
+ getVideosList,
+ immutableAssign,
+ makeDeleteRequest,
+ makeGetRequest,
+ makePutBodyRequest,
+ makeUploadRequest,
+ removeVideo,
+ ServerInfo,
+ setAccessTokensToServers,
+ userLogin,
+ root
+} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
-} from '../../../../shared/utils/requests/check-api-params'
-import { getAccountsList } from '../../../../shared/utils/users/accounts'
+} from '../../../../shared/extra-utils/requests/check-api-params'
const expect = chai.expect
before(async function () {
this.timeout(30000)
- await flushTests()
-
- server = await runServer(1)
+ server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
const username = 'user1'
const password = 'my super password'
- await createUser(server.url, server.accessToken, username, password)
+ await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
userAccessToken = await userLogin(server, { username, password })
{
}
})
- describe('When listing a video', function () {
+ describe('When listing videos', function () {
it('Should fail with a bad start pagination', async function () {
await checkBadStartPagination(server.url, path)
})
await checkBadSortPagination(server.url, path)
})
+ it('Should fail with a bad skipVideos query', async function () {
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: 200, query: { skipCount: 'toto' } })
+ })
+
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: 200, query: { skipCount: false } })
})
})
describe('When adding a video', function () {
let baseCorrectParams
const baseCorrectAttaches = {
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
}
before(function () {
language: 'pt',
nsfw: false,
commentsEnabled: true,
+ downloadEnabled: true,
waitTranscoding: true,
description: 'my super description',
support: 'my super support text',
tags: [ 'tag1', 'tag2' ],
privacy: VideoPrivacy.PUBLIC,
- channelId: channelId
+ channelId: channelId,
+ originallyPublishedAt: new Date().toISOString()
}
})
username: 'fake',
password: 'fake_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 })
const accessTokenUser = await userLogin(server, user)
const res = await getMyUserInformation(server.url, accessTokenUser)
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
+ it('Should fail with a bad originally published at attribute', async function () {
+ const fields = immutableAssign(baseCorrectParams, { 'originallyPublishedAt': 'toto' })
+ const attaches = baseCorrectAttaches
+
+ await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+ })
+
it('Should fail without an input file', async function () {
const fields = baseCorrectParams
const attaches = {}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
- it('Should fail without an incorrect input file', async function () {
+ it('Should fail with an incorrect input file', async function () {
const fields = baseCorrectParams
- const attaches = {
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
+ let attaches = {
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
+ }
+ await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+
+ attaches = {
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
{
const attaches = immutableAssign(baseCorrectAttaches, {
- videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
})
await makeUploadRequest({
{
const attaches = immutableAssign(baseCorrectAttaches, {
- videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.ogv')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
})
await makeUploadRequest({
language: 'pt',
nsfw: false,
commentsEnabled: false,
+ downloadEnabled: false,
description: 'my super description',
privacy: VideoPrivacy.PUBLIC,
tags: [ 'tag1', 'tag2' ]
await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
})
+ it('Should fail with a bad originally published at param', async function () {
+ const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
+
+ await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
+ })
+
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({
})
after(async function () {
- killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ await cleanupTests([ server ])
})
})