Cleanup tests imports
This commit is contained in:
parent
0b2f03d371
commit
d175a6f7ab
|
@ -11,28 +11,25 @@ killall -q peertube || true
|
||||||
|
|
||||||
if [ "$1" = "misc" ]; then
|
if [ "$1" = "misc" ]; then
|
||||||
npm run build -- --light-fr
|
npm run build -- --light-fr
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/client.ts \
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/client.ts \
|
||||||
server/tests/feeds/index.ts \
|
server/tests/feeds/index.ts \
|
||||||
server/tests/misc-endpoints.ts \
|
server/tests/misc-endpoints.ts \
|
||||||
server/tests/helpers/index.ts
|
server/tests/helpers/index.ts
|
||||||
elif [ "$1" = "api" ]; then
|
|
||||||
npm run build:server
|
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts
|
|
||||||
elif [ "$1" = "cli" ]; then
|
elif [ "$1" = "cli" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/cli/index.ts
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts
|
||||||
elif [ "$1" = "api-1" ]; then
|
elif [ "$1" = "api-1" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-1.ts
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-1.ts
|
||||||
elif [ "$1" = "api-2" ]; then
|
elif [ "$1" = "api-2" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-2.ts
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-2.ts
|
||||||
elif [ "$1" = "api-3" ]; then
|
elif [ "$1" = "api-3" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-3.ts
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-3.ts
|
||||||
elif [ "$1" = "api-4" ]; then
|
elif [ "$1" = "api-4" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-4.ts
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-4.ts
|
||||||
elif [ "$1" = "lint" ]; then
|
elif [ "$1" = "lint" ]; then
|
||||||
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
|
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as ffmpeg from 'fluent-ffmpeg'
|
import * as ffmpeg from 'fluent-ffmpeg'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { getTargetBitrate, VideoResolution } from '../../shared/models/videos'
|
import { getTargetBitrate, VideoResolution } from '../../shared/models/videos'
|
||||||
import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers'
|
import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants'
|
||||||
import { processImage } from './image-utils'
|
import { processImage } from './image-utils'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
import { checkFFmpegEncoders } from '../initializers/checker-before-init'
|
import { checkFFmpegEncoders } from '../initializers/checker-before-init'
|
||||||
|
|
|
@ -17,10 +17,8 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse
|
||||||
validate: validateUser
|
validate: validateUser
|
||||||
}
|
}
|
||||||
|
|
||||||
const [ userCreated, accountCreated ] = await Promise.all([
|
const userCreated = await userToCreate.save(userOptions)
|
||||||
userToCreate.save(userOptions),
|
const accountCreated = await createLocalAccountWithoutKeys(userCreated.username, userCreated.id, null, t)
|
||||||
createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t)
|
|
||||||
])
|
|
||||||
userCreated.Account = accountCreated
|
userCreated.Account = accountCreated
|
||||||
|
|
||||||
let channelName = userCreated.username + '_channel'
|
let channelName = userCreated.username + '_channel'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AfterDelete,
|
AfterDestroy,
|
||||||
AfterUpdate,
|
AfterUpdate,
|
||||||
AllowNull,
|
AllowNull,
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
|
@ -179,7 +179,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterUpdate
|
@AfterUpdate
|
||||||
@AfterDelete
|
@AfterDestroy
|
||||||
static removeTokenCache (instance: UserModel) {
|
static removeTokenCache (instance: UserModel) {
|
||||||
return clearCacheByUserId(instance.id)
|
return clearCacheByUserId(instance.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {
|
import {
|
||||||
AfterDelete,
|
AfterDestroy,
|
||||||
AfterUpdate,
|
AfterUpdate,
|
||||||
AllowNull,
|
AllowNull,
|
||||||
BelongsTo,
|
BelongsTo,
|
||||||
|
@ -126,7 +126,7 @@ export class OAuthTokenModel extends Model<OAuthTokenModel> {
|
||||||
OAuthClients: OAuthClientModel[]
|
OAuthClients: OAuthClientModel[]
|
||||||
|
|
||||||
@AfterUpdate
|
@AfterUpdate
|
||||||
@AfterDelete
|
@AfterDestroy
|
||||||
static removeTokenCache (token: OAuthTokenModel) {
|
static removeTokenCache (token: OAuthTokenModel) {
|
||||||
return clearCacheByToken(token.accessToken)
|
return clearCacheByToken(token.accessToken)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
|
||||||
import { flushAndRunMultipleServers, flushTests, killallServers, makePOSTAPRequest, makeFollowRequest, ServerInfo } from '../../utils'
|
import { flushAndRunMultipleServers, flushTests, killallServers, ServerInfo } from '../../utils'
|
||||||
import { HTTP_SIGNATURE } from '../../../initializers'
|
import { HTTP_SIGNATURE } from '../../../initializers'
|
||||||
import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
|
import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { setActorField } from '../../utils/miscs/sql'
|
import { setActorField } from '../../utils/miscs/sql'
|
||||||
import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub'
|
import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub'
|
||||||
|
import { makeFollowRequest, makePOSTAPRequest } from '../../utils/requests/activitypub'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import './blocklist'
|
import './blocklist'
|
||||||
import './user-subscriptions'
|
import './user-subscriptions'
|
||||||
import './users'
|
import './users'
|
||||||
import './users-verification'
|
|
||||||
import './users-multiple-servers'
|
import './users-multiple-servers'
|
||||||
|
import './users-verification'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* tslint:disable:no-unused-expression */
|
/* tslint:disable:no-unused-expression */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import * as lodash from 'lodash'
|
import { orderBy } from 'lodash'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
addVideoToBlacklist,
|
addVideoToBlacklist,
|
||||||
|
@ -22,7 +22,6 @@ import { waitJobs } from '../../utils/server/jobs'
|
||||||
import { VideoAbuse } from '../../../../shared/models/videos'
|
import { VideoAbuse } from '../../../../shared/models/videos'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
const orderBy = lodash.orderBy
|
|
||||||
|
|
||||||
describe('Test video blacklist management', function () {
|
describe('Test video blacklist management', function () {
|
||||||
let servers: ServerInfo[] = []
|
let servers: ServerInfo[] = []
|
||||||
|
|
|
@ -7,10 +7,12 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getVideoChannelVideos, serverLogin, testImage,
|
getVideoChannelVideos,
|
||||||
|
testImage,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
updateVideoChannelAvatar,
|
updateVideoChannelAvatar,
|
||||||
uploadVideo, wait, userLogin
|
uploadVideo,
|
||||||
|
userLogin
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import {
|
import {
|
||||||
addVideoChannel,
|
addVideoChannel,
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
wait
|
wait
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import { join } from 'path'
|
|
||||||
import { waitJobs } from '../../utils/server/jobs'
|
import { waitJobs } from '../../utils/server/jobs'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { omit } from 'lodash'
|
import { omit } from 'lodash'
|
||||||
import * as ffmpeg from 'fluent-ffmpeg'
|
|
||||||
import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
|
import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
|
||||||
import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
|
import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
|
||||||
import {
|
import {
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
generateHighBitrateVideo,
|
||||||
getMyVideos,
|
getMyVideos,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
|
@ -18,12 +18,10 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
webtorrentAdd,
|
webtorrentAdd
|
||||||
generateHighBitrateVideo
|
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { waitJobs } from '../../utils/server/jobs'
|
import { waitJobs } from '../../utils/server/jobs'
|
||||||
import { pathExists } from 'fs-extra'
|
|
||||||
import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
|
import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
|
@ -7,7 +7,6 @@ export * from './miscs/miscs'
|
||||||
export * from './miscs/stubs'
|
export * from './miscs/stubs'
|
||||||
export * from './server/follows'
|
export * from './server/follows'
|
||||||
export * from './requests/requests'
|
export * from './requests/requests'
|
||||||
export * from './requests/activitypub'
|
|
||||||
export * from './server/servers'
|
export * from './server/servers'
|
||||||
export * from './videos/services'
|
export * from './videos/services'
|
||||||
export * from './users/users'
|
export * from './users/users'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { makeGetRequest } from './requests'
|
import { makeGetRequest } from './requests'
|
||||||
import { immutableAssign } from '..'
|
import { immutableAssign } from '../miscs/miscs'
|
||||||
|
|
||||||
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
|
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
|
||||||
return makeGetRequest({
|
return makeGetRequest({
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { VideosSearchQuery } from '../../../../shared/models/search'
|
import { VideosSearchQuery } from '../../../../shared/models/search'
|
||||||
import { immutableAssign } from '..'
|
import { immutableAssign } from '../miscs/miscs'
|
||||||
|
|
||||||
function searchVideo (url: string, search: string) {
|
function searchVideo (url: string, search: string) {
|
||||||
const path = '/api/v1/search/videos'
|
const path = '/api/v1/search/videos'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../'
|
import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
|
||||||
import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
|
import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
|
||||||
|
|
||||||
function getConfig (url: string) {
|
function getConfig (url: string) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { Job, JobState } from '../../../../shared/models'
|
import { Job, JobState } from '../../../../shared/models'
|
||||||
import { ServerInfo, wait } from '../index'
|
import { ServerInfo } from './servers'
|
||||||
|
import { wait } from '../miscs/miscs'
|
||||||
|
|
||||||
function getJobsList (url: string, accessToken: string, state: JobState) {
|
function getJobsList (url: string, accessToken: string, state: JobState) {
|
||||||
const path = '/api/v1/jobs/' + state
|
const path = '/api/v1/jobs/' + state
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { makeGetRequest } from '../'
|
import { makeGetRequest } from '../requests/requests'
|
||||||
|
|
||||||
function getStats (url: string, useCache = false) {
|
function getStats (url: string, useCache = false) {
|
||||||
const path = '/api/v1/server/stats'
|
const path = '/api/v1/server/stats'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { expect } from 'chai'
|
||||||
import { existsSync, readdir } from 'fs-extra'
|
import { existsSync, readdir } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { Account } from '../../../../shared/models/actors'
|
import { Account } from '../../../../shared/models/actors'
|
||||||
import { root } from '../index'
|
import { root } from '../miscs/miscs'
|
||||||
import { makeGetRequest } from '../requests/requests'
|
import { makeGetRequest } from '../requests/requests'
|
||||||
|
|
||||||
function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) {
|
function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* tslint:disable:no-unused-expression */
|
/* tslint:disable:no-unused-expression */
|
||||||
|
|
||||||
import { makeDeleteRequest, makePostBodyRequest } from '../index'
|
import { makeDeleteRequest, makePostBodyRequest } from '../requests/requests'
|
||||||
import { makeGetRequest } from '../requests/requests'
|
import { makeGetRequest } from '../requests/requests'
|
||||||
|
|
||||||
function getAccountBlocklistByAccount (
|
function getAccountBlocklistByAccount (
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../'
|
import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../requests/requests'
|
||||||
|
|
||||||
function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = 204) {
|
function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = 204) {
|
||||||
const path = '/api/v1/users/me/subscriptions'
|
const path = '/api/v1/users/me/subscriptions'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../'
|
import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests'
|
||||||
|
|
||||||
import { UserRole } from '../../../../shared/index'
|
import { UserRole } from '../../../../shared/index'
|
||||||
import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { VideoAbuseUpdate } from '../../../../shared/models/videos/abuse/video-abuse-update.model'
|
import { VideoAbuseUpdate } from '../../../../shared/models/videos/abuse/video-abuse-update.model'
|
||||||
import { makeDeleteRequest, makePutBodyRequest } from '..'
|
import { makeDeleteRequest, makePutBodyRequest } from '../requests/requests'
|
||||||
|
|
||||||
function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) {
|
function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) {
|
||||||
const path = '/api/v1/videos/' + videoId + '/abuse'
|
const path = '/api/v1/videos/' + videoId + '/abuse'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { makeDeleteRequest, makeGetRequest } from '../'
|
import { makeDeleteRequest, makeGetRequest, makeUploadRequest } from '../requests/requests'
|
||||||
import { buildAbsoluteFixturePath, makeUploadRequest } from '../index'
|
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
import { buildAbsoluteFixturePath } from '../miscs/miscs'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared/models/videos'
|
import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared/models/videos'
|
||||||
import { updateAvatarRequest } from '../index'
|
import { updateAvatarRequest } from '../requests/requests'
|
||||||
|
|
||||||
function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
|
function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
|
||||||
const path = '/api/v1/video-channels'
|
const path = '/api/v1/video-channels'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { makeDeleteRequest } from '../'
|
import { makeDeleteRequest } from '../requests/requests'
|
||||||
|
|
||||||
function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: string) {
|
function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: string) {
|
||||||
const path = '/api/v1/videos/' + videoId + '/comment-threads'
|
const path = '/api/v1/videos/' + videoId + '/comment-threads'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { VideoImportCreate } from '../../../../shared/models/videos'
|
import { VideoImportCreate } from '../../../../shared/models/videos'
|
||||||
import { makeGetRequest, makeUploadRequest } from '..'
|
import { makeGetRequest, makeUploadRequest } from '../requests/requests'
|
||||||
|
|
||||||
function getYoutubeVideoUrl () {
|
function getYoutubeVideoUrl () {
|
||||||
return 'https://youtu.be/msX3jv1XdvM'
|
return 'https://youtu.be/msX3jv1XdvM'
|
||||||
|
|
|
@ -17,8 +17,8 @@ import {
|
||||||
testImage
|
testImage
|
||||||
} from '../'
|
} from '../'
|
||||||
import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
|
import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
|
||||||
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers'
|
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants'
|
||||||
import { dateIsValid, webtorrentAdd } from '../index'
|
import { dateIsValid, webtorrentAdd } from '../miscs/miscs'
|
||||||
|
|
||||||
type VideoAttributes = {
|
type VideoAttributes = {
|
||||||
name?: string
|
name?: string
|
||||||
|
|
Loading…
Reference in New Issue