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,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 'mocha'
@@ -6,8 +6,6 @@ import {
cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
killallServers,
makeActivityPubGetRequest,
ServerInfo,
setAccessTokensToServers,

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
@@ -8,9 +8,7 @@ import {
createUser,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
getVideosListSort,
killallServers,
ServerInfo,
setAccessTokensToServers,
setActorField,

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
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 'mocha'
import {
@@ -43,32 +43,32 @@ describe('Test AP refresher', function () {
await setDefaultVideoChannel(servers)
{
videoUUID1 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video1' })).uuid
videoUUID2 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video2' })).uuid
videoUUID3 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video3' })).uuid
videoUUID1 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video1' })).uuid
videoUUID2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video2' })).uuid
videoUUID3 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video3' })).uuid
}
{
const a1 = await generateUserAccessToken(servers[ 1 ], 'user1')
await uploadVideo(servers[ 1 ].url, a1, { name: 'video4' })
const a1 = await generateUserAccessToken(servers[1], 'user1')
await uploadVideo(servers[1].url, a1, { name: 'video4' })
const a2 = await generateUserAccessToken(servers[ 1 ], 'user2')
await uploadVideo(servers[ 1 ].url, a2, { name: 'video5' })
const a2 = await generateUserAccessToken(servers[1], 'user2')
await uploadVideo(servers[1].url, a2, { name: 'video5' })
}
{
const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }
const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
playlistUUID1 = res.body.videoPlaylist.uuid
}
{
const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }
const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
playlistUUID2 = res.body.videoPlaylist.uuid
}
await doubleFollow(servers[ 0 ], servers[ 1 ])
await doubleFollow(servers[0], servers[1])
})
describe('Videos refresher', function () {
@@ -79,34 +79,34 @@ describe('Test AP refresher', function () {
await wait(10000)
// Change UUID so the remote server returns a 404
await setVideoField(servers[ 1 ].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
await setVideoField(servers[1].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
await getVideo(servers[ 0 ].url, videoUUID1)
await getVideo(servers[ 0 ].url, videoUUID2)
await getVideo(servers[0].url, videoUUID1)
await getVideo(servers[0].url, videoUUID2)
await waitJobs(servers)
await getVideo(servers[ 0 ].url, videoUUID1, 404)
await getVideo(servers[ 0 ].url, videoUUID2, 200)
await getVideo(servers[0].url, videoUUID1, 404)
await getVideo(servers[0].url, videoUUID2, 200)
})
it('Should not update a remote video if the remote instance is down', async function () {
this.timeout(70000)
killallServers([ servers[ 1 ] ])
killallServers([ servers[1] ])
await setVideoField(servers[ 1 ].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
await setVideoField(servers[1].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
// Video will need a refresh
await wait(10000)
await getVideo(servers[ 0 ].url, videoUUID3)
await getVideo(servers[0].url, videoUUID3)
// The refresh should fail
await waitJobs([ servers[ 0 ] ])
await waitJobs([ servers[0] ])
await reRunServer(servers[ 1 ])
await reRunServer(servers[1])
await getVideo(servers[ 0 ].url, videoUUID3, 200)
await getVideo(servers[0].url, videoUUID3, 200)
})
})
@@ -118,16 +118,16 @@ describe('Test AP refresher', function () {
await wait(10000)
// Change actor name so the remote server returns a 404
const to = 'http://localhost:' + servers[ 1 ].port + '/accounts/user2'
await setActorField(servers[ 1 ].internalServerNumber, to, 'preferredUsername', 'toto')
const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
await setActorField(servers[1].internalServerNumber, to, 'preferredUsername', 'toto')
await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port)
await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port)
await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port)
await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port)
await waitJobs(servers)
await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port, 200)
await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port, 404)
await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, 200)
await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, 404)
})
})
@@ -139,15 +139,15 @@ describe('Test AP refresher', function () {
await wait(10000)
// Change UUID so the remote server returns a 404
await setPlaylistField(servers[ 1 ].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
await setPlaylistField(servers[1].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
await getVideoPlaylist(servers[ 0 ].url, playlistUUID1)
await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)
await getVideoPlaylist(servers[0].url, playlistUUID1)
await getVideoPlaylist(servers[0].url, playlistUUID2)
await waitJobs(servers)
await getVideoPlaylist(servers[ 0 ].url, playlistUUID1, 200)
await getVideoPlaylist(servers[ 0 ].url, playlistUUID2, 404)
await getVideoPlaylist(servers[0].url, playlistUUID1, 200)
await getVideoPlaylist(servers[0].url, playlistUUID2, 404)
})
})

View File

@@ -1,15 +1,8 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
cleanupTests,
closeAllSequelize,
flushAndRunMultipleServers,
killallServers,
ServerInfo,
setActorField
} from '../../../../shared/extra-utils'
import { cleanupTests, closeAllSequelize, flushAndRunMultipleServers, ServerInfo, setActorField } from '../../../../shared/extra-utils'
import { HTTP_SIGNATURE } from '../../../initializers/constants'
import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
import * as chai from 'chai'
@@ -33,7 +26,7 @@ function getAnnounceWithoutContext (server2: ServerInfo) {
if (Array.isArray(json[key])) {
result[key] = json[key].map(v => v.replace(':9002', `:${server2.port}`))
} else {
result[ key ] = json[ key ].replace(':9002', `:${server2.port}`)
result[key] = json[key].replace(':9002', `:${server2.port}`)
}
}

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { omit } from 'lodash'
import 'mocha'

View File

@@ -1,22 +1,8 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
flushTests,
immutableAssign,
killallServers,
reRunServer,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers, cleanupTests
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { getAccount } from '../../../../shared/extra-utils/users/accounts'
import { cleanupTests, flushAndRunServer, immutableAssign, killallServers, reRunServer, ServerInfo } from '../../../../shared/extra-utils'
import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'

View File

@@ -1,15 +1,14 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
cleanupTests,
createUser,
flushTests,
killallServers,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin, cleanupTests
userLogin
} from '../../../../shared/extra-utils'
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,16 +1,14 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
cleanupTests,
createUser,
flushTests,
killallServers,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin,
cleanupTests
userLogin
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,

View File

@@ -1,16 +1,14 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
cleanupTests,
createUser,
flushTests,
killallServers,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin,
cleanupTests
userLogin
} from '../../../../shared/extra-utils'
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
@@ -38,7 +38,7 @@ describe('Test server redundancy API validators', function () {
password: 'password'
}
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
userAccessToken = await userLogin(servers[0], user)
videoIdLocal = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video' })).id

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import * as io from 'socket.io-client'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { omit } from 'lodash'
import 'mocha'
@@ -50,6 +50,7 @@ describe('Test users API validators', function () {
let serverWithRegistrationDisabled: ServerInfo
let userAccessToken = ''
let moderatorAccessToken = ''
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let channelId: number
// ---------------------------------------------------------------
@@ -120,7 +121,7 @@ describe('Test users API validators', function () {
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[ 0 ].id
channelId = res.body.videoChannels[0].id
}
{
@@ -529,7 +530,7 @@ describe('Test users API validators', function () {
it('Should fail without an incorrect input file', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
})
@@ -537,7 +538,7 @@ describe('Test users API validators', function () {
it('Should fail with a big file', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
})
@@ -545,7 +546,7 @@ describe('Test users API validators', function () {
it('Should fail with an unauthenticated user', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
url: server.url,
@@ -559,7 +560,7 @@ describe('Test users API validators', function () {
it('Should succeed with the correct params', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
url: server.url,

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
@@ -126,6 +126,7 @@ describe('Test video abuses API validators', function () {
describe('When updating a video abuse', function () {
const basePath = '/api/v1/videos/'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let path: string
before(() => {
@@ -163,6 +164,7 @@ describe('Test video abuses API validators', function () {
describe('When deleting a video abuse', function () {
const basePath = '/api/v1/videos/'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let path: string
before(() => {

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
@@ -7,25 +7,24 @@ import {
createUser,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
getBlacklistedVideosList,
getVideo,
getVideoWithToken,
killallServers,
makePostBodyRequest,
makePutBodyRequest,
removeVideoFromBlacklist,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
userLogin, waitJobs
userLogin,
waitJobs
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { VideoDetails, VideoBlacklistType } from '../../../../shared/models/videos'
import { VideoBlacklistType, VideoDetails } from '../../../../shared/models/videos'
import { expect } from 'chai'
describe('Test video blacklist API validators', function () {
@@ -48,14 +47,14 @@ describe('Test video blacklist API validators', function () {
{
const username = 'user1'
const password = 'my super password'
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: username, password: password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password })
userAccessToken1 = await userLogin(servers[0], { username, password })
}
{
const username = 'user2'
const password = 'my super password'
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: username, password: password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password })
userAccessToken2 = await userLogin(servers[0], { username, password })
}
@@ -120,7 +119,7 @@ describe('Test video blacklist API validators', function () {
it('Should succeed with the correct params', async function () {
const path = basePath + servers[0].video.uuid + '/blacklist'
const fields = { }
const fields = {}
await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields, statusCodeExpected: 204 })
})

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
@@ -50,7 +50,7 @@ describe('Test video captions API validator', function () {
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 () {

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 { omit } from 'lodash'
@@ -243,7 +243,7 @@ describe('Test video channels API validator', function () {
it('Should fail with an incorrect input file', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/avatar/pick', token: server.accessToken, fields, attaches })
})
@@ -251,7 +251,7 @@ describe('Test video channels API validator', function () {
it('Should fail with a big file', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({ url: server.url, path: path + '/avatar/pick', token: server.accessToken, fields, attaches })
})
@@ -259,7 +259,7 @@ describe('Test video channels API validator', function () {
it('Should fail with an unauthenticated user', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
url: server.url,
@@ -273,7 +273,7 @@ describe('Test video channels API validator', function () {
it('Should succeed with the correct params', async function () {
const fields = {}
const attaches = {
'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
url: server.url,
@@ -324,7 +324,7 @@ describe('Test video channels API validator', function () {
})
it('Should fail with an unknown video channel id', async function () {
await deleteVideoChannel(server.url, server.accessToken,'super_channel2', 404)
await deleteVideoChannel(server.url, server.accessToken, 'super_channel2', 404)
})
it('Should succeed with the correct parameters', async function () {

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 'mocha'

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { omit } from 'lodash'
import 'mocha'
@@ -29,6 +29,7 @@ describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
let server: ServerInfo
let userAccessToken = ''
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let accountName: string
let channelId: number
@@ -48,7 +49,7 @@ describe('Test video imports API validator', function () {
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[ 0 ].id
channelId = res.body.videoChannels[0].id
accountName = res.body.account.name + '@' + res.body.account.host
}
})
@@ -196,7 +197,7 @@ describe('Test video imports API validator', function () {
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -205,7 +206,7 @@ describe('Test video imports API validator', function () {
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -214,7 +215,7 @@ describe('Test video imports API validator', function () {
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
previewfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -223,7 +224,7 @@ describe('Test video imports API validator', function () {
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
previewfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -232,7 +233,7 @@ describe('Test video imports API validator', function () {
it('Should fail with an invalid torrent file', async function () {
const fields = omit(baseCorrectParams, 'targetUrl')
const attaches = {
'torrentfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
torrentfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -303,7 +304,7 @@ describe('Test video imports API validator', function () {
fields = omit(fields, 'magnetUri')
const attaches = {
'torrentfile': join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent')
torrentfile: join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent')
}
await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 409 })

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
@@ -36,6 +36,7 @@ describe('Test video playlists API validator', function () {
let privatePlaylistUUID: string
let watchLaterPlaylistId: number
let videoId: number
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let videoId2: number
let playlistElementId: number
@@ -449,7 +450,7 @@ describe('Test video playlists API validator', function () {
videoId3 = (await uploadVideoAndGetId({ server, videoName: 'video 3' })).id
videoId4 = (await uploadVideoAndGetId({ server, videoName: 'video 4' })).id
for (let id of [ videoId3, videoId4 ]) {
for (const id of [ videoId3, videoId4 ]) {
await addVideoInPlaylist({
url: server.url,
token: server.accessToken,
@@ -476,7 +477,7 @@ describe('Test video playlists API validator', function () {
}
{
const params = getBase({}, { playlistId: 42, expectedStatus: 404 })
const params = getBase({}, { playlistId: 42, expectedStatus: 404 })
await reorderVideosPlaylist(params)
}
})

View File

@@ -1,10 +1,9 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
cleanupTests,
createUser,
createVideoPlaylist,
flushAndRunServer,
makeGetRequest,
ServerInfo,
@@ -13,7 +12,6 @@ import {
userLogin
} from '../../../../shared/extra-utils'
import { UserRole } from '../../../../shared/models/users'
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
async function testEndpoints (server: ServerInfo, token: string, filter: string, statusCodeExpected: number) {
const paths = [
@@ -77,7 +75,7 @@ describe('Test videos filters', function () {
})
it('Should succeed with a good filter', async function () {
await testEndpoints(server, server.accessToken,'local', 200)
await testEndpoints(server, server.accessToken, 'local', 200)
})
it('Should fail to list all-local with a simple user', async function () {

View File

@@ -1,6 +1,5 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
checkBadCountPagination,
@@ -15,12 +14,10 @@ import {
uploadVideo
} from '../../../../shared/extra-utils'
const expect = chai.expect
describe('Test videos history API validator', function () {
const myHistoryPath = '/api/v1/users/me/history/videos'
const myHistoryRemove = myHistoryPath + '/remove'
let watchingPath: string
let myHistoryPath = '/api/v1/users/me/history/videos'
let myHistoryRemove = myHistoryPath + '/remove'
let server: ServerInfo
// ---------------------------------------------------------------

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 { omit } from 'lodash'
@@ -56,8 +56,8 @@ describe('Test videos API validator', function () {
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[ 0 ].id
channelName = res.body.videoChannels[ 0 ].name
channelId = res.body.videoChannels[0].id
channelName = res.body.videoChannels[0].name
accountName = res.body.account.name + '@' + res.body.account.host
}
})
@@ -182,7 +182,7 @@ describe('Test videos API validator', function () {
describe('When adding a video', function () {
let baseCorrectParams
const baseCorrectAttaches = {
'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
}
before(function () {
@@ -330,7 +330,7 @@ describe('Test videos API validator', function () {
})
it('Should fail with a bad originally published at attribute', async function () {
const fields = immutableAssign(baseCorrectParams, { 'originallyPublishedAt': 'toto' })
const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
const attaches = baseCorrectAttaches
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -345,12 +345,12 @@ describe('Test videos API validator', function () {
it('Should fail with an incorrect input file', async function () {
const fields = baseCorrectParams
let attaches = {
'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
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')
videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
@@ -358,8 +358,8 @@ describe('Test videos API validator', function () {
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
'videofile': join(root(), 'server', 'tests', '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 })
@@ -368,8 +368,8 @@ describe('Test videos API validator', function () {
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
'videofile': join(root(), 'server', 'tests', '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 })
@@ -378,8 +378,8 @@ describe('Test videos API validator', function () {
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
'videofile': join(root(), 'server', 'tests', '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 })
@@ -388,8 +388,8 @@ describe('Test videos API validator', function () {
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
'videofile': join(root(), 'server', 'tests', '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 })
@@ -566,7 +566,7 @@ describe('Test videos API validator', function () {
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
@@ -582,7 +582,7 @@ describe('Test videos API validator', function () {
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({
@@ -598,7 +598,7 @@ describe('Test videos API validator', function () {
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
previewfile: join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
@@ -614,7 +614,7 @@ describe('Test videos API validator', function () {
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
previewfile: join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({

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 'mocha'
@@ -74,7 +74,7 @@ async function uploadVideoByRemoteAccount (servers: ServerInfo[], additionalPara
const name = 'remote video ' + uuidv4()
const data = Object.assign({ name }, additionalParams)
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, data)
const res = await uploadVideo(servers[1].url, servers[1].accessToken, data)
await waitJobs(servers)
@@ -85,7 +85,7 @@ async function uploadVideoByLocalAccount (servers: ServerInfo[], additionalParam
const name = 'local video ' + uuidv4()
const data = Object.assign({ name }, additionalParams)
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, data)
const res = await uploadVideo(servers[0].url, servers[0].accessToken, data)
await waitJobs(servers)
@@ -95,9 +95,9 @@ async function uploadVideoByLocalAccount (servers: ServerInfo[], additionalParam
describe('Test users notifications', function () {
let servers: ServerInfo[] = []
let userAccessToken: string
let userNotifications: UserNotification[] = []
let adminNotifications: UserNotification[] = []
let adminNotificationsServer2: UserNotification[] = []
const userNotifications: UserNotification[] = []
const adminNotifications: UserNotification[] = []
const adminNotificationsServer2: UserNotification[] = []
const emails: object[] = []
let channelId: number
@@ -142,8 +142,8 @@ describe('Test users notifications', function () {
password: 'super password'
}
await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: user.username,
password: user.password,
videoQuota: 10 * 1000 * 1000
@@ -155,15 +155,15 @@ describe('Test users notifications', function () {
await updateMyNotificationSettings(servers[1].url, servers[1].accessToken, allNotificationSettings)
{
const socket = getUserNotificationSocket(servers[ 0 ].url, userAccessToken)
const socket = getUserNotificationSocket(servers[0].url, userAccessToken)
socket.on('new-notification', n => userNotifications.push(n))
}
{
const socket = getUserNotificationSocket(servers[ 0 ].url, servers[0].accessToken)
const socket = getUserNotificationSocket(servers[0].url, servers[0].accessToken)
socket.on('new-notification', n => adminNotifications.push(n))
}
{
const socket = getUserNotificationSocket(servers[ 1 ].url, servers[1].accessToken)
const socket = getUserNotificationSocket(servers[1].url, servers[1].accessToken)
socket.on('new-notification', n => adminNotificationsServer2.push(n))
}
@@ -190,7 +190,7 @@ describe('Test users notifications', function () {
await uploadVideoByLocalAccount(servers)
const notification = await getLastNotification(servers[ 0 ].url, userAccessToken)
const notification = await getLastNotification(servers[0].url, userAccessToken)
expect(notification).to.be.undefined
expect(emails).to.have.lengthOf(0)
@@ -221,7 +221,7 @@ describe('Test users notifications', function () {
this.timeout(20000)
// In 2 seconds
let updateAt = new Date(new Date().getTime() + 2000)
const updateAt = new Date(new Date().getTime() + 2000)
const data = {
privacy: VideoPrivacy.PRIVATE,
@@ -240,7 +240,7 @@ describe('Test users notifications', function () {
this.timeout(50000)
// In 2 seconds
let updateAt = new Date(new Date().getTime() + 2000)
const updateAt = new Date(new Date().getTime() + 2000)
const data = {
privacy: VideoPrivacy.PRIVATE,
@@ -259,7 +259,7 @@ describe('Test users notifications', function () {
it('Should not send a notification before the video is published', async function () {
this.timeout(20000)
let updateAt = new Date(new Date().getTime() + 1000000)
const updateAt = new Date(new Date().getTime() + 1000000)
const data = {
privacy: VideoPrivacy.PRIVATE,
@@ -386,7 +386,7 @@ describe('Test users notifications', function () {
it('Should not send a new comment notification if the account is muted', async function () {
this.timeout(10000)
await addAccountToAccountBlocklist(servers[ 0 ].url, userAccessToken, 'root')
await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root')
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
const uuid = resVideo.body.video.uuid
@@ -397,7 +397,7 @@ describe('Test users notifications', function () {
await wait(500)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
await removeAccountFromAccountBlocklist(servers[ 0 ].url, userAccessToken, 'root')
await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
})
it('Should send a new comment notification after a local comment on my video', async function () {
@@ -456,9 +456,9 @@ describe('Test users notifications', function () {
await waitJobs(servers)
{
const resThread = await addVideoCommentThread(servers[ 1 ].url, servers[ 1 ].accessToken, uuid, 'comment')
const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment')
const threadId = resThread.body.comment.id
await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, uuid, threadId, 'reply')
await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, threadId, 'reply')
}
await waitJobs(servers)
@@ -530,7 +530,7 @@ describe('Test users notifications', function () {
it('Should not send a new mention notification if the account is muted', async function () {
this.timeout(10000)
await addAccountToAccountBlocklist(servers[ 0 ].url, userAccessToken, 'root')
await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root')
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
const uuid = resVideo.body.video.uuid
@@ -541,7 +541,7 @@ describe('Test users notifications', function () {
await wait(500)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
await removeAccountFromAccountBlocklist(servers[ 0 ].url, userAccessToken, 'root')
await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
})
it('Should not send a new mention notification if the remote account mention a local account', async function () {
@@ -585,7 +585,7 @@ describe('Test users notifications', function () {
await waitJobs(servers)
const text1 = `hello @user_1@localhost:${servers[ 0 ].port} 1`
const text1 = `hello @user_1@localhost:${servers[0].port} 1`
const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1)
const server2ThreadId = resThread.body.comment.id
@@ -596,7 +596,7 @@ describe('Test users notifications', function () {
const server1ThreadId = resThread2.body.data[0].id
await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
const text2 = `@user_1@localhost:${servers[ 0 ].port} hello 2 @root@localhost:${servers[ 0 ].port}`
const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2)
await waitJobs(servers)
@@ -611,7 +611,7 @@ describe('Test users notifications', function () {
})
})
describe('Video abuse for moderators notification' , function () {
describe('Video abuse for moderators notification', function () {
let baseParams: CheckerBaseParams
before(() => {
@@ -722,7 +722,7 @@ describe('Test users notifications', function () {
await uploadVideoByRemoteAccount(servers, { waitTranscoding: false })
await waitJobs(servers)
const notification = await getLastNotification(servers[ 0 ].url, userAccessToken)
const notification = await getLastNotification(servers[0].url, userAccessToken)
if (notification) {
expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED)
}
@@ -769,7 +769,7 @@ describe('Test users notifications', function () {
this.timeout(70000)
// In 2 seconds
let updateAt = new Date(new Date().getTime() + 2000)
const updateAt = new Date(new Date().getTime() + 2000)
const data = {
privacy: VideoPrivacy.PRIVATE,
@@ -787,7 +787,7 @@ describe('Test users notifications', function () {
it('Should not send a notification before the video is published', async function () {
this.timeout(20000)
let updateAt = new Date(new Date().getTime() + 1000000)
const updateAt = new Date(new Date().getTime() + 1000000)
const data = {
privacy: VideoPrivacy.PRIVATE,
@@ -970,8 +970,8 @@ describe('Test users notifications', function () {
describe('New actor follow', function () {
let baseParams: CheckerBaseParams
let myChannelName = 'super channel name'
let myUserName = 'super user name'
const myChannelName = 'super channel name'
const myUserName = 'super user name'
before(async () => {
baseParams = {
@@ -1143,7 +1143,7 @@ describe('Test users notifications', function () {
it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
this.timeout(20000)
let updateAt = new Date(new Date().getTime() + 1000000)
const updateAt = new Date(new Date().getTime() + 1000000)
const name = 'video with auto-blacklist and future schedule ' + uuidv4()
@@ -1176,7 +1176,7 @@ describe('Test users notifications', function () {
this.timeout(20000)
// In 2 seconds
let updateAt = new Date(new Date().getTime() + 2000)
const updateAt = new Date(new Date().getTime() + 2000)
const name = 'video with schedule done and still auto-blacklisted ' + uuidv4()
@@ -1221,26 +1221,26 @@ describe('Test users notifications', function () {
describe('Mark as read', function () {
it('Should mark as read some notifications', async function () {
const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 2, 3)
const res = await getUserNotifications(servers[0].url, userAccessToken, 2, 3)
const ids = res.body.data.map(n => n.id)
await markAsReadNotifications(servers[ 0 ].url, userAccessToken, ids)
await markAsReadNotifications(servers[0].url, userAccessToken, ids)
})
it('Should have the notifications marked as read', async function () {
const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10)
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10)
const notifications = res.body.data as UserNotification[]
expect(notifications[ 0 ].read).to.be.false
expect(notifications[ 1 ].read).to.be.false
expect(notifications[ 2 ].read).to.be.true
expect(notifications[ 3 ].read).to.be.true
expect(notifications[ 4 ].read).to.be.true
expect(notifications[ 5 ].read).to.be.false
expect(notifications[0].read).to.be.false
expect(notifications[1].read).to.be.false
expect(notifications[2].read).to.be.true
expect(notifications[3].read).to.be.true
expect(notifications[4].read).to.be.true
expect(notifications[5].read).to.be.false
})
it('Should only list read notifications', async function () {
const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, false)
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10, false)
const notifications = res.body.data as UserNotification[]
for (const notification of notifications) {
@@ -1249,7 +1249,7 @@ describe('Test users notifications', function () {
})
it('Should only list unread notifications', async function () {
const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, true)
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10, true)
const notifications = res.body.data as UserNotification[]
for (const notification of notifications) {
@@ -1258,9 +1258,9 @@ describe('Test users notifications', function () {
})
it('Should mark as read all notifications', async function () {
await markAsReadAllNotifications(servers[ 0 ].url, userAccessToken)
await markAsReadAllNotifications(servers[0].url, userAccessToken)
const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, true)
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10, true)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.have.lengthOf(0)

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 'mocha'
@@ -56,20 +56,20 @@ describe('Test manage videos redundancy', function () {
await setAccessTokensToServers(servers)
{
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 server 2' })
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' })
video1Server2UUID = res.body.video.uuid
}
{
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 2 server 2' })
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' })
video2Server2UUID = res.body.video.uuid
}
await waitJobs(servers)
// Server 1 and server 2 follow each other
await doubleFollow(servers[ 0 ], servers[ 1 ])
await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true)
await doubleFollow(servers[0], servers[1])
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
await waitJobs(servers)
})
@@ -195,8 +195,8 @@ describe('Test manage videos redundancy', function () {
})
const videos = res.body.data
expect(videos[ 0 ].name).to.equal('video 1 server 2')
expect(videos[ 1 ].name).to.equal('video 2 server 2')
expect(videos[0].name).to.equal('video 1 server 2')
expect(videos[1].name).to.equal('video 2 server 2')
}
{
@@ -210,8 +210,8 @@ describe('Test manage videos redundancy', function () {
})
const videos = res.body.data
expect(videos[ 0 ].name).to.equal('video 2 server 2')
expect(videos[ 1 ].name).to.equal('video 1 server 2')
expect(videos[0].name).to.equal('video 2 server 2')
expect(videos[1].name).to.equal('video 1 server 2')
}
{
@@ -225,14 +225,14 @@ describe('Test manage videos redundancy', function () {
})
const videos = res.body.data
expect(videos[ 0 ].name).to.equal('video 1 server 2')
expect(videos[0].name).to.equal('video 1 server 2')
}
})
it('Should manually add a redundancy and list it', async function () {
this.timeout(120000)
const uuid = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
const uuid = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
await waitJobs(servers)
const videoId = await getLocalIdByUUID(servers[0].url, uuid)
@@ -257,9 +257,9 @@ describe('Test manage videos redundancy', function () {
})
const videos = res.body.data
expect(videos[ 0 ].name).to.equal('video 3 server 2')
expect(videos[0].name).to.equal('video 3 server 2')
const video = videos[ 0 ]
const video = videos[0]
expect(video.redundancies.files).to.have.lengthOf(4)
expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1)
@@ -286,9 +286,9 @@ describe('Test manage videos redundancy', function () {
})
const videos = res.body.data
expect(videos[ 0 ].name).to.equal('video 3 server 2')
expect(videos[0].name).to.equal('video 3 server 2')
const video = videos[ 0 ]
const video = videos[0]
expect(video.redundancies.files).to.have.lengthOf(4)
expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1)
@@ -308,8 +308,8 @@ describe('Test manage videos redundancy', function () {
for (const redundancyId of redundanciesToRemove) {
await removeVideoRedundancy({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
redundancyId
})
}
@@ -327,10 +327,10 @@ describe('Test manage videos redundancy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('video 2 server 2')
expect(videos[0].name).to.equal('video 2 server 2')
redundanciesToRemove = []
const video = videos[ 0 ]
const video = videos[0]
expect(video.redundancies.files).to.have.lengthOf(4)
expect(video.redundancies.streamingPlaylists).to.have.lengthOf(1)
@@ -346,8 +346,8 @@ describe('Test manage videos redundancy', function () {
{
for (const redundancyId of redundanciesToRemove) {
await removeVideoRedundancy({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
redundancyId
})
}
@@ -362,7 +362,7 @@ describe('Test manage videos redundancy', function () {
})
const videos = res.body.data
expect(videos[ 0 ].name).to.equal('video 1 server 2')
expect(videos[0].name).to.equal('video 1 server 2')
expect(videos).to.have.lengthOf(1)
}
})

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 'mocha'
@@ -92,21 +92,21 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
await setAccessTokensToServers(servers)
{
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 server 2' })
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' })
video1Server2UUID = res.body.video.uuid
video1Server2Id = res.body.video.id
await viewVideo(servers[ 1 ].url, video1Server2UUID)
await viewVideo(servers[1].url, video1Server2UUID)
}
await waitJobs(servers)
// Server 1 and server 2 follow each other
await doubleFollow(servers[ 0 ], servers[ 1 ])
await doubleFollow(servers[0], servers[1])
// Server 1 and server 3 follow each other
await doubleFollow(servers[ 0 ], servers[ 2 ])
await doubleFollow(servers[0], servers[2])
// Server 2 and server 3 follow each other
await doubleFollow(servers[ 1 ], servers[ 2 ])
await doubleFollow(servers[1], servers[2])
await waitJobs(servers)
}
@@ -115,7 +115,7 @@ async function check1WebSeed (videoUUID?: string) {
if (!videoUUID) videoUUID = video1Server2UUID
const webseeds = [
`http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}`
`http://localhost:${servers[1].port}/static/webseed/${videoUUID}`
]
for (const server of servers) {
@@ -133,8 +133,8 @@ async function check2Webseeds (videoUUID?: string) {
if (!videoUUID) videoUUID = video1Server2UUID
const webseeds = [
`http://localhost:${servers[ 0 ].port}/static/redundancy/${videoUUID}`,
`http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}`
`http://localhost:${servers[0].port}/static/redundancy/${videoUUID}`,
`http://localhost:${servers[1].port}/static/webseed/${videoUUID}`
]
for (const server of servers) {
@@ -269,12 +269,12 @@ async function checkStatsWith1Webseed (strategy: VideoRedundancyStrategyWithManu
}
async function enableRedundancyOnServer1 () {
await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true)
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: '-createdAt' })
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' })
const follows: ActorFollow[] = res.body.data
const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`)
const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`)
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
expect(server3).to.not.be.undefined
expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -284,12 +284,12 @@ async function enableRedundancyOnServer1 () {
}
async function disableRedundancyOnServer1 () {
await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, false)
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false)
const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: '-createdAt' })
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' })
const follows: ActorFollow[] = res.body.data
const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`)
const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`)
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
expect(server3).to.not.be.undefined
expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -434,8 +434,8 @@ describe('Test videos redundancy', function () {
it('Should view 2 times the first video to have > min_views config', async function () {
this.timeout(80000)
await viewVideo(servers[ 0 ].url, video1Server2UUID)
await viewVideo(servers[ 2 ].url, video1Server2UUID)
await viewVideo(servers[0].url, video1Server2UUID)
await viewVideo(servers[2].url, video1Server2UUID)
await wait(10000)
await waitJobs(servers)
@@ -620,7 +620,7 @@ describe('Test videos redundancy', function () {
await check1PlaylistRedundancies()
await checkStatsWith2Webseed(strategy)
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 2 server 2' })
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' })
video2Server2UUID = res.body.video.uuid
})
@@ -652,8 +652,8 @@ describe('Test videos redundancy', function () {
await waitJobs(servers)
killallServers([ servers[ 0 ] ])
await reRunServer(servers[ 0 ], {
killallServers([ servers[0] ])
await reRunServer(servers[0], {
redundancy: {
videos: {
check_interval: '1 second',

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 'mocha'
@@ -39,7 +39,7 @@ describe('Test ActivityPub video channels search', function () {
await setAccessTokensToServers(servers)
{
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: 'user1_server1', password: 'password' })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'user1_server1', password: 'password' })
const channel = {
name: 'channel1_server1',
displayName: 'Channel 1 server 1'
@@ -49,7 +49,7 @@ describe('Test ActivityPub video channels search', function () {
{
const user = { username: 'user1_server2', password: 'password' }
await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
userServer2Token = await userLogin(servers[1], user)
const channel = {
@@ -70,8 +70,8 @@ describe('Test ActivityPub video channels search', function () {
this.timeout(15000)
{
const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server3'
const res = await searchVideoChannel(servers[ 0 ].url, search, servers[ 0 ].accessToken)
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server3'
const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')
@@ -80,7 +80,7 @@ describe('Test ActivityPub video channels search', function () {
{
// Without token
const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const res = await searchVideoChannel(servers[0].url, search)
expect(res.body.total).to.equal(0)
@@ -91,35 +91,35 @@ describe('Test ActivityPub video channels search', function () {
it('Should search a local video channel', async function () {
const searches = [
'http://localhost:' + servers[ 0 ].port + '/video-channels/channel1_server1',
'channel1_server1@localhost:' + servers[ 0 ].port
'http://localhost:' + servers[0].port + '/video-channels/channel1_server1',
'channel1_server1@localhost:' + servers[0].port
]
for (const search of searches) {
const res = await searchVideoChannel(servers[ 0 ].url, search)
const res = await searchVideoChannel(servers[0].url, search)
expect(res.body.total).to.equal(1)
expect(res.body.data).to.be.an('array')
expect(res.body.data).to.have.lengthOf(1)
expect(res.body.data[ 0 ].name).to.equal('channel1_server1')
expect(res.body.data[ 0 ].displayName).to.equal('Channel 1 server 1')
expect(res.body.data[0].name).to.equal('channel1_server1')
expect(res.body.data[0].displayName).to.equal('Channel 1 server 1')
}
})
it('Should search a remote video channel with URL or handle', async function () {
const searches = [
'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2',
'channel1_server2@localhost:' + servers[ 1 ].port
'http://localhost:' + servers[1].port + '/video-channels/channel1_server2',
'channel1_server2@localhost:' + servers[1].port
]
for (const search of searches) {
const res = await searchVideoChannel(servers[ 0 ].url, search, servers[ 0 ].accessToken)
const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
expect(res.body.total).to.equal(1)
expect(res.body.data).to.be.an('array')
expect(res.body.data).to.have.lengthOf(1)
expect(res.body.data[ 0 ].name).to.equal('channel1_server2')
expect(res.body.data[ 0 ].displayName).to.equal('Channel 1 server 2')
expect(res.body.data[0].name).to.equal('channel1_server2')
expect(res.body.data[0].displayName).to.equal('Channel 1 server 2')
}
})
@@ -137,13 +137,13 @@ describe('Test ActivityPub video channels search', function () {
await waitJobs(servers)
const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[ 1 ].port, 0, 5)
const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[1].port, 0, 5)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.have.lengthOf(0)
})
it('Should list video channel videos of server 2 with token', async function () {
const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[ 1 ].port, 0, 5)
const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[1].port, 0, 5)
expect(res.body.total).to.equal(1)
expect(res.body.data[0].name).to.equal('video 1 server 2')
@@ -159,7 +159,7 @@ describe('Test ActivityPub video channels search', function () {
// Expire video channel
await wait(10000)
const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
expect(res.body.total).to.equal(1)
expect(res.body.data).to.have.lengthOf(1)
@@ -182,12 +182,12 @@ describe('Test ActivityPub video channels search', function () {
// Expire video channel
await wait(10000)
const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
await waitJobs(servers)
const videoChannelName = 'channel1_server2@localhost:' + servers[ 1 ].port
const videoChannelName = 'channel1_server2@localhost:' + servers[1].port
const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, videoChannelName, 0, 5, '-createdAt')
expect(res.body.total).to.equal(2)
@@ -204,7 +204,7 @@ describe('Test ActivityPub video channels search', function () {
// Expire video
await wait(10000)
const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.have.lengthOf(0)

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 'mocha'
@@ -34,12 +34,12 @@ describe('Test ActivityPub videos search', function () {
await setAccessTokensToServers(servers)
{
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1 on server 1' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1 on server 1' })
videoServer1UUID = res.body.video.uuid
}
{
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 on server 2' })
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 on server 2' })
videoServer2UUID = res.body.video.uuid
}
@@ -49,7 +49,7 @@ describe('Test ActivityPub videos search', function () {
it('Should not find a remote video', async function () {
{
const search = 'http://localhost:' + servers[1].port + '/videos/watch/43'
const res = await searchVideoWithToken(servers[ 0 ].url, search, servers[ 0 ].accessToken)
const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')

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 'mocha'
@@ -78,7 +78,7 @@ describe('Test videos search', function () {
const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined })
await uploadVideo(server.url, server.accessToken, attributes5)
const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2 '] })
const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] })
await uploadVideo(server.url, server.accessToken, attributes6)
const attributes7 = immutableAssign(attributes1, {
@@ -269,16 +269,16 @@ describe('Test videos search', function () {
{
const res = await advancedVideosSearch(server.url, query)
expect(res.body.total).to.equal(2)
expect(res.body.data[ 0 ].name).to.equal('1111 2222 3333 - 3')
expect(res.body.data[ 1 ].name).to.equal('1111 2222 3333 - 4')
expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3')
expect(res.body.data[1].name).to.equal('1111 2222 3333 - 4')
}
{
const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'pl', 'en', '_unknown' ] }))
expect(res.body.total).to.equal(3)
expect(res.body.data[ 0 ].name).to.equal('1111 2222 3333 - 3')
expect(res.body.data[ 1 ].name).to.equal('1111 2222 3333 - 4')
expect(res.body.data[ 2 ].name).to.equal('1111 2222 3333 - 5')
expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3')
expect(res.body.data[1].name).to.equal('1111 2222 3333 - 4')
expect(res.body.data[2].name).to.equal('1111 2222 3333 - 5')
}
{

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 'mocha'
@@ -59,9 +59,10 @@ async function server1Follows2 (servers: ServerInfo[]) {
async function resetFollows (servers: ServerInfo[]) {
try {
await unfollow(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ])
await unfollow(servers[ 1 ].url, servers[ 1 ].accessToken, servers[ 0 ])
} catch { /* empty */ }
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
await unfollow(servers[1].url, servers[1].accessToken, servers[0])
} catch { /* empty */
}
await waitJobs(servers)
@@ -163,8 +164,8 @@ describe('Test auto follows', function () {
await wait(5000)
await waitJobs(servers)
await checkFollow(servers[ 0 ], servers[ 1 ], false)
await checkFollow(servers[ 1 ], servers[ 0 ], false)
await checkFollow(servers[0], servers[1], false)
await checkFollow(servers[1], servers[0], false)
})
it('Should auto follow the index', async function () {
@@ -187,7 +188,7 @@ describe('Test auto follows', function () {
await wait(5000)
await waitJobs(servers)
await checkFollow(servers[ 0 ], servers[ 1 ], true)
await checkFollow(servers[0], servers[1], true)
await resetFollows(servers)
})
@@ -200,8 +201,8 @@ describe('Test auto follows', function () {
await wait(5000)
await waitJobs(servers)
await checkFollow(servers[ 0 ], servers[ 1 ], false)
await checkFollow(servers[ 0 ], servers[ 2 ], true)
await checkFollow(servers[0], servers[1], false)
await checkFollow(servers[0], servers[2], true)
})
})

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import * as chai from 'chai'
@@ -11,11 +11,14 @@ import {
getAbout,
getConfig,
getCustomConfig,
killallServers, parallelTests,
killallServers,
parallelTests,
registerUser,
reRunServer, ServerInfo,
reRunServer,
ServerInfo,
setAccessTokensToServers,
updateCustomConfig, uploadVideo
updateCustomConfig,
uploadVideo
} from '../../../../shared/extra-utils'
import { ServerConfig } from '../../../../shared/models'

View File

@@ -1,16 +1,8 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
flushTests,
killallServers,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
wait,
cleanupTests
} from '../../../../shared/extra-utils'
import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, wait } from '../../../../shared/extra-utils'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'

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 'mocha'

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 'mocha'
@@ -35,11 +35,11 @@ describe('Test follow constraints', function () {
await setAccessTokensToServers(servers)
{
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video server 1' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video server 1' })
video1UUID = res.body.video.uuid
}
{
const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video server 2' })
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video server 2' })
video2UUID = res.body.video.uuid
}
@@ -47,7 +47,7 @@ describe('Test follow constraints', function () {
username: 'user1',
password: 'super_password'
}
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
userAccessToken = await userLogin(servers[0], user)
await doubleFollow(servers[0], servers[1])

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 'mocha'
@@ -24,7 +24,7 @@ const expect = chai.expect
async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
{
const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
const follow = res.body.data[0] as ActorFollow
@@ -34,7 +34,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
}
{
const res = await getFollowersListPaginationAndSort({ url: servers[ 1 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
const follow = res.body.data[0] as ActorFollow
@@ -46,12 +46,12 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
async function checkNoFollowers (servers: ServerInfo[]) {
{
const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(0)
}
{
const res = await getFollowersListPaginationAndSort({ url: servers[ 1 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(0)
}
}
@@ -164,17 +164,17 @@ describe('Test follows moderation', function () {
await waitJobs(servers)
{
const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(2)
}
{
const res = await getFollowersListPaginationAndSort({ url: servers[ 1 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
}
{
const res = await getFollowersListPaginationAndSort({ url: servers[ 2 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
}
@@ -184,7 +184,7 @@ describe('Test follows moderation', function () {
await checkServer1And2HasFollowers(servers)
{
const res = await getFollowersListPaginationAndSort({ url: servers[ 2 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(0)
}
})

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 'mocha'
@@ -78,14 +78,14 @@ describe('Test follows', function () {
})
it('Should have 2 followings on server 1', async function () {
let res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 1, sort: 'createdAt' })
let res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 1, sort: 'createdAt' })
let follows = res.body.data
expect(res.body.total).to.equal(2)
expect(follows).to.be.an('array')
expect(follows.length).to.equal(1)
res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 1, count: 1, sort: 'createdAt' })
res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 1, count: 1, sort: 'createdAt' })
follows = follows.concat(res.body.data)
const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port)
@@ -101,7 +101,7 @@ describe('Test follows', function () {
const sort = 'createdAt'
const start = 0
const count = 1
const url = servers[ 0 ].url
const url = servers[0].url
{
const search = ':' + servers[1].port
@@ -112,7 +112,7 @@ describe('Test follows', function () {
expect(res.body.total).to.equal(1)
expect(follows.length).to.equal(1)
expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[ 1 ].port)
expect(follows[0].following.host).to.equal('localhost:' + servers[1].port)
}
{
@@ -170,9 +170,9 @@ describe('Test follows', function () {
it('Should have 1 followers on server 2 and 3', async function () {
for (const server of [ servers[1], servers[2] ]) {
let res = await getFollowersListPaginationAndSort({ url: server.url, start: 0, count: 1, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: server.url, start: 0, count: 1, sort: 'createdAt' })
let follows = res.body.data
const follows = res.body.data
expect(res.body.total).to.equal(1)
expect(follows).to.be.an('array')
expect(follows.length).to.equal(1)
@@ -181,7 +181,7 @@ describe('Test follows', function () {
})
it('Should search/filter followers on server 2', async function () {
const url = servers[ 2 ].url
const url = servers[2].url
const start = 0
const count = 5
const sort = 'createdAt'
@@ -195,7 +195,7 @@ describe('Test follows', function () {
expect(res.body.total).to.equal(1)
expect(follows.length).to.equal(1)
expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[ 2 ].port)
expect(follows[0].following.host).to.equal('localhost:' + servers[2].port)
}
{
@@ -241,7 +241,7 @@ describe('Test follows', function () {
})
it('Should have 0 followers on server 1', async function () {
const res = await getFollowersListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 5, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
const follows = res.body.data
expect(res.body.total).to.equal(0)
@@ -271,8 +271,8 @@ describe('Test follows', function () {
})
it('Should not follow server 3 on server 1 anymore', async function () {
const res = await getFollowingListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 2, sort: 'createdAt' })
let follows = res.body.data
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 2, sort: 'createdAt' })
const follows = res.body.data
expect(res.body.total).to.equal(1)
expect(follows).to.be.an('array')
@@ -282,9 +282,9 @@ describe('Test follows', function () {
})
it('Should not have server 1 as follower on server 3 anymore', async function () {
const res = await getFollowersListPaginationAndSort({ url: servers[ 2 ].url, start: 0, count: 1, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 1, sort: 'createdAt' })
let follows = res.body.data
const follows = res.body.data
expect(res.body.total).to.equal(0)
expect(follows).to.be.an('array')
expect(follows.length).to.equal(0)
@@ -336,59 +336,59 @@ describe('Test follows', function () {
tags: [ 'tag1', 'tag2', 'tag3' ]
}
await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-2' })
await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-3' })
await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4Attributes)
await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-5' })
await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-6' })
await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' })
await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' })
await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes)
await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' })
await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' })
{
const user = { username: 'captain', password: 'password' }
await createUser({ url: servers[ 2 ].url, accessToken: servers[ 2 ].accessToken, username: user.username, password: user.password })
const userAccessToken = await userLogin(servers[ 2 ], user)
await createUser({ url: servers[2].url, accessToken: servers[2].accessToken, username: user.username, password: user.password })
const userAccessToken = await userLogin(servers[2], user)
const resVideos = await getVideosList(servers[ 2 ].url)
const resVideos = await getVideosList(servers[2].url)
video4 = resVideos.body.data.find(v => v.name === 'server3-4')
{
await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like')
await rateVideo(servers[ 2 ].url, userAccessToken, video4.id, 'dislike')
await rateVideo(servers[2].url, servers[2].accessToken, video4.id, 'like')
await rateVideo(servers[2].url, userAccessToken, video4.id, 'dislike')
}
{
{
const text = 'my super first comment'
const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
const res = await addVideoCommentThread(servers[2].url, servers[2].accessToken, video4.id, text)
const threadId = res.body.comment.id
const text1 = 'my super answer to thread 1'
const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1)
const childCommentRes = await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text1)
const childCommentId = childCommentRes.body.comment.id
const text2 = 'my super answer to answer of thread 1'
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text2)
await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, childCommentId, text2)
const text3 = 'my second answer to thread 1'
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text3)
await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text3)
}
{
const text = 'will be deleted'
const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
const res = await addVideoCommentThread(servers[2].url, servers[2].accessToken, video4.id, text)
const threadId = res.body.comment.id
const text1 = 'answer to deleted'
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1)
await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text1)
const text2 = 'will also be deleted'
const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text2)
const childCommentRes = await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text2)
const childCommentId = childCommentRes.body.comment.id
const text3 = 'my second answer to deleted'
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text3)
await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, childCommentId, text3)
await deleteVideoComment(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId)
await deleteVideoComment(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId)
await deleteVideoComment(servers[2].url, servers[2].accessToken, video4.id, threadId)
await deleteVideoComment(servers[2].url, servers[2].accessToken, video4.id, childCommentId)
}
}
@@ -406,7 +406,7 @@ describe('Test follows', function () {
await waitJobs(servers)
// Server 1 follows server 3
await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken)
await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken)
await waitJobs(servers)
})
@@ -424,7 +424,7 @@ describe('Test follows', function () {
})
it('Should have propagated videos', async function () {
const res = await getVideosList(servers[ 0 ].url)
const res = await getVideosList(servers[0].url)
expect(res.body.total).to.equal(7)
const video2 = res.body.data.find(v => v.name === 'server3-2')
@@ -470,7 +470,7 @@ describe('Test follows', function () {
}
]
}
await completeVideoCheck(servers[ 0 ].url, video4, checkAttributes)
await completeVideoCheck(servers[0].url, video4, checkAttributes)
})
it('Should have propagated comments', async function () {
@@ -481,34 +481,34 @@ describe('Test follows', function () {
expect(res1.body.data).to.have.lengthOf(2)
{
const comment: VideoComment = res1.body.data[ 0 ]
const comment: VideoComment = res1.body.data[0]
expect(comment.inReplyToCommentId).to.be.null
expect(comment.text).equal('my super first comment')
expect(comment.videoId).to.equal(video4.id)
expect(comment.id).to.equal(comment.threadId)
expect(comment.account.name).to.equal('root')
expect(comment.account.host).to.equal('localhost:' + servers[ 2 ].port)
expect(comment.account.host).to.equal('localhost:' + servers[2].port)
expect(comment.totalReplies).to.equal(3)
expect(dateIsValid(comment.createdAt as string)).to.be.true
expect(dateIsValid(comment.updatedAt as string)).to.be.true
const threadId = comment.threadId
const res2 = await getVideoThreadComments(servers[ 0 ].url, video4.id, threadId)
const res2 = await getVideoThreadComments(servers[0].url, video4.id, threadId)
const tree: VideoCommentThreadTree = res2.body
expect(tree.comment.text).equal('my super first comment')
expect(tree.children).to.have.lengthOf(2)
const firstChild = tree.children[ 0 ]
const firstChild = tree.children[0]
expect(firstChild.comment.text).to.equal('my super answer to thread 1')
expect(firstChild.children).to.have.lengthOf(1)
const childOfFirstChild = firstChild.children[ 0 ]
const childOfFirstChild = firstChild.children[0]
expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
expect(childOfFirstChild.children).to.have.lengthOf(0)
const secondChild = tree.children[ 1 ]
const secondChild = tree.children[1]
expect(secondChild.comment.text).to.equal('my second answer to thread 1')
expect(secondChild.children).to.have.lengthOf(0)
}
@@ -569,7 +569,7 @@ describe('Test follows', function () {
await waitJobs(servers)
let res = await getVideosList(servers[ 0 ].url)
const res = await getVideosList(servers[0].url)
expect(res.body.total).to.equal(1)
})

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 'mocha'
@@ -8,6 +8,7 @@ import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-c
import {
cleanupTests,
closeAllSequelize,
completeVideoCheck,
flushAndRunMultipleServers,
getVideo,
@@ -17,11 +18,12 @@ import {
reRunServer,
ServerInfo,
setAccessTokensToServers,
setActorFollowScores,
unfollow,
updateVideo,
uploadVideo, uploadVideoAndGetId,
wait,
setActorFollowScores, closeAllSequelize
uploadVideo,
uploadVideoAndGetId,
wait
} from '../../../../shared/extra-utils'
import { follow, getFollowersListPaginationAndSort } from '../../../../shared/extra-utils/server/follows'
import { getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -44,7 +46,7 @@ describe('Test handle downs', function () {
let missedVideo2: Video
let unlistedVideo: Video
let videoIdsServer1: number[] = []
const videoIdsServer1: number[] = []
const videoAttributes = {
name: 'my super name for server 1',
@@ -137,7 +139,7 @@ describe('Test handle downs', function () {
// Remove server 2 follower
for (let i = 0; i < 10; i++) {
await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
}
await waitJobs(servers[0])
@@ -145,14 +147,14 @@ describe('Test handle downs', function () {
// Kill server 3
killallServers([ servers[2] ])
const resLastVideo1 = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
const resLastVideo1 = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
missedVideo1 = resLastVideo1.body.video
const resLastVideo2 = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
const resLastVideo2 = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
missedVideo2 = resLastVideo2.body.video
// Unlisted video
let resVideo = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, unlistedVideoAttributes)
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, unlistedVideoAttributes)
unlistedVideo = resVideo.body.video
// Add comments to video 2
@@ -174,7 +176,7 @@ describe('Test handle downs', function () {
await wait(11000)
// Only server 3 is still a follower of server 1
const res = await getFollowersListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 2, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[0].url, start: 0, count: 2, sort: 'createdAt' })
expect(res.body.data).to.be.an('array')
expect(res.body.data).to.have.lengthOf(1)
expect(res.body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
@@ -185,8 +187,8 @@ describe('Test handle downs', function () {
for (const state of states) {
const res = await getJobsListPaginationAndSort({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
state: state,
start: 0,
count: 50,
@@ -209,7 +211,7 @@ describe('Test handle downs', function () {
await waitJobs(servers)
const res = await getFollowersListPaginationAndSort({ url: servers[ 0 ].url, start: 0, count: 2, sort: 'createdAt' })
const res = await getFollowersListPaginationAndSort({ url: servers[0].url, start: 0, count: 2, sort: 'createdAt' })
expect(res.body.data).to.be.an('array')
expect(res.body.data).to.have.lengthOf(2)
})
@@ -221,8 +223,8 @@ describe('Test handle downs', function () {
expect(res1.body.data).to.be.an('array')
expect(res1.body.data).to.have.lengthOf(11)
await updateVideo(servers[0].url, servers[0].accessToken, missedVideo1.uuid, { })
await updateVideo(servers[0].url, servers[0].accessToken, unlistedVideo.uuid, { })
await updateVideo(servers[0].url, servers[0].accessToken, missedVideo1.uuid, {})
await updateVideo(servers[0].url, servers[0].accessToken, unlistedVideo.uuid, {})
await waitJobs(servers)
@@ -313,14 +315,14 @@ describe('Test handle downs', function () {
this.timeout(120000)
for (let i = 0; i < 10; i++) {
const uuid = (await uploadVideoAndGetId({ server: servers[ 0 ], videoName: 'video ' + i })).uuid
const uuid = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video ' + i })).uuid
videoIdsServer1.push(uuid)
}
await waitJobs(servers)
for (const id of videoIdsServer1) {
await getVideo(servers[ 1 ].url, id)
await getVideo(servers[1].url, id)
}
await waitJobs(servers)

View File

@@ -1,8 +1,8 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import { cleanupTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { cleanupTests, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { flushAndRunMultipleServers } from '../../../../shared/extra-utils/server/servers'
@@ -44,8 +44,8 @@ describe('Test jobs', function () {
it('Should list jobs with sort, pagination and job type', async function () {
{
const res = await getJobsListPaginationAndSort({
url: servers[ 1 ].url,
accessToken: servers[ 1 ].accessToken,
url: servers[1].url,
accessToken: servers[1].accessToken,
state: 'completed',
start: 1,
count: 2,
@@ -54,9 +54,9 @@ describe('Test jobs', function () {
expect(res.body.total).to.be.above(2)
expect(res.body.data).to.have.lengthOf(2)
let job: Job = res.body.data[ 0 ]
let job: Job = res.body.data[0]
// Skip repeat jobs
if (job.type === 'videos-views') job = res.body.data[ 1 ]
if (job.type === 'videos-views') job = res.body.data[1]
expect(job.state).to.equal('completed')
expect(job.type.startsWith('activitypub-')).to.be.true
@@ -67,8 +67,8 @@ describe('Test jobs', function () {
{
const res = await getJobsListPaginationAndSort({
url: servers[ 1 ].url,
accessToken: servers[ 1 ].accessToken,
url: servers[1].url,
accessToken: servers[1].accessToken,
state: 'completed',
start: 0,
count: 100,

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 'mocha'

View File

@@ -9,7 +9,7 @@ describe('Start and stop server without web client routes', function () {
before(async function () {
this.timeout(30000)
server = await flushAndRunServer(1, {}, ['--no-client'])
server = await flushAndRunServer(1, {}, [ '--no-client' ])
})
it('Should fail getting the client', function () {

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import * as chai from 'chai'
@@ -6,19 +6,28 @@ import {
cleanupTests,
closeAllSequelize,
flushAndRunServer,
getConfig, getMyUserInformation, getPluginPackageJSON,
getConfig,
getMyUserInformation,
getPlugin,
getPluginPackageJSON,
getPluginRegisteredSettings,
getPluginsCSS,
installPlugin, killallServers,
getPublicSettings,
installPlugin,
killallServers,
listAvailablePlugins,
listPlugins, reRunServer,
listPlugins,
reRunServer,
ServerInfo,
setAccessTokensToServers,
setPluginVersion, uninstallPlugin,
updateCustomSubConfig, updateMyUser, updatePluginPackageJSON, updatePlugin,
setPluginVersion,
uninstallPlugin,
updateCustomSubConfig,
updateMyUser,
updatePlugin,
updatePluginPackageJSON,
updatePluginSettings,
wait, getPublicSettings
wait
} from '../../../../shared/extra-utils'
import { PluginType } from '../../../../shared/models/plugins/plugin.type'
import { PeerTubePluginIndex } from '../../../../shared/models/plugins/peertube-plugin-index.model'
@@ -88,7 +97,7 @@ describe('Test plugins', function () {
expect(res2.body.total).to.be.at.least(2)
expect(data2).to.have.lengthOf(2)
expect(data1[0].npmName).to.not.equal(data2[ 0 ].npmName)
expect(data1[0].npmName).to.not.equal(data2[0].npmName)
}
{

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import * as chai 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 * as chai from 'chai'
import 'mocha'
@@ -9,13 +9,12 @@ import {
doubleFollow,
flushAndRunMultipleServers,
follow,
killallServers,
ServerInfo,
uploadVideo,
viewVideo,
wait
} from '../../../../shared/extra-utils'
import { flushTests, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { getStats } from '../../../../shared/extra-utils/server/stats'
import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -36,7 +35,7 @@ describe('Test stats (excluding redundancy)', function () {
username: 'user1',
password: 'super_password'
}
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' })
const videoUUID = resVideo.body.video.uuid

View File

@@ -1,4 +1,4 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await,@typescript-eslint/no-floating-promises */
import * as magnetUtil from 'magnet-uri'
import 'mocha'

View File

@@ -1,21 +1,20 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import { AccountBlock, ServerBlock, UserNotificationType, Video } from '../../../../shared/index'
import { AccountBlock, ServerBlock, Video } from '../../../../shared/index'
import {
cleanupTests,
createUser, deleteVideoComment,
createUser,
deleteVideoComment,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
killallServers,
ServerInfo,
uploadVideo,
userLogin
} from '../../../../shared/extra-utils/index'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
import { getVideosListWithToken, getVideosList } from '../../../../shared/extra-utils/videos/videos'
import { getVideosList, getVideosListWithToken } from '../../../../shared/extra-utils/videos/videos'
import {
addVideoCommentReply,
addVideoCommentThread,
@@ -79,7 +78,7 @@ async function checkCommentNotification (
const resComment = await addVideoCommentThread(comment.server.url, comment.token, comment.videoUUID, comment.text)
const threadId = resComment.body.comment.id
await waitJobs([ mainServer, comment.server])
await waitJobs([ mainServer, comment.server ])
const res = await getUserNotifications(mainServer.url, mainServer.accessToken, 0, 30)
const commentNotifications = res.body.data
@@ -90,7 +89,7 @@ async function checkCommentNotification (
await deleteVideoComment(comment.server.url, comment.token, comment.videoUUID, threadId)
await waitJobs([ mainServer, comment.server])
await waitJobs([ mainServer, comment.server ])
}
describe('Test blocklist', function () {
@@ -109,7 +108,7 @@ describe('Test blocklist', function () {
{
const user = { username: 'user1', password: 'password' }
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
userToken1 = await userLogin(servers[0], user)
await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
@@ -117,14 +116,14 @@ describe('Test blocklist', function () {
{
const user = { username: 'moderator', password: 'password' }
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
userModeratorToken = await userLogin(servers[0], user)
}
{
const user = { username: 'user2', password: 'password' }
await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
userToken2 = await userLogin(servers[1], user)
await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
@@ -143,14 +142,14 @@ describe('Test blocklist', function () {
await doubleFollow(servers[0], servers[1])
{
const resComment = await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1, 'comment root 1')
const resReply = await addVideoCommentReply(servers[ 0 ].url, userToken1, videoUUID1, resComment.body.comment.id, 'comment user 1')
await addVideoCommentReply(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1, resReply.body.comment.id, 'comment root 1')
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID1, 'comment root 1')
const resReply = await addVideoCommentReply(servers[0].url, userToken1, videoUUID1, resComment.body.comment.id, 'comment user 1')
await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID1, resReply.body.comment.id, 'comment root 1')
}
{
const resComment = await addVideoCommentThread(servers[ 0 ].url, userToken1, videoUUID1, 'comment user 1')
await addVideoCommentReply(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1, resComment.body.comment.id, 'comment root 1')
const resComment = await addVideoCommentThread(servers[0].url, userToken1, videoUUID1, 'comment user 1')
await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID1, resComment.body.comment.id, 'comment root 1')
}
await waitJobs(servers)
@@ -160,19 +159,19 @@ describe('Test blocklist', function () {
describe('When managing account blocklist', function () {
it('Should list all videos', function () {
return checkAllVideos(servers[ 0 ].url, servers[ 0 ].accessToken)
return checkAllVideos(servers[0].url, servers[0].accessToken)
})
it('Should list the comments', function () {
return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
})
it('Should block a remote account', async function () {
await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(3)
@@ -182,11 +181,11 @@ describe('Test blocklist', function () {
})
it('Should block a local account', async function () {
await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1')
})
it('Should hide its videos', async function () {
const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(2)
@@ -196,17 +195,17 @@ describe('Test blocklist', function () {
})
it('Should hide its comments', async function () {
const resThreads = await getVideoCommentThreads(servers[ 0 ].url, videoUUID1, 0, 5, '-createdAt', servers[ 0 ].accessToken)
const resThreads = await getVideoCommentThreads(servers[0].url, videoUUID1, 0, 5, '-createdAt', servers[0].accessToken)
const threads: VideoComment[] = resThreads.body.data
expect(threads).to.have.lengthOf(1)
expect(threads[ 0 ].totalReplies).to.equal(0)
expect(threads[0].totalReplies).to.equal(0)
const t = threads.find(t => t.text === 'comment user 1')
expect(t).to.be.undefined
for (const thread of threads) {
const res = await getVideoThreadComments(servers[ 0 ].url, videoUUID1, thread.id, servers[ 0 ].accessToken)
const res = await getVideoThreadComments(servers[0].url, videoUUID1, thread.id, servers[0].accessToken)
const tree: VideoCommentThreadTree = res.body
expect(tree.children).to.have.lengthOf(0)
@@ -217,37 +216,37 @@ describe('Test blocklist', function () {
this.timeout(20000)
{
const comment = { server: servers[ 0 ], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[ 0 ], comment, 'absence')
const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[0], comment, 'absence')
}
{
const comment = {
server: servers[ 0 ],
server: servers[0],
token: userToken1,
videoUUID: videoUUID2,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'absence')
await checkCommentNotification(servers[0], comment, 'absence')
}
})
it('Should list all the videos with another user', async function () {
return checkAllVideos(servers[ 0 ].url, userToken1)
return checkAllVideos(servers[0].url, userToken1)
})
it('Should list all the comments with another user', async function () {
return checkAllComments(servers[ 0 ].url, userToken1, videoUUID1)
return checkAllComments(servers[0].url, userToken1, videoUUID1)
})
it('Should list blocked accounts', async function () {
{
const res = await getAccountBlocklistByAccount(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
const blocks: AccountBlock[] = res.body.data
expect(res.body.total).to.equal(2)
const block = blocks[ 0 ]
const block = blocks[0]
expect(block.byAccount.displayName).to.equal('root')
expect(block.byAccount.name).to.equal('root')
expect(block.blockedAccount.displayName).to.equal('user2')
@@ -256,12 +255,12 @@ describe('Test blocklist', function () {
}
{
const res = await getAccountBlocklistByAccount(servers[ 0 ].url, servers[ 0 ].accessToken, 1, 2, 'createdAt')
const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt')
const blocks: AccountBlock[] = res.body.data
expect(res.body.total).to.equal(2)
const block = blocks[ 0 ]
const block = blocks[0]
expect(block.byAccount.displayName).to.equal('root')
expect(block.byAccount.name).to.equal('root')
expect(block.blockedAccount.displayName).to.equal('user1')
@@ -271,11 +270,11 @@ describe('Test blocklist', function () {
})
it('Should unblock the remote account', async function () {
await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should display its videos', async function () {
const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(3)
@@ -285,48 +284,48 @@ describe('Test blocklist', function () {
})
it('Should unblock the local account', async function () {
await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1')
})
it('Should display its comments', function () {
return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
})
it('Should have a notification from a non blocked account', async function () {
this.timeout(20000)
{
const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[ 0 ], comment, 'presence')
const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[0], comment, 'presence')
}
{
const comment = {
server: servers[ 0 ],
server: servers[0],
token: userToken1,
videoUUID: videoUUID2,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'presence')
await checkCommentNotification(servers[0], comment, 'presence')
}
})
})
describe('When managing server blocklist', function () {
it('Should list all videos', function () {
return checkAllVideos(servers[ 0 ].url, servers[ 0 ].accessToken)
return checkAllVideos(servers[0].url, servers[0].accessToken)
})
it('Should list the comments', function () {
return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
})
it('Should block a remote server', async function () {
await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
await addServerToAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(2)
@@ -339,81 +338,81 @@ describe('Test blocklist', function () {
})
it('Should list all the videos with another user', async function () {
return checkAllVideos(servers[ 0 ].url, userToken1)
return checkAllVideos(servers[0].url, userToken1)
})
it('Should hide its comments', async function () {
this.timeout(10000)
const resThreads = await addVideoCommentThread(servers[ 1 ].url, userToken2, videoUUID1, 'hidden comment 2')
const resThreads = await addVideoCommentThread(servers[1].url, userToken2, videoUUID1, 'hidden comment 2')
const threadId = resThreads.body.comment.id
await waitJobs(servers)
await checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
await checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
await deleteVideoComment(servers[ 1 ].url, userToken2, videoUUID1, threadId)
await deleteVideoComment(servers[1].url, userToken2, videoUUID1, threadId)
})
it('Should not have notifications from blocked server', async function () {
this.timeout(20000)
{
const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[ 0 ], comment, 'absence')
const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[0], comment, 'absence')
}
{
const comment = {
server: servers[ 1 ],
server: servers[1],
token: userToken2,
videoUUID: videoUUID1,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'absence')
await checkCommentNotification(servers[0], comment, 'absence')
}
})
it('Should list blocked servers', async function () {
const res = await getServerBlocklistByAccount(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
const res = await getServerBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
const blocks: ServerBlock[] = res.body.data
expect(res.body.total).to.equal(1)
const block = blocks[ 0 ]
const block = blocks[0]
expect(block.byAccount.displayName).to.equal('root')
expect(block.byAccount.name).to.equal('root')
expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
})
it('Should unblock the remote server', async function () {
await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
await removeServerFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
})
it('Should display its videos', function () {
return checkAllVideos(servers[ 0 ].url, servers[ 0 ].accessToken)
return checkAllVideos(servers[0].url, servers[0].accessToken)
})
it('Should display its comments', function () {
return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
})
it('Should have notification from unblocked server', async function () {
this.timeout(20000)
{
const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[ 0 ], comment, 'presence')
const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[0], comment, 'presence')
}
{
const comment = {
server: servers[ 1 ],
server: servers[1],
token: userToken2,
videoUUID: videoUUID1,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'presence')
await checkCommentNotification(servers[0], comment, 'presence')
}
})
})
@@ -423,24 +422,24 @@ describe('Test blocklist', function () {
describe('When managing account blocklist', function () {
it('Should list all videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllVideos(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllVideos(servers[0].url, token)
}
})
it('Should list the comments', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllComments(servers[ 0 ].url, token, videoUUID1)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllComments(servers[0].url, token, videoUUID1)
}
})
it('Should block a remote account', async function () {
await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
const res = await getVideosListWithToken(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const res = await getVideosListWithToken(servers[0].url, token)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(3)
@@ -451,12 +450,12 @@ describe('Test blocklist', function () {
})
it('Should block a local account', async function () {
await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user1')
})
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
const res = await getVideosListWithToken(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const res = await getVideosListWithToken(servers[0].url, token)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(2)
@@ -467,18 +466,18 @@ describe('Test blocklist', function () {
})
it('Should hide its comments', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
const resThreads = await getVideoCommentThreads(servers[ 0 ].url, videoUUID1, 0, 5, '-createdAt', token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const resThreads = await getVideoCommentThreads(servers[0].url, videoUUID1, 0, 5, '-createdAt', token)
const threads: VideoComment[] = resThreads.body.data
expect(threads).to.have.lengthOf(1)
expect(threads[ 0 ].totalReplies).to.equal(0)
expect(threads[0].totalReplies).to.equal(0)
const t = threads.find(t => t.text === 'comment user 1')
expect(t).to.be.undefined
for (const thread of threads) {
const res = await getVideoThreadComments(servers[ 0 ].url, videoUUID1, thread.id, token)
const res = await getVideoThreadComments(servers[0].url, videoUUID1, thread.id, token)
const tree: VideoCommentThreadTree = res.body
expect(tree.children).to.have.lengthOf(0)
@@ -490,29 +489,29 @@ describe('Test blocklist', function () {
this.timeout(20000)
{
const comment = { server: servers[ 0 ], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[ 0 ], comment, 'absence')
const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[0], comment, 'absence')
}
{
const comment = {
server: servers[ 1 ],
server: servers[1],
token: userToken2,
videoUUID: videoUUID1,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'absence')
await checkCommentNotification(servers[0], comment, 'absence')
}
})
it('Should list blocked accounts', async function () {
{
const res = await getAccountBlocklistByServer(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
const blocks: AccountBlock[] = res.body.data
expect(res.body.total).to.equal(2)
const block = blocks[ 0 ]
const block = blocks[0]
expect(block.byAccount.displayName).to.equal('peertube')
expect(block.byAccount.name).to.equal('peertube')
expect(block.blockedAccount.displayName).to.equal('user2')
@@ -521,12 +520,12 @@ describe('Test blocklist', function () {
}
{
const res = await getAccountBlocklistByServer(servers[ 0 ].url, servers[ 0 ].accessToken, 1, 2, 'createdAt')
const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt')
const blocks: AccountBlock[] = res.body.data
expect(res.body.total).to.equal(2)
const block = blocks[ 0 ]
const block = blocks[0]
expect(block.byAccount.displayName).to.equal('peertube')
expect(block.byAccount.name).to.equal('peertube')
expect(block.blockedAccount.displayName).to.equal('user1')
@@ -536,12 +535,12 @@ describe('Test blocklist', function () {
})
it('Should unblock the remote account', async function () {
await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should display its videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
const res = await getVideosListWithToken(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const res = await getVideosListWithToken(servers[0].url, token)
const videos: Video[] = res.body.data
expect(videos).to.have.lengthOf(3)
@@ -552,12 +551,12 @@ describe('Test blocklist', function () {
})
it('Should unblock the local account', async function () {
await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user1')
})
it('Should display its comments', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllComments(servers[ 0 ].url, token, videoUUID1)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllComments(servers[0].url, token, videoUUID1)
}
})
@@ -565,43 +564,43 @@ describe('Test blocklist', function () {
this.timeout(20000)
{
const comment = { server: servers[ 0 ], token: userToken1, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[ 0 ], comment, 'presence')
const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[0], comment, 'presence')
}
{
const comment = {
server: servers[ 1 ],
server: servers[1],
token: userToken2,
videoUUID: videoUUID1,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'presence')
await checkCommentNotification(servers[0], comment, 'presence')
}
})
})
describe('When managing server blocklist', function () {
it('Should list all videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllVideos(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllVideos(servers[0].url, token)
}
})
it('Should list the comments', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllComments(servers[ 0 ].url, token, videoUUID1)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllComments(servers[0].url, token, videoUUID1)
}
})
it('Should block a remote server', async function () {
await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
const res1 = await getVideosList(servers[ 0 ].url)
const res2 = await getVideosListWithToken(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const res1 = await getVideosList(servers[0].url)
const res2 = await getVideosListWithToken(servers[0].url, token)
for (const res of [ res1, res2 ]) {
const videos: Video[] = res.body.data
@@ -619,60 +618,60 @@ describe('Test blocklist', function () {
it('Should hide its comments', async function () {
this.timeout(10000)
const resThreads = await addVideoCommentThread(servers[ 1 ].url, userToken2, videoUUID1, 'hidden comment 2')
const resThreads = await addVideoCommentThread(servers[1].url, userToken2, videoUUID1, 'hidden comment 2')
const threadId = resThreads.body.comment.id
await waitJobs(servers)
await checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
await checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
await deleteVideoComment(servers[ 1 ].url, userToken2, videoUUID1, threadId)
await deleteVideoComment(servers[1].url, userToken2, videoUUID1, threadId)
})
it('Should not have notification from blocked instances by instance', async function () {
this.timeout(20000)
{
const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[ 0 ], comment, 'absence')
const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
await checkCommentNotification(servers[0], comment, 'absence')
}
{
const comment = {
server: servers[ 1 ],
server: servers[1],
token: userToken2,
videoUUID: videoUUID1,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'absence')
await checkCommentNotification(servers[0], comment, 'absence')
}
})
it('Should list blocked servers', async function () {
const res = await getServerBlocklistByServer(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
const res = await getServerBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
const blocks: ServerBlock[] = res.body.data
expect(res.body.total).to.equal(1)
const block = blocks[ 0 ]
const block = blocks[0]
expect(block.byAccount.displayName).to.equal('peertube')
expect(block.byAccount.name).to.equal('peertube')
expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
})
it('Should unblock the remote server', async function () {
await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
})
it('Should list all videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllVideos(servers[ 0 ].url, token)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllVideos(servers[0].url, token)
}
})
it('Should list the comments', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
await checkAllComments(servers[ 0 ].url, token, videoUUID1)
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
await checkAllComments(servers[0].url, token, videoUUID1)
}
})
@@ -680,18 +679,18 @@ describe('Test blocklist', function () {
this.timeout(20000)
{
const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[ 0 ], comment, 'presence')
const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
await checkCommentNotification(servers[0], comment, 'presence')
}
{
const comment = {
server: servers[ 1 ],
server: servers[1],
token: userToken2,
videoUUID: videoUUID1,
text: 'hello @root@localhost:' + servers[ 0 ].port
text: 'hello @root@localhost:' + servers[0].port
}
await checkCommentNotification(servers[ 0 ], comment, 'presence')
await checkCommentNotification(servers[0], comment, 'presence')
}
})
})

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 'mocha'
@@ -13,16 +13,17 @@ import {
updateVideo,
userLogin
} from '../../../../shared/extra-utils'
import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
import { Video, VideoChannel } from '../../../../shared/models/videos'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import {
addUserSubscription,
areSubscriptionsExist,
getUserSubscription,
listUserSubscriptions,
listUserSubscriptionVideos,
removeUserSubscription,
getUserSubscription, areSubscriptionsExist
removeUserSubscription
} from '../../../../shared/extra-utils/users/user-subscriptions'
const expect = chai.expect
@@ -116,7 +117,7 @@ describe('Test users subscriptions', function () {
it('Should get subscription', async function () {
{
const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:' + servers[2].port)
const res = await getUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
const videoChannel: VideoChannel = res.body
expect(videoChannel.name).to.equal('user3_channel')
@@ -127,7 +128,7 @@ describe('Test users subscriptions', function () {
}
{
const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:' + servers[0].port)
const res = await getUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)
const videoChannel: VideoChannel = res.body
expect(videoChannel.name).to.equal('root_channel')
@@ -146,7 +147,7 @@ describe('Test users subscriptions', function () {
'user3_channel@localhost:' + servers[0].port
]
const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)
const res = await areSubscriptionsExist(servers[0].url, users[0].accessToken, uris)
const body = res.body
expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true

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 'mocha'
@@ -57,17 +57,17 @@ describe('Test users with multiple servers', function () {
password: 'password'
}
const res = await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: user.username,
password: user.password
})
userId = res.body.user.id
userAccessToken = await userLogin(servers[ 0 ], user)
userAccessToken = await userLogin(servers[0], user)
}
{
const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {})
const resVideo = await uploadVideo(servers[0].url, userAccessToken, {})
videoUUID = resVideo.body.video.uuid
}
@@ -86,7 +86,6 @@ describe('Test users with multiple servers', function () {
const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
user = res.body
const account: Account = user.account
expect(user.account.displayName).to.equal('my super display name')
await waitJobs(servers)

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 'mocha'

View File

@@ -1,8 +1,8 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import { User, UserRole, Video, MyUser, VideoPlaylistType } from '../../../../shared/index'
import { MyUser, User, UserRole, Video, VideoPlaylistType } from '../../../../shared/index'
import {
blockUser,
cleanupTests,
@@ -18,7 +18,8 @@ import {
getUsersList,
getUsersListPaginationAndSort,
getVideoChannel,
getVideosList, installPlugin,
getVideosList,
installPlugin,
login,
makePutBodyRequest,
rateVideo,
@@ -121,13 +122,13 @@ describe('Test users', function () {
it('Should be able to login with an insensitive username', async function () {
const user = { username: 'RoOt', password: server.user.password }
const res = await login(server.url, server.client, user, 200)
await login(server.url, server.client, user, 200)
const user2 = { username: 'rOoT', password: server.user.password }
const res2 = await login(server.url, server.client, user2, 200)
await login(server.url, server.client, user2, 200)
const user3 = { username: 'ROOt', password: server.user.password }
const res3 = await login(server.url, server.client, user3, 200)
await login(server.url, server.client, user3, 200)
})
})
@@ -137,7 +138,7 @@ describe('Test users', function () {
const videoAttributes = {}
await uploadVideo(server.url, accessToken, videoAttributes)
const res = await getVideosList(server.url)
const video = res.body.data[ 0 ]
const video = res.body.data[0]
expect(video.account.name).to.equal('root')
videoId = video.id
@@ -167,8 +168,8 @@ describe('Test users', function () {
const ratings = res.body
expect(ratings.total).to.equal(1)
expect(ratings.data[ 0 ].video.id).to.equal(videoId)
expect(ratings.data[ 0 ].rating).to.equal('like')
expect(ratings.data[0].video.id).to.equal(videoId)
expect(ratings.data[0].rating).to.equal('like')
})
it('Should retrieve ratings list by rating type', async function () {
@@ -307,7 +308,7 @@ describe('Test users', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
const video: Video = videos[ 0 ]
const video: Video = videos[0]
expect(video.name).to.equal('super user video')
expect(video.thumbnailPath).to.not.be.null
expect(video.previewPath).to.not.be.null
@@ -344,12 +345,12 @@ describe('Test users', function () {
expect(users).to.be.an('array')
expect(users.length).to.equal(2)
const user = users[ 0 ]
const user = users[0]
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.nsfwPolicy).to.equal('display')
const rootUser = users[ 1 ]
const rootUser = users[1]
expect(rootUser.username).to.equal('root')
expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(user.nsfwPolicy).to.equal('display')
@@ -367,7 +368,7 @@ describe('Test users', function () {
expect(total).to.equal(2)
expect(users.length).to.equal(1)
const user = users[ 0 ]
const user = users[0]
expect(user.username).to.equal('root')
expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(user.roleLabel).to.equal('Administrator')
@@ -383,7 +384,7 @@ describe('Test users', function () {
expect(total).to.equal(2)
expect(users.length).to.equal(1)
const user = users[ 0 ]
const user = users[0]
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.nsfwPolicy).to.equal('display')
@@ -398,7 +399,7 @@ describe('Test users', function () {
expect(total).to.equal(2)
expect(users.length).to.equal(1)
const user = users[ 0 ]
const user = users[0]
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.nsfwPolicy).to.equal('display')
@@ -413,13 +414,13 @@ describe('Test users', function () {
expect(total).to.equal(2)
expect(users.length).to.equal(2)
expect(users[ 0 ].username).to.equal('root')
expect(users[ 0 ].email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(users[ 0 ].nsfwPolicy).to.equal('display')
expect(users[0].username).to.equal('root')
expect(users[0].email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(users[0].nsfwPolicy).to.equal('display')
expect(users[ 1 ].username).to.equal('user_1')
expect(users[ 1 ].email).to.equal('user_1@example.com')
expect(users[ 1 ].nsfwPolicy).to.equal('display')
expect(users[1].username).to.equal('user_1')
expect(users[1].email).to.equal('user_1@example.com')
expect(users[1].nsfwPolicy).to.equal('display')
})
it('Should search user by username', async function () {
@@ -429,7 +430,7 @@ describe('Test users', function () {
expect(res.body.total).to.equal(1)
expect(users.length).to.equal(1)
expect(users[ 0 ].username).to.equal('root')
expect(users[0].username).to.equal('root')
})
it('Should search user by email', async function () {
@@ -440,8 +441,8 @@ describe('Test users', function () {
expect(res.body.total).to.equal(1)
expect(users.length).to.equal(1)
expect(users[ 0 ].username).to.equal('user_1')
expect(users[ 0 ].email).to.equal('user_1@example.com')
expect(users[0].username).to.equal('user_1')
expect(users[0].email).to.equal('user_1@example.com')
}
{
@@ -451,8 +452,8 @@ describe('Test users', function () {
expect(res.body.total).to.equal(2)
expect(users.length).to.equal(2)
expect(users[ 0 ].username).to.equal('root')
expect(users[ 1 ].username).to.equal('user_1')
expect(users[0].username).to.equal('root')
expect(users[1].username).to.equal('user_1')
}
})
})
@@ -691,7 +692,7 @@ describe('Test users', function () {
expect(res.body.total).to.equal(1)
const video = res.body.data[ 0 ]
const video = res.body.data[0]
expect(video.account.name).to.equal('root')
})
})

View File

@@ -1,28 +1,21 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
checkDirectoryIsEmpty,
checkSegmentHash,
checkTmpIsEmpty,
cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
getPlaylist,
getVideo, makeGetRequest, makeRawRequest,
removeVideo, root,
getVideo,
root,
ServerInfo,
setAccessTokensToServers, updateCustomSubConfig,
updateVideo,
setAccessTokensToServers,
uploadVideo,
waitJobs, webtorrentAdd
waitJobs
} from '../../../../shared/extra-utils'
import { VideoDetails } from '../../../../shared/models/videos'
import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
import { join } from 'path'
import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils'
import { audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils'
const expect = chai.expect
@@ -87,14 +80,14 @@ describe('Test audio only video transcoding', function () {
it('0p transcoded video should not have video', async function () {
const paths = [
join(root(), 'test' + servers[ 0 ].internalServerNumber, 'videos', videoUUID + '-0.mp4'),
join(root(), 'test' + servers[ 0 ].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')
join(root(), 'test' + servers[0].internalServerNumber, 'videos', videoUUID + '-0.mp4'),
join(root(), 'test' + servers[0].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')
]
for (const path of paths) {
const { audioStream } = await audio.get(path)
expect(audioStream[ 'codec_name' ]).to.be.equal('aac')
expect(audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000)
expect(audioStream['codec_name']).to.be.equal('aac')
expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
const size = await getVideoStreamSize(path)
expect(size.height).to.equal(0)

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 'mocha'
@@ -63,9 +63,9 @@ describe('Test multiple servers', function () {
displayName: 'my channel',
description: 'super channel'
}
await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
const channelRes = await getVideoChannelsList(servers[ 0 ].url, 0, 1)
videoChannelId = channelRes.body.data[ 0 ].id
await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
const channelRes = await getVideoChannelsList(servers[0].url, 0, 1)
videoChannelId = channelRes.body.data[0].id
}
// Server 1 and server 2 follow each other
@@ -163,7 +163,7 @@ describe('Test multiple servers', function () {
username: 'user1',
password: 'super_password'
}
await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
const userAccessToken = await userLogin(servers[1], user)
const videoAttributes = {
@@ -762,12 +762,12 @@ describe('Test multiple servers', function () {
{
const text = 'my super first comment'
await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, text)
}
{
const text = 'my super second comment'
await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
await addVideoCommentThread(servers[2].url, servers[2].accessToken, videoUUID, text)
}
await waitJobs(servers)
@@ -777,7 +777,7 @@ describe('Test multiple servers', function () {
const threadId = res.body.data.find(c => c.text === 'my super first comment').id
const text = 'my super answer to thread 1'
await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID, threadId, text)
}
await waitJobs(servers)
@@ -790,10 +790,10 @@ describe('Test multiple servers', function () {
const childCommentId = res2.body.children[0].comment.id
const text3 = 'my second answer to thread 1'
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)
await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, threadId, text3)
const text2 = 'my super answer to answer of thread 1'
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, childCommentId, text2)
}
await waitJobs(servers)
@@ -900,9 +900,9 @@ describe('Test multiple servers', function () {
it('Should delete the thread comments', async function () {
this.timeout(10000)
const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5)
const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
const threadId = res.body.data.find(c => c.text === 'my super first comment').id
await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId)
await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
await waitJobs(servers)
})
@@ -945,9 +945,9 @@ describe('Test multiple servers', function () {
it('Should delete a remote thread by the origin server', async function () {
this.timeout(5000)
const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5)
const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
const threadId = res.body.data.find(c => c.text === 'my super second comment').id
await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId)
await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
await waitJobs(servers)
})
@@ -1021,7 +1021,7 @@ describe('Test multiple servers', function () {
const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
await req.attach('videofile', filePath)
.expect(200)
.expect(200)
await waitJobs(servers)
@@ -1046,7 +1046,7 @@ describe('Test multiple servers', function () {
duration: 5,
commentsEnabled: true,
downloadEnabled: true,
tags: [ ],
tags: [],
privacy: VideoPrivacy.PUBLIC,
channel: {
displayName: 'Main root channel',

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 'mocha'
@@ -31,8 +31,8 @@ describe('Test services', function () {
const res = await getOEmbed(server.url, oembedUrl)
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
`src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
`src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg'
expect(res.body.html).to.equal(expectedHtml)
@@ -53,8 +53,8 @@ describe('Test services', function () {
const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
`src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
`src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(server.video.name)

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 { keyBy } from 'lodash'

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 'mocha'
@@ -183,9 +183,9 @@ describe('Test video abuses', function () {
const accountToBlock = 'root@localhost:' + servers[1].port
{
await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock)
await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock)
const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
expect(res.body.total).to.equal(2)
const abuse = res.body.data.find(a => a.reason === 'will mute this')
@@ -193,9 +193,9 @@ describe('Test video abuses', function () {
}
{
await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock)
await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock)
const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
expect(res.body.total).to.equal(3)
}
})
@@ -204,9 +204,9 @@ describe('Test video abuses', function () {
const serverToBlock = servers[1].host
{
await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, servers[1].host)
await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host)
const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
expect(res.body.total).to.equal(2)
const abuse = res.body.data.find(a => a.reason === 'will mute this')
@@ -214,9 +214,9 @@ describe('Test video abuses', function () {
}
{
await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, serverToBlock)
await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, serverToBlock)
const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
expect(res.body.total).to.equal(3)
}
})

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 { orderBy } from 'lodash'
@@ -8,7 +8,8 @@ import {
cleanupTests,
createUser,
flushAndRunMultipleServers,
getBlacklistedVideosList, getMyUserInformation,
getBlacklistedVideosList,
getMyUserInformation,
getMyVideos,
getVideosList,
killallServers,
@@ -17,7 +18,6 @@ import {
searchVideo,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateVideo,
updateVideoBlacklist,
uploadVideo,
@@ -27,7 +27,7 @@ import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos'
import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
import { User, UserRole, UserUpdateMe } from '../../../../shared/models/users'
import { User, UserRole } from '../../../../shared/models/users'
import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
const expect = chai.expect
@@ -40,7 +40,7 @@ describe('Test video blacklist', function () {
const res = await getVideosList(server.url)
const videos = res.body.data
for (let video of videos) {
for (const video of videos) {
await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason')
}
}
@@ -72,7 +72,7 @@ describe('Test video blacklist', function () {
it('Should not have the video blacklisted in videos list/search on server 1', async function () {
{
const res = await getVideosList(servers[ 0 ].url)
const res = await getVideosList(servers[0].url)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')
@@ -80,7 +80,7 @@ describe('Test video blacklist', function () {
}
{
const res = await searchVideo(servers[ 0 ].url, 'name')
const res = await searchVideo(servers[0].url, 'name')
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')
@@ -90,7 +90,7 @@ describe('Test video blacklist', function () {
it('Should have the blacklisted video in videos list/search on server 2', async function () {
{
const res = await getVideosList(servers[ 1 ].url)
const res = await getVideosList(servers[1].url)
expect(res.body.total).to.equal(2)
expect(res.body.data).to.be.an('array')
@@ -98,7 +98,7 @@ describe('Test video blacklist', function () {
}
{
const res = await searchVideo(servers[ 1 ].url, 'video')
const res = await searchVideo(servers[1].url, 'video')
expect(res.body.total).to.equal(2)
expect(res.body.data).to.be.an('array')
@@ -125,8 +125,8 @@ describe('Test video blacklist', function () {
it('Should display all the blacklisted videos when applying manual type filter', async function () {
const res = await getBlacklistedVideosList({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
type: VideoBlacklistType.MANUAL
})
@@ -139,8 +139,8 @@ describe('Test video blacklist', function () {
it('Should display nothing when applying automatic type filter', async function () {
const res = await getBlacklistedVideosList({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
})
@@ -152,7 +152,7 @@ describe('Test video blacklist', function () {
})
it('Should get the correct sort when sorting by descending id', async function () {
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-id' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-id' })
expect(res.body.total).to.equal(2)
const blacklistedVideos = res.body.data
@@ -165,7 +165,7 @@ describe('Test video blacklist', function () {
})
it('Should get the correct sort when sorting by descending video name', async function () {
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' })
expect(res.body.total).to.equal(2)
const blacklistedVideos = res.body.data
@@ -178,7 +178,7 @@ describe('Test video blacklist', function () {
})
it('Should get the correct sort when sorting by ascending creation date', async function () {
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: 'createdAt' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' })
expect(res.body.total).to.equal(2)
const blacklistedVideos = res.body.data
@@ -195,7 +195,7 @@ describe('Test video blacklist', function () {
it('Should change the reason', async function () {
await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated')
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' })
const video = res.body.data.find(b => b.video.id === videoId)
expect(video.reason).to.equal('my super reason updated')
@@ -231,7 +231,7 @@ describe('Test video blacklist', function () {
it('Should remove a video from the blacklist on server 1', async function () {
// Get one video in the blacklist
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' })
videoToRemove = res.body.data[0]
blacklist = res.body.data.slice(1)
@@ -252,7 +252,7 @@ describe('Test video blacklist', function () {
})
it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () {
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' })
expect(res.body.total).to.equal(1)
const videos = res.body.data
@@ -274,7 +274,7 @@ describe('Test video blacklist', function () {
video3UUID = res.body.video.uuid
}
{
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'Video 4' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'Video 4' })
video4UUID = res.body.video.uuid
}
@@ -284,17 +284,17 @@ describe('Test video blacklist', function () {
it('Should blacklist video 3 and keep it federated', async function () {
this.timeout(10000)
await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video3UUID, 'super reason', false)
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video3UUID, 'super reason', false)
await waitJobs(servers)
{
const res = await getVideosList(servers[ 0 ].url)
const res = await getVideosList(servers[0].url)
expect(res.body.data.find(v => v.uuid === video3UUID)).to.be.undefined
}
{
const res = await getVideosList(servers[ 1 ].url)
const res = await getVideosList(servers[1].url)
expect(res.body.data.find(v => v.uuid === video3UUID)).to.not.be.undefined
}
})
@@ -302,7 +302,7 @@ describe('Test video blacklist', function () {
it('Should unfederate the video', async function () {
this.timeout(10000)
await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID, 'super reason', true)
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video4UUID, 'super reason', true)
await waitJobs(servers)
@@ -315,7 +315,7 @@ describe('Test video blacklist', function () {
it('Should have the video unfederated even after an Update AP message', async function () {
this.timeout(10000)
await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID, { description: 'super description' })
await updateVideo(servers[0].url, servers[0].accessToken, video4UUID, { description: 'super description' })
await waitJobs(servers)
@@ -326,7 +326,7 @@ describe('Test video blacklist', function () {
})
it('Should have the correct video blacklist unfederate attribute', async function () {
const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: 'createdAt' })
const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' })
const blacklistedVideos: VideoBlacklist[] = res.body.data
const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID)
@@ -339,7 +339,7 @@ describe('Test video blacklist', function () {
it('Should remove the video from blacklist and refederate the video', async function () {
this.timeout(10000)
await removeVideoFromBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID)
await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video4UUID)
await waitJobs(servers)
@@ -362,9 +362,9 @@ describe('Test video blacklist', function () {
killallServers([ servers[0] ])
const config = {
'auto_blacklist': {
auto_blacklist: {
videos: {
'of_users': {
of_users: {
enabled: true
}
}
@@ -375,8 +375,8 @@ describe('Test video blacklist', function () {
{
const user = { username: 'user_without_flag', password: 'password' }
await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: user.username,
adminFlags: UserAdminFlag.NONE,
password: user.password,
@@ -393,8 +393,8 @@ describe('Test video blacklist', function () {
{
const user = { username: 'user_with_flag', password: 'password' }
await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: user.username,
adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST,
password: user.password,
@@ -411,8 +411,8 @@ describe('Test video blacklist', function () {
await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' })
const res = await getBlacklistedVideosList({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
})
@@ -428,11 +428,11 @@ describe('Test video blacklist', function () {
name: 'URL import',
channelId: channelOfUserWithoutFlag
}
await importVideo(servers[ 0 ].url, userWithoutFlag, attributes)
await importVideo(servers[0].url, userWithoutFlag, attributes)
const res = await getBlacklistedVideosList({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
sort: 'createdAt',
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
})
@@ -447,11 +447,11 @@ describe('Test video blacklist', function () {
name: 'Torrent import',
channelId: channelOfUserWithoutFlag
}
await importVideo(servers[ 0 ].url, userWithoutFlag, attributes)
await importVideo(servers[0].url, userWithoutFlag, attributes)
const res = await getBlacklistedVideosList({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
sort: 'createdAt',
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
})
@@ -464,8 +464,8 @@ describe('Test video blacklist', function () {
await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' })
const res = await getBlacklistedVideosList({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
})

View File

@@ -1,16 +1,17 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
checkVideoFilesWereRemoved, cleanupTests,
checkVideoFilesWereRemoved,
cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
removeVideo,
uploadVideo,
wait
} from '../../../../shared/extra-utils'
import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import {
createVideoCaption,
@@ -36,7 +37,7 @@ describe('Test video captions', function () {
await waitJobs(servers)
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name' })
videoUUID = res.body.video.uuid
await waitJobs(servers)

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 'mocha'
@@ -38,7 +38,7 @@ describe('Test video change ownership - nominal', function () {
}
let firstUserAccessToken = ''
let secondUserAccessToken = ''
let lastRequestChangeOwnershipId = undefined
let lastRequestChangeOwnershipId = ''
before(async function () {
this.timeout(50000)
@@ -48,15 +48,15 @@ describe('Test video change ownership - nominal', function () {
const videoQuota = 42000000
await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: firstUser.username,
password: firstUser.password,
videoQuota: videoQuota
})
await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: secondUser.username,
password: secondUser.password,
videoQuota: videoQuota
@@ -209,7 +209,7 @@ describe('Test video change ownership - nominal', function () {
})
describe('Test video change ownership - quota too small', function () {
let server: ServerInfo = undefined
let server: ServerInfo
const firstUser = {
username: 'first',
password: 'My great password'
@@ -220,14 +220,14 @@ describe('Test video change ownership - quota too small', function () {
}
let firstUserAccessToken = ''
let secondUserAccessToken = ''
let lastRequestChangeOwnershipId = undefined
let lastRequestChangeOwnershipId = ''
before(async function () {
this.timeout(50000)
// Run one server
server = await flushAndRunServer(1)
await setAccessTokensToServers([server])
await setAccessTokensToServers([ server ])
const videoQuota = 42000000
const limitedVideoQuota = 10

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 'mocha'
@@ -7,7 +7,8 @@ import {
cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers, getVideo,
flushAndRunMultipleServers,
getVideo,
getVideoChannelVideos,
testImage,
updateVideo,
@@ -73,14 +74,14 @@ describe('Test video channels', function () {
description: 'super video channel description',
support: 'super video channel support text'
}
const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
secondVideoChannelId = res.body.videoChannel.id
}
// The channel is 1 is propagated to servers 2
{
const videoAttributesArg = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' }
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributesArg)
const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributesArg)
videoUUID = res.body.video.uuid
}
@@ -106,7 +107,7 @@ describe('Test video channels', function () {
it('Should have two video channels when getting account channels on server 1', async function () {
const res = await getAccountVideoChannelsList({
url: servers[ 0 ].url,
url: servers[0].url,
accountName: userInfo.account.name + '@' + userInfo.account.host
})
@@ -127,7 +128,7 @@ describe('Test video channels', function () {
it('Should paginate and sort account channels', async function () {
{
const res = await getAccountVideoChannelsList({
url: servers[ 0 ].url,
url: servers[0].url,
accountName: userInfo.account.name + '@' + userInfo.account.host,
start: 0,
count: 1,
@@ -137,13 +138,13 @@ describe('Test video channels', function () {
expect(res.body.total).to.equal(2)
expect(res.body.data).to.have.lengthOf(1)
const videoChannel: VideoChannel = res.body.data[ 0 ]
const videoChannel: VideoChannel = res.body.data[0]
expect(videoChannel.name).to.equal('root_channel')
}
{
const res = await getAccountVideoChannelsList({
url: servers[ 0 ].url,
url: servers[0].url,
accountName: userInfo.account.name + '@' + userInfo.account.host,
start: 0,
count: 1,
@@ -153,13 +154,13 @@ describe('Test video channels', function () {
expect(res.body.total).to.equal(2)
expect(res.body.data).to.have.lengthOf(1)
const videoChannel: VideoChannel = res.body.data[ 0 ]
const videoChannel: VideoChannel = res.body.data[0]
expect(videoChannel.name).to.equal('second_video_channel')
}
{
const res = await getAccountVideoChannelsList({
url: servers[ 0 ].url,
url: servers[0].url,
accountName: userInfo.account.name + '@' + userInfo.account.host,
start: 1,
count: 1,
@@ -169,14 +170,14 @@ describe('Test video channels', function () {
expect(res.body.total).to.equal(2)
expect(res.body.data).to.have.lengthOf(1)
const videoChannel: VideoChannel = res.body.data[ 0 ]
const videoChannel: VideoChannel = res.body.data[0]
expect(videoChannel.name).to.equal('root_channel')
}
})
it('Should have one video channel when getting account channels on server 2', async function () {
const res = await getAccountVideoChannelsList({
url: servers[ 1 ].url,
url: servers[1].url,
accountName: userInfo.account.name + '@' + userInfo.account.host
})
@@ -349,15 +350,15 @@ describe('Test video channels', function () {
it('Should create the main channel with an uuid if there is a conflict', async function () {
{
const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
}
{
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: 'toto', password: 'password' })
const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' })
const accessToken = await userLogin(servers[0], { username: 'toto', password: 'password' })
const res = await getMyUserInformation(servers[ 0 ].url, accessToken)
const videoChannel = res.body.videoChannels[ 0 ]
const res = await getMyUserInformation(servers[0].url, accessToken)
const videoChannel = res.body.videoChannels[0]
expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
}
})

View File

@@ -1,17 +1,17 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { cleanupTests, testImage } from '../../../../shared/extra-utils'
import {
createUser,
dateIsValid,
flushAndRunServer,
getAccessToken,
ServerInfo,
setAccessTokensToServers,
updateMyAvatar,
getAccessToken,
createUser,
uploadVideo
} from '../../../../shared/extra-utils/index'
import {

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 'mocha'
@@ -8,7 +8,6 @@ import {
getVideo,
getVideoDescription,
getVideosList,
killallServers,
ServerInfo,
setAccessTokensToServers,
updateVideo,
@@ -23,7 +22,7 @@ describe('Test video description', function () {
let servers: ServerInfo[] = []
let videoUUID = ''
let videoId: number
let longDescription = 'my super description for server 1'.repeat(50)
const longDescription = 'my super description for server 1'.repeat(50)
before(async function () {
this.timeout(40000)
@@ -61,7 +60,7 @@ describe('Test video description', function () {
// 30 characters * 6 -> 240 characters
const truncatedDescription = 'my super description for server 1'.repeat(7) +
'my super descrip...'
'my super descrip...'
expect(video.description).to.equal(truncatedDescription)
}

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 'mocha'
@@ -10,13 +10,16 @@ import {
doubleFollow,
flushAndRunMultipleServers,
getPlaylist,
getVideo, makeGetRequest, makeRawRequest,
getVideo,
makeRawRequest,
removeVideo,
ServerInfo,
setAccessTokensToServers, updateCustomSubConfig,
setAccessTokensToServers,
updateCustomSubConfig,
updateVideo,
uploadVideo,
waitJobs, webtorrentAdd
waitJobs,
webtorrentAdd
} from '../../../../shared/extra-utils'
import { VideoDetails } from '../../../../shared/models/videos'
import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
@@ -48,7 +51,9 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
expect(file.magnetUri).to.have.lengthOf.above(2)
expect(file.torrentUrl).to.equal(`${baseUrl}/static/torrents/${videoDetails.uuid}-${file.resolution.id}-hls.torrent`)
expect(file.fileUrl).to.equal(`${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${videoDetails.uuid}-${file.resolution.id}-fragmented.mp4`)
expect(file.fileUrl).to.equal(
`${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${videoDetails.uuid}-${file.resolution.id}-fragmented.mp4`
)
expect(file.resolution.label).to.equal(resolution + 'p')
await makeRawRequest(file.torrentUrl, 200)
@@ -66,7 +71,9 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
const masterPlaylist = res.text
for (const resolution of resolutions) {
const reg = new RegExp('#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',FRAME-RATE=\\d+,CODECS="avc1.64001f,mp4a.40.2"')
const reg = new RegExp(
'#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',FRAME-RATE=\\d+,CODECS="avc1.64001f,mp4a.40.2"'
)
expect(masterPlaylist).to.match(reg)
expect(masterPlaylist).to.contain(`${resolution}.m3u8`)
@@ -102,7 +109,7 @@ describe('Test HLS videos', function () {
it('Should upload a video and transcode it to HLS', async function () {
this.timeout(120000)
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1', fixture: 'video_short.webm' })
videoUUID = res.body.video.uuid
await waitJobs(servers)
@@ -113,7 +120,7 @@ describe('Test HLS videos', function () {
it('Should upload an audio file and transcode it to HLS', async function () {
this.timeout(120000)
const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video audio', fixture: 'sample.ogg' })
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video audio', fixture: 'sample.ogg' })
videoAudioUUID = res.body.video.uuid
await waitJobs(servers)
@@ -124,7 +131,7 @@ describe('Test HLS videos', function () {
it('Should update the video', async function () {
this.timeout(10000)
await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, { name: 'video 1 updated' })
await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' })
await waitJobs(servers)
@@ -134,8 +141,8 @@ describe('Test HLS videos', function () {
it('Should delete videos', async function () {
this.timeout(10000)
await removeVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID)
await removeVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAudioUUID)
await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID)
await waitJobs(servers)

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 'mocha'
@@ -12,12 +12,11 @@ import {
getVideo,
getVideosList,
immutableAssign,
killallServers,
ServerInfo,
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { getMagnetURI, getYoutubeVideoUrl, importVideo, getMyVideoImports } from '../../../../shared/extra-utils/videos/video-imports'
import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
const expect = chai.expect
@@ -88,12 +87,12 @@ describe('Test video imports', function () {
{
const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
channelIdServer1 = res.body.videoChannels[ 0 ].id
channelIdServer1 = res.body.videoChannels[0].id
}
{
const res = await getMyUserInformation(servers[1].url, servers[1].accessToken)
channelIdServer2 = res.body.videoChannels[ 0 ].id
channelIdServer2 = res.body.videoChannels[0].id
}
await doubleFollow(servers[0], servers[1])
@@ -214,7 +213,7 @@ describe('Test video imports', function () {
await checkVideoServer2(server.url, res.body.data[0].uuid)
const [ ,videoHttp, videoMagnet, videoTorrent ] = res.body.data
const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data
await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
}
})

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 'mocha'
@@ -89,8 +89,8 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[ 1 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('normal')
expect(videos[1].name).to.equal('nsfw')
}
})
@@ -107,7 +107,7 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[0].name).to.equal('normal')
}
})
@@ -124,8 +124,8 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[ 1 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('normal')
expect(videos[1].name).to.equal('nsfw')
}
})
})
@@ -154,8 +154,8 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[ 1 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('normal')
expect(videos[1].name).to.equal('nsfw')
}
})
@@ -171,8 +171,8 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[ 1 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('normal')
expect(videos[1].name).to.equal('nsfw')
}
})
@@ -188,7 +188,7 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[0].name).to.equal('normal')
}
})
@@ -198,8 +198,8 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[ 1 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('normal')
expect(videos[1].name).to.equal('nsfw')
})
it('Should display NSFW videos when the nsfw param === true', async function () {
@@ -208,7 +208,7 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
expect(videos[ 0 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('nsfw')
}
})
@@ -218,7 +218,7 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[0].name).to.equal('normal')
}
})
@@ -228,8 +228,8 @@ describe('Test video NSFW policy', function () {
const videos = res.body.data
expect(videos).to.have.lengthOf(2)
expect(videos[ 0 ].name).to.equal('normal')
expect(videos[ 1 ].name).to.equal('nsfw')
expect(videos[0].name).to.equal('normal')
expect(videos[1].name).to.equal('nsfw')
}
})
})

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 'mocha'
@@ -8,14 +8,15 @@ import {
createVideoPlaylist,
doubleFollow,
flushAndRunMultipleServers,
getVideoPlaylistsList, removeVideoFromPlaylist,
getVideoPlaylistsList,
removeVideoFromPlaylist,
reorderVideosPlaylist,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
testImage,
uploadVideoAndGetId,
waitJobs,
reorderVideosPlaylist
waitJobs
} from '../../../../shared/extra-utils'
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
@@ -69,19 +70,19 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
const res = await createVideoPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist without thumbnail',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: servers[ 1 ].videoChannel.id
videoChannelId: servers[1].videoChannel.id
}
})
playlistWithoutThumbnail = res.body.videoPlaylist.id
const res2 = await addVideoInPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithoutThumbnail,
elementAttrs: { videoId: video1 }
})
@@ -99,20 +100,20 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
const res = await createVideoPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist with thumbnail',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: servers[ 1 ].videoChannel.id,
videoChannelId: servers[1].videoChannel.id,
thumbnailfile: 'thumbnail.jpg'
}
})
playlistWithThumbnail = res.body.videoPlaylist.id
const res2 = await addVideoInPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithThumbnail,
elementAttrs: { videoId: video1 }
})
@@ -130,8 +131,8 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
const res = await addVideoInPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithoutThumbnail,
elementAttrs: { videoId: video2 }
})
@@ -159,8 +160,8 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
const res = await addVideoInPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithThumbnail,
elementAttrs: { videoId: video2 }
})
@@ -188,8 +189,8 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
await removeVideoFromPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithoutThumbnail,
playlistElementId: withoutThumbnailE1
})
@@ -206,8 +207,8 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
await removeVideoFromPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithThumbnail,
playlistElementId: withThumbnailE1
})
@@ -224,8 +225,8 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
await removeVideoFromPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithoutThumbnail,
playlistElementId: withoutThumbnailE2
})
@@ -242,8 +243,8 @@ describe('Playlist thumbnail', function () {
this.timeout(30000)
await removeVideoFromPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: playlistWithThumbnail,
playlistElementId: withThumbnailE2
})

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 'mocha'
@@ -141,12 +141,12 @@ describe('Test video playlists', function () {
servers[2].videos = await Promise.all(serverPromises[2])
}
nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[ 0 ], videoName: 'NSFW video', nsfw: true })).id
nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id
{
await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: 'user1',
password: 'password'
})
@@ -158,17 +158,17 @@ describe('Test video playlists', function () {
describe('Get default playlists', function () {
it('Should list video playlist privacies', async function () {
const res = await getVideoPlaylistPrivacies(servers[ 0 ].url)
const res = await getVideoPlaylistPrivacies(servers[0].url)
const privacies = res.body
expect(Object.keys(privacies)).to.have.length.at.least(3)
expect(privacies[ 3 ]).to.equal('Private')
expect(privacies[3]).to.equal('Private')
})
it('Should list watch later playlist', async function () {
const url = servers[ 0 ].url
const accessToken = servers[ 0 ].accessToken
const url = servers[0].url
const accessToken = servers[0].accessToken
{
const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER)
@@ -176,7 +176,7 @@ describe('Test video playlists', function () {
expect(res.body.total).to.equal(1)
expect(res.body.data).to.have.lengthOf(1)
const playlist: VideoPlaylist = res.body.data[ 0 ]
const playlist: VideoPlaylist = res.body.data[0]
expect(playlist.displayName).to.equal('Watch later')
expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
expect(playlist.type.label).to.equal('Watch later')
@@ -197,15 +197,15 @@ describe('Test video playlists', function () {
})
it('Should get private playlist for a classic user', async function () {
const token = await generateUserAccessToken(servers[ 0 ], 'toto')
const token = await generateUserAccessToken(servers[0], 'toto')
const res = await getAccountPlaylistsListWithToken(servers[ 0 ].url, token, 'toto', 0, 5)
const res = await getAccountPlaylistsListWithToken(servers[0].url, token, 'toto', 0, 5)
expect(res.body.total).to.equal(1)
expect(res.body.data).to.have.lengthOf(1)
const playlistId = res.body.data[ 0 ].id
await getPlaylistVideos(servers[ 0 ].url, token, playlistId, 0, 5)
const playlistId = res.body.data[0].id
await getPlaylistVideos(servers[0].url, token, playlistId, 0, 5)
})
})
@@ -215,14 +215,14 @@ describe('Test video playlists', function () {
this.timeout(30000)
await createVideoPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistAttrs: {
displayName: 'my super playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
description: 'my super description',
thumbnailfile: 'thumbnail.jpg',
videoChannelId: servers[ 0 ].videoChannel.id
videoChannelId: servers[0].videoChannel.id
}
})
@@ -233,7 +233,7 @@ describe('Test video playlists', function () {
expect(res.body.total).to.equal(1)
expect(res.body.data).to.have.lengthOf(1)
const playlistFromList = res.body.data[ 0 ] as VideoPlaylist
const playlistFromList = res.body.data[0] as VideoPlaylist
const res2 = await getVideoPlaylist(server.url, playlistFromList.uuid)
const playlistFromGet = res2.body
@@ -266,12 +266,12 @@ describe('Test video playlists', function () {
{
const res = await createVideoPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist 2',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: servers[ 1 ].videoChannel.id
videoChannelId: servers[1].videoChannel.id
}
})
playlistServer2Id1 = res.body.videoPlaylist.id
@@ -279,13 +279,13 @@ describe('Test video playlists', function () {
{
const res = await createVideoPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist 3',
privacy: VideoPlaylistPrivacy.PUBLIC,
thumbnailfile: 'thumbnail.jpg',
videoChannelId: servers[ 1 ].videoChannel.id
videoChannelId: servers[1].videoChannel.id
}
})
@@ -293,24 +293,24 @@ describe('Test video playlists', function () {
playlistServer2UUID2 = res.body.videoPlaylist.uuid
}
for (let id of [ playlistServer2Id1, playlistServer2Id2 ]) {
for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) {
await addVideoInPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: id,
elementAttrs: { videoId: servers[ 1 ].videos[ 0 ].id, startTimestamp: 1, stopTimestamp: 2 }
elementAttrs: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 }
})
await addVideoInPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistId: id,
elementAttrs: { videoId: servers[ 1 ].videos[ 1 ].id }
elementAttrs: { videoId: servers[1].videos[1].id }
})
}
await waitJobs(servers)
for (const server of [ servers[ 0 ], servers[ 1 ] ]) {
for (const server of [ servers[0], servers[1] ]) {
const res = await getVideoPlaylistsList(server.url, 0, 5)
const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2')
@@ -322,7 +322,7 @@ describe('Test video playlists', function () {
await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
}
const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
expect(res.body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
})
@@ -331,13 +331,13 @@ describe('Test video playlists', function () {
this.timeout(30000)
// Server 2 and server 3 follow each other
await doubleFollow(servers[ 1 ], servers[ 2 ])
await doubleFollow(servers[1], servers[2])
const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2')
expect(playlist2).to.not.be.undefined
await testImage(servers[ 2 ].url, 'thumbnail-playlist', playlist2.thumbnailPath)
await testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath)
expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined
})
@@ -349,25 +349,25 @@ describe('Test video playlists', function () {
this.timeout(30000)
{
const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, 'createdAt')
const res = await getVideoPlaylistsList(servers[2].url, 1, 2, 'createdAt')
expect(res.body.total).to.equal(3)
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(2)
expect(data[ 0 ].displayName).to.equal('playlist 2')
expect(data[ 1 ].displayName).to.equal('playlist 3')
expect(data[0].displayName).to.equal('playlist 2')
expect(data[1].displayName).to.equal('playlist 3')
}
{
const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, '-createdAt')
const res = await getVideoPlaylistsList(servers[2].url, 1, 2, '-createdAt')
expect(res.body.total).to.equal(3)
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(2)
expect(data[ 0 ].displayName).to.equal('playlist 2')
expect(data[ 1 ].displayName).to.equal('my super playlist')
expect(data[0].displayName).to.equal('playlist 2')
expect(data[1].displayName).to.equal('my super playlist')
}
})
@@ -375,13 +375,13 @@ describe('Test video playlists', function () {
this.timeout(30000)
{
const res = await getVideoChannelPlaylistsList(servers[ 0 ].url, 'root_channel', 0, 2, '-createdAt')
const res = await getVideoChannelPlaylistsList(servers[0].url, 'root_channel', 0, 2, '-createdAt')
expect(res.body.total).to.equal(1)
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(1)
expect(data[ 0 ].displayName).to.equal('my super playlist')
expect(data[0].displayName).to.equal('my super playlist')
}
})
@@ -389,37 +389,37 @@ describe('Test video playlists', function () {
this.timeout(30000)
{
const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, '-createdAt')
const res = await getAccountPlaylistsList(servers[1].url, 'root', 1, 2, '-createdAt')
expect(res.body.total).to.equal(2)
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(1)
expect(data[ 0 ].displayName).to.equal('playlist 2')
expect(data[0].displayName).to.equal('playlist 2')
}
{
const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, 'createdAt')
const res = await getAccountPlaylistsList(servers[1].url, 'root', 1, 2, 'createdAt')
expect(res.body.total).to.equal(2)
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(1)
expect(data[ 0 ].displayName).to.equal('playlist 3')
expect(data[0].displayName).to.equal('playlist 3')
}
{
const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 0, 10, 'createdAt', '3')
const res = await getAccountPlaylistsList(servers[1].url, 'root', 0, 10, 'createdAt', '3')
expect(res.body.total).to.equal(1)
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(1)
expect(data[ 0 ].displayName).to.equal('playlist 3')
expect(data[0].displayName).to.equal('playlist 3')
}
{
const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 0, 10, 'createdAt', '4')
const res = await getAccountPlaylistsList(servers[1].url, 'root', 0, 10, 'createdAt', '4')
expect(res.body.total).to.equal(0)
@@ -432,8 +432,8 @@ describe('Test video playlists', function () {
this.timeout(30000)
await createVideoPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist unlisted',
privacy: VideoPlaylistPrivacy.UNLISTED
@@ -441,8 +441,8 @@ describe('Test video playlists', function () {
})
await createVideoPlaylist({
url: servers[ 1 ].url,
token: servers[ 1 ].accessToken,
url: servers[1].url,
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist private',
privacy: VideoPlaylistPrivacy.PRIVATE
@@ -453,18 +453,18 @@ describe('Test video playlists', function () {
for (const server of servers) {
const results = [
await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[ 1 ].port, 0, 5, '-createdAt'),
await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'),
await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
]
expect(results[ 0 ].body.total).to.equal(2)
expect(results[ 1 ].body.total).to.equal(3)
expect(results[0].body.total).to.equal(2)
expect(results[1].body.total).to.equal(3)
for (const res of results) {
const data: VideoPlaylist[] = res.body.data
expect(data).to.have.lengthOf(2)
expect(data[ 0 ].displayName).to.equal('playlist 3')
expect(data[ 1 ].displayName).to.equal('playlist 2')
expect(data[0].displayName).to.equal('playlist 3')
expect(data[1].displayName).to.equal('playlist 2')
}
}
})
@@ -519,32 +519,32 @@ describe('Test video playlists', function () {
this.timeout(30000)
const addVideo = (elementAttrs: any) => {
return addVideoInPlaylist({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, playlistId: playlistServer1Id, elementAttrs })
return addVideoInPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: playlistServer1Id, elementAttrs })
}
const res = await createVideoPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistAttrs: {
displayName: 'playlist 4',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: servers[ 0 ].videoChannel.id
videoChannelId: servers[0].videoChannel.id
}
})
playlistServer1Id = res.body.videoPlaylist.id
playlistServer1UUID = res.body.videoPlaylist.uuid
await addVideo({ videoId: servers[ 0 ].videos[ 0 ].uuid, startTimestamp: 15, stopTimestamp: 28 })
await addVideo({ videoId: servers[ 2 ].videos[ 1 ].uuid, startTimestamp: 35 })
await addVideo({ videoId: servers[ 2 ].videos[ 2 ].uuid })
await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 })
await addVideo({ videoId: servers[2].videos[2].uuid })
{
const res = await addVideo({ videoId: servers[ 0 ].videos[ 3 ].uuid, stopTimestamp: 35 })
const res = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 })
playlistElementServer1Video4 = res.body.videoPlaylistElement.id
}
{
const res = await addVideo({ videoId: servers[ 0 ].videos[ 4 ].uuid, startTimestamp: 45, stopTimestamp: 60 })
const res = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
playlistElementServer1Video5 = res.body.videoPlaylistElement.id
}
@@ -567,35 +567,35 @@ describe('Test video playlists', function () {
const videoElements: VideoPlaylistElement[] = res.body.data
expect(videoElements).to.have.lengthOf(6)
expect(videoElements[ 0 ].video.name).to.equal('video 0 server 1')
expect(videoElements[ 0 ].position).to.equal(1)
expect(videoElements[ 0 ].startTimestamp).to.equal(15)
expect(videoElements[ 0 ].stopTimestamp).to.equal(28)
expect(videoElements[0].video.name).to.equal('video 0 server 1')
expect(videoElements[0].position).to.equal(1)
expect(videoElements[0].startTimestamp).to.equal(15)
expect(videoElements[0].stopTimestamp).to.equal(28)
expect(videoElements[ 1 ].video.name).to.equal('video 1 server 3')
expect(videoElements[ 1 ].position).to.equal(2)
expect(videoElements[ 1 ].startTimestamp).to.equal(35)
expect(videoElements[ 1 ].stopTimestamp).to.be.null
expect(videoElements[1].video.name).to.equal('video 1 server 3')
expect(videoElements[1].position).to.equal(2)
expect(videoElements[1].startTimestamp).to.equal(35)
expect(videoElements[1].stopTimestamp).to.be.null
expect(videoElements[ 2 ].video.name).to.equal('video 2 server 3')
expect(videoElements[ 2 ].position).to.equal(3)
expect(videoElements[ 2 ].startTimestamp).to.be.null
expect(videoElements[ 2 ].stopTimestamp).to.be.null
expect(videoElements[2].video.name).to.equal('video 2 server 3')
expect(videoElements[2].position).to.equal(3)
expect(videoElements[2].startTimestamp).to.be.null
expect(videoElements[2].stopTimestamp).to.be.null
expect(videoElements[ 3 ].video.name).to.equal('video 3 server 1')
expect(videoElements[ 3 ].position).to.equal(4)
expect(videoElements[ 3 ].startTimestamp).to.be.null
expect(videoElements[ 3 ].stopTimestamp).to.equal(35)
expect(videoElements[3].video.name).to.equal('video 3 server 1')
expect(videoElements[3].position).to.equal(4)
expect(videoElements[3].startTimestamp).to.be.null
expect(videoElements[3].stopTimestamp).to.equal(35)
expect(videoElements[ 4 ].video.name).to.equal('video 4 server 1')
expect(videoElements[ 4 ].position).to.equal(5)
expect(videoElements[ 4 ].startTimestamp).to.equal(45)
expect(videoElements[ 4 ].stopTimestamp).to.equal(60)
expect(videoElements[4].video.name).to.equal('video 4 server 1')
expect(videoElements[4].position).to.equal(5)
expect(videoElements[4].startTimestamp).to.equal(45)
expect(videoElements[4].stopTimestamp).to.equal(60)
expect(videoElements[ 5 ].video.name).to.equal('NSFW video')
expect(videoElements[ 5 ].position).to.equal(6)
expect(videoElements[ 5 ].startTimestamp).to.equal(5)
expect(videoElements[ 5 ].stopTimestamp).to.be.null
expect(videoElements[5].video.name).to.equal('NSFW video')
expect(videoElements[5].position).to.equal(6)
expect(videoElements[5].startTimestamp).to.equal(5)
expect(videoElements[5].stopTimestamp).to.be.null
const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2)
expect(res3.body.data).to.have.lengthOf(2)
@@ -616,18 +616,18 @@ describe('Test video playlists', function () {
before(async function () {
this.timeout(30000)
groupUser1 = [ Object.assign({}, servers[ 0 ], { accessToken: userAccessTokenServer1 }) ]
groupWithoutToken1 = [ Object.assign({}, servers[ 0 ], { accessToken: undefined }) ]
group1 = [ servers[ 0 ] ]
group2 = [ servers[ 1 ], servers[ 2 ] ]
groupUser1 = [ Object.assign({}, servers[0], { accessToken: userAccessTokenServer1 }) ]
groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ]
group1 = [ servers[0] ]
group2 = [ servers[1], servers[2] ]
const res = await createVideoPlaylist({
url: servers[ 0 ].url,
url: servers[0].url,
token: userAccessTokenServer1,
playlistAttrs: {
displayName: 'playlist 56',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: servers[ 0 ].videoChannel.id
videoChannelId: servers[0].videoChannel.id
}
})
@@ -635,7 +635,7 @@ describe('Test video playlists', function () {
playlistServer1UUID2 = res.body.videoPlaylist.uuid
const addVideo = (elementAttrs: any) => {
return addVideoInPlaylist({ url: servers[ 0 ].url, token: userAccessTokenServer1, playlistId: playlistServer1Id2, elementAttrs })
return addVideoInPlaylist({ url: servers[0].url, token: userAccessTokenServer1, playlistId: playlistServer1Id2, elementAttrs })
}
video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userAccessTokenServer1 })).uuid
@@ -656,7 +656,7 @@ describe('Test video playlists', function () {
const position = 1
{
await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video1, { privacy: VideoPrivacy.PRIVATE })
await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PRIVATE })
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -666,7 +666,7 @@ describe('Test video playlists', function () {
}
{
await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video1, { privacy: VideoPrivacy.PUBLIC })
await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PUBLIC })
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -684,7 +684,7 @@ describe('Test video playlists', function () {
const position = 1
{
await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video1, 'reason', true)
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video1, 'reason', true)
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -694,7 +694,7 @@ describe('Test video playlists', function () {
}
{
await removeVideoFromBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video1)
await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video1)
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -712,52 +712,52 @@ describe('Test video playlists', function () {
const position = 2
{
await addAccountToAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port)
await addAccountToAccountBlocklist(servers[0].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
await removeAccountFromAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port)
await removeAccountFromAccountBlocklist(servers[0].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
}
{
await addServerToAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'localhost:' + servers[1].port)
await addServerToAccountBlocklist(servers[0].url, userAccessTokenServer1, 'localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
await removeServerFromAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'localhost:' + servers[1].port)
await removeServerFromAccountBlocklist(servers[0].url, userAccessTokenServer1, 'localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
}
{
await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'root@localhost:' + servers[1].port)
await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'root@localhost:' + servers[1].port)
await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
}
{
await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
await waitJobs(servers)
await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -785,8 +785,8 @@ describe('Test video playlists', function () {
{
await reorderVideosPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
elementAttrs: {
startPosition: 2,
@@ -813,8 +813,8 @@ describe('Test video playlists', function () {
{
await reorderVideosPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
elementAttrs: {
startPosition: 1,
@@ -842,8 +842,8 @@ describe('Test video playlists', function () {
{
await reorderVideosPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
elementAttrs: {
startPosition: 6,
@@ -868,7 +868,7 @@ describe('Test video playlists', function () {
])
for (let i = 1; i <= elements.length; i++) {
expect(elements[ i - 1 ].position).to.equal(i)
expect(elements[i - 1].position).to.equal(i)
}
}
}
@@ -878,8 +878,8 @@ describe('Test video playlists', function () {
this.timeout(30000)
await updateVideoPlaylistElement({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
playlistElementId: playlistElementServer1Video4,
elementAttrs: {
@@ -888,8 +888,8 @@ describe('Test video playlists', function () {
})
await updateVideoPlaylistElement({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
playlistElementId: playlistElementServer1Video5,
elementAttrs: {
@@ -903,62 +903,62 @@ describe('Test video playlists', function () {
const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
const elements: VideoPlaylistElement[] = res.body.data
expect(elements[ 0 ].video.name).to.equal('video 3 server 1')
expect(elements[ 0 ].position).to.equal(1)
expect(elements[ 0 ].startTimestamp).to.equal(1)
expect(elements[ 0 ].stopTimestamp).to.equal(35)
expect(elements[0].video.name).to.equal('video 3 server 1')
expect(elements[0].position).to.equal(1)
expect(elements[0].startTimestamp).to.equal(1)
expect(elements[0].stopTimestamp).to.equal(35)
expect(elements[ 5 ].video.name).to.equal('video 4 server 1')
expect(elements[ 5 ].position).to.equal(6)
expect(elements[ 5 ].startTimestamp).to.equal(45)
expect(elements[ 5 ].stopTimestamp).to.be.null
expect(elements[5].video.name).to.equal('video 4 server 1')
expect(elements[5].position).to.equal(6)
expect(elements[5].startTimestamp).to.equal(45)
expect(elements[5].stopTimestamp).to.be.null
}
})
it('Should check videos existence in my playlist', async function () {
const videoIds = [
servers[ 0 ].videos[ 0 ].id,
servers[0].videos[0].id,
42000,
servers[ 0 ].videos[ 3 ].id,
servers[0].videos[3].id,
43000,
servers[ 0 ].videos[ 4 ].id
servers[0].videos[4].id
]
const res = await doVideosExistInMyPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, videoIds)
const res = await doVideosExistInMyPlaylist(servers[0].url, servers[0].accessToken, videoIds)
const obj = res.body as VideoExistInPlaylist
{
const elem = obj[ servers[ 0 ].videos[ 0 ].id ]
const elem = obj[servers[0].videos[0].id]
expect(elem).to.have.lengthOf(1)
expect(elem[ 0 ].playlistElementId).to.exist
expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
expect(elem[ 0 ].startTimestamp).to.equal(15)
expect(elem[ 0 ].stopTimestamp).to.equal(28)
expect(elem[0].playlistElementId).to.exist
expect(elem[0].playlistId).to.equal(playlistServer1Id)
expect(elem[0].startTimestamp).to.equal(15)
expect(elem[0].stopTimestamp).to.equal(28)
}
{
const elem = obj[ servers[ 0 ].videos[ 3 ].id ]
const elem = obj[servers[0].videos[3].id]
expect(elem).to.have.lengthOf(1)
expect(elem[ 0 ].playlistElementId).to.equal(playlistElementServer1Video4)
expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
expect(elem[ 0 ].startTimestamp).to.equal(1)
expect(elem[ 0 ].stopTimestamp).to.equal(35)
expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4)
expect(elem[0].playlistId).to.equal(playlistServer1Id)
expect(elem[0].startTimestamp).to.equal(1)
expect(elem[0].stopTimestamp).to.equal(35)
}
{
const elem = obj[ servers[ 0 ].videos[ 4 ].id ]
const elem = obj[servers[0].videos[4].id]
expect(elem).to.have.lengthOf(1)
expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
expect(elem[ 0 ].startTimestamp).to.equal(45)
expect(elem[ 0 ].stopTimestamp).to.equal(null)
expect(elem[0].playlistId).to.equal(playlistServer1Id)
expect(elem[0].startTimestamp).to.equal(45)
expect(elem[0].stopTimestamp).to.equal(null)
}
expect(obj[ 42000 ]).to.have.lengthOf(0)
expect(obj[ 43000 ]).to.have.lengthOf(0)
expect(obj[42000]).to.have.lengthOf(0)
expect(obj[43000]).to.have.lengthOf(0)
})
it('Should automatically update updatedAt field of playlists', async function () {
const server = servers[ 1 ]
const videoId = servers[ 1 ].videos[ 5 ].id
const server = servers[1]
const videoId = servers[1].videos[5].id
async function getPlaylistNames () {
const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt')
@@ -974,8 +974,8 @@ describe('Test video playlists', function () {
const element2 = res2.body.videoPlaylistElement.id
const names1 = await getPlaylistNames()
expect(names1[ 0 ]).to.equal('playlist 3 updated')
expect(names1[ 1 ]).to.equal('playlist 2')
expect(names1[0]).to.equal('playlist 3 updated')
expect(names1[1]).to.equal('playlist 2')
await removeVideoFromPlaylist({
url: server.url,
@@ -985,8 +985,8 @@ describe('Test video playlists', function () {
})
const names2 = await getPlaylistNames()
expect(names2[ 0 ]).to.equal('playlist 2')
expect(names2[ 1 ]).to.equal('playlist 3 updated')
expect(names2[0]).to.equal('playlist 2')
expect(names2[1]).to.equal('playlist 3 updated')
await removeVideoFromPlaylist({
url: server.url,
@@ -996,23 +996,23 @@ describe('Test video playlists', function () {
})
const names3 = await getPlaylistNames()
expect(names3[ 0 ]).to.equal('playlist 3 updated')
expect(names3[ 1 ]).to.equal('playlist 2')
expect(names3[0]).to.equal('playlist 3 updated')
expect(names3[1]).to.equal('playlist 2')
})
it('Should delete some elements', async function () {
this.timeout(30000)
await removeVideoFromPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
playlistElementId: playlistElementServer1Video4
})
await removeVideoFromPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistId: playlistServer1Id,
playlistElementId: playlistElementNSFW
})
@@ -1027,17 +1027,17 @@ describe('Test video playlists', function () {
const elements: VideoPlaylistElement[] = res.body.data
expect(elements).to.have.lengthOf(4)
expect(elements[ 0 ].video.name).to.equal('video 0 server 1')
expect(elements[ 0 ].position).to.equal(1)
expect(elements[0].video.name).to.equal('video 0 server 1')
expect(elements[0].position).to.equal(1)
expect(elements[ 1 ].video.name).to.equal('video 2 server 3')
expect(elements[ 1 ].position).to.equal(2)
expect(elements[1].video.name).to.equal('video 2 server 3')
expect(elements[1].position).to.equal(2)
expect(elements[ 2 ].video.name).to.equal('video 1 server 3')
expect(elements[ 2 ].position).to.equal(3)
expect(elements[2].video.name).to.equal('video 1 server 3')
expect(elements[2].position).to.equal(3)
expect(elements[ 3 ].video.name).to.equal('video 4 server 1')
expect(elements[ 3 ].position).to.equal(4)
expect(elements[3].video.name).to.equal('video 4 server 1')
expect(elements[3].position).to.equal(4)
}
})
@@ -1045,12 +1045,12 @@ describe('Test video playlists', function () {
this.timeout(30000)
const res = await createVideoPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistAttrs: {
displayName: 'my super public playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: servers[ 0 ].videoChannel.id
videoChannelId: servers[0].videoChannel.id
}
})
const videoPlaylistIds = res.body.videoPlaylist
@@ -1062,16 +1062,16 @@ describe('Test video playlists', function () {
}
const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE }
await updateVideoPlaylist({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, playlistId: videoPlaylistIds.id, playlistAttrs })
await updateVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: videoPlaylistIds.id, playlistAttrs })
await waitJobs(servers)
for (const server of [ servers[ 1 ], servers[ 2 ] ]) {
for (const server of [ servers[1], servers[2] ]) {
await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 404)
}
await getVideoPlaylist(servers[ 0 ].url, videoPlaylistIds.uuid, 401)
await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, 401)
await getVideoPlaylistWithToken(servers[ 0 ].url, servers[ 0 ].accessToken, videoPlaylistIds.uuid, 200)
await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, 200)
})
})
@@ -1080,7 +1080,7 @@ describe('Test video playlists', function () {
it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () {
this.timeout(30000)
await deleteVideoPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, playlistServer1Id)
await deleteVideoPlaylist(servers[0].url, servers[0].accessToken, playlistServer1Id)
await waitJobs(servers)
@@ -1103,15 +1103,15 @@ describe('Test video playlists', function () {
const finder = data => data.find(p => p.displayName === 'my super playlist')
{
const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
expect(res.body.total).to.equal(3)
expect(finder(res.body.data)).to.not.be.undefined
}
await unfollow(servers[ 2 ].url, servers[ 2 ].accessToken, servers[ 0 ])
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
{
const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5)
const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
expect(res.body.total).to.equal(1)
expect(finder(res.body.data)).to.be.undefined
@@ -1121,12 +1121,12 @@ describe('Test video playlists', function () {
it('Should delete a channel and put the associated playlist in private mode', async function () {
this.timeout(30000)
const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'super_channel', displayName: 'super channel' })
const res = await addVideoChannel(servers[0].url, servers[0].accessToken, { name: 'super_channel', displayName: 'super channel' })
const videoChannelId = res.body.videoChannel.id
const res2 = await createVideoPlaylist({
url: servers[ 0 ].url,
token: servers[ 0 ].accessToken,
url: servers[0].url,
token: servers[0].accessToken,
playlistAttrs: {
displayName: 'channel playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
@@ -1137,15 +1137,15 @@ describe('Test video playlists', function () {
await waitJobs(servers)
await deleteVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, 'super_channel')
await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'super_channel')
await waitJobs(servers)
const res3 = await getVideoPlaylistWithToken(servers[ 0 ].url, servers[ 0 ].accessToken, videoPlaylistUUID)
const res3 = await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistUUID)
expect(res3.body.displayName).to.equal('channel playlist')
expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
await getVideoPlaylist(servers[ 1 ].url, videoPlaylistUUID, 404)
await getVideoPlaylist(servers[1].url, videoPlaylistUUID, 404)
})
it('Should delete an account and delete its playlists', async function () {
@@ -1153,20 +1153,20 @@ describe('Test video playlists', function () {
const user = { username: 'user_1', password: 'password' }
const res = await createUser({
url: servers[ 0 ].url,
accessToken: servers[ 0 ].accessToken,
url: servers[0].url,
accessToken: servers[0].accessToken,
username: user.username,
password: user.password
})
const userId = res.body.user.id
const userAccessToken = await userLogin(servers[ 0 ], user)
const userAccessToken = await userLogin(servers[0], user)
const resChannel = await getMyUserInformation(servers[ 0 ].url, userAccessToken)
const userChannel = (resChannel.body as User).videoChannels[ 0 ]
const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
const userChannel = (resChannel.body as User).videoChannels[0]
await createVideoPlaylist({
url: servers[ 0 ].url,
url: servers[0].url,
token: userAccessToken,
playlistAttrs: {
displayName: 'playlist to be deleted',
@@ -1180,17 +1180,17 @@ describe('Test video playlists', function () {
const finder = data => data.find(p => p.displayName === 'playlist to be deleted')
{
for (const server of [ servers[ 0 ], servers[ 1 ] ]) {
for (const server of [ servers[0], servers[1] ]) {
const res = await getVideoPlaylistsList(server.url, 0, 15)
expect(finder(res.body.data)).to.not.be.undefined
}
}
await removeUser(servers[ 0 ].url, userId, servers[ 0 ].accessToken)
await removeUser(servers[0].url, userId, servers[0].accessToken)
await waitJobs(servers)
{
for (const server of [ servers[ 0 ], servers[ 1 ] ]) {
for (const server of [ servers[0], servers[1] ]) {
const res = await getVideoPlaylistsList(server.url, 0, 15)
expect(finder(res.body.data)).to.be.undefined
}

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 'mocha'
@@ -6,7 +6,8 @@ import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enu
import {
cleanupTests,
flushAndRunMultipleServers,
getVideosList, getVideosListWithToken,
getVideosList,
getVideosListWithToken,
ServerInfo,
setAccessTokensToServers,
uploadVideo
@@ -110,7 +111,7 @@ describe('Test video privacy', function () {
username: 'hello',
password: 'super password'
}
await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
anotherUserToken = await userLogin(servers[0], user)
await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, 403)
@@ -174,7 +175,7 @@ describe('Test video privacy', function () {
privacy: VideoPrivacy.PUBLIC
}
await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, privateVideoId, attribute)
await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute)
}
{
@@ -182,7 +183,7 @@ describe('Test video privacy', function () {
name: 'internal video becomes public',
privacy: VideoPrivacy.PUBLIC
}
await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, internalVideoId, attribute)
await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute)
}
await waitJobs(servers)

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 'mocha'
@@ -10,7 +10,6 @@ import {
getMyVideos,
getVideosList,
getVideoWithToken,
killallServers,
ServerInfo,
setAccessTokensToServers,
updateVideo,

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 'mocha'
@@ -56,19 +56,19 @@ describe('Test video transcoding', function () {
for (const server of servers) {
const res = await getVideosList(server.url)
const video = res.body.data[ 0 ]
const video = res.body.data[0]
const res2 = await getVideo(server.url, video.id)
const videoDetails = res2.body
expect(videoDetails.files).to.have.lengthOf(1)
const magnetUri = videoDetails.files[ 0 ].magnetUri
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.match(/\.webm/)
const torrent = await webtorrentAdd(magnetUri, true)
expect(torrent.files).to.be.an('array')
expect(torrent.files.length).to.equal(1)
expect(torrent.files[ 0 ].path).match(/\.webm$/)
expect(torrent.files[0].path).match(/\.webm$/)
}
})
@@ -93,13 +93,13 @@ describe('Test video transcoding', function () {
expect(videoDetails.files).to.have.lengthOf(4)
const magnetUri = videoDetails.files[ 0 ].magnetUri
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.match(/\.mp4/)
const torrent = await webtorrentAdd(magnetUri, true)
expect(torrent.files).to.be.an('array')
expect(torrent.files.length).to.equal(1)
expect(torrent.files[ 0 ].path).match(/\.mp4$/)
expect(torrent.files[0].path).match(/\.mp4$/)
}
})
@@ -127,8 +127,8 @@ describe('Test video transcoding', function () {
const probe = await audio.get(path)
if (probe.audioStream) {
expect(probe.audioStream[ 'codec_name' ]).to.be.equal('aac')
expect(probe.audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000)
expect(probe.audioStream['codec_name']).to.be.equal('aac')
expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000)
} else {
this.fail('Could not retrieve the audio stream on ' + probe.absolutePath)
}
@@ -212,10 +212,10 @@ describe('Test video transcoding', function () {
const videoDetails: VideoDetails = res2.body
expect(videoDetails.files).to.have.lengthOf(4)
expect(videoDetails.files[ 0 ].fps).to.be.above(58).and.below(62)
expect(videoDetails.files[ 1 ].fps).to.be.below(31)
expect(videoDetails.files[ 2 ].fps).to.be.below(31)
expect(videoDetails.files[ 3 ].fps).to.be.below(31)
expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
expect(videoDetails.files[1].fps).to.be.below(31)
expect(videoDetails.files[2].fps).to.be.below(31)
expect(videoDetails.files[3].fps).to.be.below(31)
for (const resolution of [ '240', '360', '480' ]) {
const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4')
@@ -241,11 +241,11 @@ describe('Test video transcoding', function () {
fixture: 'video_short1.webm',
waitTranscoding: true
}
const resVideo = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes)
const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
const videoId = resVideo.body.video.uuid
// Should be in transcode state
const { body } = await getVideo(servers[ 1 ].url, videoId)
const { body } = await getVideo(servers[1].url, videoId)
expect(body.name).to.equal('waiting video')
expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
expect(body.state.label).to.equal('To transcode')
@@ -311,7 +311,7 @@ describe('Test video transcoding', function () {
const video = res.body.data.find(v => v.name === videoAttributes.name)
for (const resolution of ['240', '360', '480', '720', '1080']) {
for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4')
const bitrate = await getVideoFileBitrate(path)
const fps = await getVideoFileFPS(path)
@@ -341,7 +341,7 @@ describe('Test video transcoding', function () {
fixture
}
await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes)
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
await waitJobs(servers)
@@ -354,7 +354,7 @@ describe('Test video transcoding', function () {
expect(videoDetails.files).to.have.lengthOf(4)
const magnetUri = videoDetails.files[ 0 ].magnetUri
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.contain('.mp4')
}
}
@@ -371,7 +371,7 @@ describe('Test video transcoding', function () {
this.timeout(60000)
const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributesArg)
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg)
await waitJobs(servers)
@@ -387,7 +387,7 @@ describe('Test video transcoding', function () {
await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 })
await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 })
const magnetUri = videoDetails.files[ 0 ].magnetUri
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.contain('.mp4')
}
})
@@ -396,7 +396,7 @@ describe('Test video transcoding', function () {
this.timeout(60000)
const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' }
await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributesArg)
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg)
await waitJobs(servers)
@@ -412,7 +412,7 @@ describe('Test video transcoding', function () {
await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 })
await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 })
const magnetUri = videoDetails.files[ 0 ].magnetUri
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.contain('.mp4')
}
})
@@ -445,13 +445,13 @@ describe('Test video transcoding', function () {
const video = res.body.data.find(v => v.name === videoAttributes.name)
{
const path = join(root(), 'test' + servers[ 1 ].internalServerNumber, 'videos', video.uuid + '-240.mp4')
const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
const fps = await getVideoFileFPS(path)
expect(fps).to.be.equal(25)
}
{
const path = join(root(), 'test' + servers[ 1 ].internalServerNumber, 'videos', video.uuid + '-720.mp4')
const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4')
const fps = await getVideoFileFPS(path)
expect(fps).to.be.equal(59)
}

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 'mocha'
@@ -7,8 +7,6 @@ import {
createUser,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
killallServers,
makeGetRequest,
ServerInfo,
setAccessTokensToServers,
@@ -98,7 +96,7 @@ describe('Test videos filter validator', function () {
const namesResults = await getVideosNames(server, server.accessToken, 'local')
for (const names of namesResults) {
expect(names).to.have.lengthOf(1)
expect(names[ 0 ]).to.equal('public ' + server.serverNumber)
expect(names[0]).to.equal('public ' + server.serverNumber)
}
}
})
@@ -111,9 +109,9 @@ describe('Test videos filter validator', function () {
for (const names of namesResults) {
expect(names).to.have.lengthOf(3)
expect(names[ 0 ]).to.equal('public ' + server.serverNumber)
expect(names[ 1 ]).to.equal('unlisted ' + server.serverNumber)
expect(names[ 2 ]).to.equal('private ' + server.serverNumber)
expect(names[0]).to.equal('public ' + server.serverNumber)
expect(names[1]).to.equal('unlisted ' + server.serverNumber)
expect(names[2]).to.equal('private ' + server.serverNumber)
}
}
}

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 'mocha'

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 'mocha'

View File

@@ -1,20 +1,22 @@
/* tslint:disable:no-unused-expression */
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
cleanupTests,
closeAllSequelize,
countVideoViewsOf,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
killallServers,
reRunServer,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize
uploadVideoAndGetId,
viewVideo,
wait,
waitJobs
} from '../../../../shared/extra-utils'
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
import { VideosOverview } from '../../../../shared/models/overviews'
import { listMyVideosHistory } from '../../../../shared/extra-utils/videos/video-history'
const expect = chai.expect