diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-17 11:58:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-17 12:24:03 +0100 |
commit | c55e3d7227fe1453869e309025996b9d75256d5d (patch) | |
tree | 08e9b0ca210d75c82c8606fef0852eca020e8e0e | |
parent | bf54587a3e2ad9c2c186828f2a5682b91ee2cc00 (diff) | |
download | PeerTube-c55e3d7227fe1453869e309025996b9d75256d5d.tar.gz PeerTube-c55e3d7227fe1453869e309025996b9d75256d5d.tar.zst PeerTube-c55e3d7227fe1453869e309025996b9d75256d5d.zip |
Move test functions outside extra-utils
202 files changed, 795 insertions, 892 deletions
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts index 42f4f6096..5ada4a805 100644 --- a/server/controllers/api/users/token.ts +++ b/server/controllers/api/users/token.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import RateLimit from 'express-rate-limit' | 2 | import RateLimit from 'express-rate-limit' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { buildUUID } from '@shared/core-utils/uuid' | ||
5 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
6 | import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth' | 5 | import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth' |
7 | import { handleOAuthToken } from '@server/lib/auth/oauth' | 6 | import { handleOAuthToken } from '@server/lib/auth/oauth' |
8 | import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model' | 7 | import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model' |
9 | import { Hooks } from '@server/lib/plugins/hooks' | 8 | import { Hooks } from '@server/lib/plugins/hooks' |
10 | import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares' | 9 | import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares' |
10 | import { buildUUID } from '@shared/core-utils' | ||
11 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | 11 | import { ScopedToken } from '@shared/models/users/user-scoped-token' |
12 | 12 | ||
13 | const tokensRouter = express.Router() | 13 | const tokensRouter = express.Router() |
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index f8f07b1c6..dc1947764 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { uuidToShort } from '@shared/core-utils/uuid' | ||
4 | import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' | 3 | import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' |
5 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
6 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
7 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' | 6 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' |
7 | import { uuidToShort } from '@shared/core-utils' | ||
8 | import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' | 8 | import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' |
9 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 9 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
10 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' | 10 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' |
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index e466d041b..4ee39aa4f 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { createReqFiles } from '@server/helpers/express-utils' | 2 | import { createReqFiles } from '@server/helpers/express-utils' |
3 | import { buildUUID, uuidToShort } from '@shared/core-utils/uuid' | ||
4 | import { CONFIG } from '@server/initializers/config' | 3 | import { CONFIG } from '@server/initializers/config' |
5 | import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' | 4 | import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' |
6 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | 5 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
@@ -10,6 +9,7 @@ import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } fro | |||
10 | import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live' | 9 | import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live' |
11 | import { VideoLiveModel } from '@server/models/video/video-live' | 10 | import { VideoLiveModel } from '@server/models/video/video-live' |
12 | import { MVideoDetails, MVideoFullLight } from '@server/types/models' | 11 | import { MVideoDetails, MVideoFullLight } from '@server/types/models' |
12 | import { buildUUID, uuidToShort } from '@shared/core-utils' | ||
13 | import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' | 13 | import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' |
14 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 14 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
15 | import { logger } from '../../../helpers/logger' | 15 | import { logger } from '../../../helpers/logger' |
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index a4d0f980f..9f620c04d 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts | |||
@@ -1,9 +1,7 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { move } from 'fs-extra' | 2 | import { move } from 'fs-extra' |
3 | import { basename } from 'path' | 3 | import { basename } from 'path' |
4 | import { getLowercaseExtension } from '@shared/core-utils' | ||
5 | import { getResumableUploadPath } from '@server/helpers/upload' | 4 | import { getResumableUploadPath } from '@server/helpers/upload' |
6 | import { uuidToShort } from '@shared/core-utils/uuid' | ||
7 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 5 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
8 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | 6 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
9 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' | 7 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' |
@@ -20,6 +18,7 @@ import { VideoPathManager } from '@server/lib/video-path-manager' | |||
20 | import { buildNextVideoState } from '@server/lib/video-state' | 18 | import { buildNextVideoState } from '@server/lib/video-state' |
21 | import { openapiOperationDoc } from '@server/middlewares/doc' | 19 | import { openapiOperationDoc } from '@server/middlewares/doc' |
22 | import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' | 20 | import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' |
21 | import { getLowercaseExtension, uuidToShort } from '@shared/core-utils' | ||
23 | import { VideoCreate, VideoState } from '../../../../shared' | 22 | import { VideoCreate, VideoState } from '../../../../shared' |
24 | import { HttpStatusCode } from '../../../../shared/models' | 23 | import { HttpStatusCode } from '../../../../shared/models' |
25 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 24 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index eaabdbbea..65578c143 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -2,7 +2,7 @@ import 'multer' | |||
2 | import { UploadFilesForCheck } from 'express' | 2 | import { UploadFilesForCheck } from 'express' |
3 | import { sep } from 'path' | 3 | import { sep } from 'path' |
4 | import validator from 'validator' | 4 | import validator from 'validator' |
5 | import { isShortUUID, shortToUUID } from '@shared/core-utils/uuid' | 5 | import { isShortUUID, shortToUUID } from '@shared/core-utils' |
6 | 6 | ||
7 | function exists (value: any) { | 7 | function exists (value: any) { |
8 | return value !== undefined && value !== null | 8 | return value !== undefined && value !== null |
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index ced288045..c4704b189 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { copy, readFile, remove, rename } from 'fs-extra' | 1 | import { copy, readFile, remove, rename } from 'fs-extra' |
2 | import Jimp, { read } from 'jimp' | 2 | import Jimp, { read } from 'jimp' |
3 | import { getLowercaseExtension } from '@shared/core-utils' | 3 | import { buildUUID, getLowercaseExtension } from '@shared/core-utils' |
4 | import { convertWebPToJPG, processGIF } from './ffmpeg-utils' | 4 | import { convertWebPToJPG, processGIF } from './ffmpeg-utils' |
5 | import { logger } from './logger' | 5 | import { logger } from './logger' |
6 | import { buildUUID } from '@shared/core-utils/uuid' | ||
7 | 6 | ||
8 | function generateImageFilename (extension = '.jpg') { | 7 | function generateImageFilename (extension = '.jpg') { |
9 | return buildUUID() + extension | 8 | return buildUUID() + extension |
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index 31705e7fa..66a353204 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts | |||
@@ -4,7 +4,7 @@ import { Request } from 'express' | |||
4 | import { cloneDeep } from 'lodash' | 4 | import { cloneDeep } from 'lodash' |
5 | import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' | 5 | import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' |
6 | import { MActor } from '../types/models' | 6 | import { MActor } from '../types/models' |
7 | import { sha256 } from '@shared/core-utils/crypto' | 7 | import { sha256 } from '@shared/core-utils/common/crypto' |
8 | import { createPrivateKey, getPublicKey, promisify1, promisify2 } from './core-utils' | 8 | import { createPrivateKey, getPublicKey, promisify1, promisify2 } from './core-utils' |
9 | import { jsonld } from './custom-jsonld-signature' | 9 | import { jsonld } from './custom-jsonld-signature' |
10 | import { logger } from './logger' | 10 | import { logger } from './logger' |
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 882f808ab..d6a3dae95 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -3,7 +3,7 @@ import { Instance as ParseTorrent } from 'parse-torrent' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { ResultList } from '../../shared' | 4 | import { ResultList } from '../../shared' |
5 | import { CONFIG } from '../initializers/config' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { sha256 } from '@shared/core-utils/crypto' | 6 | import { sha256 } from '@shared/core-utils/common/crypto' |
7 | import { execPromise, execPromise2, randomBytesPromise } from './core-utils' | 7 | import { execPromise, execPromise2, randomBytesPromise } from './core-utils' |
8 | import { logger } from './logger' | 8 | import { logger } from './logger' |
9 | 9 | ||
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 67cb3971d..03663d73c 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -15,7 +15,7 @@ import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/vide | |||
15 | import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist' | 15 | import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist' |
16 | import { CONFIG } from '../initializers/config' | 16 | import { CONFIG } from '../initializers/config' |
17 | import { promisify2 } from './core-utils' | 17 | import { promisify2 } from './core-utils' |
18 | import { sha1 } from '@shared/core-utils/crypto' | 18 | import { sha1 } from '@shared/core-utils/common/crypto' |
19 | import { logger } from './logger' | 19 | import { logger } from './logger' |
20 | import { generateVideoImportTmpPath } from './utils' | 20 | import { generateVideoImportTmpPath } from './utils' |
21 | import { extractVideo } from './video' | 21 | import { extractVideo } from './video' |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 258ccdb51..57f7af789 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -2,7 +2,7 @@ import { CronRepeatOptions, EveryRepeatOptions } from 'bull' | |||
2 | import { randomBytes } from 'crypto' | 2 | import { randomBytes } from 'crypto' |
3 | import { invert } from 'lodash' | 3 | import { invert } from 'lodash' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { randomInt } from '../../shared/core-utils/common/miscs' | 5 | import { randomInt, root } from '@shared/core-utils' |
6 | import { | 6 | import { |
7 | AbuseState, | 7 | AbuseState, |
8 | JobType, | 8 | JobType, |
@@ -18,7 +18,6 @@ import { FollowState } from '../../shared/models/actors' | |||
18 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 18 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
19 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' | 19 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' |
20 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' | 20 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' |
21 | import { root } from '../../shared/core-utils' | ||
22 | // Do not use barrels, remain constants as independent as possible | 21 | // Do not use barrels, remain constants as independent as possible |
23 | import { isTestInstance, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' | 22 | import { isTestInstance, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
24 | import { CONFIG, registerConfigChangedHandler } from './config' | 23 | import { CONFIG, registerConfigChangedHandler } from './config' |
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts index 82971c9f5..221475bb1 100644 --- a/server/initializers/migrations/0080-video-channels.ts +++ b/server/initializers/migrations/0080-video-channels.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { buildUUID } from '@shared/core-utils/uuid' | 1 | import { buildUUID } from '@shared/core-utils' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | 3 | ||
4 | async function up (utils: { | 4 | async function up (utils: { |
diff --git a/server/initializers/migrations/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.ts index 5cc52e7ee..fb27c9301 100644 --- a/server/initializers/migrations/0345-video-playlists.ts +++ b/server/initializers/migrations/0345-video-playlists.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { buildUUID } from '@shared/core-utils/uuid' | 2 | import { buildUUID } from '@shared/core-utils' |
3 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' | 3 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' |
4 | import { WEBSERVER } from '../constants' | 4 | import { WEBSERVER } from '../constants' |
5 | 5 | ||
diff --git a/server/initializers/migrations/0560-user-feed-token.ts b/server/initializers/migrations/0560-user-feed-token.ts index 961777e35..4ed4d9681 100644 --- a/server/initializers/migrations/0560-user-feed-token.ts +++ b/server/initializers/migrations/0560-user-feed-token.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { buildUUID } from '@shared/core-utils/uuid' | 2 | import { buildUUID } from '@shared/core-utils' |
3 | 3 | ||
4 | async function up (utils: { | 4 | async function up (utils: { |
5 | transaction: Sequelize.Transaction | 5 | transaction: Sequelize.Transaction |
diff --git a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts b/server/lib/activitypub/actors/shared/object-to-model-attributes.ts index 1ad89ac56..38d93c108 100644 --- a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts +++ b/server/lib/activitypub/actors/shared/object-to-model-attributes.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { getLowercaseExtension } from '@shared/core-utils' | ||
2 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 1 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
3 | import { buildUUID } from '@shared/core-utils/uuid' | ||
4 | import { MIMETYPES } from '@server/initializers/constants' | 2 | import { MIMETYPES } from '@server/initializers/constants' |
5 | import { ActorModel } from '@server/models/actor/actor' | 3 | import { ActorModel } from '@server/models/actor/actor' |
6 | import { FilteredModelAttributes } from '@server/types' | 4 | import { FilteredModelAttributes } from '@server/types' |
5 | import { buildUUID, getLowercaseExtension } from '@shared/core-utils' | ||
7 | import { ActivityPubActor, ActorImageType } from '@shared/models' | 6 | import { ActivityPubActor, ActorImageType } from '@shared/models' |
8 | 7 | ||
9 | function getActorAttributesFromObject ( | 8 | function getActorAttributesFromObject ( |
diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts index 47bc8c055..dc0022852 100644 --- a/server/lib/auth/oauth.ts +++ b/server/lib/auth/oauth.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | UnauthorizedClientError, | 8 | UnauthorizedClientError, |
9 | UnsupportedGrantTypeError | 9 | UnsupportedGrantTypeError |
10 | } from 'oauth2-server' | 10 | } from 'oauth2-server' |
11 | import { sha1 } from '@shared/core-utils/crypto' | 11 | import { sha1 } from '@shared/core-utils/common/crypto' |
12 | import { randomBytesPromise } from '@server/helpers/core-utils' | 12 | import { randomBytesPromise } from '@server/helpers/core-utils' |
13 | import { MOAuthClient } from '@server/types/models' | 13 | import { MOAuthClient } from '@server/types/models' |
14 | import { OAUTH_LIFETIME } from '../../initializers/constants' | 14 | import { OAUTH_LIFETIME } from '../../initializers/constants' |
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index dee7ca8ed..91708839b 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -9,7 +9,7 @@ import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from | |||
9 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 9 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
10 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' | 10 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' |
11 | import { isTestInstance } from '../helpers/core-utils' | 11 | import { isTestInstance } from '../helpers/core-utils' |
12 | import { sha256 } from '@shared/core-utils/crypto' | 12 | import { sha256 } from '@shared/core-utils/common/crypto' |
13 | import { logger } from '../helpers/logger' | 13 | import { logger } from '../helpers/logger' |
14 | import { mdToPlainText } from '../helpers/markdown' | 14 | import { mdToPlainText } from '../helpers/markdown' |
15 | import { CONFIG } from '../initializers/config' | 15 | import { CONFIG } from '../initializers/config' |
diff --git a/server/lib/hls.ts b/server/lib/hls.ts index 220b7733b..e4904be5f 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts | |||
@@ -2,7 +2,7 @@ import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat, | |||
2 | import { flatten, uniq } from 'lodash' | 2 | import { flatten, uniq } from 'lodash' |
3 | import { basename, dirname, join } from 'path' | 3 | import { basename, dirname, join } from 'path' |
4 | import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models' | 4 | import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models' |
5 | import { sha256 } from '@shared/core-utils/crypto' | 5 | import { sha256 } from '@shared/core-utils/common/crypto' |
6 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils' | 6 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils' |
7 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
8 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' | 8 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' |
diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts index 572696f2a..04ad98f3e 100644 --- a/server/lib/local-actor.ts +++ b/server/lib/local-actor.ts | |||
@@ -2,9 +2,8 @@ import 'multer' | |||
2 | import { queue } from 'async' | 2 | import { queue } from 'async' |
3 | import LRUCache from 'lru-cache' | 3 | import LRUCache from 'lru-cache' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { getLowercaseExtension } from '@shared/core-utils' | ||
6 | import { buildUUID } from '@shared/core-utils/uuid' | ||
7 | import { ActorModel } from '@server/models/actor/actor' | 5 | import { ActorModel } from '@server/models/actor/actor' |
6 | import { buildUUID, getLowercaseExtension } from '@shared/core-utils' | ||
8 | import { ActivityPubActorType, ActorImageType } from '@shared/models' | 7 | import { ActivityPubActorType, ActorImageType } from '@shared/models' |
9 | import { retryTransactionWrapper } from '../helpers/database-utils' | 8 | import { retryTransactionWrapper } from '../helpers/database-utils' |
10 | import { processImage } from '../helpers/image-utils' | 9 | import { processImage } from '../helpers/image-utils' |
diff --git a/server/lib/paths.ts b/server/lib/paths.ts index d8cf812e3..bf0c3a86b 100644 --- a/server/lib/paths.ts +++ b/server/lib/paths.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { buildUUID } from '@shared/core-utils/uuid' | ||
3 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
4 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' | 3 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' |
5 | import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' | 4 | import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' |
6 | import { removeFragmentedMP4Ext } from '@shared/core-utils' | 5 | import { buildUUID, removeFragmentedMP4Ext } from '@shared/core-utils' |
7 | 6 | ||
8 | // ################## Video file name ################## | 7 | // ################## Video file name ################## |
9 | 8 | ||
diff --git a/server/lib/user.ts b/server/lib/user.ts index 230bf37d0..3ba0c0ca4 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Transaction } from 'sequelize/types' | 1 | import { Transaction } from 'sequelize/types' |
2 | import { buildUUID } from '@shared/core-utils/uuid' | ||
3 | import { UserModel } from '@server/models/user/user' | 2 | import { UserModel } from '@server/models/user/user' |
4 | import { MActorDefault } from '@server/types/models/actor' | 3 | import { MActorDefault } from '@server/types/models/actor' |
4 | import { buildUUID } from '@shared/core-utils' | ||
5 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 5 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
6 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' | 6 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' |
7 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' | 7 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' |
diff --git a/server/lib/video-path-manager.ts b/server/lib/video-path-manager.ts index 429b36df9..4027f885d 100644 --- a/server/lib/video-path-manager.ts +++ b/server/lib/video-path-manager.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import { extname, join } from 'path' | 2 | import { extname, join } from 'path' |
3 | import { buildUUID } from '@shared/core-utils/uuid' | ||
4 | import { extractVideo } from '@server/helpers/video' | 3 | import { extractVideo } from '@server/helpers/video' |
5 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
6 | import { | 5 | import { |
@@ -11,6 +10,7 @@ import { | |||
11 | MVideoFileVideo, | 10 | MVideoFileVideo, |
12 | MVideoUUID | 11 | MVideoUUID |
13 | } from '@server/types/models' | 12 | } from '@server/types/models' |
13 | import { buildUUID } from '@shared/core-utils' | ||
14 | import { VideoStorage } from '@shared/models' | 14 | import { VideoStorage } from '@shared/models' |
15 | import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage' | 15 | import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage' |
16 | import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths' | 16 | import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths' |
diff --git a/server/models/user/user-notification.ts b/server/models/user/user-notification.ts index 4a9a84a5b..d71bb4d56 100644 --- a/server/models/user/user-notification.ts +++ b/server/models/user/user-notification.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize' | 1 | import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize' |
2 | import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { uuidToShort } from '@shared/core-utils/uuid' | ||
4 | import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user' | 3 | import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user' |
4 | import { uuidToShort } from '@shared/core-utils' | ||
5 | import { AttributesOnly } from '@shared/typescript-utils' | 5 | import { AttributesOnly } from '@shared/typescript-utils' |
6 | import { UserNotification, UserNotificationType } from '../../../shared' | 6 | import { UserNotification, UserNotificationType } from '../../../shared' |
7 | import { isBooleanValid } from '../../helpers/custom-validators/misc' | 7 | import { isBooleanValid } from '../../helpers/custom-validators/misc' |
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts index f6c750ccf..99a4818ab 100644 --- a/server/models/video/formatter/video-format-utils.ts +++ b/server/models/video/formatter/video-format-utils.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { uuidToShort } from '@shared/core-utils/uuid' | ||
2 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 1 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
3 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' | 2 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' |
4 | import { VideoViews } from '@server/lib/video-views' | 3 | import { VideoViews } from '@server/lib/video-views' |
4 | import { uuidToShort } from '@shared/core-utils' | ||
5 | import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models' | 5 | import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models' |
6 | import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects' | 6 | import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects' |
7 | import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos' | 7 | import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos' |
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index 642613cfe..20741ea64 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts | |||
@@ -15,8 +15,8 @@ import { | |||
15 | Table, | 15 | Table, |
16 | UpdatedAt | 16 | UpdatedAt |
17 | } from 'sequelize-typescript' | 17 | } from 'sequelize-typescript' |
18 | import { buildUUID } from '@shared/core-utils/uuid' | ||
19 | import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' | 18 | import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' |
19 | import { buildUUID } from '@shared/core-utils' | ||
20 | import { AttributesOnly } from '@shared/typescript-utils' | 20 | import { AttributesOnly } from '@shared/typescript-utils' |
21 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' | 21 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' |
22 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' | 22 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' |
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 132fa0e68..07bb64810 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -18,8 +18,7 @@ import { | |||
18 | UpdatedAt | 18 | UpdatedAt |
19 | } from 'sequelize-typescript' | 19 | } from 'sequelize-typescript' |
20 | import { MAccountId, MChannelId } from '@server/types/models' | 20 | import { MAccountId, MChannelId } from '@server/types/models' |
21 | import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils' | 21 | import { buildPlaylistEmbedPath, buildPlaylistWatchPath, buildUUID, pick, uuidToShort } from '@shared/core-utils' |
22 | import { buildUUID, uuidToShort } from '@shared/core-utils/uuid' | ||
23 | import { AttributesOnly } from '@shared/typescript-utils' | 22 | import { AttributesOnly } from '@shared/typescript-utils' |
24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 23 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
25 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' | 24 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' |
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index d813f89b5..7b410f8ee 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -21,7 +21,7 @@ import { MStreamingPlaylist, MVideo } from '@server/types/models' | |||
21 | import { AttributesOnly } from '@shared/typescript-utils' | 21 | import { AttributesOnly } from '@shared/typescript-utils' |
22 | import { VideoStorage } from '@shared/models' | 22 | import { VideoStorage } from '@shared/models' |
23 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' | 23 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' |
24 | import { sha1 } from '@shared/core-utils/crypto' | 24 | import { sha1 } from '@shared/core-utils/common/crypto' |
25 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 25 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
26 | import { isArrayOf } from '../../helpers/custom-validators/misc' | 26 | import { isArrayOf } from '../../helpers/custom-validators/misc' |
27 | import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' | 27 | import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index a99b012b9..66a9a28fa 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -32,8 +32,7 @@ import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths' | |||
32 | import { VideoPathManager } from '@server/lib/video-path-manager' | 32 | import { VideoPathManager } from '@server/lib/video-path-manager' |
33 | import { getServerActor } from '@server/models/application/application' | 33 | import { getServerActor } from '@server/models/application/application' |
34 | import { ModelCache } from '@server/models/model-cache' | 34 | import { ModelCache } from '@server/models/model-cache' |
35 | import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' | 35 | import { buildVideoEmbedPath, buildVideoWatchPath, pick, uuidToShort } from '@shared/core-utils' |
36 | import { uuidToShort } from '@shared/core-utils/uuid' | ||
37 | import { VideoFile, VideoInclude } from '@shared/models' | 36 | import { VideoFile, VideoInclude } from '@shared/models' |
38 | import { AttributesOnly } from '@shared/typescript-utils' | 37 | import { AttributesOnly } from '@shared/typescript-utils' |
39 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' | 38 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' |
diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts index c3368c7eb..7a443b553 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/server/tests/api/activitypub/cleaner.ts | |||
@@ -2,13 +2,13 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
8 | doubleFollow, | 9 | doubleFollow, |
9 | PeerTubeServer, | 10 | PeerTubeServer, |
10 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/server-commands' | 13 | } from '@shared/server-commands' |
14 | 14 | ||
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index 93bf01842..cc71e82ea 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts | |||
@@ -2,7 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | const expect = chai.expect | 14 | const expect = chai.expect |
8 | 15 | ||
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 5aa94af5d..25e1d9823 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts | |||
@@ -3,7 +3,8 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cloneDeep } from 'lodash' | 5 | import { cloneDeep } from 'lodash' |
6 | import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/server-commands' | 6 | import { buildRequestStub } from '@server/tests/shared' |
7 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
7 | import { buildSignedActivity } from '../../../helpers/activitypub' | 8 | import { buildSignedActivity } from '../../../helpers/activitypub' |
8 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' | 9 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' |
9 | 10 | ||
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index 669a86fca..71e1c40ba 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { wait } from '@shared/core-utils' | ||
5 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | cleanupTests, | 7 | cleanupTests, |
6 | createMultipleServers, | 8 | createMultipleServers, |
@@ -9,10 +11,8 @@ import { | |||
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
12 | wait, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | ||
16 | 16 | ||
17 | describe('Test AP refresher', function () { | 17 | describe('Test AP refresher', function () { |
18 | let servers: PeerTubeServer[] = [] | 18 | let servers: PeerTubeServer[] = [] |
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index 3b871ae12..c4cb5ea0d 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts | |||
@@ -6,9 +6,10 @@ import { activityPubContextify, buildSignedActivity } from '@server/helpers/acti | |||
6 | import { buildDigest } from '@server/helpers/peertube-crypto' | 6 | import { buildDigest } from '@server/helpers/peertube-crypto' |
7 | import { HTTP_SIGNATURE } from '@server/initializers/constants' | 7 | import { HTTP_SIGNATURE } from '@server/initializers/constants' |
8 | import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' | 8 | import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' |
9 | import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/server-commands' | ||
10 | import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared' | 9 | import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared' |
10 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' | ||
11 | import { HttpStatusCode } from '@shared/models' | 11 | import { HttpStatusCode } from '@shared/models' |
12 | import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands' | ||
12 | 13 | ||
13 | const expect = chai.expect | 14 | const expect = chai.expect |
14 | 15 | ||
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index 58167cbab..c4b051723 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | AbusesCommand, | 7 | AbusesCommand, |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | doubleFollow, | 10 | doubleFollow, |
@@ -15,7 +14,6 @@ import { | |||
15 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
16 | waitJobs | 15 | waitJobs |
17 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
18 | import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models' | ||
19 | 17 | ||
20 | describe('Test abuses API validators', function () { | 18 | describe('Test abuses API validators', function () { |
21 | const basePath = '/api/v1/abuses/' | 19 | const basePath = '/api/v1/abuses/' |
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts index fc8e63ed4..07f879e0e 100644 --- a/server/tests/api/check-params/accounts.ts +++ b/server/tests/api/check-params/accounts.ts | |||
@@ -1,15 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | PeerTubeServer | ||
11 | } from '@shared/server-commands' | ||
12 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' | ||
13 | 7 | ||
14 | describe('Test accounts API validators', function () { | 8 | describe('Test accounts API validators', function () { |
15 | const path = '/api/v1/accounts/' | 9 | const path = '/api/v1/accounts/' |
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index 2dc3a166d..36526d494 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createMultipleServers, | 8 | createMultipleServers, |
10 | doubleFollow, | 9 | doubleFollow, |
@@ -14,7 +13,6 @@ import { | |||
14 | PeerTubeServer, | 13 | PeerTubeServer, |
15 | setAccessTokensToServers | 14 | setAccessTokensToServers |
16 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
17 | import { HttpStatusCode } from '@shared/models' | ||
18 | 16 | ||
19 | describe('Test blocklist API validators', function () { | 17 | describe('Test blocklist API validators', function () { |
20 | let servers: PeerTubeServer[] | 18 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts index a2e51e14d..9db442b0b 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/server/tests/api/check-params/contact-form.ts | |||
@@ -1,15 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { MockSmtpServer } from '@server/tests/shared' | ||
4 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 6 | import { cleanupTests, ContactFormCommand, createSingleServer, killallServers, PeerTubeServer } from '@shared/server-commands' |
6 | cleanupTests, | ||
7 | ContactFormCommand, | ||
8 | createSingleServer, | ||
9 | killallServers, | ||
10 | MockSmtpServer, | ||
11 | PeerTubeServer | ||
12 | } from '@shared/server-commands' | ||
13 | 7 | ||
14 | describe('Test contact form API validators', function () { | 8 | describe('Test contact form API validators', function () { |
15 | let server: PeerTubeServer | 9 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index 6121d2202..d4dae5a75 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createSingleServer, | 8 | createSingleServer, |
10 | makeDeleteRequest, | 9 | makeDeleteRequest, |
@@ -13,7 +12,6 @@ import { | |||
13 | PeerTubeServer, | 12 | PeerTubeServer, |
14 | setAccessTokensToServers | 13 | setAccessTokensToServers |
15 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
16 | import { HttpStatusCode } from '@shared/models' | ||
17 | 15 | ||
18 | describe('Test server follows API validators', function () { | 16 | describe('Test server follows API validators', function () { |
19 | let server: PeerTubeServer | 17 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index b7c603755..d85961d62 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts | |||
@@ -1,17 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers | ||
13 | } from '@shared/server-commands' | ||
14 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
15 | 7 | ||
16 | describe('Test jobs API validators', function () { | 8 | describe('Test jobs API validators', function () { |
17 | const path = '/api/v1/jobs/failed' | 9 | const path = '/api/v1/jobs/failed' |
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 8b79d97e0..8aee6164c 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | buildAbsoluteFixturePath, | ||
7 | cleanupTests, | 8 | cleanupTests, |
8 | createSingleServer, | 9 | createSingleServer, |
9 | LiveCommand, | 10 | LiveCommand, |
@@ -14,7 +15,6 @@ import { | |||
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
15 | stopFfmpeg | 16 | stopFfmpeg |
16 | } from '@shared/server-commands' | 17 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
18 | 18 | ||
19 | describe('Test video lives API validator', function () { | 19 | describe('Test video lives API validator', function () { |
20 | const path = '/api/v1/videos/live' | 20 | const path = '/api/v1/videos/live' |
diff --git a/server/tests/api/check-params/my-user.ts b/server/tests/api/check-params/my-user.ts index c8ac71476..95f2122ae 100644 --- a/server/tests/api/check-params/my-user.ts +++ b/server/tests/api/check-params/my-user.ts | |||
@@ -1,22 +1,19 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared' | ||
5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models' | ||
4 | import { | 7 | import { |
5 | buildAbsoluteFixturePath, | ||
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | makeGetRequest, | 10 | makeGetRequest, |
12 | makePutBodyRequest, | 11 | makePutBodyRequest, |
13 | makeUploadRequest, | 12 | makeUploadRequest, |
14 | MockSmtpServer, | ||
15 | PeerTubeServer, | 13 | PeerTubeServer, |
16 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
17 | UsersCommand | 15 | UsersCommand |
18 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models' | ||
20 | 17 | ||
21 | describe('Test my user API validators', function () { | 18 | describe('Test my user API validators', function () { |
22 | const path = '/api/v1/users/' | 19 | const path = '/api/v1/users/' |
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts index 79e487590..c3f15b86e 100644 --- a/server/tests/api/check-params/plugins.ts +++ b/server/tests/api/check-params/plugins.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createSingleServer, | 8 | createSingleServer, |
10 | makeGetRequest, | 9 | makeGetRequest, |
@@ -13,7 +12,6 @@ import { | |||
13 | PeerTubeServer, | 12 | PeerTubeServer, |
14 | setAccessTokensToServers | 13 | setAccessTokensToServers |
15 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models' | ||
17 | 15 | ||
18 | describe('Test server plugins API validators', function () { | 16 | describe('Test server plugins API validators', function () { |
19 | let server: PeerTubeServer | 17 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index f3bfcb16c..04519cf23 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createMultipleServers, | 8 | createMultipleServers, |
10 | doubleFollow, | 9 | doubleFollow, |
@@ -16,7 +15,6 @@ import { | |||
16 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
17 | waitJobs | 16 | waitJobs |
18 | } from '@shared/server-commands' | 17 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
20 | 18 | ||
21 | describe('Test server redundancy API validators', function () { | 19 | describe('Test server redundancy API validators', function () { |
22 | let servers: PeerTubeServer[] | 20 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index edeeed571..ca0fbf31d 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -1,17 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers | ||
13 | } from '@shared/server-commands' | ||
14 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
15 | 7 | ||
16 | function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) { | 8 | function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) { |
17 | return server.config.updateCustomSubConfig({ | 9 | return server.config.updateCustomSubConfig({ |
diff --git a/server/tests/api/check-params/transcoding.ts b/server/tests/api/check-params/transcoding.ts index 11ade9071..333012940 100644 --- a/server/tests/api/check-params/transcoding.ts +++ b/server/tests/api/check-params/transcoding.ts | |||
@@ -1,8 +1,15 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
5 | import { HttpStatusCode, UserRole } from '@shared/models' | 4 | import { HttpStatusCode, UserRole } from '@shared/models' |
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | describe('Test transcoding API validators', function () { | 14 | describe('Test transcoding API validators', function () { |
8 | let servers: PeerTubeServer[] | 15 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index 02898bb87..deb4a7aa3 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -2,18 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { FIXTURE_URLS } from '@server/tests/shared' | ||
5 | import { randomInt } from '@shared/core-utils' | 6 | import { randomInt } from '@shared/core-utils' |
7 | import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models' | ||
6 | import { | 8 | import { |
7 | cleanupTests, | 9 | cleanupTests, |
8 | createSingleServer, | 10 | createSingleServer, |
9 | FIXTURE_URLS, | ||
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
13 | VideosCommand, | 14 | VideosCommand, |
14 | waitJobs | 15 | waitJobs |
15 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models' | ||
17 | 17 | ||
18 | describe('Test upload quota', function () { | 18 | describe('Test upload quota', function () { |
19 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 912d4a992..4bc8084a1 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts | |||
@@ -2,20 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { io } from 'socket.io-client' | 4 | import { io } from 'socket.io-client' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 9 | cleanupTests, |
10 | createSingleServer, | 10 | createSingleServer, |
11 | makeGetRequest, | 11 | makeGetRequest, |
12 | makePostBodyRequest, | 12 | makePostBodyRequest, |
13 | makePutBodyRequest, | 13 | makePutBodyRequest, |
14 | PeerTubeServer, | 14 | PeerTubeServer, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers |
16 | wait | ||
17 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
18 | import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' | ||
19 | 17 | ||
20 | describe('Test user notifications API validators', function () { | 18 | describe('Test user notifications API validators', function () { |
21 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 95226dff5..a13ed5aa3 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -2,9 +2,6 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 5 | cleanupTests, |
9 | createSingleServer, | 6 | createSingleServer, |
10 | makeDeleteRequest, | 7 | makeDeleteRequest, |
@@ -15,6 +12,7 @@ import { | |||
15 | waitJobs | 12 | waitJobs |
16 | } from '@shared/server-commands' | 13 | } from '@shared/server-commands' |
17 | import { HttpStatusCode } from '@shared/models' | 14 | import { HttpStatusCode } from '@shared/models' |
15 | import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@server/tests/shared' | ||
18 | 16 | ||
19 | describe('Test user subscriptions API validators', function () { | 17 | describe('Test user subscriptions API validators', function () { |
20 | const path = '/api/v1/users/me/subscriptions' | 18 | const path = '/api/v1/users/me/subscriptions' |
diff --git a/server/tests/api/check-params/users-admin.ts b/server/tests/api/check-params/users-admin.ts index c98b5e189..d8353f83b 100644 --- a/server/tests/api/check-params/users-admin.ts +++ b/server/tests/api/check-params/users-admin.ts | |||
@@ -2,21 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | killallServers, | 10 | killallServers, |
12 | makeGetRequest, | 11 | makeGetRequest, |
13 | makePostBodyRequest, | 12 | makePostBodyRequest, |
14 | makePutBodyRequest, | 13 | makePutBodyRequest, |
15 | MockSmtpServer, | ||
16 | PeerTubeServer, | 14 | PeerTubeServer, |
17 | setAccessTokensToServers | 15 | setAccessTokensToServers |
18 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models' | ||
20 | 17 | ||
21 | describe('Test users admin API validators', function () { | 18 | describe('Test users admin API validators', function () { |
22 | const path = '/api/v1/users/' | 19 | const path = '/api/v1/users/' |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 254177afd..84254945c 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -2,15 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | makePostBodyRequest, | ||
9 | MockSmtpServer, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers | ||
12 | } from '@shared/server-commands' | ||
13 | import { HttpStatusCode, UserRole } from '@shared/models' | 6 | import { HttpStatusCode, UserRole } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
14 | 8 | ||
15 | describe('Test users API validators', function () { | 9 | describe('Test users API validators', function () { |
16 | const path = '/api/v1/users/' | 10 | const path = '/api/v1/users/' |
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 7eb3c1cae..1aab60826 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -2,11 +2,10 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, VideoBlacklistType } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | BlacklistCommand, | 8 | BlacklistCommand, |
7 | checkBadCountPagination, | ||
8 | checkBadSortPagination, | ||
9 | checkBadStartPagination, | ||
10 | cleanupTests, | 9 | cleanupTests, |
11 | createMultipleServers, | 10 | createMultipleServers, |
12 | doubleFollow, | 11 | doubleFollow, |
@@ -16,7 +15,6 @@ import { | |||
16 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
17 | waitJobs | 16 | waitJobs |
18 | } from '@shared/server-commands' | 17 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, VideoBlacklistType } from '@shared/models' | ||
20 | 18 | ||
21 | describe('Test video blacklist API validators', function () { | 19 | describe('Test video blacklist API validators', function () { |
22 | let servers: PeerTubeServer[] | 20 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 34c1a9673..8a8840793 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
5 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | buildAbsoluteFixturePath, | ||
6 | cleanupTests, | 7 | cleanupTests, |
7 | createSingleServer, | 8 | createSingleServer, |
8 | makeDeleteRequest, | 9 | makeDeleteRequest, |
@@ -11,7 +12,6 @@ import { | |||
11 | PeerTubeServer, | 12 | PeerTubeServer, |
12 | setAccessTokensToServers | 13 | setAccessTokensToServers |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
15 | 15 | ||
16 | describe('Test video captions API validator', function () { | 16 | describe('Test video captions API validator', function () { |
17 | const path = '/api/v1/videos/' | 17 | const path = '/api/v1/videos/' |
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index 747a5d3ec..1e9732fe9 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -3,12 +3,11 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
7 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, VideoChannelUpdate } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | buildAbsoluteFixturePath, | ||
8 | ChannelsCommand, | 10 | ChannelsCommand, |
9 | checkBadCountPagination, | ||
10 | checkBadSortPagination, | ||
11 | checkBadStartPagination, | ||
12 | cleanupTests, | 11 | cleanupTests, |
13 | createSingleServer, | 12 | createSingleServer, |
14 | makeGetRequest, | 13 | makeGetRequest, |
@@ -18,7 +17,6 @@ import { | |||
18 | PeerTubeServer, | 17 | PeerTubeServer, |
19 | setAccessTokensToServers | 18 | setAccessTokensToServers |
20 | } from '@shared/server-commands' | 19 | } from '@shared/server-commands' |
21 | import { HttpStatusCode, VideoChannelUpdate } from '@shared/models' | ||
22 | 20 | ||
23 | const expect = chai.expect | 21 | const expect = chai.expect |
24 | 22 | ||
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 05cf61cba..63c3582e9 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -2,10 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | makeDeleteRequest, | 10 | makeDeleteRequest, |
@@ -14,7 +13,6 @@ import { | |||
14 | PeerTubeServer, | 13 | PeerTubeServer, |
15 | setAccessTokensToServers | 14 | setAccessTokensToServers |
16 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
18 | 16 | ||
19 | const expect = chai.expect | 17 | const expect = chai.expect |
20 | 18 | ||
diff --git a/server/tests/api/check-params/video-files.ts b/server/tests/api/check-params/video-files.ts index 90ab4460c..8c0795092 100644 --- a/server/tests/api/check-params/video-files.ts +++ b/server/tests/api/check-params/video-files.ts | |||
@@ -1,8 +1,15 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
5 | import { HttpStatusCode, UserRole } from '@shared/models' | 4 | import { HttpStatusCode, UserRole } from '@shared/models' |
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | describe('Test videos files', function () { | 14 | describe('Test videos files', function () { |
8 | let servers: PeerTubeServer[] | 15 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 7cefb2a54..ddea68db4 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -2,21 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared' | ||
6 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | buildAbsoluteFixturePath, | ||
7 | checkBadCountPagination, | ||
8 | checkBadSortPagination, | ||
9 | checkBadStartPagination, | ||
10 | cleanupTests, | 9 | cleanupTests, |
11 | createSingleServer, | 10 | createSingleServer, |
12 | FIXTURE_URLS, | ||
13 | makeGetRequest, | 11 | makeGetRequest, |
14 | makePostBodyRequest, | 12 | makePostBodyRequest, |
15 | makeUploadRequest, | 13 | makeUploadRequest, |
16 | PeerTubeServer, | 14 | PeerTubeServer, |
17 | setAccessTokensToServers | 15 | setAccessTokensToServers |
18 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
20 | 17 | ||
21 | describe('Test video imports API validator', function () { | 18 | describe('Test video imports API validator', function () { |
22 | const path = '/api/v1/videos/imports' | 19 | const path = '/api/v1/videos/imports' |
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index ac3c13f78..4b17ce7db 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -1,18 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | PlaylistsCommand, | ||
13 | setAccessTokensToServers, | ||
14 | setDefaultVideoChannel | ||
15 | } from '@shared/server-commands' | ||
16 | import { | 5 | import { |
17 | HttpStatusCode, | 6 | HttpStatusCode, |
18 | VideoPlaylistCreate, | 7 | VideoPlaylistCreate, |
@@ -23,6 +12,15 @@ import { | |||
23 | VideoPlaylistReorder, | 12 | VideoPlaylistReorder, |
24 | VideoPlaylistType | 13 | VideoPlaylistType |
25 | } from '@shared/models' | 14 | } from '@shared/models' |
15 | import { | ||
16 | cleanupTests, | ||
17 | createSingleServer, | ||
18 | makeGetRequest, | ||
19 | PeerTubeServer, | ||
20 | PlaylistsCommand, | ||
21 | setAccessTokensToServers, | ||
22 | setDefaultVideoChannel | ||
23 | } from '@shared/server-commands' | ||
26 | 24 | ||
27 | describe('Test video playlists API validator', function () { | 25 | describe('Test video playlists API validator', function () { |
28 | let server: PeerTubeServer | 26 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index e4b4c4b2a..31a0752c7 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadStartPagination, | ||
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
9 | makeGetRequest, | 9 | makeGetRequest, |
@@ -12,7 +12,6 @@ import { | |||
12 | PeerTubeServer, | 12 | PeerTubeServer, |
13 | setAccessTokensToServers | 13 | setAccessTokensToServers |
14 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
15 | import { HttpStatusCode } from '@shared/models' | ||
16 | 15 | ||
17 | describe('Test videos history API validator', function () { | 16 | describe('Test videos history API validator', function () { |
18 | const myHistoryPath = '/api/v1/users/me/history/videos' | 17 | const myHistoryPath = '/api/v1/users/me/history/videos' |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 3b2607eed..4cc70f5cc 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -4,12 +4,10 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '@shared/core-utils' | 7 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared' |
8 | import { randomInt, root } from '@shared/core-utils' | ||
9 | import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
8 | import { | 10 | import { |
9 | checkBadCountPagination, | ||
10 | checkBadSortPagination, | ||
11 | checkBadStartPagination, | ||
12 | checkUploadVideoParam, | ||
13 | cleanupTests, | 11 | cleanupTests, |
14 | createSingleServer, | 12 | createSingleServer, |
15 | makeDeleteRequest, | 13 | makeDeleteRequest, |
@@ -17,10 +15,8 @@ import { | |||
17 | makePutBodyRequest, | 15 | makePutBodyRequest, |
18 | makeUploadRequest, | 16 | makeUploadRequest, |
19 | PeerTubeServer, | 17 | PeerTubeServer, |
20 | root, | ||
21 | setAccessTokensToServers | 18 | setAccessTokensToServers |
22 | } from '@shared/server-commands' | 19 | } from '@shared/server-commands' |
23 | import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
24 | 20 | ||
25 | const expect = chai.expect | 21 | const expect = chai.expect |
26 | 22 | ||
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 89880c46b..909399836 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -2,9 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { VideoPrivacy } from '@shared/models' | 6 | import { VideoPrivacy } from '@shared/models' |
6 | import { | 7 | import { |
7 | checkLiveCleanupAfterSave, | ||
8 | cleanupTests, | 8 | cleanupTests, |
9 | ConfigCommand, | 9 | ConfigCommand, |
10 | createMultipleServers, | 10 | createMultipleServers, |
@@ -12,9 +12,9 @@ import { | |||
12 | PeerTubeServer, | 12 | PeerTubeServer, |
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
15 | wait, | ||
16 | waitJobs | 15 | waitJobs |
17 | } from '../../../../shared/server-commands' | 16 | } from '@shared/server-commands' |
17 | import { checkLiveCleanupAfterSave } from '../../shared' | ||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 12a4d64d8..c2392603b 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | 6 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' |
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
@@ -12,9 +13,8 @@ import { | |||
12 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
14 | stopFfmpeg, | 15 | stopFfmpeg, |
15 | wait, | ||
16 | waitJobs | 16 | waitJobs |
17 | } from '../../../../shared/server-commands' | 17 | } from '@shared/server-commands' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-rtmps.ts b/server/tests/api/live/live-rtmps.ts index 31e8f906e..935061971 100644 --- a/server/tests/api/live/live-rtmps.ts +++ b/server/tests/api/live/live-rtmps.ts | |||
@@ -2,9 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
5 | import { VideoPrivacy } from '@shared/models' | 6 | import { VideoPrivacy } from '@shared/models' |
6 | import { | 7 | import { |
7 | buildAbsoluteFixturePath, | ||
8 | cleanupTests, | 8 | cleanupTests, |
9 | createSingleServer, | 9 | createSingleServer, |
10 | PeerTubeServer, | 10 | PeerTubeServer, |
@@ -14,7 +14,7 @@ import { | |||
14 | stopFfmpeg, | 14 | stopFfmpeg, |
15 | testFfmpegStreamError, | 15 | testFfmpegStreamError, |
16 | waitUntilLivePublishedOnAllServers | 16 | waitUntilLivePublishedOnAllServers |
17 | } from '../../../../shared/server-commands' | 17 | } from '@shared/server-commands' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 9fb6b4e54..95a342b01 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -3,8 +3,10 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { checkLiveCleanupAfterSave } from '@server/tests/shared' | ||
7 | import { wait } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | checkLiveCleanupAfterSave, | ||
8 | cleanupTests, | 10 | cleanupTests, |
9 | ConfigCommand, | 11 | ConfigCommand, |
10 | createMultipleServers, | 12 | createMultipleServers, |
@@ -14,12 +16,10 @@ import { | |||
14 | setDefaultVideoChannel, | 16 | setDefaultVideoChannel, |
15 | stopFfmpeg, | 17 | stopFfmpeg, |
16 | testFfmpegStreamError, | 18 | testFfmpegStreamError, |
17 | wait, | ||
18 | waitJobs, | 19 | waitJobs, |
19 | waitUntilLivePublishedOnAllServers, | 20 | waitUntilLivePublishedOnAllServers, |
20 | waitUntilLiveSavedOnAllServers | 21 | waitUntilLiveSavedOnAllServers |
21 | } from '@shared/server-commands' | 22 | } from '@shared/server-commands' |
22 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | ||
23 | 23 | ||
24 | const expect = chai.expect | 24 | const expect = chai.expect |
25 | 25 | ||
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts index 42cf9c5f6..50b16443e 100644 --- a/server/tests/api/live/live-socket-messages.ts +++ b/server/tests/api/live/live-socket-messages.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { VideoPrivacy, VideoState } from '@shared/models' | 6 | import { VideoPrivacy, VideoState } from '@shared/models' |
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
@@ -11,10 +12,9 @@ import { | |||
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
13 | stopFfmpeg, | 14 | stopFfmpeg, |
14 | wait, | ||
15 | waitJobs, | 15 | waitJobs, |
16 | waitUntilLivePublishedOnAllServers | 16 | waitUntilLivePublishedOnAllServers |
17 | } from '../../../../shared/server-commands' | 17 | } from '@shared/server-commands' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts index 5de4436be..446d0913c 100644 --- a/server/tests/api/live/live-views.ts +++ b/server/tests/api/live/live-views.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | 7 | import { VideoPrivacy } from '@shared/models' |
7 | import { | 8 | import { |
8 | cleanupTests, | 9 | cleanupTests, |
@@ -12,10 +13,9 @@ import { | |||
12 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
14 | stopFfmpeg, | 15 | stopFfmpeg, |
15 | wait, | ||
16 | waitJobs, | 16 | waitJobs, |
17 | waitUntilLivePublishedOnAllServers | 17 | waitUntilLivePublishedOnAllServers |
18 | } from '../../../../shared/server-commands' | 18 | } from '@shared/server-commands' |
19 | 19 | ||
20 | const expect = chai.expect | 20 | const expect = chai.expect |
21 | 21 | ||
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 3869fd6c7..3f9355d2d 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -4,10 +4,18 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | 6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' |
7 | import { checkLiveCleanupAfterSave, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' | ||
8 | import { wait } from '@shared/core-utils' | ||
9 | import { | ||
10 | HttpStatusCode, | ||
11 | LiveVideo, | ||
12 | LiveVideoCreate, | ||
13 | VideoDetails, | ||
14 | VideoPrivacy, | ||
15 | VideoState, | ||
16 | VideoStreamingPlaylistType | ||
17 | } from '@shared/models' | ||
7 | import { | 18 | import { |
8 | checkLiveCleanupAfterSave, | ||
9 | checkLiveSegmentHash, | ||
10 | checkResolutionsInMasterPlaylist, | ||
11 | cleanupTests, | 19 | cleanupTests, |
12 | createMultipleServers, | 20 | createMultipleServers, |
13 | doubleFollow, | 21 | doubleFollow, |
@@ -20,20 +28,9 @@ import { | |||
20 | setDefaultVideoChannel, | 28 | setDefaultVideoChannel, |
21 | stopFfmpeg, | 29 | stopFfmpeg, |
22 | testFfmpegStreamError, | 30 | testFfmpegStreamError, |
23 | testImage, | ||
24 | wait, | ||
25 | waitJobs, | 31 | waitJobs, |
26 | waitUntilLivePublishedOnAllServers | 32 | waitUntilLivePublishedOnAllServers |
27 | } from '@shared/server-commands' | 33 | } from '@shared/server-commands' |
28 | import { | ||
29 | HttpStatusCode, | ||
30 | LiveVideo, | ||
31 | LiveVideoCreate, | ||
32 | VideoDetails, | ||
33 | VideoPrivacy, | ||
34 | VideoState, | ||
35 | VideoStreamingPlaylistType | ||
36 | } from '@shared/models' | ||
37 | 34 | ||
38 | const expect = chai.expect | 35 | const expect = chai.expect |
39 | 36 | ||
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index d1e2ea56e..87d147998 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -2,8 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
6 | import { UserNotificationType } from '@shared/models' | 5 | import { UserNotificationType } from '@shared/models' |
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts index 4e2887fa0..322e93815 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/server/tests/api/moderation/video-blacklist.ts | |||
@@ -3,18 +3,18 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { orderBy } from 'lodash' | 5 | import { orderBy } from 'lodash' |
6 | import { FIXTURE_URLS } from '@server/tests/shared' | ||
7 | import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' | ||
6 | import { | 8 | import { |
7 | BlacklistCommand, | 9 | BlacklistCommand, |
8 | cleanupTests, | 10 | cleanupTests, |
9 | createMultipleServers, | 11 | createMultipleServers, |
10 | doubleFollow, | 12 | doubleFollow, |
11 | FIXTURE_URLS, | ||
12 | killallServers, | 13 | killallServers, |
13 | PeerTubeServer, | 14 | PeerTubeServer, |
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
15 | waitJobs | 16 | waitJobs |
16 | } from '@shared/server-commands' | 17 | } from '@shared/server-commands' |
17 | import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' | ||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index 18962a71e..f037e7aae 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts | |||
@@ -6,14 +6,13 @@ import { | |||
6 | CheckerBaseParams, | 6 | CheckerBaseParams, |
7 | checkNewPeerTubeVersion, | 7 | checkNewPeerTubeVersion, |
8 | checkNewPluginVersion, | 8 | checkNewPluginVersion, |
9 | cleanupTests, | ||
10 | MockJoinPeerTubeVersions, | 9 | MockJoinPeerTubeVersions, |
11 | MockSmtpServer, | 10 | MockSmtpServer, |
12 | PeerTubeServer, | 11 | prepareNotificationsTest |
13 | prepareNotificationsTest, | 12 | } from '@server/tests/shared' |
14 | wait | 13 | import { wait } from '@shared/core-utils' |
15 | } from '@shared/server-commands' | ||
16 | import { PluginType, UserNotification, UserNotificationType } from '@shared/models' | 14 | import { PluginType, UserNotification, UserNotificationType } from '@shared/models' |
15 | import { cleanupTests, PeerTubeServer } from '@shared/server-commands' | ||
17 | 16 | ||
18 | describe('Test admin notifications', function () { | 17 | describe('Test admin notifications', function () { |
19 | let server: PeerTubeServer | 18 | let server: PeerTubeServer |
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index 919be4bca..b82f1712a 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts | |||
@@ -6,13 +6,11 @@ import { | |||
6 | checkCommentMention, | 6 | checkCommentMention, |
7 | CheckerBaseParams, | 7 | CheckerBaseParams, |
8 | checkNewCommentOnMyVideo, | 8 | checkNewCommentOnMyVideo, |
9 | cleanupTests, | ||
10 | MockSmtpServer, | 9 | MockSmtpServer, |
11 | PeerTubeServer, | 10 | prepareNotificationsTest |
12 | prepareNotificationsTest, | 11 | } from '@server/tests/shared' |
13 | waitJobs | ||
14 | } from '@shared/server-commands' | ||
15 | import { UserNotification } from '@shared/models' | 12 | import { UserNotification } from '@shared/models' |
13 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
16 | 14 | ||
17 | const expect = chai.expect | 15 | const expect = chai.expect |
18 | 16 | ||
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 4da9d2684..e6e1d5f7b 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { buildUUID } from '@shared/core-utils/uuid' | ||
5 | import { | 4 | import { |
6 | checkAbuseStateChange, | 5 | checkAbuseStateChange, |
7 | checkAutoInstanceFollowing, | 6 | checkAutoInstanceFollowing, |
@@ -16,15 +15,13 @@ import { | |||
16 | checkUserRegistered, | 15 | checkUserRegistered, |
17 | checkVideoAutoBlacklistForModerators, | 16 | checkVideoAutoBlacklistForModerators, |
18 | checkVideoIsPublished, | 17 | checkVideoIsPublished, |
19 | cleanupTests, | ||
20 | MockInstancesIndex, | 18 | MockInstancesIndex, |
21 | MockSmtpServer, | 19 | MockSmtpServer, |
22 | PeerTubeServer, | 20 | prepareNotificationsTest |
23 | prepareNotificationsTest, | 21 | } from '@server/tests/shared' |
24 | wait, | 22 | import { buildUUID, wait } from '@shared/core-utils' |
25 | waitJobs | ||
26 | } from '@shared/server-commands' | ||
27 | import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models' | 23 | import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models' |
24 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
28 | 25 | ||
29 | describe('Test moderation notifications', function () { | 26 | describe('Test moderation notifications', function () { |
30 | let servers: PeerTubeServer[] = [] | 27 | let servers: PeerTubeServer[] = [] |
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index aeb73350b..ac08449f8 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts | |||
@@ -5,14 +5,12 @@ import * as chai from 'chai' | |||
5 | import { | 5 | import { |
6 | CheckerBaseParams, | 6 | CheckerBaseParams, |
7 | checkNewVideoFromSubscription, | 7 | checkNewVideoFromSubscription, |
8 | cleanupTests, | ||
9 | getAllNotificationsSettings, | 8 | getAllNotificationsSettings, |
10 | MockSmtpServer, | 9 | MockSmtpServer, |
11 | PeerTubeServer, | 10 | prepareNotificationsTest |
12 | prepareNotificationsTest, | 11 | } from '@server/tests/shared' |
13 | waitJobs | ||
14 | } from '@shared/server-commands' | ||
15 | import { UserNotification, UserNotificationSettingValue } from '@shared/models' | 12 | import { UserNotification, UserNotificationSettingValue } from '@shared/models' |
13 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
16 | 14 | ||
17 | const expect = chai.expect | 15 | const expect = chai.expect |
18 | 16 | ||
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index a2fcdf2ef..bb3024617 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -2,23 +2,20 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildUUID } from '@shared/core-utils/uuid' | ||
6 | import { | 5 | import { |
7 | CheckerBaseParams, | 6 | CheckerBaseParams, |
8 | checkMyVideoImportIsFinished, | 7 | checkMyVideoImportIsFinished, |
9 | checkNewActorFollow, | 8 | checkNewActorFollow, |
10 | checkNewVideoFromSubscription, | 9 | checkNewVideoFromSubscription, |
11 | checkVideoIsPublished, | 10 | checkVideoIsPublished, |
12 | cleanupTests, | ||
13 | FIXTURE_URLS, | 11 | FIXTURE_URLS, |
14 | MockSmtpServer, | 12 | MockSmtpServer, |
15 | PeerTubeServer, | ||
16 | prepareNotificationsTest, | 13 | prepareNotificationsTest, |
17 | uploadRandomVideoOnServers, | 14 | uploadRandomVideoOnServers |
18 | wait, | 15 | } from '@server/tests/shared' |
19 | waitJobs | 16 | import { buildUUID, wait } from '@shared/core-utils' |
20 | } from '@shared/server-commands' | ||
21 | import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' | 17 | import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' |
18 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
22 | 19 | ||
23 | const expect = chai.expect | 20 | const expect = chai.expect |
24 | 21 | ||
diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts index 2c341c139..0cb0a6e34 100644 --- a/server/tests/api/object-storage/live.ts +++ b/server/tests/api/object-storage/live.ts | |||
@@ -3,11 +3,12 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { expectStartWith } from '@server/tests/shared' | ||
7 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | areObjectStorageTestsDisabled, | ||
8 | createMultipleServers, | 10 | createMultipleServers, |
9 | doubleFollow, | 11 | doubleFollow, |
10 | expectStartWith, | ||
11 | killallServers, | 12 | killallServers, |
12 | makeRawRequest, | 13 | makeRawRequest, |
13 | ObjectStorageCommand, | 14 | ObjectStorageCommand, |
@@ -19,7 +20,6 @@ import { | |||
19 | waitUntilLivePublishedOnAllServers, | 20 | waitUntilLivePublishedOnAllServers, |
20 | waitUntilLiveSavedOnAllServers | 21 | waitUntilLiveSavedOnAllServers |
21 | } from '@shared/server-commands' | 22 | } from '@shared/server-commands' |
22 | import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models' | ||
23 | 23 | ||
24 | const expect = chai.expect | 24 | const expect = chai.expect |
25 | 25 | ||
diff --git a/server/tests/api/object-storage/video-imports.ts b/server/tests/api/object-storage/video-imports.ts index adca16e8f..fb81832af 100644 --- a/server/tests/api/object-storage/video-imports.ts +++ b/server/tests/api/object-storage/video-imports.ts | |||
@@ -2,11 +2,11 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared' | ||
6 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | areObjectStorageTestsDisabled, | ||
7 | createSingleServer, | 9 | createSingleServer, |
8 | expectStartWith, | ||
9 | FIXTURE_URLS, | ||
10 | killallServers, | 10 | killallServers, |
11 | makeRawRequest, | 11 | makeRawRequest, |
12 | ObjectStorageCommand, | 12 | ObjectStorageCommand, |
@@ -15,7 +15,6 @@ import { | |||
15 | setDefaultVideoChannel, | 15 | setDefaultVideoChannel, |
16 | waitJobs | 16 | waitJobs |
17 | } from '@shared/server-commands' | 17 | } from '@shared/server-commands' |
18 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
19 | 18 | ||
20 | const expect = chai.expect | 19 | const expect = chai.expect |
21 | 20 | ||
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index bf469015f..498efcb17 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts | |||
@@ -3,25 +3,22 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { merge } from 'lodash' | 5 | import { merge } from 'lodash' |
6 | import { checkTmpIsEmpty, expectLogDoesNotContain, expectStartWith, MockObjectStorage } from '@server/tests/shared' | ||
7 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | areObjectStorageTestsDisabled, | ||
8 | checkTmpIsEmpty, | ||
9 | cleanupTests, | 10 | cleanupTests, |
10 | createMultipleServers, | 11 | createMultipleServers, |
11 | createSingleServer, | 12 | createSingleServer, |
12 | doubleFollow, | 13 | doubleFollow, |
13 | expectLogDoesNotContain, | ||
14 | expectStartWith, | ||
15 | killallServers, | 14 | killallServers, |
16 | makeRawRequest, | 15 | makeRawRequest, |
17 | MockObjectStorage, | ||
18 | ObjectStorageCommand, | 16 | ObjectStorageCommand, |
19 | PeerTubeServer, | 17 | PeerTubeServer, |
20 | setAccessTokensToServers, | 18 | setAccessTokensToServers, |
21 | waitJobs, | 19 | waitJobs, |
22 | webtorrentAdd | 20 | webtorrentAdd |
23 | } from '@shared/server-commands' | 21 | } from '@shared/server-commands' |
24 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
25 | 22 | ||
26 | const expect = chai.expect | 23 | const expect = chai.expect |
27 | 24 | ||
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 1a8d8183b..17c6b25a5 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts | |||
@@ -2,8 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
6 | import { VideoPrivacy } from '@shared/models' | 5 | import { VideoPrivacy } from '@shared/models' |
6 | import { | ||
7 | cleanupTests, | ||
8 | createSingleServer, | ||
9 | killallServers, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | describe('Test redundancy constraints', function () { | 15 | describe('Test redundancy constraints', function () { |
9 | let remoteServer: PeerTubeServer | 16 | let remoteServer: PeerTubeServer |
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 556cfbc31..3f2286278 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -5,29 +5,26 @@ import * as chai from 'chai' | |||
5 | import { readdir } from 'fs-extra' | 5 | import { readdir } from 'fs-extra' |
6 | import magnetUtil from 'magnet-uri' | 6 | import magnetUtil from 'magnet-uri' |
7 | import { basename, join } from 'path' | 7 | import { basename, join } from 'path' |
8 | import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared' | ||
9 | import { root, wait } from '@shared/core-utils' | ||
10 | import { | ||
11 | HttpStatusCode, | ||
12 | VideoDetails, | ||
13 | VideoFile, | ||
14 | VideoPrivacy, | ||
15 | VideoRedundancyStrategy, | ||
16 | VideoRedundancyStrategyWithManual | ||
17 | } from '@shared/models' | ||
8 | import { | 18 | import { |
9 | checkSegmentHash, | ||
10 | checkVideoFilesWereRemoved, | ||
11 | cleanupTests, | 19 | cleanupTests, |
12 | createMultipleServers, | 20 | createMultipleServers, |
13 | doubleFollow, | 21 | doubleFollow, |
14 | killallServers, | 22 | killallServers, |
15 | makeRawRequest, | 23 | makeRawRequest, |
16 | PeerTubeServer, | 24 | PeerTubeServer, |
17 | root, | ||
18 | saveVideoInServers, | ||
19 | setAccessTokensToServers, | 25 | setAccessTokensToServers, |
20 | wait, | ||
21 | waitJobs | 26 | waitJobs |
22 | } from '@shared/server-commands' | 27 | } from '@shared/server-commands' |
23 | import { | ||
24 | HttpStatusCode, | ||
25 | VideoDetails, | ||
26 | VideoFile, | ||
27 | VideoPrivacy, | ||
28 | VideoRedundancyStrategy, | ||
29 | VideoRedundancyStrategyWithManual | ||
30 | } from '@shared/models' | ||
31 | 28 | ||
32 | const expect = chai.expect | 29 | const expect = chai.expect |
33 | 30 | ||
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 1f29f840a..2e0abc6ba 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoChannel } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | PeerTubeServer, | 10 | PeerTubeServer, |
9 | SearchCommand, | 11 | SearchCommand, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { VideoChannel } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 550af8ed2..d9243ac53 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
@@ -9,10 +11,8 @@ import { | |||
9 | SearchCommand, | 11 | SearchCommand, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
12 | wait, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 5aa3738c9..60b95ae4c 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | PeerTubeServer, | 10 | PeerTubeServer, |
9 | SearchCommand, | 11 | SearchCommand, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { VideoPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index bf2375ffa..c544705d3 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -10,10 +10,10 @@ import { | |||
10 | SearchCommand, | 10 | SearchCommand, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 12 | setDefaultVideoChannel, |
13 | stopFfmpeg, | 13 | stopFfmpeg |
14 | wait | ||
15 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
16 | import { VideoPrivacy } from '@shared/models' | 15 | import { VideoPrivacy } from '@shared/models' |
16 | import { wait } from '@shared/core-utils' | ||
17 | 17 | ||
18 | const expect = chai.expect | 18 | const expect = chai.expect |
19 | 19 | ||
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts index 74bb96040..6d2333a6b 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/server/tests/api/server/auto-follows.ts | |||
@@ -2,15 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { MockInstancesIndex } from '@server/tests/shared' |
6 | cleanupTests, | 6 | import { wait } from '@shared/core-utils' |
7 | createMultipleServers, | 7 | import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' |
8 | MockInstancesIndex, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | wait, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
14 | 8 | ||
15 | const expect = chai.expect | 9 | const expect = chai.expect |
16 | 10 | ||
diff --git a/server/tests/api/server/config-defaults.ts b/server/tests/api/server/config-defaults.ts index 4ceda7de3..3ff09bf7e 100644 --- a/server/tests/api/server/config-defaults.ts +++ b/server/tests/api/server/config-defaults.ts | |||
@@ -2,15 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { FIXTURE_URLS } from '@server/tests/shared' |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | FIXTURE_URLS, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | setDefaultVideoChannel | ||
12 | } from '@shared/server-commands' | ||
13 | import { VideoDetails, VideoPrivacy } from '@shared/models' | 6 | import { VideoDetails, VideoPrivacy } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' | ||
14 | 8 | ||
15 | const expect = chai.expect | 9 | const expect = chai.expect |
16 | 10 | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 2e6617a15..2356f701c 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { parallelTests } from '@shared/core-utils' | ||
6 | import { CustomConfig, HttpStatusCode } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | killallServers, | 10 | killallServers, |
9 | makeGetRequest, | 11 | makeGetRequest, |
10 | parallelTests, | ||
11 | PeerTubeServer, | 12 | PeerTubeServer, |
12 | setAccessTokensToServers | 13 | setAccessTokensToServers |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { CustomConfig, HttpStatusCode } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index 109251453..f3facb04a 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts | |||
@@ -2,17 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { MockSmtpServer } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | cleanupTests, | 9 | cleanupTests, |
7 | ContactFormCommand, | 10 | ContactFormCommand, |
8 | createSingleServer, | 11 | createSingleServer, |
9 | MockSmtpServer, | ||
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
12 | wait, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { HttpStatusCode } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 6fa6053cb..20b5e378c 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index e128c36a5..cd34df15d 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -2,19 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { completeVideoCheck, dateIsValid, expectAccountFollows, expectChannelsFollows, testCaptionFile } from '@server/tests/shared' |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | dateIsValid, | ||
9 | expectAccountFollows, | ||
10 | expectChannelsFollows, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers, | ||
13 | testCaptionFile, | ||
14 | waitJobs | ||
15 | } from '@shared/server-commands' | ||
16 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' | 6 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' |
17 | import { completeVideoCheck } from '@server/tests/shared/video' | 7 | import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' |
18 | 8 | ||
19 | const expect = chai.expect | 9 | const expect = chai.expect |
20 | 10 | ||
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index b134e074b..7c3836681 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -2,6 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { completeVideoCheck } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | cleanupTests, | 9 | cleanupTests, |
7 | CommentsCommand, | 10 | CommentsCommand, |
@@ -9,11 +12,8 @@ import { | |||
9 | killallServers, | 12 | killallServers, |
10 | PeerTubeServer, | 13 | PeerTubeServer, |
11 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
12 | wait, | ||
13 | waitJobs | 15 | waitJobs |
14 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
15 | import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
16 | import { completeVideoCheck } from '@server/tests/shared/video' | ||
17 | 17 | ||
18 | const expect = chai.expect | 18 | const expect = chai.expect |
19 | 19 | ||
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts index 5b38f6741..4294e1fd5 100644 --- a/server/tests/api/server/jobs.ts +++ b/server/tests/api/server/jobs.ts | |||
@@ -2,10 +2,10 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { dateIsValid } from '@server/tests/shared' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
8 | dateIsValid, | ||
9 | doubleFollow, | 9 | doubleFollow, |
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts index fbcd89101..e82096c48 100644 --- a/server/tests/api/server/plugins.ts +++ b/server/tests/api/server/plugins.ts | |||
@@ -2,17 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testHelloWorldRegisteredSettings } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, PluginType } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | cleanupTests, | 9 | cleanupTests, |
7 | createSingleServer, | 10 | createSingleServer, |
8 | killallServers, | 11 | killallServers, |
9 | PeerTubeServer, | 12 | PeerTubeServer, |
10 | PluginsCommand, | 13 | PluginsCommand, |
11 | setAccessTokensToServers, | 14 | setAccessTokensToServers |
12 | testHelloWorldRegisteredSettings, | ||
13 | wait | ||
14 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { HttpStatusCode, PluginType } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.ts index 626a0d860..c40a4f9b8 100644 --- a/server/tests/api/server/proxy.ts +++ b/server/tests/api/server/proxy.ts | |||
@@ -2,18 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FIXTURE_URLS, MockProxy } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | FIXTURE_URLS, | ||
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { MockProxy } from '@shared/server-commands/mock-servers/mock-proxy' | ||
16 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
17 | 16 | ||
18 | const expect = chai.expect | 17 | const expect = chai.expect |
19 | 18 | ||
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts index fc9b88a6a..968d98e96 100644 --- a/server/tests/api/server/reverse-proxy.ts +++ b/server/tests/api/server/reverse-proxy.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/server-commands' | 4 | import { wait } from '@shared/core-utils' |
5 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
6 | 7 | ||
7 | describe('Test application behind a reverse proxy', function () { | 8 | describe('Test application behind a reverse proxy', function () { |
8 | let server: PeerTubeServer | 9 | let server: PeerTubeServer |
diff --git a/server/tests/api/server/slow-follows.ts b/server/tests/api/server/slow-follows.ts index 5f24c351b..666a7c2e6 100644 --- a/server/tests/api/server/slow-follows.ts +++ b/server/tests/api/server/slow-follows.ts | |||
@@ -2,8 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
6 | import { Job } from '@shared/models' | 5 | import { Job } from '@shared/models' |
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index 65ef4607b..f0334532b 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { ActivityType, VideoPlaylistPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { ActivityType, VideoPlaylistPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index e6699a059..5b2bbc520 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -6,16 +6,18 @@ import { | |||
6 | checkActorFilesWereRemoved, | 6 | checkActorFilesWereRemoved, |
7 | checkTmpIsEmpty, | 7 | checkTmpIsEmpty, |
8 | checkVideoFilesWereRemoved, | 8 | checkVideoFilesWereRemoved, |
9 | saveVideoInServers, | ||
10 | testImage | ||
11 | } from '@server/tests/shared' | ||
12 | import { MyUser } from '@shared/models' | ||
13 | import { | ||
9 | cleanupTests, | 14 | cleanupTests, |
10 | createMultipleServers, | 15 | createMultipleServers, |
11 | doubleFollow, | 16 | doubleFollow, |
12 | PeerTubeServer, | 17 | PeerTubeServer, |
13 | saveVideoInServers, | ||
14 | setAccessTokensToServers, | 18 | setAccessTokensToServers, |
15 | testImage, | ||
16 | waitJobs | 19 | waitJobs |
17 | } from '@shared/server-commands' | 20 | } from '@shared/server-commands' |
18 | import { MyUser } from '@shared/models' | ||
19 | 21 | ||
20 | const expect = chai.expect | 22 | const expect = chai.expect |
21 | 23 | ||
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index 9b23ba797..0f3cc401a 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index fc44a6acd..ff9172a82 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testImage } from '@server/tests/shared' | ||
6 | import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
@@ -9,10 +11,8 @@ import { | |||
9 | makePutBodyRequest, | 11 | makePutBodyRequest, |
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
12 | testImage, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index 4b27f2fbe..e58360ffe 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts | |||
@@ -3,7 +3,14 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' | 5 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' |
6 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | 6 | import { |
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index cb83fa0f0..9fa03f1a9 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -4,23 +4,24 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import request from 'supertest' | 5 | import request from 'supertest' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | ||
8 | checkTmpIsEmpty, | 7 | checkTmpIsEmpty, |
9 | checkVideoFilesWereRemoved, | 8 | checkVideoFilesWereRemoved, |
9 | completeVideoCheck, | ||
10 | dateIsValid, | ||
11 | saveVideoInServers, | ||
12 | testImage | ||
13 | } from '@server/tests/shared' | ||
14 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' | ||
15 | import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models' | ||
16 | import { | ||
10 | cleanupTests, | 17 | cleanupTests, |
11 | createMultipleServers, | 18 | createMultipleServers, |
12 | dateIsValid, | ||
13 | doubleFollow, | 19 | doubleFollow, |
14 | PeerTubeServer, | 20 | PeerTubeServer, |
15 | saveVideoInServers, | ||
16 | setAccessTokensToServers, | 21 | setAccessTokensToServers, |
17 | testImage, | ||
18 | wait, | ||
19 | waitJobs, | 22 | waitJobs, |
20 | webtorrentAdd | 23 | webtorrentAdd |
21 | } from '@shared/server-commands' | 24 | } from '@shared/server-commands' |
22 | import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models' | ||
23 | import { completeVideoCheck } from '@server/tests/shared/video' | ||
24 | 25 | ||
25 | const expect = chai.expect | 26 | const expect = chai.expect |
26 | 27 | ||
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index 0842817dc..d6f4da630 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts | |||
@@ -4,15 +4,9 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { pathExists, readdir, stat } from 'fs-extra' | 5 | import { pathExists, readdir, stat } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { | 7 | import { buildAbsoluteFixturePath } from '@shared/core-utils' |
8 | buildAbsoluteFixturePath, | ||
9 | cleanupTests, | ||
10 | createSingleServer, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers, | ||
13 | setDefaultVideoChannel | ||
14 | } from '@shared/server-commands' | ||
15 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | 8 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
9 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' | ||
16 | 10 | ||
17 | const expect = chai.expect | 11 | const expect = chai.expect |
18 | 12 | ||
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index e5e12dd19..28bf018c5 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -2,17 +2,10 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { checkVideoFilesWereRemoved, completeVideoCheck, testImage } from '@server/tests/shared' |
6 | checkVideoFilesWereRemoved, | 6 | import { wait } from '@shared/core-utils' |
7 | cleanupTests, | ||
8 | createSingleServer, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | testImage, | ||
12 | wait | ||
13 | } from '@shared/server-commands' | ||
14 | import { Video, VideoPrivacy } from '@shared/models' | 7 | import { Video, VideoPrivacy } from '@shared/models' |
15 | import { completeVideoCheck } from '@server/tests/shared/video' | 8 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
16 | 9 | ||
17 | const expect = chai.expect | 10 | const expect = chai.expect |
18 | 11 | ||
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 9f00312aa..b7f26c35f 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts | |||
@@ -2,15 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { checkVideoFilesWereRemoved, testCaptionFile } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
5 | import { | 7 | import { |
6 | checkVideoFilesWereRemoved, | ||
7 | cleanupTests, | 8 | cleanupTests, |
8 | createMultipleServers, | 9 | createMultipleServers, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | testCaptionFile, | ||
13 | wait, | ||
14 | waitJobs | 13 | waitJobs |
15 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
16 | 15 | ||
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 2ac577a59..d435f3682 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -4,6 +4,9 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename } from 'path' | 5 | import { basename } from 'path' |
6 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' | 6 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' |
7 | import { testFileExistsOrNot, testImage } from '@server/tests/shared' | ||
8 | import { wait } from '@shared/core-utils' | ||
9 | import { User, VideoChannel } from '@shared/models' | ||
7 | import { | 10 | import { |
8 | cleanupTests, | 11 | cleanupTests, |
9 | createMultipleServers, | 12 | createMultipleServers, |
@@ -11,12 +14,8 @@ import { | |||
11 | PeerTubeServer, | 14 | PeerTubeServer, |
12 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 16 | setDefaultVideoChannel, |
14 | testFileExistsOrNot, | ||
15 | testImage, | ||
16 | wait, | ||
17 | waitJobs | 17 | waitJobs |
18 | } from '@shared/server-commands' | 18 | } from '@shared/server-commands' |
19 | import { User, VideoChannel } from '@shared/models' | ||
20 | 19 | ||
21 | const expect = chai.expect | 20 | const expect = chai.expect |
22 | 21 | ||
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index bb4f92a9b..2ae523970 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts | |||
@@ -2,15 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { dateIsValid, testImage } from '@server/tests/shared' |
6 | cleanupTests, | 6 | import { cleanupTests, CommentsCommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
7 | CommentsCommand, | ||
8 | createSingleServer, | ||
9 | dateIsValid, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | testImage | ||
13 | } from '@shared/server-commands' | ||
14 | 7 | ||
15 | const expect = chai.expect | 8 | const expect = chai.expect |
16 | 9 | ||
diff --git a/server/tests/api/videos/video-create-transcoding.ts b/server/tests/api/videos/video-create-transcoding.ts index e81f54714..62a6bab0d 100644 --- a/server/tests/api/videos/video-create-transcoding.ts +++ b/server/tests/api/videos/video-create-transcoding.ts | |||
@@ -2,20 +2,20 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { expectStartWith } from '@server/tests/shared' | ||
6 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | areObjectStorageTestsDisabled, | ||
7 | cleanupTests, | 9 | cleanupTests, |
8 | createMultipleServers, | 10 | createMultipleServers, |
9 | doubleFollow, | 11 | doubleFollow, |
10 | expectNoFailedTranscodingJob, | 12 | expectNoFailedTranscodingJob, |
11 | expectStartWith, | ||
12 | makeRawRequest, | 13 | makeRawRequest, |
13 | ObjectStorageCommand, | 14 | ObjectStorageCommand, |
14 | PeerTubeServer, | 15 | PeerTubeServer, |
15 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
16 | waitJobs | 17 | waitJobs |
17 | } from '@shared/server-commands' | 18 | } from '@shared/server-commands' |
18 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
19 | 19 | ||
20 | const expect = chai.expect | 20 | const expect = chai.expect |
21 | 21 | ||
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts index 23c55f728..20b20488f 100644 --- a/server/tests/api/videos/video-description.ts +++ b/server/tests/api/videos/video-description.ts | |||
@@ -2,7 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | const expect = chai.expect | 14 | const expect = chai.expect |
8 | 15 | ||
diff --git a/server/tests/api/videos/video-files.ts b/server/tests/api/videos/video-files.ts index 0b5121740..b0ef4a2e9 100644 --- a/server/tests/api/videos/video-files.ts +++ b/server/tests/api/videos/video-files.ts | |||
@@ -2,7 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | describe('Test videos files', function () { | 14 | describe('Test videos files', function () { |
8 | let servers: PeerTubeServer[] | 15 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index d050a7a7e..218ec08ae 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -3,18 +3,20 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils' | ||
7 | import { | 6 | import { |
8 | areObjectStorageTestsDisabled, | ||
9 | checkDirectoryIsEmpty, | 7 | checkDirectoryIsEmpty, |
10 | checkResolutionsInMasterPlaylist, | 8 | checkResolutionsInMasterPlaylist, |
11 | checkSegmentHash, | 9 | checkSegmentHash, |
12 | checkTmpIsEmpty, | 10 | checkTmpIsEmpty, |
11 | expectStartWith, | ||
12 | hlsInfohashExist | ||
13 | } from '@server/tests/shared' | ||
14 | import { areObjectStorageTestsDisabled, removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils' | ||
15 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' | ||
16 | import { | ||
13 | cleanupTests, | 17 | cleanupTests, |
14 | createMultipleServers, | 18 | createMultipleServers, |
15 | doubleFollow, | 19 | doubleFollow, |
16 | expectStartWith, | ||
17 | hlsInfohashExist, | ||
18 | makeRawRequest, | 20 | makeRawRequest, |
19 | ObjectStorageCommand, | 21 | ObjectStorageCommand, |
20 | PeerTubeServer, | 22 | PeerTubeServer, |
@@ -22,7 +24,6 @@ import { | |||
22 | waitJobs, | 24 | waitJobs, |
23 | webtorrentAdd | 25 | webtorrentAdd |
24 | } from '@shared/server-commands' | 26 | } from '@shared/server-commands' |
25 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' | ||
26 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | 27 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' |
27 | 28 | ||
28 | const expect = chai.expect | 29 | const expect = chai.expect |
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 2518743f7..e8e0f01f1 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -4,21 +4,19 @@ import 'mocha' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists, readdir, remove } from 'fs-extra' | 5 | import { pathExists, readdir, remove } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared' | ||
8 | import { areHttpImportTestsDisabled } from '@shared/core-utils' | ||
9 | import { VideoPrivacy, VideoResolution } from '@shared/models' | ||
7 | import { | 10 | import { |
8 | areHttpImportTestsDisabled, | ||
9 | cleanupTests, | 11 | cleanupTests, |
10 | createMultipleServers, | 12 | createMultipleServers, |
11 | createSingleServer, | 13 | createSingleServer, |
12 | doubleFollow, | 14 | doubleFollow, |
13 | FIXTURE_URLS, | ||
14 | PeerTubeServer, | 15 | PeerTubeServer, |
15 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
16 | setDefaultVideoChannel, | 17 | setDefaultVideoChannel, |
17 | testCaptionFile, | ||
18 | testImage, | ||
19 | waitJobs | 18 | waitJobs |
20 | } from '@shared/server-commands' | 19 | } from '@shared/server-commands' |
21 | import { VideoPrivacy, VideoResolution } from '@shared/models' | ||
22 | 20 | ||
23 | async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { | 21 | async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { |
24 | const videoHttp = await server.videos.get({ id: idHttp }) | 22 | const videoHttp = await server.videos.get({ id: idHttp }) |
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts index e6b6c34eb..5fdb0fc03 100644 --- a/server/tests/api/videos/video-playlist-thumbnails.ts +++ b/server/tests/api/videos/video-playlist-thumbnails.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testImage } from '@server/tests/shared' | ||
6 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
@@ -9,10 +11,8 @@ import { | |||
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
12 | testImage, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '../../../../shared/server-commands' | 15 | } from '@shared/server-commands' |
15 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 6279f5cd0..34327334f 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -2,8 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { checkPlaylistFilesWereRemoved, testImage } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { | ||
8 | HttpStatusCode, | ||
9 | VideoPlaylist, | ||
10 | VideoPlaylistCreateResult, | ||
11 | VideoPlaylistElementType, | ||
12 | VideoPlaylistPrivacy, | ||
13 | VideoPlaylistType, | ||
14 | VideoPrivacy | ||
15 | } from '@shared/models' | ||
5 | import { | 16 | import { |
6 | checkPlaylistFilesWereRemoved, | ||
7 | cleanupTests, | 17 | cleanupTests, |
8 | createMultipleServers, | 18 | createMultipleServers, |
9 | doubleFollow, | 19 | doubleFollow, |
@@ -11,19 +21,8 @@ import { | |||
11 | PlaylistsCommand, | 21 | PlaylistsCommand, |
12 | setAccessTokensToServers, | 22 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 23 | setDefaultVideoChannel, |
14 | testImage, | ||
15 | wait, | ||
16 | waitJobs | 24 | waitJobs |
17 | } from '@shared/server-commands' | 25 | } from '@shared/server-commands' |
18 | import { | ||
19 | HttpStatusCode, | ||
20 | VideoPlaylist, | ||
21 | VideoPlaylistCreateResult, | ||
22 | VideoPlaylistElementType, | ||
23 | VideoPlaylistPrivacy, | ||
24 | VideoPlaylistType, | ||
25 | VideoPrivacy | ||
26 | } from '@shared/models' | ||
27 | 26 | ||
28 | const expect = chai.expect | 27 | const expect = chai.expect |
29 | 28 | ||
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index 13eb941ea..3051a443d 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -2,16 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { wait } from '@shared/core-utils' |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | wait, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
14 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | 6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
15 | 8 | ||
16 | const expect = chai.expect | 9 | const expect = chai.expect |
17 | 10 | ||
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index 9408574ad..00b4f6cbc 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { VideoPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index f4b0bc53a..d24a8f4e1 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -3,29 +3,21 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' | 6 | import { canDoQuickTranscode } from '@server/helpers/ffprobe-utils' |
7 | import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared' | ||
8 | import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' | ||
9 | import { getAudioStream, getMetadataFromFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils' | ||
10 | import { HttpStatusCode, VideoState } from '@shared/models' | ||
7 | import { | 11 | import { |
8 | buildAbsoluteFixturePath, | ||
9 | cleanupTests, | 12 | cleanupTests, |
10 | createMultipleServers, | 13 | createMultipleServers, |
11 | doubleFollow, | 14 | doubleFollow, |
12 | generateHighBitrateVideo, | ||
13 | generateVideoWithFramerate, | ||
14 | makeGetRequest, | 15 | makeGetRequest, |
15 | PeerTubeServer, | 16 | PeerTubeServer, |
16 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
17 | waitJobs, | 18 | waitJobs, |
18 | webtorrentAdd | 19 | webtorrentAdd |
19 | } from '@shared/server-commands' | 20 | } from '@shared/server-commands' |
20 | import { HttpStatusCode, VideoState } from '@shared/models' | ||
21 | import { | ||
22 | canDoQuickTranscode, | ||
23 | getAudioStream, | ||
24 | getMetadataFromFile, | ||
25 | getVideoFileBitrate, | ||
26 | getVideoFileFPS, | ||
27 | getVideoFileResolution | ||
28 | } from '../../../helpers/ffprobe-utils' | ||
29 | 21 | ||
30 | const expect = chai.expect | 22 | const expect = chai.expect |
31 | 23 | ||
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index 813fc4f45..4e5ba13aa 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, Video } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | HistoryCommand, | 10 | HistoryCommand, |
9 | killallServers, | 11 | killallServers, |
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
12 | wait | ||
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { HttpStatusCode, Video } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 08a4efb63..61fc0cb20 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/server-commands' | 5 | import { wait } from '@shared/core-utils' |
6 | import { VideosOverview } from '@shared/models' | 6 | import { VideosOverview } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index 7f7597af4..e6815a4a8 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
@@ -9,9 +10,8 @@ import { | |||
9 | killallServers, | 10 | killallServers, |
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | wait, | ||
13 | waitJobs | 13 | waitJobs |
14 | } from '../../../../shared/server-commands' | 14 | } from '@shared/server-commands' |
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 5973272e5..8ef0545d0 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts | |||
@@ -2,19 +2,19 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | areObjectStorageTestsDisabled, | ||
7 | cleanupTests, | 8 | cleanupTests, |
8 | createMultipleServers, | 9 | createMultipleServers, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | expectStartWith, | ||
11 | makeRawRequest, | 11 | makeRawRequest, |
12 | ObjectStorageCommand, | 12 | ObjectStorageCommand, |
13 | PeerTubeServer, | 13 | PeerTubeServer, |
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | waitJobs | 15 | waitJobs |
16 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models' | 17 | import { expectStartWith } from '../shared' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/cli/create-move-video-storage-job.ts b/server/tests/cli/create-move-video-storage-job.ts index 8b66f24bf..c674d28d2 100644 --- a/server/tests/cli/create-move-video-storage-job.ts +++ b/server/tests/cli/create-move-video-storage-job.ts | |||
@@ -1,20 +1,19 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | |
5 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | areObjectStorageTestsDisabled, | ||
7 | cleanupTests, | 7 | cleanupTests, |
8 | createMultipleServers, | 8 | createMultipleServers, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | expectStartWith, | ||
11 | makeRawRequest, | 10 | makeRawRequest, |
12 | ObjectStorageCommand, | 11 | ObjectStorageCommand, |
13 | PeerTubeServer, | 12 | PeerTubeServer, |
14 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
15 | waitJobs | 14 | waitJobs |
16 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoDetails } from '@shared/models' | 16 | import { expectStartWith } from '../shared' |
18 | 17 | ||
19 | async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) { | 18 | async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) { |
20 | for (const file of video.files) { | 19 | for (const file of video.files) { |
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index ea3428662..c85130fef 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts | |||
@@ -2,19 +2,19 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
5 | import { HttpStatusCode, VideoFile } from '@shared/models' | 6 | import { HttpStatusCode, VideoFile } from '@shared/models' |
6 | import { | 7 | import { |
7 | areObjectStorageTestsDisabled, | ||
8 | cleanupTests, | 8 | cleanupTests, |
9 | createMultipleServers, | 9 | createMultipleServers, |
10 | doubleFollow, | 10 | doubleFollow, |
11 | expectStartWith, | ||
12 | makeRawRequest, | 11 | makeRawRequest, |
13 | ObjectStorageCommand, | 12 | ObjectStorageCommand, |
14 | PeerTubeServer, | 13 | PeerTubeServer, |
15 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
16 | waitJobs | 15 | waitJobs |
17 | } from '../../../shared/server-commands' | 16 | } from '@shared/server-commands' |
17 | import { expectStartWith } from '../shared' | ||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 72213473b..034d216e3 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts | |||
@@ -2,19 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { areHttpImportTestsDisabled, buildAbsoluteFixturePath } from '@shared/core-utils' | ||
5 | import { | 6 | import { |
6 | areHttpImportTestsDisabled, | ||
7 | buildAbsoluteFixturePath, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | CLICommand, | 8 | CLICommand, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | doubleFollow, | 10 | doubleFollow, |
12 | FIXTURE_URLS, | ||
13 | PeerTubeServer, | 11 | PeerTubeServer, |
14 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
15 | testHelloWorldRegisteredSettings, | ||
16 | waitJobs | 13 | waitJobs |
17 | } from '../../../shared/server-commands' | 14 | } from '@shared/server-commands' |
15 | import { FIXTURE_URLS, testHelloWorldRegisteredSettings } from '../shared' | ||
18 | 16 | ||
19 | describe('Test CLI wrapper', function () { | 17 | describe('Test CLI wrapper', function () { |
20 | let server: PeerTubeServer | 18 | let server: PeerTubeServer |
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index d9cf9465c..cd9f4e1c3 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | PluginsCommand, | 10 | PluginsCommand, |
11 | setAccessTokensToServers | 11 | setAccessTokensToServers |
12 | } from '../../../shared/server-commands' | 12 | } from '@shared/server-commands' |
13 | 13 | ||
14 | describe('Test plugin scripts', function () { | 14 | describe('Test plugin scripts', function () { |
15 | let server: PeerTubeServer | 15 | let server: PeerTubeServer |
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts index 36c43c6df..27896f031 100644 --- a/server/tests/cli/print-transcode-command.ts +++ b/server/tests/cli/print-transcode-command.ts | |||
@@ -2,7 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildAbsoluteFixturePath, CLICommand } from '@shared/server-commands' | 5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' |
6 | import { CLICommand } from '@shared/server-commands' | ||
6 | import { VideoResolution } from '../../../shared/models/videos' | 7 | import { VideoResolution } from '../../../shared/models/videos' |
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index e0bc6a589..8e8fc7e20 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts | |||
@@ -4,7 +4,8 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { createFile, readdir } from 'fs-extra' | 5 | import { createFile, readdir } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { buildUUID } from '@shared/core-utils/uuid' | 7 | import { buildUUID, wait } from '@shared/core-utils' |
8 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | ||
8 | import { | 9 | import { |
9 | cleanupTests, | 10 | cleanupTests, |
10 | CLICommand, | 11 | CLICommand, |
@@ -15,10 +16,8 @@ import { | |||
15 | PeerTubeServer, | 16 | PeerTubeServer, |
16 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
17 | setDefaultVideoChannel, | 18 | setDefaultVideoChannel, |
18 | wait, | ||
19 | waitJobs | 19 | waitJobs |
20 | } from '@shared/server-commands' | 20 | } from '@shared/server-commands' |
21 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | ||
22 | 21 | ||
23 | const expect = chai.expect | 22 | const expect = chai.expect |
24 | 23 | ||
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index 34dedb113..018e9d788 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import 'mocha' | 1 | import 'mocha' |
2 | import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '../../../shared/server-commands' | 2 | import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
3 | 3 | ||
4 | describe('Test reset password scripts', function () { | 4 | describe('Test reset password scripts', function () { |
5 | let server: PeerTubeServer | 5 | let server: PeerTubeServer |
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts index 2f75ad25b..bc5c93621 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts | |||
@@ -2,17 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { Video } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | killallServers, | 11 | killallServers, |
10 | MockBlocklist, | ||
11 | PeerTubeServer, | 12 | PeerTubeServer, |
12 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
13 | wait | ||
14 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
15 | import { Video } from '@shared/models' | 15 | import { MockBlocklist } from '../shared' |
16 | 16 | ||
17 | async function check (server: PeerTubeServer, videoUUID: string, exists = true) { | 17 | async function check (server: PeerTubeServer, videoUUID: string, exists = true) { |
18 | const { data } = await server.videos.list() | 18 | const { data } = await server.videos.list() |
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index bfa67e7ad..375ccf91a 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts | |||
@@ -2,18 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { HttpStatusCode } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | killallServers, | 11 | killallServers, |
10 | makeGetRequest, | 12 | makeGetRequest, |
11 | MockBlocklist, | ||
12 | PeerTubeServer, | 13 | PeerTubeServer, |
13 | setAccessTokensToServers, | 14 | setAccessTokensToServers |
14 | wait | ||
15 | } from '@shared/server-commands' | 15 | } from '@shared/server-commands' |
16 | import { HttpStatusCode } from '@shared/models' | 16 | import { MockBlocklist } from '../shared' |
17 | 17 | ||
18 | describe('Official plugin auto-mute', function () { | 18 | describe('Official plugin auto-mute', function () { |
19 | const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' | 19 | const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' |
diff --git a/server/tests/helpers/image.ts b/server/tests/helpers/image.ts index 330139ee4..64bd373cc 100644 --- a/server/tests/helpers/image.ts +++ b/server/tests/helpers/image.ts | |||
@@ -4,8 +4,8 @@ import 'mocha' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { readFile, remove } from 'fs-extra' | 5 | import { readFile, remove } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { buildAbsoluteFixturePath, root } from '@shared/core-utils' | ||
7 | import { processImage } from '../../../server/helpers/image-utils' | 8 | import { processImage } from '../../../server/helpers/image-utils' |
8 | import { buildAbsoluteFixturePath, root } from '../../../shared/server-commands' | ||
9 | 9 | ||
10 | async function checkBuffers (path1: string, path2: string, equals: boolean) { | 10 | async function checkBuffers (path1: string, path2: string, equals: boolean) { |
11 | const [ buf1, buf2 ] = await Promise.all([ | 11 | const [ buf1, buf2 ] = await Promise.all([ |
diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts index db0cca390..de507ba35 100644 --- a/server/tests/helpers/request.ts +++ b/server/tests/helpers/request.ts | |||
@@ -4,9 +4,9 @@ import 'mocha' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists, remove } from 'fs-extra' | 5 | import { pathExists, remove } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { Mock429 } from '@shared/server-commands/mock-servers/mock-429' | 7 | import { root, wait } from '@shared/core-utils' |
8 | import { FIXTURE_URLS, root, wait } from '../../../shared/server-commands' | ||
9 | import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' | 8 | import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' |
9 | import { FIXTURE_URLS, Mock429 } from '../shared' | ||
10 | 10 | ||
11 | describe('Request helpers', function () { | 11 | describe('Request helpers', function () { |
12 | const destPath1 = join(root(), 'test-output-1.txt') | 12 | const destPath1 = join(root(), 'test-output-1.txt') |
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index a4a3764f5..583100671 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, UserRole } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | decodeQueryString, | 10 | decodeQueryString, |
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | PluginsCommand, | 12 | PluginsCommand, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
12 | wait | ||
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { HttpStatusCode, UserRole } from '@shared/models' | ||
15 | 15 | ||
16 | async function loginExternal (options: { | 16 | async function loginExternal (options: { |
17 | server: PeerTubeServer | 17 | server: PeerTubeServer |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index a84edfac6..52ba396e5 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -2,11 +2,11 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
8 | doubleFollow, | 9 | doubleFollow, |
9 | FIXTURE_URLS, | ||
10 | makeRawRequest, | 10 | makeRawRequest, |
11 | PeerTubeServer, | 11 | PeerTubeServer, |
12 | PluginsCommand, | 12 | PluginsCommand, |
@@ -14,7 +14,7 @@ import { | |||
14 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
15 | waitJobs | 15 | waitJobs |
16 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 17 | import { FIXTURE_URLS } from '../shared' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 9e10d3302..0a3a9c25f 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | PluginsCommand, | 10 | PluginsCommand, |
11 | setAccessTokensToServers | 11 | setAccessTokensToServers |
12 | } from '../../../shared/server-commands' | 12 | } from '@shared/server-commands' |
13 | 13 | ||
14 | const expect = chai.expect | 14 | const expect = chai.expect |
15 | 15 | ||
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index ea3b0f6ab..e72046ce2 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers, wait } from '@shared/server-commands' | 5 | import { wait } from '@shared/core-utils' |
6 | import { HttpStatusCode, UserRole } from '@shared/models' | 6 | import { HttpStatusCode, UserRole } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands' | ||
7 | 8 | ||
8 | describe('Test id and pass auth plugins', function () { | 9 | describe('Test id and pass auth plugins', function () { |
9 | let server: PeerTubeServer | 10 | let server: PeerTubeServer |
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 4ab4acd58..167429ef4 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts | |||
@@ -3,8 +3,8 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists } from 'fs-extra' | 5 | import { pathExists } from 'fs-extra' |
6 | import { HttpStatusCode, ThumbnailType } from '@shared/models' | ||
6 | import { | 7 | import { |
7 | checkVideoFilesWereRemoved, | ||
8 | cleanupTests, | 8 | cleanupTests, |
9 | createMultipleServers, | 9 | createMultipleServers, |
10 | doubleFollow, | 10 | doubleFollow, |
@@ -16,7 +16,7 @@ import { | |||
16 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
17 | waitJobs | 17 | waitJobs |
18 | } from '@shared/server-commands' | 18 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, ThumbnailType } from '@shared/models' | 19 | import { checkVideoFilesWereRemoved } from '../shared' |
20 | 20 | ||
21 | function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { | 21 | function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { |
22 | const body = { command } | 22 | const body = { command } |
diff --git a/shared/server-commands/users/actors.ts b/server/tests/shared/actors.ts index 12c3e078a..f8f4a5137 100644 --- a/shared/server-commands/users/actors.ts +++ b/server/tests/shared/actors.ts | |||
@@ -5,7 +5,7 @@ import { pathExists, readdir } from 'fs-extra' | |||
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { root } from '@shared/core-utils' | 6 | import { root } from '@shared/core-utils' |
7 | import { Account, VideoChannel } from '@shared/models' | 7 | import { Account, VideoChannel } from '@shared/models' |
8 | import { PeerTubeServer } from '../server' | 8 | import { PeerTubeServer } from '@shared/server-commands' |
9 | 9 | ||
10 | async function expectChannelsFollows (options: { | 10 | async function expectChannelsFollows (options: { |
11 | server: PeerTubeServer | 11 | server: PeerTubeServer |
diff --git a/shared/server-commands/videos/captions.ts b/server/tests/shared/captions.ts index 35e722408..35e722408 100644 --- a/shared/server-commands/videos/captions.ts +++ b/server/tests/shared/captions.ts | |||
diff --git a/shared/server-commands/miscs/checks.ts b/server/tests/shared/checks.ts index 589928997..9ecc84b5d 100644 --- a/shared/server-commands/miscs/checks.ts +++ b/server/tests/shared/checks.ts | |||
@@ -5,8 +5,7 @@ import { pathExists, readFile } from 'fs-extra' | |||
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { root } from '@shared/core-utils' | 6 | import { root } from '@shared/core-utils' |
7 | import { HttpStatusCode } from '@shared/models' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { makeGetRequest } from '../requests' | 8 | import { makeGetRequest, PeerTubeServer } from '@shared/server-commands' |
9 | import { PeerTubeServer } from '../server' | ||
10 | 9 | ||
11 | // Default interval -> 5 minutes | 10 | // Default interval -> 5 minutes |
12 | function dateIsValid (dateString: string, interval = 300000) { | 11 | function dateIsValid (dateString: string, interval = 300000) { |
@@ -49,10 +48,51 @@ async function testFileExistsOrNot (server: PeerTubeServer, directory: string, f | |||
49 | expect(await pathExists(join(base, filePath))).to.equal(exist) | 48 | expect(await pathExists(join(base, filePath))).to.equal(exist) |
50 | } | 49 | } |
51 | 50 | ||
51 | function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { | ||
52 | return makeGetRequest({ | ||
53 | url, | ||
54 | path, | ||
55 | token, | ||
56 | query: { ...query, start: 'hello' }, | ||
57 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
58 | }) | ||
59 | } | ||
60 | |||
61 | async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) { | ||
62 | await makeGetRequest({ | ||
63 | url, | ||
64 | path, | ||
65 | token, | ||
66 | query: { ...query, count: 'hello' }, | ||
67 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
68 | }) | ||
69 | |||
70 | await makeGetRequest({ | ||
71 | url, | ||
72 | path, | ||
73 | token, | ||
74 | query: { ...query, count: 2000 }, | ||
75 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
76 | }) | ||
77 | } | ||
78 | |||
79 | function checkBadSortPagination (url: string, path: string, token?: string, query = {}) { | ||
80 | return makeGetRequest({ | ||
81 | url, | ||
82 | path, | ||
83 | token, | ||
84 | query: { ...query, sort: 'hello' }, | ||
85 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
86 | }) | ||
87 | } | ||
88 | |||
52 | export { | 89 | export { |
53 | dateIsValid, | 90 | dateIsValid, |
54 | testImage, | 91 | testImage, |
55 | expectLogDoesNotContain, | 92 | expectLogDoesNotContain, |
56 | testFileExistsOrNot, | 93 | testFileExistsOrNot, |
57 | expectStartWith | 94 | expectStartWith, |
95 | checkBadStartPagination, | ||
96 | checkBadCountPagination, | ||
97 | checkBadSortPagination | ||
58 | } | 98 | } |
diff --git a/shared/server-commands/server/directories.ts b/server/tests/shared/directories.ts index e6f72d6fc..c7065a767 100644 --- a/shared/server-commands/server/directories.ts +++ b/server/tests/shared/directories.ts | |||
@@ -4,7 +4,7 @@ import { expect } from 'chai' | |||
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { root } from '@shared/core-utils' | 6 | import { root } from '@shared/core-utils' |
7 | import { PeerTubeServer } from './server' | 7 | import { PeerTubeServer } from '@shared/server-commands' |
8 | 8 | ||
9 | async function checkTmpIsEmpty (server: PeerTubeServer) { | 9 | async function checkTmpIsEmpty (server: PeerTubeServer) { |
10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) | 10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) |
diff --git a/shared/server-commands/miscs/generate.ts b/server/tests/shared/generate.ts index 93673a063..f806df2f5 100644 --- a/shared/server-commands/miscs/generate.ts +++ b/server/tests/shared/generate.ts | |||
@@ -2,9 +2,8 @@ import { expect } from 'chai' | |||
2 | import ffmpeg from 'fluent-ffmpeg' | 2 | import ffmpeg from 'fluent-ffmpeg' |
3 | import { ensureDir, pathExists } from 'fs-extra' | 3 | import { ensureDir, pathExists } from 'fs-extra' |
4 | import { dirname } from 'path' | 4 | import { dirname } from 'path' |
5 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils/ffprobe' | 5 | import { buildAbsoluteFixturePath, getMaxBitrate } from '@shared/core-utils' |
6 | import { getMaxBitrate } from '@shared/core-utils' | 6 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils' |
7 | import { buildAbsoluteFixturePath } from './tests' | ||
8 | 7 | ||
9 | async function ensureHasTooBigBitrate (fixturePath: string) { | 8 | async function ensureHasTooBigBitrate (fixturePath: string) { |
10 | const bitrate = await getVideoFileBitrate(fixturePath) | 9 | const bitrate = await getVideoFileBitrate(fixturePath) |
diff --git a/server/tests/shared/index.ts b/server/tests/shared/index.ts index 938817268..47019d6a8 100644 --- a/server/tests/shared/index.ts +++ b/server/tests/shared/index.ts | |||
@@ -1,2 +1,15 @@ | |||
1 | export * from './mock-servers' | ||
2 | export * from './actors' | ||
3 | export * from './captions' | ||
4 | export * from './checks' | ||
5 | export * from './directories' | ||
6 | export * from './generate' | ||
7 | export * from './live' | ||
8 | export * from './notifications' | ||
9 | export * from './playlists' | ||
10 | export * from './plugins' | ||
1 | export * from './requests' | 11 | export * from './requests' |
2 | export * from './video' | 12 | export * from './streaming-playlists' |
13 | export * from './tests' | ||
14 | export * from './tracker' | ||
15 | export * from './videos' | ||
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts new file mode 100644 index 000000000..72e3e27f6 --- /dev/null +++ b/server/tests/shared/live.ts | |||
@@ -0,0 +1,41 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { pathExists, readdir } from 'fs-extra' | ||
5 | import { join } from 'path' | ||
6 | import { PeerTubeServer } from '@shared/server-commands' | ||
7 | |||
8 | async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) { | ||
9 | const basePath = server.servers.buildDirectory('streaming-playlists') | ||
10 | const hlsPath = join(basePath, 'hls', videoUUID) | ||
11 | |||
12 | if (resolutions.length === 0) { | ||
13 | const result = await pathExists(hlsPath) | ||
14 | expect(result).to.be.false | ||
15 | |||
16 | return | ||
17 | } | ||
18 | |||
19 | const files = await readdir(hlsPath) | ||
20 | |||
21 | // fragmented file and playlist per resolution + master playlist + segments sha256 json file | ||
22 | expect(files).to.have.lengthOf(resolutions.length * 2 + 2) | ||
23 | |||
24 | for (const resolution of resolutions) { | ||
25 | const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`)) | ||
26 | expect(fragmentedFile).to.exist | ||
27 | |||
28 | const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`)) | ||
29 | expect(playlistFile).to.exist | ||
30 | } | ||
31 | |||
32 | const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8')) | ||
33 | expect(masterPlaylistFile).to.exist | ||
34 | |||
35 | const shaFile = files.find(f => f.endsWith('-segments-sha256.json')) | ||
36 | expect(shaFile).to.exist | ||
37 | } | ||
38 | |||
39 | export { | ||
40 | checkLiveCleanupAfterSave | ||
41 | } | ||
diff --git a/shared/server-commands/mock-servers/index.ts b/server/tests/shared/mock-servers/index.ts index 93c00c788..abf4a8203 100644 --- a/shared/server-commands/mock-servers/index.ts +++ b/server/tests/shared/mock-servers/index.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | export * from './mock-429' | ||
1 | export * from './mock-email' | 2 | export * from './mock-email' |
2 | export * from './mock-instances-index' | 3 | export * from './mock-instances-index' |
3 | export * from './mock-joinpeertube-versions' | 4 | export * from './mock-joinpeertube-versions' |
4 | export * from './mock-plugin-blocklist' | ||
5 | export * from './mock-object-storage' | 5 | export * from './mock-object-storage' |
6 | export * from './mock-plugin-blocklist' | ||
7 | export * from './mock-proxy' | ||
diff --git a/shared/server-commands/mock-servers/mock-429.ts b/server/tests/shared/mock-servers/mock-429.ts index 9e0d1281a..1fc20b079 100644 --- a/shared/server-commands/mock-servers/mock-429.ts +++ b/server/tests/shared/mock-servers/mock-429.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { Server } from 'http' | 2 | import { Server } from 'http' |
3 | import { getPort, randomListen, terminateServer } from './utils' | 3 | import { getPort, randomListen, terminateServer } from './shared' |
4 | 4 | ||
5 | export class Mock429 { | 5 | export class Mock429 { |
6 | private server: Server | 6 | private server: Server |
diff --git a/shared/server-commands/mock-servers/mock-email.ts b/server/tests/shared/mock-servers/mock-email.ts index f646c1621..c518679c9 100644 --- a/shared/server-commands/mock-servers/mock-email.ts +++ b/server/tests/shared/mock-servers/mock-email.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { ChildProcess } from 'child_process' | 1 | import { ChildProcess } from 'child_process' |
2 | import MailDev from '@peertube/maildev' | 2 | import MailDev from '@peertube/maildev' |
3 | import { randomInt } from '@shared/core-utils' | 3 | import { parallelTests, randomInt } from '@shared/core-utils' |
4 | import { parallelTests } from '../miscs' | ||
5 | 4 | ||
6 | class MockSmtpServer { | 5 | class MockSmtpServer { |
7 | 6 | ||
diff --git a/shared/server-commands/mock-servers/mock-instances-index.ts b/server/tests/shared/mock-servers/mock-instances-index.ts index 92b12d6f3..598b007f1 100644 --- a/shared/server-commands/mock-servers/mock-instances-index.ts +++ b/server/tests/shared/mock-servers/mock-instances-index.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { Server } from 'http' | 2 | import { Server } from 'http' |
3 | import { getPort, randomListen, terminateServer } from './utils' | 3 | import { getPort, randomListen, terminateServer } from './shared' |
4 | 4 | ||
5 | export class MockInstancesIndex { | 5 | export class MockInstancesIndex { |
6 | private server: Server | 6 | private server: Server |
diff --git a/shared/server-commands/mock-servers/mock-joinpeertube-versions.ts b/server/tests/shared/mock-servers/mock-joinpeertube-versions.ts index e7906ea56..502f4e2f5 100644 --- a/shared/server-commands/mock-servers/mock-joinpeertube-versions.ts +++ b/server/tests/shared/mock-servers/mock-joinpeertube-versions.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { Server } from 'http' | 2 | import { Server } from 'http' |
3 | import { getPort, randomListen } from './utils' | 3 | import { getPort, randomListen } from './shared' |
4 | 4 | ||
5 | export class MockJoinPeerTubeVersions { | 5 | export class MockJoinPeerTubeVersions { |
6 | private server: Server | 6 | private server: Server |
diff --git a/shared/server-commands/mock-servers/mock-object-storage.ts b/server/tests/shared/mock-servers/mock-object-storage.ts index d135c2631..99d68e014 100644 --- a/shared/server-commands/mock-servers/mock-object-storage.ts +++ b/server/tests/shared/mock-servers/mock-object-storage.ts | |||
@@ -2,8 +2,8 @@ import express from 'express' | |||
2 | import got, { RequestError } from 'got' | 2 | import got, { RequestError } from 'got' |
3 | import { Server } from 'http' | 3 | import { Server } from 'http' |
4 | import { pipeline } from 'stream' | 4 | import { pipeline } from 'stream' |
5 | import { ObjectStorageCommand } from '../server' | 5 | import { ObjectStorageCommand } from '@shared/server-commands' |
6 | import { getPort, randomListen, terminateServer } from './utils' | 6 | import { getPort, randomListen, terminateServer } from './shared' |
7 | 7 | ||
8 | export class MockObjectStorage { | 8 | export class MockObjectStorage { |
9 | private server: Server | 9 | private server: Server |
diff --git a/shared/server-commands/mock-servers/mock-plugin-blocklist.ts b/server/tests/shared/mock-servers/mock-plugin-blocklist.ts index f8a271cba..5d6e01816 100644 --- a/shared/server-commands/mock-servers/mock-plugin-blocklist.ts +++ b/server/tests/shared/mock-servers/mock-plugin-blocklist.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express, { Request, Response } from 'express' | 1 | import express, { Request, Response } from 'express' |
2 | import { Server } from 'http' | 2 | import { Server } from 'http' |
3 | import { getPort, randomListen, terminateServer } from './utils' | 3 | import { getPort, randomListen, terminateServer } from './shared' |
4 | 4 | ||
5 | type BlocklistResponse = { | 5 | type BlocklistResponse = { |
6 | data: { | 6 | data: { |
diff --git a/shared/server-commands/mock-servers/mock-proxy.ts b/server/tests/shared/mock-servers/mock-proxy.ts index 75ac79055..cbc7c4466 100644 --- a/shared/server-commands/mock-servers/mock-proxy.ts +++ b/server/tests/shared/mock-servers/mock-proxy.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | |||
2 | import { createServer, Server } from 'http' | 1 | import { createServer, Server } from 'http' |
3 | import proxy from 'proxy' | 2 | import proxy from 'proxy' |
4 | import { getPort, terminateServer } from './utils' | 3 | import { getPort, terminateServer } from './shared' |
5 | 4 | ||
6 | class MockProxy { | 5 | class MockProxy { |
7 | private server: Server | 6 | private server: Server |
diff --git a/shared/server-commands/mock-servers/utils.ts b/server/tests/shared/mock-servers/shared.ts index 235642439..235642439 100644 --- a/shared/server-commands/mock-servers/utils.ts +++ b/server/tests/shared/mock-servers/shared.ts | |||
diff --git a/shared/server-commands/users/notifications.ts b/server/tests/shared/notifications.ts index 07ccb0f8d..cdc21fdc8 100644 --- a/shared/server-commands/users/notifications.ts +++ b/server/tests/shared/notifications.ts | |||
@@ -2,13 +2,16 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { inspect } from 'util' | 4 | import { inspect } from 'util' |
5 | import { AbuseState, PluginType } from '@shared/models' | 5 | import { |
6 | import { UserNotification, UserNotificationSetting, UserNotificationSettingValue, UserNotificationType } from '../../models/users' | 6 | AbuseState, |
7 | import { MockSmtpServer } from '../mock-servers/mock-email' | 7 | PluginType, |
8 | import { PeerTubeServer } from '../server' | 8 | UserNotification, |
9 | import { doubleFollow } from '../server/follows' | 9 | UserNotificationSetting, |
10 | import { createMultipleServers } from '../server/servers' | 10 | UserNotificationSettingValue, |
11 | import { setAccessTokensToServers } from './login' | 11 | UserNotificationType |
12 | } from '@shared/models' | ||
13 | import { createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
14 | import { MockSmtpServer } from './mock-servers' | ||
12 | 15 | ||
13 | type CheckerBaseParams = { | 16 | type CheckerBaseParams = { |
14 | server: PeerTubeServer | 17 | server: PeerTubeServer |
diff --git a/shared/server-commands/videos/playlists.ts b/server/tests/shared/playlists.ts index 3dde52bb9..fdd541d20 100644 --- a/shared/server-commands/videos/playlists.ts +++ b/server/tests/shared/playlists.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { readdir } from 'fs-extra' | 2 | import { readdir } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root } from '../miscs' | 4 | import { root } from '@shared/core-utils' |
5 | 5 | ||
6 | async function checkPlaylistFilesWereRemoved ( | 6 | async function checkPlaylistFilesWereRemoved ( |
7 | playlistUUID: string, | 7 | playlistUUID: string, |
diff --git a/shared/server-commands/server/plugins.ts b/server/tests/shared/plugins.ts index c6316898d..036fce2ff 100644 --- a/shared/server-commands/server/plugins.ts +++ b/server/tests/shared/plugins.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { PeerTubeServer } from './server' | 4 | import { PeerTubeServer } from '@shared/server-commands' |
5 | 5 | ||
6 | async function testHelloWorldRegisteredSettings (server: PeerTubeServer) { | 6 | async function testHelloWorldRegisteredSettings (server: PeerTubeServer) { |
7 | const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) | 7 | const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) |
diff --git a/server/tests/shared/requests.ts b/server/tests/shared/requests.ts index 9eb596029..7f1acc0e1 100644 --- a/server/tests/shared/requests.ts +++ b/server/tests/shared/requests.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { doRequest } from '@server/helpers/requests' | ||
2 | import { activityPubContextify } from '@server/helpers/activitypub' | 1 | import { activityPubContextify } from '@server/helpers/activitypub' |
3 | import { HTTP_SIGNATURE } from '@server/initializers/constants' | 2 | import { buildDigest } from '@server/helpers/peertube-crypto' |
4 | import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' | 3 | import { doRequest } from '@server/helpers/requests' |
4 | import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants' | ||
5 | 5 | ||
6 | export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { | 6 | export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { |
7 | const options = { | 7 | const options = { |
@@ -31,7 +31,11 @@ export async function makeFollowRequest (to: { url: string }, by: { url: string, | |||
31 | key: by.privateKey, | 31 | key: by.privateKey, |
32 | headers: HTTP_SIGNATURE.HEADERS_TO_SIGN | 32 | headers: HTTP_SIGNATURE.HEADERS_TO_SIGN |
33 | } | 33 | } |
34 | const headers = buildGlobalHeaders(body) | 34 | const headers = { |
35 | 'digest': buildDigest(body), | ||
36 | 'content-type': 'application/activity+json', | ||
37 | 'accept': ACTIVITY_PUB.ACCEPT_HEADER | ||
38 | } | ||
35 | 39 | ||
36 | return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers) | 40 | return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers) |
37 | } | 41 | } |
diff --git a/shared/server-commands/videos/streaming-playlists.ts b/server/tests/shared/streaming-playlists.ts index 0451c0efe..738dc90e1 100644 --- a/shared/server-commands/videos/streaming-playlists.ts +++ b/server/tests/shared/streaming-playlists.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { basename } from 'path' | 2 | import { basename } from 'path' |
3 | import { sha256 } from '@shared/core-utils/crypto' | ||
4 | import { removeFragmentedMP4Ext } from '@shared/core-utils' | 3 | import { removeFragmentedMP4Ext } from '@shared/core-utils' |
4 | import { sha256 } from '@shared/core-utils/common/crypto' | ||
5 | import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models' | 5 | import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models' |
6 | import { PeerTubeServer } from '../server' | 6 | import { PeerTubeServer } from '@shared/server-commands' |
7 | 7 | ||
8 | async function checkSegmentHash (options: { | 8 | async function checkSegmentHash (options: { |
9 | server: PeerTubeServer | 9 | server: PeerTubeServer |
diff --git a/server/tests/shared/tests.ts b/server/tests/shared/tests.ts new file mode 100644 index 000000000..3abaf833d --- /dev/null +++ b/server/tests/shared/tests.ts | |||
@@ -0,0 +1,37 @@ | |||
1 | const FIXTURE_URLS = { | ||
2 | peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e', | ||
3 | peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd', | ||
4 | |||
5 | youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM', | ||
6 | |||
7 | /** | ||
8 | * The video is used to check format-selection correctness wrt. HDR, | ||
9 | * which brings its own set of oddities outside of a MediaSource. | ||
10 | * | ||
11 | * The video needs to have the following format_ids: | ||
12 | * (which you can check by using `youtube-dl <url> -F`): | ||
13 | * - (webm vp9) | ||
14 | * - (mp4 avc1) | ||
15 | * - (webm vp9.2 HDR) | ||
16 | */ | ||
17 | youtubeHDR: 'https://www.youtube.com/watch?v=RQgnBB9z_N4', | ||
18 | |||
19 | // eslint-disable-next-line max-len | ||
20 | magnet: 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Flazy-static%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4', | ||
21 | |||
22 | badVideo: 'https://download.cpy.re/peertube/bad_video.mp4', | ||
23 | goodVideo: 'https://download.cpy.re/peertube/good_video.mp4', | ||
24 | goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4', | ||
25 | |||
26 | file4K: 'https://download.cpy.re/peertube/4k_file.txt' | ||
27 | } | ||
28 | |||
29 | function buildRequestStub (): any { | ||
30 | return { } | ||
31 | } | ||
32 | |||
33 | export { | ||
34 | FIXTURE_URLS, | ||
35 | |||
36 | buildRequestStub | ||
37 | } | ||
diff --git a/shared/server-commands/server/tracker.ts b/server/tests/shared/tracker.ts index ed43a5924..699895d5f 100644 --- a/shared/server-commands/server/tracker.ts +++ b/server/tests/shared/tracker.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { sha1 } from '@shared/core-utils/crypto' | 2 | import { sha1 } from '@shared/core-utils' |
3 | import { makeGetRequest } from '../requests' | 3 | import { makeGetRequest } from '@shared/server-commands' |
4 | 4 | ||
5 | async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) { | 5 | async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) { |
6 | const path = '/tracker/announce' | 6 | const path = '/tracker/announce' |
diff --git a/server/tests/shared/video.ts b/server/tests/shared/videos.ts index cf923d4cd..6be094f2b 100644 --- a/server/tests/shared/video.ts +++ b/server/tests/shared/videos.ts | |||
@@ -1,12 +1,17 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | import { dateIsValid, makeRawRequest, PeerTubeServer, testImage, webtorrentAdd } from '@shared/server-commands' | 2 | |
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | ||
5 | import { basename, join } from 'path' | ||
4 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '@server/initializers/constants' | 6 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '@server/initializers/constants' |
5 | import { getLowercaseExtension, uuidRegex } from '@shared/core-utils' | 7 | import { getLowercaseExtension, uuidRegex } from '@shared/core-utils' |
8 | import { HttpStatusCode, VideoCaption, VideoDetails } from '@shared/models' | ||
9 | import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs, webtorrentAdd } from '@shared/server-commands' | ||
10 | import { dateIsValid, testImage } from './checks' | ||
6 | 11 | ||
7 | loadLanguages() | 12 | loadLanguages() |
8 | 13 | ||
9 | export async function completeVideoCheck ( | 14 | async function completeVideoCheck ( |
10 | server: PeerTubeServer, | 15 | server: PeerTubeServer, |
11 | video: any, | 16 | video: any, |
12 | attributes: { | 17 | attributes: { |
@@ -148,3 +153,99 @@ export async function completeVideoCheck ( | |||
148 | await testImage(server.url, attributes.previewfile, videoDetails.previewPath) | 153 | await testImage(server.url, attributes.previewfile, videoDetails.previewPath) |
149 | } | 154 | } |
150 | } | 155 | } |
156 | |||
157 | async function checkVideoFilesWereRemoved (options: { | ||
158 | server: PeerTubeServer | ||
159 | video: VideoDetails | ||
160 | captions?: VideoCaption[] | ||
161 | onlyVideoFiles?: boolean // default false | ||
162 | }) { | ||
163 | const { video, server, captions = [], onlyVideoFiles = false } = options | ||
164 | |||
165 | const webtorrentFiles = video.files || [] | ||
166 | const hlsFiles = video.streamingPlaylists[0]?.files || [] | ||
167 | |||
168 | const thumbnailName = basename(video.thumbnailPath) | ||
169 | const previewName = basename(video.previewPath) | ||
170 | |||
171 | const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl)) | ||
172 | |||
173 | const captionNames = captions.map(c => basename(c.captionPath)) | ||
174 | |||
175 | const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl)) | ||
176 | const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl)) | ||
177 | |||
178 | let directories: { [ directory: string ]: string[] } = { | ||
179 | videos: webtorrentFilenames, | ||
180 | redundancy: webtorrentFilenames, | ||
181 | [join('playlists', 'hls')]: hlsFilenames, | ||
182 | [join('redundancy', 'hls')]: hlsFilenames | ||
183 | } | ||
184 | |||
185 | if (onlyVideoFiles !== true) { | ||
186 | directories = { | ||
187 | ...directories, | ||
188 | |||
189 | thumbnails: [ thumbnailName ], | ||
190 | previews: [ previewName ], | ||
191 | torrents: torrentNames, | ||
192 | captions: captionNames | ||
193 | } | ||
194 | } | ||
195 | |||
196 | for (const directory of Object.keys(directories)) { | ||
197 | const directoryPath = server.servers.buildDirectory(directory) | ||
198 | |||
199 | const directoryExists = await pathExists(directoryPath) | ||
200 | if (directoryExists === false) continue | ||
201 | |||
202 | const existingFiles = await readdir(directoryPath) | ||
203 | for (const existingFile of existingFiles) { | ||
204 | for (const shouldNotExist of directories[directory]) { | ||
205 | expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist) | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | |||
211 | async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) { | ||
212 | for (const server of servers) { | ||
213 | server.store.videoDetails = await server.videos.get({ id: uuid }) | ||
214 | } | ||
215 | } | ||
216 | |||
217 | function checkUploadVideoParam ( | ||
218 | server: PeerTubeServer, | ||
219 | token: string, | ||
220 | attributes: Partial<VideoEdit>, | ||
221 | expectedStatus = HttpStatusCode.OK_200, | ||
222 | mode: 'legacy' | 'resumable' = 'legacy' | ||
223 | ) { | ||
224 | return mode === 'legacy' | ||
225 | ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus }) | ||
226 | : server.videos.buildResumeUpload({ token, attributes, expectedStatus }) | ||
227 | } | ||
228 | |||
229 | // serverNumber starts from 1 | ||
230 | async function uploadRandomVideoOnServers ( | ||
231 | servers: PeerTubeServer[], | ||
232 | serverNumber: number, | ||
233 | additionalParams?: VideoEdit & { prefixName?: string } | ||
234 | ) { | ||
235 | const server = servers.find(s => s.serverNumber === serverNumber) | ||
236 | const res = await server.videos.randomUpload({ wait: false, additionalParams }) | ||
237 | |||
238 | await waitJobs(servers) | ||
239 | |||
240 | return res | ||
241 | } | ||
242 | |||
243 | // --------------------------------------------------------------------------- | ||
244 | |||
245 | export { | ||
246 | completeVideoCheck, | ||
247 | checkUploadVideoParam, | ||
248 | uploadRandomVideoOnServers, | ||
249 | checkVideoFilesWereRemoved, | ||
250 | saveVideoInServers | ||
251 | } | ||
diff --git a/shared/core-utils/utils/array.ts b/shared/core-utils/common/array.ts index 9e326a5aa..9e326a5aa 100644 --- a/shared/core-utils/utils/array.ts +++ b/shared/core-utils/common/array.ts | |||
diff --git a/shared/core-utils/crypto.ts b/shared/core-utils/common/crypto.ts index d6d1150d0..1a583f1a0 100644 --- a/shared/core-utils/crypto.ts +++ b/shared/core-utils/common/crypto.ts | |||
@@ -8,7 +8,13 @@ function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') { | |||
8 | return createHash('sha1').update(str).digest(encoding) | 8 | return createHash('sha1').update(str).digest(encoding) |
9 | } | 9 | } |
10 | 10 | ||
11 | // high excluded | ||
12 | function randomInt (low: number, high: number) { | ||
13 | return Math.floor(Math.random() * (high - low) + low) | ||
14 | } | ||
15 | |||
11 | export { | 16 | export { |
17 | randomInt, | ||
12 | sha256, | 18 | sha256, |
13 | sha1 | 19 | sha1 |
14 | } | 20 | } |
diff --git a/shared/core-utils/common/env.ts b/shared/core-utils/common/env.ts new file mode 100644 index 000000000..38c96b152 --- /dev/null +++ b/shared/core-utils/common/env.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | function parallelTests () { | ||
2 | return process.env.MOCHA_PARALLEL === 'true' | ||
3 | } | ||
4 | |||
5 | function isGithubCI () { | ||
6 | return !!process.env.GITHUB_WORKSPACE | ||
7 | } | ||
8 | |||
9 | function areHttpImportTestsDisabled () { | ||
10 | const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true' | ||
11 | |||
12 | if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled') | ||
13 | |||
14 | return disabled | ||
15 | } | ||
16 | |||
17 | function areObjectStorageTestsDisabled () { | ||
18 | const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true' | ||
19 | |||
20 | if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled') | ||
21 | |||
22 | return disabled | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | parallelTests, | ||
27 | isGithubCI, | ||
28 | areHttpImportTestsDisabled, | ||
29 | areObjectStorageTestsDisabled | ||
30 | } | ||
diff --git a/shared/core-utils/common/index.ts b/shared/core-utils/common/index.ts index 5d3512148..f9ba10d5e 100644 --- a/shared/core-utils/common/index.ts +++ b/shared/core-utils/common/index.ts | |||
@@ -1,5 +1,11 @@ | |||
1 | export * from './array' | ||
2 | export * from './crypto' | ||
1 | export * from './date' | 3 | export * from './date' |
2 | export * from './miscs' | 4 | export * from './env' |
5 | export * from './object' | ||
6 | export * from './path' | ||
3 | export * from './regexp' | 7 | export * from './regexp' |
8 | export * from './time' | ||
4 | export * from './promises' | 9 | export * from './promises' |
5 | export * from './url' | 10 | export * from './url' |
11 | export * from './version' | ||
diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.ts new file mode 100644 index 000000000..88d6b7514 --- /dev/null +++ b/shared/core-utils/common/object.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> { | ||
2 | const result: any = {} | ||
3 | |||
4 | for (const key of keys) { | ||
5 | if (Object.prototype.hasOwnProperty.call(object, key)) { | ||
6 | result[key] = object[key] | ||
7 | } | ||
8 | } | ||
9 | |||
10 | return result | ||
11 | } | ||
12 | |||
13 | function sortObjectComparator (key: string, order: 'asc' | 'desc') { | ||
14 | return (a: any, b: any) => { | ||
15 | if (a[key] < b[key]) { | ||
16 | return order === 'asc' ? -1 : 1 | ||
17 | } | ||
18 | |||
19 | if (a[key] > b[key]) { | ||
20 | return order === 'asc' ? 1 : -1 | ||
21 | } | ||
22 | |||
23 | return 0 | ||
24 | } | ||
25 | } | ||
26 | |||
27 | export { | ||
28 | pick, | ||
29 | sortObjectComparator | ||
30 | } | ||
diff --git a/shared/core-utils/path.ts b/shared/core-utils/common/path.ts index b1a45d69b..ec507538b 100644 --- a/shared/core-utils/path.ts +++ b/shared/core-utils/common/path.ts | |||
@@ -7,6 +7,7 @@ function root () { | |||
7 | 7 | ||
8 | rootPath = __dirname | 8 | rootPath = __dirname |
9 | 9 | ||
10 | if (basename(rootPath) === 'common') rootPath = resolve(rootPath, '..') | ||
10 | if (basename(rootPath) === 'core-utils') rootPath = resolve(rootPath, '..') | 11 | if (basename(rootPath) === 'core-utils') rootPath = resolve(rootPath, '..') |
11 | if (basename(rootPath) === 'shared') rootPath = resolve(rootPath, '..') | 12 | if (basename(rootPath) === 'shared') rootPath = resolve(rootPath, '..') |
12 | if (basename(rootPath) === 'server') rootPath = resolve(rootPath, '..') | 13 | if (basename(rootPath) === 'server') rootPath = resolve(rootPath, '..') |
@@ -27,8 +28,19 @@ function getLowercaseExtension (filename: string) { | |||
27 | return ext.toLowerCase() | 28 | return ext.toLowerCase() |
28 | } | 29 | } |
29 | 30 | ||
31 | function buildAbsoluteFixturePath (path: string, customCIPath = false) { | ||
32 | if (isAbsolute(path)) return path | ||
33 | |||
34 | if (customCIPath && process.env.GITHUB_WORKSPACE) { | ||
35 | return join(process.env.GITHUB_WORKSPACE, 'fixtures', path) | ||
36 | } | ||
37 | |||
38 | return join(root(), 'server', 'tests', 'fixtures', path) | ||
39 | } | ||
40 | |||
30 | export { | 41 | export { |
31 | root, | 42 | root, |
32 | buildPath, | 43 | buildPath, |
44 | buildAbsoluteFixturePath, | ||
33 | getLowercaseExtension | 45 | getLowercaseExtension |
34 | } | 46 | } |
diff --git a/shared/core-utils/common/time.ts b/shared/core-utils/common/time.ts new file mode 100644 index 000000000..2992609ca --- /dev/null +++ b/shared/core-utils/common/time.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | function wait (milliseconds: number) { | ||
2 | return new Promise(resolve => setTimeout(resolve, milliseconds)) | ||
3 | } | ||
4 | |||
5 | export { | ||
6 | wait | ||
7 | } | ||
diff --git a/shared/core-utils/common/miscs.ts b/shared/core-utils/common/version.ts index bc65dc338..8a64f8c4d 100644 --- a/shared/core-utils/common/miscs.ts +++ b/shared/core-utils/common/version.ts | |||
@@ -1,8 +1,3 @@ | |||
1 | // high excluded | ||
2 | function randomInt (low: number, high: number) { | ||
3 | return Math.floor(Math.random() * (high - low) + low) | ||
4 | } | ||
5 | |||
6 | // Thanks https://stackoverflow.com/a/16187766 | 1 | // Thanks https://stackoverflow.com/a/16187766 |
7 | function compareSemVer (a: string, b: string) { | 2 | function compareSemVer (a: string, b: string) { |
8 | const regExStrip0 = /(\.0+)+$/ | 3 | const regExStrip0 = /(\.0+)+$/ |
@@ -20,22 +15,6 @@ function compareSemVer (a: string, b: string) { | |||
20 | return segmentsA.length - segmentsB.length | 15 | return segmentsA.length - segmentsB.length |
21 | } | 16 | } |
22 | 17 | ||
23 | function sortObjectComparator (key: string, order: 'asc' | 'desc') { | ||
24 | return (a: any, b: any) => { | ||
25 | if (a[key] < b[key]) { | ||
26 | return order === 'asc' ? -1 : 1 | ||
27 | } | ||
28 | |||
29 | if (a[key] > b[key]) { | ||
30 | return order === 'asc' ? 1 : -1 | ||
31 | } | ||
32 | |||
33 | return 0 | ||
34 | } | ||
35 | } | ||
36 | |||
37 | export { | 18 | export { |
38 | randomInt, | 19 | compareSemVer |
39 | compareSemVer, | ||
40 | sortObjectComparator | ||
41 | } | 20 | } |
diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.ts index ee5cd4412..8daaa2d04 100644 --- a/shared/core-utils/index.ts +++ b/shared/core-utils/index.ts | |||
@@ -1,10 +1,7 @@ | |||
1 | export * from './abuse' | 1 | export * from './abuse' |
2 | export * from './common' | 2 | export * from './common' |
3 | export * from './i18n' | 3 | export * from './i18n' |
4 | export * from './path' | ||
5 | export * from './plugins' | 4 | export * from './plugins' |
6 | export * from './renderer' | 5 | export * from './renderer' |
7 | export * from './users' | 6 | export * from './users' |
8 | export * from './utils' | ||
9 | export * from './videos' | 7 | export * from './videos' |
10 | export * from './uuid' | ||
diff --git a/shared/core-utils/utils/index.ts b/shared/core-utils/utils/index.ts deleted file mode 100644 index 8d16365a8..000000000 --- a/shared/core-utils/utils/index.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | export * from './array' | ||
2 | export * from './object' | ||
diff --git a/shared/core-utils/utils/object.ts b/shared/core-utils/utils/object.ts deleted file mode 100644 index 9a8a98f9b..000000000 --- a/shared/core-utils/utils/object.ts +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> { | ||
2 | const result: any = {} | ||
3 | |||
4 | for (const key of keys) { | ||
5 | if (Object.prototype.hasOwnProperty.call(object, key)) { | ||
6 | result[key] = object[key] | ||
7 | } | ||
8 | } | ||
9 | |||
10 | return result | ||
11 | } | ||
12 | |||
13 | export { | ||
14 | pick | ||
15 | } | ||
diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.ts index 620e3a716..8f6736d39 100644 --- a/shared/core-utils/videos/index.ts +++ b/shared/core-utils/videos/index.ts | |||
@@ -1,2 +1,3 @@ | |||
1 | export * from './bitrate' | 1 | export * from './bitrate' |
2 | export * from './privacy' | 2 | export * from './privacy' |
3 | export * from './uuid' | ||
diff --git a/shared/core-utils/uuid.ts b/shared/core-utils/videos/uuid.ts index f3c80e046..f3c80e046 100644 --- a/shared/core-utils/uuid.ts +++ b/shared/core-utils/videos/uuid.ts | |||
diff --git a/shared/extra-utils/file.ts b/shared/extra-utils/file.ts new file mode 100644 index 000000000..8060ab520 --- /dev/null +++ b/shared/extra-utils/file.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { stat } from 'fs-extra' | ||
2 | |||
3 | async function getFileSize (path: string) { | ||
4 | const stats = await stat(path) | ||
5 | |||
6 | return stats.size | ||
7 | } | ||
8 | |||
9 | export { | ||
10 | getFileSize | ||
11 | } | ||
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 5710c5ab5..38303cf1f 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -1 +1,2 @@ | |||
1 | export * from './ffprobe' | 1 | export * from './ffprobe' |
2 | export * from './file' | ||
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts index b61a8cd40..a24ffee96 100644 --- a/shared/models/users/index.ts +++ b/shared/models/users/index.ts | |||
@@ -8,6 +8,7 @@ export * from './user-refresh-token.model' | |||
8 | export * from './user-register.model' | 8 | export * from './user-register.model' |
9 | export * from './user-right.enum' | 9 | export * from './user-right.enum' |
10 | export * from './user-role' | 10 | export * from './user-role' |
11 | export * from './user-scoped-token' | ||
11 | export * from './user-update-me.model' | 12 | export * from './user-update-me.model' |
12 | export * from './user-update.model' | 13 | export * from './user-update.model' |
13 | export * from './user-video-quota.model' | 14 | export * from './user-video-quota.model' |
diff --git a/shared/server-commands/index.ts b/shared/server-commands/index.ts index 4b3636d06..c24ebb2df 100644 --- a/shared/server-commands/index.ts +++ b/shared/server-commands/index.ts | |||
@@ -4,7 +4,6 @@ export * from './custom-pages' | |||
4 | export * from './feeds' | 4 | export * from './feeds' |
5 | export * from './logs' | 5 | export * from './logs' |
6 | export * from './miscs' | 6 | export * from './miscs' |
7 | export * from './mock-servers' | ||
8 | export * from './moderation' | 7 | export * from './moderation' |
9 | export * from './overviews' | 8 | export * from './overviews' |
10 | export * from './requests' | 9 | export * from './requests' |
diff --git a/shared/server-commands/logs/logs-command.ts b/shared/server-commands/logs/logs-command.ts index 7b5c66c0c..8f63383ea 100644 --- a/shared/server-commands/logs/logs-command.ts +++ b/shared/server-commands/logs/logs-command.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | 1 | import { HttpStatusCode, LogLevel } from '@shared/models' |
2 | import { LogLevel } from '../../models/server/log-level.type' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 3 | ||
5 | export class LogsCommand extends AbstractCommand { | 4 | export class LogsCommand extends AbstractCommand { |
diff --git a/shared/server-commands/miscs/index.ts b/shared/server-commands/miscs/index.ts index 4474661de..a1d14e998 100644 --- a/shared/server-commands/miscs/index.ts +++ b/shared/server-commands/miscs/index.ts | |||
@@ -1,5 +1,2 @@ | |||
1 | export * from './checks' | ||
2 | export * from './generate' | ||
3 | export * from './sql-command' | 1 | export * from './sql-command' |
4 | export * from './tests' | ||
5 | export * from './webtorrent' | 2 | export * from './webtorrent' |
diff --git a/shared/server-commands/miscs/sql-command.ts b/shared/server-commands/miscs/sql-command.ts index bedb3349b..09a99f834 100644 --- a/shared/server-commands/miscs/sql-command.ts +++ b/shared/server-commands/miscs/sql-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { QueryTypes, Sequelize } from 'sequelize' | 1 | import { QueryTypes, Sequelize } from 'sequelize' |
2 | import { AbstractCommand } from '../shared/abstract-command' | 2 | import { AbstractCommand } from '../shared' |
3 | 3 | ||
4 | export class SQLCommand extends AbstractCommand { | 4 | export class SQLCommand extends AbstractCommand { |
5 | private sequelize: Sequelize | 5 | private sequelize: Sequelize |
diff --git a/shared/server-commands/miscs/tests.ts b/shared/server-commands/miscs/tests.ts deleted file mode 100644 index 658fe5fd3..000000000 --- a/shared/server-commands/miscs/tests.ts +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | import { stat } from 'fs-extra' | ||
2 | import { basename, isAbsolute, join, resolve } from 'path' | ||
3 | |||
4 | const FIXTURE_URLS = { | ||
5 | peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e', | ||
6 | peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd', | ||
7 | |||
8 | youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM', | ||
9 | |||
10 | /** | ||
11 | * The video is used to check format-selection correctness wrt. HDR, | ||
12 | * which brings its own set of oddities outside of a MediaSource. | ||
13 | * | ||
14 | * The video needs to have the following format_ids: | ||
15 | * (which you can check by using `youtube-dl <url> -F`): | ||
16 | * - (webm vp9) | ||
17 | * - (mp4 avc1) | ||
18 | * - (webm vp9.2 HDR) | ||
19 | */ | ||
20 | youtubeHDR: 'https://www.youtube.com/watch?v=RQgnBB9z_N4', | ||
21 | |||
22 | // eslint-disable-next-line max-len | ||
23 | magnet: 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Flazy-static%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4', | ||
24 | |||
25 | badVideo: 'https://download.cpy.re/peertube/bad_video.mp4', | ||
26 | goodVideo: 'https://download.cpy.re/peertube/good_video.mp4', | ||
27 | goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4', | ||
28 | |||
29 | file4K: 'https://download.cpy.re/peertube/4k_file.txt' | ||
30 | } | ||
31 | |||
32 | function parallelTests () { | ||
33 | return process.env.MOCHA_PARALLEL === 'true' | ||
34 | } | ||
35 | |||
36 | function isGithubCI () { | ||
37 | return !!process.env.GITHUB_WORKSPACE | ||
38 | } | ||
39 | |||
40 | function areHttpImportTestsDisabled () { | ||
41 | const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true' | ||
42 | |||
43 | if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled') | ||
44 | |||
45 | return disabled | ||
46 | } | ||
47 | |||
48 | function areObjectStorageTestsDisabled () { | ||
49 | const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true' | ||
50 | |||
51 | if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled') | ||
52 | |||
53 | return disabled | ||
54 | } | ||
55 | |||
56 | function buildAbsoluteFixturePath (path: string, customCIPath = false) { | ||
57 | if (isAbsolute(path)) return path | ||
58 | |||
59 | if (customCIPath && process.env.GITHUB_WORKSPACE) { | ||
60 | return join(process.env.GITHUB_WORKSPACE, 'fixtures', path) | ||
61 | } | ||
62 | |||
63 | return join(root(), 'server', 'tests', 'fixtures', path) | ||
64 | } | ||
65 | |||
66 | function root () { | ||
67 | // We are in /miscs | ||
68 | let root = join(__dirname, '..', '..', '..') | ||
69 | |||
70 | if (basename(root) === 'dist') root = resolve(root, '..') | ||
71 | |||
72 | return root | ||
73 | } | ||
74 | |||
75 | function wait (milliseconds: number) { | ||
76 | return new Promise(resolve => setTimeout(resolve, milliseconds)) | ||
77 | } | ||
78 | |||
79 | async function getFileSize (path: string) { | ||
80 | const stats = await stat(path) | ||
81 | |||
82 | return stats.size | ||
83 | } | ||
84 | |||
85 | function buildRequestStub (): any { | ||
86 | return { } | ||
87 | } | ||
88 | |||
89 | export { | ||
90 | FIXTURE_URLS, | ||
91 | |||
92 | parallelTests, | ||
93 | isGithubCI, | ||
94 | areHttpImportTestsDisabled, | ||
95 | buildAbsoluteFixturePath, | ||
96 | getFileSize, | ||
97 | buildRequestStub, | ||
98 | areObjectStorageTestsDisabled, | ||
99 | wait, | ||
100 | root | ||
101 | } | ||
diff --git a/shared/server-commands/requests/check-api-params.ts b/shared/server-commands/requests/check-api-params.ts deleted file mode 100644 index 26ba1e913..000000000 --- a/shared/server-commands/requests/check-api-params.ts +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { makeGetRequest } from './requests' | ||
3 | |||
4 | function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { | ||
5 | return makeGetRequest({ | ||
6 | url, | ||
7 | path, | ||
8 | token, | ||
9 | query: { ...query, start: 'hello' }, | ||
10 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
11 | }) | ||
12 | } | ||
13 | |||
14 | async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) { | ||
15 | await makeGetRequest({ | ||
16 | url, | ||
17 | path, | ||
18 | token, | ||
19 | query: { ...query, count: 'hello' }, | ||
20 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
21 | }) | ||
22 | |||
23 | await makeGetRequest({ | ||
24 | url, | ||
25 | path, | ||
26 | token, | ||
27 | query: { ...query, count: 2000 }, | ||
28 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
29 | }) | ||
30 | } | ||
31 | |||
32 | function checkBadSortPagination (url: string, path: string, token?: string, query = {}) { | ||
33 | return makeGetRequest({ | ||
34 | url, | ||
35 | path, | ||
36 | token, | ||
37 | query: { ...query, sort: 'hello' }, | ||
38 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
39 | }) | ||
40 | } | ||
41 | |||
42 | // --------------------------------------------------------------------------- | ||
43 | |||
44 | export { | ||
45 | checkBadStartPagination, | ||
46 | checkBadCountPagination, | ||
47 | checkBadSortPagination | ||
48 | } | ||
diff --git a/shared/server-commands/requests/index.ts b/shared/server-commands/requests/index.ts index 501163f92..802982301 100644 --- a/shared/server-commands/requests/index.ts +++ b/shared/server-commands/requests/index.ts | |||
@@ -1,3 +1 @@ | |||
1 | // Don't include activitypub that import stuff from server | ||
2 | export * from './check-api-params' | ||
3 | export * from './requests' | export * from './requests' | |
diff --git a/shared/server-commands/requests/requests.ts b/shared/server-commands/requests/requests.ts index b6b9024ed..95e4fe6b1 100644 --- a/shared/server-commands/requests/requests.ts +++ b/shared/server-commands/requests/requests.ts | |||
@@ -3,8 +3,8 @@ | |||
3 | import { decode } from 'querystring' | 3 | import { decode } from 'querystring' |
4 | import request from 'supertest' | 4 | import request from 'supertest' |
5 | import { URL } from 'url' | 5 | import { URL } from 'url' |
6 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
6 | import { HttpStatusCode } from '@shared/models' | 7 | import { HttpStatusCode } from '@shared/models' |
7 | import { buildAbsoluteFixturePath } from '../miscs/tests' | ||
8 | 8 | ||
9 | export type CommonRequestParams = { | 9 | export type CommonRequestParams = { |
10 | url: string | 10 | url: string |
diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index 89ae8eb4f..797231b1d 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { merge } from 'lodash' | 1 | import { merge } from 'lodash' |
2 | import { About, CustomConfig, HttpStatusCode, ServerConfig } from '@shared/models' | ||
2 | import { DeepPartial } from '@shared/typescript-utils' | 3 | import { DeepPartial } from '@shared/typescript-utils' |
3 | import { About, HttpStatusCode, ServerConfig } from '@shared/models' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command' |
4 | import { CustomConfig } from '../../models/server/custom-config.model' | ||
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
6 | 5 | ||
7 | export class ConfigCommand extends AbstractCommand { | 6 | export class ConfigCommand extends AbstractCommand { |
8 | 7 | ||
diff --git a/shared/server-commands/server/index.ts b/shared/server-commands/server/index.ts index 76a2099da..0a4b21fc4 100644 --- a/shared/server-commands/server/index.ts +++ b/shared/server-commands/server/index.ts | |||
@@ -1,17 +1,14 @@ | |||
1 | export * from './config-command' | 1 | export * from './config-command' |
2 | export * from './contact-form-command' | 2 | export * from './contact-form-command' |
3 | export * from './debug-command' | 3 | export * from './debug-command' |
4 | export * from './directories' | ||
5 | export * from './follows-command' | 4 | export * from './follows-command' |
6 | export * from './follows' | 5 | export * from './follows' |
7 | export * from './jobs' | 6 | export * from './jobs' |
8 | export * from './jobs-command' | 7 | export * from './jobs-command' |
9 | export * from './object-storage-command' | 8 | export * from './object-storage-command' |
10 | export * from './plugins-command' | 9 | export * from './plugins-command' |
11 | export * from './plugins' | ||
12 | export * from './redundancy-command' | 10 | export * from './redundancy-command' |
13 | export * from './server' | 11 | export * from './server' |
14 | export * from './servers-command' | 12 | export * from './servers-command' |
15 | export * from './servers' | 13 | export * from './servers' |
16 | export * from './stats-command' | 14 | export * from './stats-command' |
17 | export * from './tracker' | ||
diff --git a/shared/server-commands/server/jobs-command.ts b/shared/server-commands/server/jobs-command.ts index 6636e7e4d..ac62157d1 100644 --- a/shared/server-commands/server/jobs-command.ts +++ b/shared/server-commands/server/jobs-command.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { pick } from '@shared/core-utils' | 1 | import { pick } from '@shared/core-utils' |
2 | import { HttpStatusCode } from '@shared/models' | 2 | import { HttpStatusCode, Job, JobState, JobType, ResultList } from '@shared/models' |
3 | import { Job, JobState, JobType, ResultList } from '../../models' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 4 | ||
6 | export class JobsCommand extends AbstractCommand { | 5 | export class JobsCommand extends AbstractCommand { |
diff --git a/shared/server-commands/server/jobs.ts b/shared/server-commands/server/jobs.ts index 34fefd444..fc65a873b 100644 --- a/shared/server-commands/server/jobs.ts +++ b/shared/server-commands/server/jobs.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | 1 | ||
2 | import { expect } from 'chai' | 2 | import { expect } from 'chai' |
3 | import { wait } from '@shared/core-utils' | ||
3 | import { JobState, JobType } from '../../models' | 4 | import { JobState, JobType } from '../../models' |
4 | import { wait } from '../miscs' | ||
5 | import { PeerTubeServer } from './server' | 5 | import { PeerTubeServer } from './server' |
6 | 6 | ||
7 | async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) { | 7 | async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) { |
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index 339b9cabb..617069b11 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts | |||
@@ -1,14 +1,14 @@ | |||
1 | import { ChildProcess, fork } from 'child_process' | 1 | import { ChildProcess, fork } from 'child_process' |
2 | import { copy } from 'fs-extra' | 2 | import { copy } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root, randomInt } from '@shared/core-utils' | 4 | import { parallelTests, randomInt, root } from '@shared/core-utils' |
5 | import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '../../models/videos' | 5 | import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '@shared/models' |
6 | import { BulkCommand } from '../bulk' | 6 | import { BulkCommand } from '../bulk' |
7 | import { CLICommand } from '../cli' | 7 | import { CLICommand } from '../cli' |
8 | import { CustomPagesCommand } from '../custom-pages' | 8 | import { CustomPagesCommand } from '../custom-pages' |
9 | import { FeedCommand } from '../feeds' | 9 | import { FeedCommand } from '../feeds' |
10 | import { LogsCommand } from '../logs' | 10 | import { LogsCommand } from '../logs' |
11 | import { parallelTests, SQLCommand } from '../miscs' | 11 | import { SQLCommand } from '../miscs' |
12 | import { AbusesCommand } from '../moderation' | 12 | import { AbusesCommand } from '../moderation' |
13 | import { OverviewsCommand } from '../overviews' | 13 | import { OverviewsCommand } from '../overviews' |
14 | import { SearchCommand } from '../search' | 14 | import { SearchCommand } from '../search' |
@@ -33,11 +33,11 @@ import { ContactFormCommand } from './contact-form-command' | |||
33 | import { DebugCommand } from './debug-command' | 33 | import { DebugCommand } from './debug-command' |
34 | import { FollowsCommand } from './follows-command' | 34 | import { FollowsCommand } from './follows-command' |
35 | import { JobsCommand } from './jobs-command' | 35 | import { JobsCommand } from './jobs-command' |
36 | import { ObjectStorageCommand } from './object-storage-command' | ||
36 | import { PluginsCommand } from './plugins-command' | 37 | import { PluginsCommand } from './plugins-command' |
37 | import { RedundancyCommand } from './redundancy-command' | 38 | import { RedundancyCommand } from './redundancy-command' |
38 | import { ServersCommand } from './servers-command' | 39 | import { ServersCommand } from './servers-command' |
39 | import { StatsCommand } from './stats-command' | 40 | import { StatsCommand } from './stats-command' |
40 | import { ObjectStorageCommand } from './object-storage-command' | ||
41 | 41 | ||
42 | export type RunServerOptions = { | 42 | export type RunServerOptions = { |
43 | hideLogs?: boolean | 43 | hideLogs?: boolean |
diff --git a/shared/server-commands/server/servers-command.ts b/shared/server-commands/server/servers-command.ts index 47420c95f..c5d8d18dc 100644 --- a/shared/server-commands/server/servers-command.ts +++ b/shared/server-commands/server/servers-command.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { exec } from 'child_process' | 1 | import { exec } from 'child_process' |
2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' | 2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' |
3 | import { basename, join } from 'path' | 3 | import { basename, join } from 'path' |
4 | import { root } from '@shared/core-utils' | 4 | import { isGithubCI, root, wait } from '@shared/core-utils' |
5 | import { getFileSize } from '@shared/extra-utils' | ||
5 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
6 | import { getFileSize, isGithubCI, wait } from '../miscs' | ||
7 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 7 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
8 | 8 | ||
9 | export class ServersCommand extends AbstractCommand { | 9 | export class ServersCommand extends AbstractCommand { |
diff --git a/shared/server-commands/server/servers.ts b/shared/server-commands/server/servers.ts index 21ab9405b..0faee3a8d 100644 --- a/shared/server-commands/server/servers.ts +++ b/shared/server-commands/server/servers.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ensureDir } from 'fs-extra' | 1 | import { ensureDir } from 'fs-extra' |
2 | import { isGithubCI } from '../miscs' | 2 | import { isGithubCI } from '@shared/core-utils' |
3 | import { PeerTubeServer, RunServerOptions } from './server' | 3 | import { PeerTubeServer, RunServerOptions } from './server' |
4 | 4 | ||
5 | async function createSingleServer (serverNumber: number, configOverride?: Object, options: RunServerOptions = {}) { | 5 | async function createSingleServer (serverNumber: number, configOverride?: Object, options: RunServerOptions = {}) { |
diff --git a/shared/server-commands/shared/abstract-command.ts b/shared/server-commands/shared/abstract-command.ts index a57c857fc..1b53a5330 100644 --- a/shared/server-commands/shared/abstract-command.ts +++ b/shared/server-commands/shared/abstract-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { isAbsolute, join } from 'path' | 1 | import { isAbsolute, join } from 'path' |
2 | import { root } from '../miscs/tests' | 2 | import { root } from '@shared/core-utils' |
3 | import { | 3 | import { |
4 | makeDeleteRequest, | 4 | makeDeleteRequest, |
5 | makeGetRequest, | 5 | makeGetRequest, |
diff --git a/shared/server-commands/users/accounts-command.ts b/shared/server-commands/users/accounts-command.ts index 98d9d5927..5844b330b 100644 --- a/shared/server-commands/users/accounts-command.ts +++ b/shared/server-commands/users/accounts-command.ts | |||
@@ -1,6 +1,4 @@ | |||
1 | import { HttpStatusCode, ResultList } from '@shared/models' | 1 | import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@shared/models' |
2 | import { Account, ActorFollow } from '../../models/actors' | ||
3 | import { AccountVideoRate, VideoRateType } from '../../models/videos' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 3 | ||
6 | export class AccountsCommand extends AbstractCommand { | 4 | export class AccountsCommand extends AbstractCommand { |
diff --git a/shared/server-commands/users/index.ts b/shared/server-commands/users/index.ts index 460a06f70..c2bc5c44f 100644 --- a/shared/server-commands/users/index.ts +++ b/shared/server-commands/users/index.ts | |||
@@ -1,9 +1,7 @@ | |||
1 | export * from './accounts-command' | 1 | export * from './accounts-command' |
2 | export * from './actors' | ||
3 | export * from './blocklist-command' | 2 | export * from './blocklist-command' |
4 | export * from './login' | 3 | export * from './login' |
5 | export * from './login-command' | 4 | export * from './login-command' |
6 | export * from './notifications' | ||
7 | export * from './notifications-command' | 5 | export * from './notifications-command' |
8 | export * from './subscriptions-command' | 6 | export * from './subscriptions-command' |
9 | export * from './users-command' | 7 | export * from './users-command' |
diff --git a/shared/server-commands/users/notifications-command.ts b/shared/server-commands/users/notifications-command.ts index 692420b8b..6bd815daa 100644 --- a/shared/server-commands/users/notifications-command.ts +++ b/shared/server-commands/users/notifications-command.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { HttpStatusCode, ResultList } from '@shared/models' | 1 | import { HttpStatusCode, ResultList, UserNotification, UserNotificationSetting } from '@shared/models' |
2 | import { UserNotification, UserNotificationSetting } from '../../models/users' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 3 | ||
5 | export class NotificationsCommand extends AbstractCommand { | 4 | export class NotificationsCommand extends AbstractCommand { |
diff --git a/shared/server-commands/users/users-command.ts b/shared/server-commands/users/users-command.ts index 90c5f2183..b5ae9008e 100644 --- a/shared/server-commands/users/users-command.ts +++ b/shared/server-commands/users/users-command.ts | |||
@@ -4,6 +4,7 @@ import { | |||
4 | HttpStatusCode, | 4 | HttpStatusCode, |
5 | MyUser, | 5 | MyUser, |
6 | ResultList, | 6 | ResultList, |
7 | ScopedToken, | ||
7 | User, | 8 | User, |
8 | UserAdminFlag, | 9 | UserAdminFlag, |
9 | UserCreateResult, | 10 | UserCreateResult, |
@@ -13,7 +14,6 @@ import { | |||
13 | UserVideoQuota, | 14 | UserVideoQuota, |
14 | UserVideoRate | 15 | UserVideoRate |
15 | } from '@shared/models' | 16 | } from '@shared/models' |
16 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | ||
17 | import { unwrapBody } from '../requests' | 17 | import { unwrapBody } from '../requests' |
18 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 18 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
19 | 19 | ||
diff --git a/shared/server-commands/videos/blacklist-command.ts b/shared/server-commands/videos/blacklist-command.ts index 3a2ef89ba..47e23ebc8 100644 --- a/shared/server-commands/videos/blacklist-command.ts +++ b/shared/server-commands/videos/blacklist-command.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | 1 | ||
2 | import { HttpStatusCode, ResultList } from '@shared/models' | 2 | import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models' |
3 | import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 4 | ||
6 | export class BlacklistCommand extends AbstractCommand { | 5 | export class BlacklistCommand extends AbstractCommand { |
diff --git a/shared/server-commands/videos/captions-command.ts b/shared/server-commands/videos/captions-command.ts index a65ea99e3..62bf9c5e6 100644 --- a/shared/server-commands/videos/captions-command.ts +++ b/shared/server-commands/videos/captions-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
1 | import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models' | 2 | import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models' |
2 | import { buildAbsoluteFixturePath } from '../miscs' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class CaptionsCommand extends AbstractCommand { | 5 | export class CaptionsCommand extends AbstractCommand { |
diff --git a/shared/server-commands/videos/channels-command.ts b/shared/server-commands/videos/channels-command.ts index e406e570b..8ab124658 100644 --- a/shared/server-commands/videos/channels-command.ts +++ b/shared/server-commands/videos/channels-command.ts | |||
@@ -1,7 +1,13 @@ | |||
1 | import { pick } from '@shared/core-utils' | 1 | import { pick } from '@shared/core-utils' |
2 | import { ActorFollow, HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' | 2 | import { |
3 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' | 3 | ActorFollow, |
4 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' | 4 | HttpStatusCode, |
5 | ResultList, | ||
6 | VideoChannel, | ||
7 | VideoChannelCreate, | ||
8 | VideoChannelCreateResult, | ||
9 | VideoChannelUpdate | ||
10 | } from '@shared/models' | ||
5 | import { unwrapBody } from '../requests' | 11 | import { unwrapBody } from '../requests' |
6 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 12 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
7 | 13 | ||
diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.ts index 26e663f46..68a188b21 100644 --- a/shared/server-commands/videos/index.ts +++ b/shared/server-commands/videos/index.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | export * from './blacklist-command' | 1 | export * from './blacklist-command' |
2 | export * from './captions-command' | 2 | export * from './captions-command' |
3 | export * from './captions' | ||
4 | export * from './change-ownership-command' | 3 | export * from './change-ownership-command' |
5 | export * from './channels' | 4 | export * from './channels' |
6 | export * from './channels-command' | 5 | export * from './channels-command' |
@@ -10,10 +9,7 @@ export * from './imports-command' | |||
10 | export * from './live-command' | 9 | export * from './live-command' |
11 | export * from './live' | 10 | export * from './live' |
12 | export * from './playlists-command' | 11 | export * from './playlists-command' |
13 | export * from './playlists' | ||
14 | export * from './services-command' | 12 | export * from './services-command' |
15 | export * from './streaming-playlists-command' | 13 | export * from './streaming-playlists-command' |
16 | export * from './streaming-playlists' | ||
17 | export * from './comments-command' | 14 | export * from './comments-command' |
18 | export * from './videos-command' | 15 | export * from './videos-command' |
19 | export * from './videos' | ||
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts index 74f5d3089..f7816eca0 100644 --- a/shared/server-commands/videos/live-command.ts +++ b/shared/server-commands/videos/live-command.ts | |||
@@ -3,8 +3,8 @@ | |||
3 | import { readdir } from 'fs-extra' | 3 | import { readdir } from 'fs-extra' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { wait } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' | 7 | import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' |
7 | import { wait } from '../miscs' | ||
8 | import { unwrapBody } from '../requests' | 8 | import { unwrapBody } from '../requests' |
9 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 9 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
10 | import { sendRTMPStream, testFfmpegStreamError } from './live' | 10 | import { sendRTMPStream, testFfmpegStreamError } from './live' |
diff --git a/shared/server-commands/videos/live.ts b/shared/server-commands/videos/live.ts index d3665bc90..7a7faa911 100644 --- a/shared/server-commands/videos/live.ts +++ b/shared/server-commands/videos/live.ts | |||
@@ -1,10 +1,5 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' | 1 | import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' |
5 | import { pathExists, readdir } from 'fs-extra' | 2 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' |
6 | import { join } from 'path' | ||
7 | import { buildAbsoluteFixturePath, wait } from '../miscs' | ||
8 | import { PeerTubeServer } from '../server/server' | 3 | import { PeerTubeServer } from '../server/server' |
9 | 4 | ||
10 | function sendRTMPStream (options: { | 5 | function sendRTMPStream (options: { |
@@ -95,43 +90,11 @@ async function waitUntilLiveSavedOnAllServers (servers: PeerTubeServer[], videoI | |||
95 | } | 90 | } |
96 | } | 91 | } |
97 | 92 | ||
98 | async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) { | ||
99 | const basePath = server.servers.buildDirectory('streaming-playlists') | ||
100 | const hlsPath = join(basePath, 'hls', videoUUID) | ||
101 | |||
102 | if (resolutions.length === 0) { | ||
103 | const result = await pathExists(hlsPath) | ||
104 | expect(result).to.be.false | ||
105 | |||
106 | return | ||
107 | } | ||
108 | |||
109 | const files = await readdir(hlsPath) | ||
110 | |||
111 | // fragmented file and playlist per resolution + master playlist + segments sha256 json file | ||
112 | expect(files).to.have.lengthOf(resolutions.length * 2 + 2) | ||
113 | |||
114 | for (const resolution of resolutions) { | ||
115 | const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`)) | ||
116 | expect(fragmentedFile).to.exist | ||
117 | |||
118 | const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`)) | ||
119 | expect(playlistFile).to.exist | ||
120 | } | ||
121 | |||
122 | const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8')) | ||
123 | expect(masterPlaylistFile).to.exist | ||
124 | |||
125 | const shaFile = files.find(f => f.endsWith('-segments-sha256.json')) | ||
126 | expect(shaFile).to.exist | ||
127 | } | ||
128 | |||
129 | export { | 93 | export { |
130 | sendRTMPStream, | 94 | sendRTMPStream, |
131 | waitFfmpegUntilError, | 95 | waitFfmpegUntilError, |
132 | testFfmpegStreamError, | 96 | testFfmpegStreamError, |
133 | stopFfmpeg, | 97 | stopFfmpeg, |
134 | waitUntilLivePublishedOnAllServers, | 98 | waitUntilLivePublishedOnAllServers, |
135 | waitUntilLiveSavedOnAllServers, | 99 | waitUntilLiveSavedOnAllServers |
136 | checkLiveCleanupAfterSave | ||
137 | } | 100 | } |
diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts index 8ea828b40..ead57b9aa 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/shared/server-commands/videos/videos-command.ts | |||
@@ -5,8 +5,7 @@ import { createReadStream, stat } from 'fs-extra' | |||
5 | import got, { Response as GotResponse } from 'got' | 5 | import got, { Response as GotResponse } from 'got' |
6 | import { omit } from 'lodash' | 6 | import { omit } from 'lodash' |
7 | import validator from 'validator' | 7 | import validator from 'validator' |
8 | import { buildUUID } from '@shared/core-utils/uuid' | 8 | import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils' |
9 | import { pick } from '@shared/core-utils' | ||
10 | import { | 9 | import { |
11 | HttpStatusCode, | 10 | HttpStatusCode, |
12 | ResultList, | 11 | ResultList, |
@@ -20,7 +19,6 @@ import { | |||
20 | VideosCommonQuery, | 19 | VideosCommonQuery, |
21 | VideoTranscodingCreate | 20 | VideoTranscodingCreate |
22 | } from '@shared/models' | 21 | } from '@shared/models' |
23 | import { buildAbsoluteFixturePath, wait } from '../miscs' | ||
24 | import { unwrapBody } from '../requests' | 22 | import { unwrapBody } from '../requests' |
25 | import { waitJobs } from '../server' | 23 | import { waitJobs } from '../server' |
26 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 24 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/server-commands/videos/videos.ts b/shared/server-commands/videos/videos.ts deleted file mode 100644 index 2c3464aa8..000000000 --- a/shared/server-commands/videos/videos.ts +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { pathExists, readdir } from 'fs-extra' | ||
5 | import { basename, join } from 'path' | ||
6 | import { HttpStatusCode, VideoCaption, VideoDetails } from '@shared/models' | ||
7 | import { waitJobs } from '../server' | ||
8 | import { PeerTubeServer } from '../server/server' | ||
9 | import { VideoEdit } from './videos-command' | ||
10 | |||
11 | async function checkVideoFilesWereRemoved (options: { | ||
12 | server: PeerTubeServer | ||
13 | video: VideoDetails | ||
14 | captions?: VideoCaption[] | ||
15 | onlyVideoFiles?: boolean // default false | ||
16 | }) { | ||
17 | const { video, server, captions = [], onlyVideoFiles = false } = options | ||
18 | |||
19 | const webtorrentFiles = video.files || [] | ||
20 | const hlsFiles = video.streamingPlaylists[0]?.files || [] | ||
21 | |||
22 | const thumbnailName = basename(video.thumbnailPath) | ||
23 | const previewName = basename(video.previewPath) | ||
24 | |||
25 | const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl)) | ||
26 | |||
27 | const captionNames = captions.map(c => basename(c.captionPath)) | ||
28 | |||
29 | const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl)) | ||
30 | const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl)) | ||
31 | |||
32 | let directories: { [ directory: string ]: string[] } = { | ||
33 | videos: webtorrentFilenames, | ||
34 | redundancy: webtorrentFilenames, | ||
35 | [join('playlists', 'hls')]: hlsFilenames, | ||
36 | [join('redundancy', 'hls')]: hlsFilenames | ||
37 | } | ||
38 | |||
39 | if (onlyVideoFiles !== true) { | ||
40 | directories = { | ||
41 | ...directories, | ||
42 | |||
43 | thumbnails: [ thumbnailName ], | ||
44 | previews: [ previewName ], | ||
45 | torrents: torrentNames, | ||
46 | captions: captionNames | ||
47 | } | ||
48 | } | ||
49 | |||
50 | for (const directory of Object.keys(directories)) { | ||
51 | const directoryPath = server.servers.buildDirectory(directory) | ||
52 | |||
53 | const directoryExists = await pathExists(directoryPath) | ||
54 | if (directoryExists === false) continue | ||
55 | |||
56 | const existingFiles = await readdir(directoryPath) | ||
57 | for (const existingFile of existingFiles) { | ||
58 | for (const shouldNotExist of directories[directory]) { | ||
59 | expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist) | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | |||
65 | async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) { | ||
66 | for (const server of servers) { | ||
67 | server.store.videoDetails = await server.videos.get({ id: uuid }) | ||
68 | } | ||
69 | } | ||
70 | |||
71 | function checkUploadVideoParam ( | ||
72 | server: PeerTubeServer, | ||
73 | token: string, | ||
74 | attributes: Partial<VideoEdit>, | ||
75 | expectedStatus = HttpStatusCode.OK_200, | ||
76 | mode: 'legacy' | 'resumable' = 'legacy' | ||
77 | ) { | ||
78 | return mode === 'legacy' | ||
79 | ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus }) | ||
80 | : server.videos.buildResumeUpload({ token, attributes, expectedStatus }) | ||
81 | } | ||
82 | |||
83 | // serverNumber starts from 1 | ||
84 | async function uploadRandomVideoOnServers ( | ||
85 | servers: PeerTubeServer[], | ||
86 | serverNumber: number, | ||
87 | additionalParams?: VideoEdit & { prefixName?: string } | ||
88 | ) { | ||
89 | const server = servers.find(s => s.serverNumber === serverNumber) | ||
90 | const res = await server.videos.randomUpload({ wait: false, additionalParams }) | ||
91 | |||
92 | await waitJobs(servers) | ||
93 | |||
94 | return res | ||
95 | } | ||
96 | |||
97 | // --------------------------------------------------------------------------- | ||
98 | |||
99 | export { | ||
100 | checkUploadVideoParam, | ||
101 | uploadRandomVideoOnServers, | ||
102 | checkVideoFilesWereRemoved, | ||
103 | saveVideoInServers | ||
104 | } | ||