/* tslint:disable:no-unused-expression */
import { expect } from 'chai'
-import { existsSync, readFile } from 'fs'
+import { existsSync, readdir, readFile } from 'fs-extra'
import * as parseTorrent from 'parse-torrent'
import { extname, join } from 'path'
import * as request from 'supertest'
import {
buildAbsoluteFixturePath,
- getMyUserInformation, immutableAssign,
+ getMyUserInformation,
+ immutableAssign,
makeGetRequest,
makePutBodyRequest,
makeUploadRequest,
testImage
} from '../'
import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
-import { readdirPromise } from '../../../helpers/core-utils'
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers'
import { dateIsValid, webtorrentAdd } from '../index'
language?: string
nsfw?: boolean
commentsEnabled?: boolean
+ downloadingEnabled?: boolean
waitTranscoding?: boolean
description?: string
tags?: string[]
function getVideoChannelVideos (
url: string,
accessToken: string,
- videoChannelId: number | string,
+ videoChannelName: string,
start: number,
count: number,
sort?: string,
query: { nsfw?: boolean } = {}
) {
- const path = '/api/v1/video-channels/' + videoChannelId + '/videos'
+ const path = '/api/v1/video-channels/' + videoChannelName + '/videos'
return makeGetRequest({
url,
.expect(expectedStatus)
}
-async function checkVideoFilesWereRemoved (videoUUID: string, serverNumber: number) {
+async function checkVideoFilesWereRemoved (
+ videoUUID: string,
+ serverNumber: number,
+ directories = [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]
+) {
const testDirectory = 'test' + serverNumber
- for (const directory of [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]) {
+ for (const directory of directories) {
const directoryPath = join(root(), testDirectory, directory)
const directoryExists = existsSync(directoryPath)
expect(directoryExists).to.be.true
- const files = await readdirPromise(directoryPath)
+ const files = await readdir(directoryPath)
for (const file of files) {
expect(file).to.not.contain(videoUUID)
}
tags: [ 'tag' ],
privacy: VideoPrivacy.PUBLIC,
commentsEnabled: true,
+ downloadingEnabled: true,
fixture: 'video_short.webm'
}, videoAttributesArg)
.field('name', attributes.name)
.field('nsfw', JSON.stringify(attributes.nsfw))
.field('commentsEnabled', JSON.stringify(attributes.commentsEnabled))
+ .field('downloadingEnabled', JSON.stringify(attributes.downloadingEnabled))
.field('waitTranscoding', JSON.stringify(attributes.waitTranscoding))
.field('privacy', attributes.privacy.toString())
.field('channelId', attributes.channelId)
if (attributes.language) body['language'] = attributes.language
if (attributes.nsfw !== undefined) body['nsfw'] = JSON.stringify(attributes.nsfw)
if (attributes.commentsEnabled !== undefined) body['commentsEnabled'] = JSON.stringify(attributes.commentsEnabled)
+ if (attributes.downloadingEnabled !== undefined) body['downloadingEnabled'] = JSON.stringify(attributes.downloadingEnabled)
if (attributes.description) body['description'] = attributes.description
if (attributes.tags) body['tags'] = attributes.tags
if (attributes.privacy) body['privacy'] = attributes.privacy
language: string
nsfw: boolean
commentsEnabled: boolean
+ downloadingEnabled: boolean
description: string
publishedAt?: string
support: string
name: string
host: string
}
- isLocal: boolean,
- tags: string[],
- privacy: number,
- likes?: number,
- dislikes?: number,
- duration: number,
+ isLocal: boolean
+ tags: string[]
+ privacy: number
+ likes?: number
+ dislikes?: number
+ duration: number
channel: {
- name: string,
+ displayName: string
+ name: string
description
isLocal: boolean
}
- fixture: string,
+ fixture: string
files: {
resolution: number
size: number
expect(video.account.uuid).to.be.a('string')
expect(video.account.host).to.equal(attributes.account.host)
expect(video.account.name).to.equal(attributes.account.name)
- expect(video.channel.displayName).to.equal(attributes.channel.name)
- expect(video.channel.name).to.have.lengthOf(36)
+ expect(video.channel.displayName).to.equal(attributes.channel.displayName)
+ expect(video.channel.name).to.equal(attributes.channel.name)
expect(video.likes).to.equal(attributes.likes)
expect(video.dislikes).to.equal(attributes.dislikes)
expect(video.isLocal).to.equal(attributes.isLocal)
expect(videoDetails.tags).to.deep.equal(attributes.tags)
expect(videoDetails.account.name).to.equal(attributes.account.name)
expect(videoDetails.account.host).to.equal(attributes.account.host)
- expect(videoDetails.channel.displayName).to.equal(attributes.channel.name)
- expect(videoDetails.channel.name).to.have.lengthOf(36)
+ expect(video.channel.displayName).to.equal(attributes.channel.displayName)
+ expect(video.channel.name).to.equal(attributes.channel.name)
expect(videoDetails.channel.host).to.equal(attributes.account.host)
expect(videoDetails.channel.isLocal).to.equal(attributes.channel.isLocal)
expect(dateIsValid(videoDetails.channel.createdAt.toString())).to.be.true
expect(dateIsValid(videoDetails.channel.updatedAt.toString())).to.be.true
expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled)
+ expect(videoDetails.downloadingEnabled).to.equal(attributes.downloadingEnabled)
for (const attributeFile of attributes.files) {
const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution)
const minSize = attributeFile.size - ((10 * attributeFile.size) / 100)
const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100)
- expect(file.size).to.be.above(minSize).and.below(maxSize)
+ expect(file.size,
+ 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')')
+ .to.be.above(minSize).and.below(maxSize)
{
await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath)