Move to eslint

This commit is contained in:
Chocobozzz
2020-01-31 16:56:52 +01:00
parent a22046d166
commit a15871560f
390 changed files with 3950 additions and 3615 deletions

View File

@@ -1,7 +1,7 @@
import * as express from 'express'
export class MockInstancesIndex {
private indexInstances: { host: string, createdAt: string }[] = []
private readonly indexInstances: { host: string, createdAt: string }[] = []
initialize () {
return new Promise(res => {

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import { basename, dirname, isAbsolute, join, resolve } from 'path'
@@ -10,11 +10,11 @@ import * as ffmpeg from 'fluent-ffmpeg'
const expect = chai.expect
let webtorrent: WebTorrent.Instance
function immutableAssign <T, U> (target: T, source: U) {
function immutableAssign<T, U> (target: T, source: U) {
return Object.assign<{}, T, U>({}, target, source)
}
// Default interval -> 5 minutes
// Default interval -> 5 minutes
function dateIsValid (dateString: string, interval = 300000) {
const dateToCheck = new Date(dateString)
const now = new Date()
@@ -89,7 +89,7 @@ async function generateHighBitrateVideo () {
// a large file in the repo. The video needs to have a certain minimum length so
// that FFmpeg properly applies bitrate limits.
// https://stackoverflow.com/a/15795112
return new Promise<string>(async (res, rej) => {
return new Promise<string>((res, rej) => {
ffmpeg()
.outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ])
.outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])
@@ -111,7 +111,7 @@ async function generateVideoWithFramerate (fps = 60) {
const exists = await pathExists(tempFixturePath)
if (!exists) {
return new Promise<string>(async (res, rej) => {
return new Promise<string>((res, rej) => {
ffmpeg()
.outputOptions([ '-f rawvideo', '-video_size 1280x720', '-i /dev/urandom' ])
.outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])

View File

@@ -1,7 +1,7 @@
import { QueryTypes, Sequelize } from 'sequelize'
import { ServerInfo } from '../server/servers'
let sequelizes: { [ id: number ]: Sequelize } = {}
const sequelizes: { [ id: number ]: Sequelize } = {}
function getSequelize (internalServerNumber: number) {
if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber]
@@ -52,7 +52,8 @@ async function countVideoViewsOf (internalServerNumber: number, uuid: string) {
const seq = getSequelize(internalServerNumber)
// tslint:disable
const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`
const query = 'SELECT SUM("videoView"."views") AS "total" FROM "videoView" ' +
`INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT }
const [ { total } ] = await seq.query<{ total: number }>(query, options)
@@ -64,9 +65,10 @@ async function countVideoViewsOf (internalServerNumber: number, uuid: string) {
async function closeAllSequelize (servers: ServerInfo[]) {
for (const server of servers) {
if (sequelizes[ server.internalServerNumber ]) {
await sequelizes[ server.internalServerNumber ].close()
delete sequelizes[ server.internalServerNumber ]
if (sequelizes[server.internalServerNumber]) {
await sequelizes[server.internalServerNumber].close()
// eslint-disable-next-line
delete sequelizes[server.internalServerNumber]
}
}
}

View File

@@ -1,25 +1,27 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
import * as request from 'supertest'
import { buildAbsoluteFixturePath, root } from '../miscs/miscs'
import { isAbsolute, join } from 'path'
import { parse } from 'url'
import { URL } from 'url'
function get4KFileUrl () {
return 'https://download.cpy.re/peertube/4k_file.txt'
}
function makeRawRequest (url: string, statusCodeExpected?: number, range?: string) {
const { host, protocol, pathname } = parse(url)
const { host, protocol, pathname } = new URL(url)
return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range })
}
function makeGetRequest (options: {
url: string,
path?: string,
query?: any,
token?: string,
statusCodeExpected?: number,
contentType?: string,
url: string
path?: string
query?: any
token?: string
statusCodeExpected?: number
contentType?: string
range?: string
}) {
if (!options.statusCodeExpected) options.statusCodeExpected = 400
@@ -36,9 +38,9 @@ function makeGetRequest (options: {
}
function makeDeleteRequest (options: {
url: string,
path: string,
token?: string,
url: string
path: string
token?: string
statusCodeExpected?: number
}) {
if (!options.statusCodeExpected) options.statusCodeExpected = 400
@@ -53,12 +55,12 @@ function makeDeleteRequest (options: {
}
function makeUploadRequest (options: {
url: string,
method?: 'POST' | 'PUT',
path: string,
token?: string,
fields: { [ fieldName: string ]: any },
attaches: { [ attachName: string ]: any | any[] },
url: string
method?: 'POST' | 'PUT'
path: string
token?: string
fields: { [ fieldName: string ]: any }
attaches: { [ attachName: string ]: any | any[] }
statusCodeExpected?: number
}) {
if (!options.statusCodeExpected) options.statusCodeExpected = 400
@@ -101,10 +103,10 @@ function makeUploadRequest (options: {
}
function makePostBodyRequest (options: {
url: string,
path: string,
token?: string,
fields?: { [ fieldName: string ]: any },
url: string
path: string
token?: string
fields?: { [ fieldName: string ]: any }
statusCodeExpected?: number
}) {
if (!options.fields) options.fields = {}
@@ -121,10 +123,10 @@ function makePostBodyRequest (options: {
}
function makePutBodyRequest (options: {
url: string,
path: string,
token?: string,
fields: { [ fieldName: string ]: any },
url: string
path: string
token?: string
fields: { [ fieldName: string ]: any }
statusCodeExpected?: number
}) {
if (!options.statusCodeExpected) options.statusCodeExpected = 400
@@ -147,9 +149,9 @@ function makeHTMLRequest (url: string, path: string) {
}
function updateAvatarRequest (options: {
url: string,
path: string,
accessToken: string,
url: string
path: string
accessToken: string
fixture: string
}) {
let filePath = ''

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as request from 'supertest'
import { VideosSearchQuery } from '../../models/search'

View File

@@ -1,12 +1,12 @@
import * as request from 'supertest'
import * as urlUtil from 'url'
import { URL } from 'url'
function getClient (url: string) {
const path = '/api/v1/oauth-clients/local'
return request(url)
.get(path)
.set('Host', urlUtil.parse(url).host)
.set('Host', new URL(url).host)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)

View File

@@ -2,11 +2,11 @@ import * as request from 'supertest'
import { ContactForm } from '../../models/server'
function sendContactForm (options: {
url: string,
fromEmail: string,
fromName: string,
subject: string,
body: string,
url: string
fromEmail: string
fromName: string
subject: string
body: string
expectedStatus?: number
}) {
const path = '/api/v1/server/contact'

View File

@@ -5,12 +5,12 @@ import { makePostBodyRequest } from '../requests/requests'
import { ActivityPubActorType, FollowState } from '@shared/models'
function getFollowersListPaginationAndSort (options: {
url: string,
start: number,
count: number,
sort: string,
search?: string,
actorType?: ActivityPubActorType,
url: string
start: number
count: number
sort: string
search?: string
actorType?: ActivityPubActorType
state?: FollowState
}) {
const { url, start, count, sort, search, state, actorType } = options
@@ -56,12 +56,12 @@ function rejectFollower (url: string, token: string, follower: string, statusCod
}
function getFollowingListPaginationAndSort (options: {
url: string,
start: number,
count: number,
sort: string,
search?: string,
actorType?: ActivityPubActorType,
url: string
start: number
count: number
sort: string
search?: string
actorType?: ActivityPubActorType
state?: FollowState
}) {
const { url, start, count, sort, search, state, actorType } = options
@@ -92,7 +92,7 @@ function follow (follower: string, following: string[], accessToken: string, exp
.post(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
.send({ 'hosts': followingHosts })
.send({ hosts: followingHosts })
.expect(expectedStatus)
}

View File

@@ -8,20 +8,20 @@ function getJobsList (url: string, accessToken: string, state: JobState) {
const path = '/api/v1/jobs/' + state
return request(url)
.get(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
.expect(200)
.expect('Content-Type', /json/)
.get(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
.expect(200)
.expect('Content-Type', /json/)
}
function getJobsListPaginationAndSort (options: {
url: string,
accessToken: string,
state: JobState,
start: number,
count: number,
sort: string,
url: string
accessToken: string
state: JobState
start: number
count: number
sort: string
jobType?: JobType
}) {
const { url, accessToken, state, start, count, sort, jobType } = options

View File

@@ -7,13 +7,13 @@ import { root } from '../miscs/miscs'
import { join } from 'path'
function listPlugins (parameters: {
url: string,
accessToken: string,
start?: number,
count?: number,
sort?: string,
pluginType?: PluginType,
uninstalled?: boolean,
url: string
accessToken: string
start?: number
count?: number
sort?: string
pluginType?: PluginType
uninstalled?: boolean
expectedStatus?: number
}) {
const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters
@@ -35,13 +35,13 @@ function listPlugins (parameters: {
}
function listAvailablePlugins (parameters: {
url: string,
accessToken: string,
start?: number,
count?: number,
sort?: string,
pluginType?: PluginType,
currentPeerTubeEngine?: string,
url: string
accessToken: string
start?: number
count?: number
sort?: string
pluginType?: PluginType
currentPeerTubeEngine?: string
search?: string
expectedStatus?: number
}) {
@@ -67,9 +67,9 @@ function listAvailablePlugins (parameters: {
}
function getPlugin (parameters: {
url: string,
accessToken: string,
npmName: string,
url: string
accessToken: string
npmName: string
expectedStatus?: number
}) {
const { url, accessToken, npmName, expectedStatus = 200 } = parameters
@@ -84,10 +84,10 @@ function getPlugin (parameters: {
}
function updatePluginSettings (parameters: {
url: string,
accessToken: string,
npmName: string,
settings: any,
url: string
accessToken: string
npmName: string
settings: any
expectedStatus?: number
}) {
const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters
@@ -103,9 +103,9 @@ function updatePluginSettings (parameters: {
}
function getPluginRegisteredSettings (parameters: {
url: string,
accessToken: string,
npmName: string,
url: string
accessToken: string
npmName: string
expectedStatus?: number
}) {
const { url, accessToken, npmName, expectedStatus = 200 } = parameters
@@ -120,8 +120,8 @@ function getPluginRegisteredSettings (parameters: {
}
function getPublicSettings (parameters: {
url: string,
npmName: string,
url: string
npmName: string
expectedStatus?: number
}) {
const { url, npmName, expectedStatus = 200 } = parameters
@@ -135,8 +135,8 @@ function getPublicSettings (parameters: {
}
function getPluginTranslations (parameters: {
url: string,
locale: string,
url: string
locale: string
expectedStatus?: number
}) {
const { url, locale, expectedStatus = 200 } = parameters
@@ -150,9 +150,9 @@ function getPluginTranslations (parameters: {
}
function installPlugin (parameters: {
url: string,
accessToken: string,
path?: string,
url: string
accessToken: string
path?: string
npmName?: string
expectedStatus?: number
}) {
@@ -169,9 +169,9 @@ function installPlugin (parameters: {
}
function updatePlugin (parameters: {
url: string,
accessToken: string,
path?: string,
url: string
accessToken: string
path?: string
npmName?: string
expectedStatus?: number
}) {
@@ -188,8 +188,8 @@ function updatePlugin (parameters: {
}
function uninstallPlugin (parameters: {
url: string,
accessToken: string,
url: string
accessToken: string
npmName: string
expectedStatus?: number
}) {

View File

@@ -15,11 +15,11 @@ function updateRedundancy (url: string, accessToken: string, host: string, redun
function listVideoRedundancies (options: {
url: string
accessToken: string,
target: VideoRedundanciesTarget,
start?: number,
count?: number,
sort?: string,
accessToken: string
target: VideoRedundanciesTarget
start?: number
count?: number
sort?: string
statusCodeExpected?: number
}) {
const path = '/api/v1/server/redundancy/videos'
@@ -41,8 +41,8 @@ function listVideoRedundancies (options: {
}
function addVideoRedundancy (options: {
url: string,
accessToken: string,
url: string
accessToken: string
videoId: number
}) {
const path = '/api/v1/server/redundancy/videos'
@@ -58,8 +58,8 @@ function addVideoRedundancy (options: {
}
function removeVideoRedundancy (options: {
url: string,
accessToken: string,
url: string
accessToken: string
redundancyId: number
}) {
const { url, accessToken, redundancyId } = options

View File

@@ -1,16 +1,15 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
import { ChildProcess, exec, fork } from 'child_process'
import { join } from 'path'
import { root, wait } from '../miscs/miscs'
import { copy, pathExists, readdir, readFile, remove } from 'fs-extra'
import { existsSync } from 'fs'
import { expect } from 'chai'
import { VideoChannel } from '../../models/videos'
import { randomInt } from '../../core-utils/miscs/miscs'
interface ServerInfo {
app: ChildProcess,
app: ChildProcess
url: string
host: string
@@ -20,13 +19,13 @@ interface ServerInfo {
serverNumber: number
client: {
id: string,
id: string
secret: string
}
user: {
username: string,
password: string,
username: string
password: string
email?: string
}
@@ -57,7 +56,7 @@ function parallelTests () {
}
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
let apps = []
const apps = []
let i = 0
return new Promise<ServerInfo[]>(res => {
@@ -203,20 +202,20 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
// Capture things if we want to
for (const key of Object.keys(regexps)) {
const regexp = regexps[ key ]
const regexp = regexps[key]
const matches = data.toString().match(regexp)
if (matches !== null) {
if (key === 'client_id') server.client.id = matches[ 1 ]
else if (key === 'client_secret') server.client.secret = matches[ 1 ]
else if (key === 'user_username') server.user.username = matches[ 1 ]
else if (key === 'user_password') server.user.password = matches[ 1 ]
if (key === 'client_id') server.client.id = matches[1]
else if (key === 'client_secret') server.client.secret = matches[1]
else if (key === 'user_username') server.user.username = matches[1]
else if (key === 'user_password') server.user.password = matches[1]
}
}
// Check if all required sentences are here
for (const key of Object.keys(serverRunString)) {
if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true
if (serverRunString[ key ] === false) dontContinue = true
if (data.toString().indexOf(key) !== -1) serverRunString[key] = true
if (serverRunString[key] === false) dontContinue = true
}
// If no, there is maybe one thing not already initialized (client/user credentials generation...)

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as request from 'supertest'
import { expect } from 'chai'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { makeGetRequest, makeDeleteRequest, makePostBodyRequest } from '../requests/requests'

View File

@@ -60,7 +60,7 @@ function setAccessTokensToServers (servers: ServerInfo[]) {
const tasks: Promise<any>[] = []
for (const server of servers) {
const p = serverLogin(server).then(t => server.accessToken = t)
const p = serverLogin(server).then(t => { server.accessToken = t })
tasks.push(p)
}

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
import { UserNotification, UserNotificationSetting, UserNotificationType } from '../../models/users'
@@ -54,6 +54,7 @@ function markAsReadNotifications (url: string, token: string, ids: number[], sta
statusCodeExpected
})
}
function markAsReadAllNotifications (url: string, token: string, statusCodeExpected = 204) {
const path = '/api/v1/users/me/notifications/read-all'
@@ -77,7 +78,7 @@ type CheckerBaseParams = {
server: ServerInfo
emails: object[]
socketNotifications: UserNotification[]
token: string,
token: string
check?: { web: boolean, mail: boolean }
}
@@ -172,7 +173,7 @@ async function checkNewVideoFromSubscription (base: CheckerBaseParams, videoName
}
function emailFinder (email: object) {
const text = email[ 'text' ]
const text = email['text']
return text.indexOf(videoUUID) !== -1 && text.indexOf('Your subscription') !== -1
}
@@ -195,7 +196,7 @@ async function checkVideoIsPublished (base: CheckerBaseParams, videoName: string
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
return text.includes(videoUUID) && text.includes('Your video')
}
@@ -226,7 +227,7 @@ async function checkMyVideoImportIsFinished (
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
const toFind = success ? ' finished' : ' error'
return text.includes(url) && text.includes(toFind)
@@ -251,7 +252,7 @@ async function checkUserRegistered (base: CheckerBaseParams, username: string, t
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
return text.includes(' registered ') && text.includes(username)
}
@@ -291,7 +292,7 @@ async function checkNewActorFollow (
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
return text.includes('Your ' + followType) && text.includes(followingDisplayName) && text.includes(followerDisplayName)
}
@@ -320,7 +321,7 @@ async function checkNewInstanceFollower (base: CheckerBaseParams, followerHost:
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
return text.includes('instance has a new follower') && text.includes(followerHost)
}
@@ -351,7 +352,7 @@ async function checkAutoInstanceFollowing (base: CheckerBaseParams, followerHost
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
return text.includes(' automatically followed a new instance') && text.includes(followingHost)
}
@@ -385,7 +386,7 @@ async function checkCommentMention (
}
function emailFinder (email: object) {
const text: string = email[ 'text' ]
const text: string = email['text']
return text.includes(' mentioned ') && text.includes(uuid) && text.includes(byAccountDisplayName)
}
@@ -394,6 +395,7 @@ async function checkCommentMention (
}
let lastEmailCount = 0
async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, commentId: number, threadId: number, type: CheckerType) {
const notificationType = UserNotificationType.NEW_COMMENT_ON_MY_VIDEO
@@ -413,8 +415,9 @@ async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string,
}
const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}`
function emailFinder (email: object) {
return email[ 'text' ].indexOf(commentUrl) !== -1
return email['text'].indexOf(commentUrl) !== -1
}
await checkNotification(base, notificationChecker, emailFinder, type)
@@ -444,7 +447,7 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU
}
function emailFinder (email: object) {
const text = email[ 'text' ]
const text = email['text']
return text.indexOf(videoUUID) !== -1 && text.indexOf('abuse') !== -1
}
@@ -469,8 +472,8 @@ async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, vi
}
function emailFinder (email: object) {
const text = email[ 'text' ]
return text.indexOf(videoUUID) !== -1 && email[ 'text' ].indexOf('video-auto-blacklist/list') !== -1
const text = email['text']
return text.indexOf(videoUUID) !== -1 && email['text'].indexOf('video-auto-blacklist/list') !== -1
}
await checkNotification(base, notificationChecker, emailFinder, type)
@@ -496,7 +499,7 @@ async function checkNewBlacklistOnMyVideo (
}
function emailFinder (email: object) {
const text = email[ 'text' ]
const text = email['text']
return text.indexOf(videoUUID) !== -1 && text.indexOf(' ' + blacklistType) !== -1
}

View File

@@ -9,14 +9,14 @@ import { UserUpdateMe } from '../../models/users'
import { omit } from 'lodash'
type CreateUserArgs = {
url: string,
accessToken: string,
username: string,
password: string,
videoQuota?: number,
videoQuotaDaily?: number,
role?: UserRole,
adminFlags?: UserAdminFlag,
url: string
accessToken: string
username: string
password: string
videoQuota?: number
videoQuotaDaily?: number
role?: UserRole
adminFlags?: UserAdminFlag
specialStatus?: number
}
function createUser (parameters: CreateUserArgs) {
@@ -74,8 +74,8 @@ function registerUser (url: string, username: string, password: string, specialS
}
function registerUserWithChannel (options: {
url: string,
user: { username: string, password: string, displayName?: string },
url: string
user: { username: string, password: string, displayName?: string }
channel: { name: string, displayName: string }
}) {
const path = '/api/v1/users/register'
@@ -230,8 +230,8 @@ function updateMyUser (options: { url: string, accessToken: string } & UserUpdat
}
function updateMyAvatar (options: {
url: string,
accessToken: string,
url: string
accessToken: string
fixture: string
}) {
const path = '/api/v1/users/me/avatar/pick'
@@ -241,14 +241,14 @@ function updateMyAvatar (options: {
function updateUser (options: {
url: string
userId: number,
accessToken: string,
email?: string,
emailVerified?: boolean,
videoQuota?: number,
videoQuotaDaily?: number,
password?: string,
adminFlags?: UserAdminFlag,
userId: number
accessToken: string
email?: string
emailVerified?: boolean
videoQuota?: number
videoQuotaDaily?: number
password?: string
adminFlags?: UserAdminFlag
role?: UserRole
}) {
const path = '/api/v1/users/' + options.userId

View File

@@ -13,11 +13,11 @@ function addVideoToBlacklist (
const path = '/api/v1/videos/' + videoId + '/blacklist'
return request(url)
.post(path)
.send({ reason, unfederate })
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + token)
.expect(specialStatus)
.post(path)
.send({ reason, unfederate })
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + token)
.expect(specialStatus)
}
function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) {
@@ -35,20 +35,20 @@ function removeVideoFromBlacklist (url: string, token: string, videoId: number |
const path = '/api/v1/videos/' + videoId + '/blacklist'
return request(url)
.delete(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + token)
.expect(specialStatus)
.delete(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + token)
.expect(specialStatus)
}
function getBlacklistedVideosList (parameters: {
url: string,
token: string,
sort?: string,
type?: VideoBlacklistType,
url: string
token: string
sort?: string
type?: VideoBlacklistType
specialStatus?: number
}) {
let { url, token, sort, type, specialStatus = 200 } = parameters
const { url, token, sort, type, specialStatus = 200 } = parameters
const path = '/api/v1/videos/blacklist/'
const query = { sort, type }

View File

@@ -6,12 +6,12 @@ import { buildAbsoluteFixturePath } from '../miscs/miscs'
const expect = chai.expect
function createVideoCaption (args: {
url: string,
url: string
accessToken: string
videoId: string | number
language: string
fixture: string,
mimeType?: string,
fixture: string
mimeType?: string
statusCodeExpected?: number
}) {
const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language

View File

@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import * as request from 'supertest'
import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'
import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'
@@ -22,11 +24,11 @@ function getVideoChannelsList (url: string, start: number, count: number, sort?:
}
function getAccountVideoChannelsList (parameters: {
url: string,
accountName: string,
start?: number,
count?: number,
sort?: string,
url: string
accountName: string
start?: number
count?: number
sort?: string
specialStatus?: number
}) {
const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200 } = parameters
@@ -113,9 +115,9 @@ function getVideoChannel (url: string, channelName: string) {
}
function updateVideoChannelAvatar (options: {
url: string,
accessToken: string,
fixture: string,
url: string
accessToken: string
fixture: string
videoChannelName: string | number
}) {
@@ -129,7 +131,7 @@ function setDefaultVideoChannel (servers: ServerInfo[]) {
for (const server of servers) {
const p = getMyUserInformation(server.url, server.accessToken)
.then(res => server.videoChannel = (res.body as User).videoChannels[0])
.then(res => { server.videoChannel = (res.body as User).videoChannels[0] })
tasks.push(p)
}

View File

@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import * as request from 'supertest'
import { makeDeleteRequest } from '../requests/requests'

View File

@@ -7,7 +7,7 @@ function getYoutubeVideoUrl () {
}
function getMagnetURI () {
// tslint:disable:max-line-length
// eslint-disable-next-line max-len
return 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4'
}

View File

@@ -123,9 +123,9 @@ function deleteVideoPlaylist (url: string, token: string, playlistId: number | s
}
function createVideoPlaylist (options: {
url: string,
token: string,
playlistAttrs: VideoPlaylistCreate,
url: string
token: string
playlistAttrs: VideoPlaylistCreate
expectedStatus?: number
}) {
const path = '/api/v1/video-playlists'
@@ -148,10 +148,10 @@ function createVideoPlaylist (options: {
}
function updateVideoPlaylist (options: {
url: string,
token: string,
playlistAttrs: VideoPlaylistUpdate,
playlistId: number | string,
url: string
token: string
playlistAttrs: VideoPlaylistUpdate
playlistId: number | string
expectedStatus?: number
}) {
const path = '/api/v1/video-playlists/' + options.playlistId
@@ -174,9 +174,9 @@ function updateVideoPlaylist (options: {
}
async function addVideoInPlaylist (options: {
url: string,
token: string,
playlistId: number | string,
url: string
token: string
playlistId: number | string
elementAttrs: VideoPlaylistElementCreate | { videoId: string }
expectedStatus?: number
}) {
@@ -194,11 +194,11 @@ async function addVideoInPlaylist (options: {
}
function updateVideoPlaylistElement (options: {
url: string,
token: string,
playlistId: number | string,
playlistElementId: number | string,
elementAttrs: VideoPlaylistElementUpdate,
url: string
token: string
playlistId: number | string
playlistElementId: number | string
elementAttrs: VideoPlaylistElementUpdate
expectedStatus?: number
}) {
const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId
@@ -213,10 +213,10 @@ function updateVideoPlaylistElement (options: {
}
function removeVideoFromPlaylist (options: {
url: string,
token: string,
playlistId: number | string,
playlistElementId: number,
url: string
token: string
playlistId: number | string
playlistElementId: number
expectedStatus?: number
}) {
const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId
@@ -230,14 +230,14 @@ function removeVideoFromPlaylist (options: {
}
function reorderVideosPlaylist (options: {
url: string,
token: string,
playlistId: number | string,
url: string
token: string
playlistId: number | string
elementAttrs: {
startPosition: number,
insertAfterPosition: number,
startPosition: number
insertAfterPosition: number
reorderLength?: number
},
}
expectedStatus?: number
}) {
const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/reorder'

View File

@@ -37,7 +37,7 @@ async function checkSegmentHash (
const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url)
const sha256Server = resSha.body[ videoName ][range]
const sha256Server = resSha.body[videoName][range]
expect(sha256(res2.body)).to.equal(sha256Server)
}

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
import { expect } from 'chai'
import { pathExists, readdir, readFile } from 'fs-extra'
@@ -488,7 +488,7 @@ async function completeVideoCheck (
description: string
publishedAt?: string
support: string
originallyPublishedAt?: string,
originallyPublishedAt?: string
account: {
name: string
host: string
@@ -509,7 +509,7 @@ async function completeVideoCheck (
files: {
resolution: number
size: number
}[],
}[]
thumbnailfile?: string
previewfile?: string
}
@@ -583,9 +583,10 @@ async function completeVideoCheck (
const minSize = attributeFile.size - ((10 * attributeFile.size) / 100)
const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100)
expect(file.size,
'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')')
.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)
const torrent = await webtorrentAdd(file.magnetUri, true)
expect(torrent.files).to.be.an('array')
@@ -608,10 +609,10 @@ async function videoUUIDToId (url: string, id: number | string) {
}
async function uploadVideoAndGetId (options: {
server: ServerInfo,
videoName: string,
nsfw?: boolean,
privacy?: VideoPrivacy,
server: ServerInfo
videoName: string
nsfw?: boolean
privacy?: VideoPrivacy
token?: string
}) {
const videoAttrs: any = { name: options.videoName }