ActivityPub-federated video streaming platform using P2P directly in your web browser
Move test functions outside extra-utils
Chocobozzzc55e3d7227fe
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.tsindex 42f4f6096f..5ada4a8052 100644--- a/server/controllers/api/users/token.ts+++ b/server/controllers/api/users/token.ts@@ -1,13 +1,13 @@import express from 'express'import RateLimit from 'express-rate-limit'import { logger } from '@server/helpers/logger'-import { buildUUID } from '@shared/core-utils/uuid'import { CONFIG } from '@server/initializers/config'import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth'import { handleOAuthToken } from '@server/lib/auth/oauth'import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model'import { Hooks } from '@server/lib/plugins/hooks'import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares'+import { buildUUID } from '@shared/core-utils'import { ScopedToken } from '@shared/models/users/user-scoped-token'const tokensRouter = express.Router()diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.tsindex f8f07b1c63..dc19477643 100644--- a/server/controllers/api/video-playlist.ts+++ b/server/controllers/api/video-playlist.ts@@ -1,10 +1,10 @@import express from 'express'import { join } from 'path'-import { uuidToShort } from '@shared/core-utils/uuid'import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'import { Hooks } from '@server/lib/plugins/hooks'import { getServerActor } from '@server/models/application/application'import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'+import { uuidToShort } from '@shared/core-utils'import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'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.tsindex e466d041be..4ee39aa4ff 100644--- a/server/controllers/api/videos/live.ts+++ b/server/controllers/api/videos/live.ts@@ -1,6 +1,5 @@import express from 'express'import { createReqFiles } from '@server/helpers/express-utils'-import { buildUUID, uuidToShort } from '@shared/core-utils/uuid'import { CONFIG } from '@server/initializers/config'import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants'import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'@@ -10,6 +9,7 @@ import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } froimport { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live'import { VideoLiveModel } from '@server/models/video/video-live'import { MVideoDetails, MVideoFullLight } from '@server/types/models'+import { buildUUID, uuidToShort } from '@shared/core-utils'import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'import { logger } from '../../../helpers/logger'diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.tsindex a4d0f980fb..9f620c04d3 100644--- a/server/controllers/api/videos/upload.ts+++ b/server/controllers/api/videos/upload.ts@@ -1,9 +1,7 @@import express from 'express'import { move } from 'fs-extra'import { basename } from 'path'-import { getLowercaseExtension } from '@shared/core-utils'import { getResumableUploadPath } from '@server/helpers/upload'-import { uuidToShort } from '@shared/core-utils/uuid'import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'import { generateWebTorrentVideoFilename } from '@server/lib/paths'@@ -20,6 +18,7 @@ import { VideoPathManager } from '@server/lib/video-path-manager'import { buildNextVideoState } from '@server/lib/video-state'import { openapiOperationDoc } from '@server/middlewares/doc'import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'+import { getLowercaseExtension, uuidToShort } from '@shared/core-utils'import { VideoCreate, VideoState } from '../../../../shared'import { HttpStatusCode } from '../../../../shared/models'import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.tsindex eaabdbbea2..65578c1438 100644--- a/server/helpers/custom-validators/misc.ts+++ b/server/helpers/custom-validators/misc.ts@@ -2,7 +2,7 @@ import 'multer'import { UploadFilesForCheck } from 'express'import { sep } from 'path'import validator from 'validator'-import { isShortUUID, shortToUUID } from '@shared/core-utils/uuid'+import { isShortUUID, shortToUUID } from '@shared/core-utils'function exists (value: any) {return value !== undefined && value !== nulldiff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.tsindex ced2880451..c4704b189f 100644--- a/server/helpers/image-utils.ts+++ b/server/helpers/image-utils.ts@@ -1,9 +1,8 @@import { copy, readFile, remove, rename } from 'fs-extra'import Jimp, { read } from 'jimp'-import { getLowercaseExtension } from '@shared/core-utils'+import { buildUUID, getLowercaseExtension } from '@shared/core-utils'import { convertWebPToJPG, processGIF } from './ffmpeg-utils'import { logger } from './logger'-import { buildUUID } from '@shared/core-utils/uuid'function generateImageFilename (extension = '.jpg') {return buildUUID() + extensiondiff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.tsindex 31705e7fa7..66a353204a 100644--- a/server/helpers/peertube-crypto.ts+++ b/server/helpers/peertube-crypto.ts@@ -4,7 +4,7 @@ import { Request } from 'express'import { cloneDeep } from 'lodash'import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'import { MActor } from '../types/models'-import { sha256 } from '@shared/core-utils/crypto'+import { sha256 } from '@shared/core-utils/common/crypto'import { createPrivateKey, getPublicKey, promisify1, promisify2 } from './core-utils'import { jsonld } from './custom-jsonld-signature'import { logger } from './logger'diff --git a/server/helpers/utils.ts b/server/helpers/utils.tsindex 882f808aba..d6a3dae955 100644--- a/server/helpers/utils.ts+++ b/server/helpers/utils.ts@@ -3,7 +3,7 @@ import { Instance as ParseTorrent } from 'parse-torrent'import { join } from 'path'import { ResultList } from '../../shared'import { CONFIG } from '../initializers/config'-import { sha256 } from '@shared/core-utils/crypto'+import { sha256 } from '@shared/core-utils/common/crypto'import { execPromise, execPromise2, randomBytesPromise } from './core-utils'import { logger } from './logger'diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.tsindex 67cb3971d4..03663d73c4 100644--- a/server/helpers/webtorrent.ts+++ b/server/helpers/webtorrent.ts@@ -15,7 +15,7 @@ import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/videimport { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist'import { CONFIG } from '../initializers/config'import { promisify2 } from './core-utils'-import { sha1 } from '@shared/core-utils/crypto'+import { sha1 } from '@shared/core-utils/common/crypto'import { logger } from './logger'import { generateVideoImportTmpPath } from './utils'import { extractVideo } from './video'diff --git a/server/initializers/constants.ts b/server/initializers/constants.tsindex 258ccdb51e..57f7af789c 100644--- a/server/initializers/constants.ts+++ b/server/initializers/constants.ts@@ -2,7 +2,7 @@ import { CronRepeatOptions, EveryRepeatOptions } from 'bull'import { randomBytes } from 'crypto'import { invert } from 'lodash'import { join } from 'path'-import { randomInt } from '../../shared/core-utils/common/miscs'+import { randomInt, root } from '@shared/core-utils'import {AbuseState,JobType,@@ -18,7 +18,6 @@ import { FollowState } from '../../shared/models/actors'import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'-import { root } from '../../shared/core-utils'// Do not use barrels, remain constants as independent as possibleimport { isTestInstance, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'import { CONFIG, registerConfigChangedHandler } from './config'diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.tsindex 82971c9f57..221475bb14 100644--- a/server/initializers/migrations/0080-video-channels.ts+++ b/server/initializers/migrations/0080-video-channels.ts@@ -1,4 +1,4 @@-import { buildUUID } from '@shared/core-utils/uuid'+import { buildUUID } from '@shared/core-utils'import * as Sequelize from 'sequelize'async function up (utils: {diff --git a/server/initializers/migrations/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.tsindex 5cc52e7ee9..fb27c93012 100644--- a/server/initializers/migrations/0345-video-playlists.ts+++ b/server/initializers/migrations/0345-video-playlists.ts@@ -1,5 +1,5 @@import * as Sequelize from 'sequelize'-import { buildUUID } from '@shared/core-utils/uuid'+import { buildUUID } from '@shared/core-utils'import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'import { WEBSERVER } from '../constants'diff --git a/server/initializers/migrations/0560-user-feed-token.ts b/server/initializers/migrations/0560-user-feed-token.tsindex 961777e357..4ed4d96817 100644--- a/server/initializers/migrations/0560-user-feed-token.ts+++ b/server/initializers/migrations/0560-user-feed-token.ts@@ -1,5 +1,5 @@import * as Sequelize from 'sequelize'-import { buildUUID } from '@shared/core-utils/uuid'+import { buildUUID } from '@shared/core-utils'async function up (utils: {transaction: Sequelize.Transactiondiff --git a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts b/server/lib/activitypub/actors/shared/object-to-model-attributes.tsindex 1ad89ac568..38d93c1085 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 @@-import { getLowercaseExtension } from '@shared/core-utils'import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'-import { buildUUID } from '@shared/core-utils/uuid'import { MIMETYPES } from '@server/initializers/constants'import { ActorModel } from '@server/models/actor/actor'import { FilteredModelAttributes } from '@server/types'+import { buildUUID, getLowercaseExtension } from '@shared/core-utils'import { ActivityPubActor, ActorImageType } from '@shared/models'function getActorAttributesFromObject (diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.tsindex 47bc8c0556..dc0022852d 100644--- a/server/lib/auth/oauth.ts+++ b/server/lib/auth/oauth.ts@@ -8,7 +8,7 @@ import {UnauthorizedClientError,UnsupportedGrantTypeError} from 'oauth2-server'-import { sha1 } from '@shared/core-utils/crypto'+import { sha1 } from '@shared/core-utils/common/crypto'import { randomBytesPromise } from '@server/helpers/core-utils'import { MOAuthClient } from '@server/types/models'import { OAUTH_LIFETIME } from '../../initializers/constants'diff --git a/server/lib/client-html.ts b/server/lib/client-html.tsindex dee7ca8edd..91708839bb 100644--- a/server/lib/client-html.ts+++ b/server/lib/client-html.ts@@ -9,7 +9,7 @@ import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } fromimport { HttpStatusCode } from '../../shared/models/http/http-error-codes'import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'import { isTestInstance } from '../helpers/core-utils'-import { sha256 } from '@shared/core-utils/crypto'+import { sha256 } from '@shared/core-utils/common/crypto'import { logger } from '../helpers/logger'import { mdToPlainText } from '../helpers/markdown'import { CONFIG } from '../initializers/config'diff --git a/server/lib/hls.ts b/server/lib/hls.tsindex 220b7733b5..e4904be5f3 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,import { flatten, uniq } from 'lodash'import { basename, dirname, join } from 'path'import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models'-import { sha256 } from '@shared/core-utils/crypto'+import { sha256 } from '@shared/core-utils/common/crypto'import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils'import { logger } from '../helpers/logger'import { doRequest, doRequestAndSaveToFile } from '../helpers/requests'diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.tsindex 572696f2ac..04ad98f3e4 100644--- a/server/lib/local-actor.ts+++ b/server/lib/local-actor.ts@@ -2,9 +2,8 @@ import 'multer'import { queue } from 'async'import LRUCache from 'lru-cache'import { join } from 'path'-import { getLowercaseExtension } from '@shared/core-utils'-import { buildUUID } from '@shared/core-utils/uuid'import { ActorModel } from '@server/models/actor/actor'+import { buildUUID, getLowercaseExtension } from '@shared/core-utils'import { ActivityPubActorType, ActorImageType } from '@shared/models'import { retryTransactionWrapper } from '../helpers/database-utils'import { processImage } from '../helpers/image-utils'diff --git a/server/lib/paths.ts b/server/lib/paths.tsindex d8cf812e3b..bf0c3a86b7 100644--- a/server/lib/paths.ts+++ b/server/lib/paths.ts@@ -1,9 +1,8 @@import { join } from 'path'-import { buildUUID } from '@shared/core-utils/uuid'import { CONFIG } from '@server/initializers/config'import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models'-import { removeFragmentedMP4Ext } from '@shared/core-utils'+import { buildUUID, removeFragmentedMP4Ext } from '@shared/core-utils'// ################## Video file name ##################diff --git a/server/lib/user.ts b/server/lib/user.tsindex 230bf37d0f..3ba0c0ca4b 100644--- a/server/lib/user.ts+++ b/server/lib/user.ts@@ -1,7 +1,7 @@import { Transaction } from 'sequelize/types'-import { buildUUID } from '@shared/core-utils/uuid'import { UserModel } from '@server/models/user/user'import { MActorDefault } from '@server/types/models/actor'+import { buildUUID } from '@shared/core-utils'import { ActivityPubActorType } from '../../shared/models/activitypub'import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'diff --git a/server/lib/video-path-manager.ts b/server/lib/video-path-manager.tsindex 429b36df98..4027f885d1 100644--- a/server/lib/video-path-manager.ts+++ b/server/lib/video-path-manager.ts@@ -1,6 +1,5 @@import { remove } from 'fs-extra'import { extname, join } from 'path'-import { buildUUID } from '@shared/core-utils/uuid'import { extractVideo } from '@server/helpers/video'import { CONFIG } from '@server/initializers/config'import {@@ -11,6 +10,7 @@ import {MVideoFileVideo,MVideoUUID} from '@server/types/models'+import { buildUUID } from '@shared/core-utils'import { VideoStorage } from '@shared/models'import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage'import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths'diff --git a/server/models/user/user-notification.ts b/server/models/user/user-notification.tsindex 4a9a84a5bd..d71bb4d561 100644--- a/server/models/user/user-notification.ts+++ b/server/models/user/user-notification.ts@@ -1,7 +1,7 @@import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize'import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'-import { uuidToShort } from '@shared/core-utils/uuid'import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user'+import { uuidToShort } from '@shared/core-utils'import { AttributesOnly } from '@shared/typescript-utils'import { UserNotification, UserNotificationType } from '../../../shared'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.tsindex f6c750ccf5..99a4818ab0 100644--- a/server/models/video/formatter/video-format-utils.ts+++ b/server/models/video/formatter/video-format-utils.ts@@ -1,7 +1,7 @@-import { uuidToShort } from '@shared/core-utils/uuid'import { generateMagnetUri } from '@server/helpers/webtorrent'import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls'import { VideoViews } from '@server/lib/video-views'+import { uuidToShort } from '@shared/core-utils'import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models'import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects'import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos'diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.tsindex 642613cfe8..20741ea64b 100644--- a/server/models/video/video-caption.ts+++ b/server/models/video/video-caption.ts@@ -15,8 +15,8 @@ import {Table,UpdatedAt} from 'sequelize-typescript'-import { buildUUID } from '@shared/core-utils/uuid'import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'+import { buildUUID } from '@shared/core-utils'import { AttributesOnly } from '@shared/typescript-utils'import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.tsindex 132fa0e680..07bb648107 100644--- a/server/models/video/video-playlist.ts+++ b/server/models/video/video-playlist.ts@@ -18,8 +18,7 @@ import {UpdatedAt} from 'sequelize-typescript'import { MAccountId, MChannelId } from '@server/types/models'-import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'-import { buildUUID, uuidToShort } from '@shared/core-utils/uuid'+import { buildPlaylistEmbedPath, buildPlaylistWatchPath, buildUUID, pick, uuidToShort } from '@shared/core-utils'import { AttributesOnly } from '@shared/typescript-utils'import { ActivityIconObject } from '../../../shared/models/activitypub/objects'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.tsindex d813f89b5a..7b410f8eea 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'import { AttributesOnly } from '@shared/typescript-utils'import { VideoStorage } from '@shared/models'import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'-import { sha1 } from '@shared/core-utils/crypto'+import { sha1 } from '@shared/core-utils/common/crypto'import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'import { isArrayOf } from '../../helpers/custom-validators/misc'import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex a99b012b9d..66a9a28fa0 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -32,8 +32,7 @@ import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths'import { VideoPathManager } from '@server/lib/video-path-manager'import { getServerActor } from '@server/models/application/application'import { ModelCache } from '@server/models/model-cache'-import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'-import { uuidToShort } from '@shared/core-utils/uuid'+import { buildVideoEmbedPath, buildVideoWatchPath, pick, uuidToShort } from '@shared/core-utils'import { VideoFile, VideoInclude } from '@shared/models'import { AttributesOnly } from '@shared/typescript-utils'import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.tsindex c3368c7ebf..7a443b5535 100644--- a/server/tests/api/activitypub/cleaner.ts+++ b/server/tests/api/activitypub/cleaner.ts@@ -2,13 +2,13 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'import {cleanupTests,createMultipleServers,doubleFollow,PeerTubeServer,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.tsindex 93bf01842d..cc71e82eaa 100644--- a/server/tests/api/activitypub/fetch.ts+++ b/server/tests/api/activitypub/fetch.ts@@ -2,7 +2,14 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.tsindex 5aa94af5d9..25e1d98234 100644--- a/server/tests/api/activitypub/helpers.ts+++ b/server/tests/api/activitypub/helpers.ts@@ -3,7 +3,8 @@import 'mocha'import { expect } from 'chai'import { cloneDeep } from 'lodash'-import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/server-commands'+import { buildRequestStub } from '@server/tests/shared'+import { buildAbsoluteFixturePath } from '@shared/core-utils'import { buildSignedActivity } from '../../../helpers/activitypub'import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.tsindex 669a86fca5..71e1c40ba6 100644--- a/server/tests/api/activitypub/refresher.ts+++ b/server/tests/api/activitypub/refresher.ts@@ -1,6 +1,8 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,@@ -9,10 +11,8 @@ import {PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,- wait,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'describe('Test AP refresher', function () {let servers: PeerTubeServer[] = []diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.tsindex 3b871ae12d..c4cb5ea0da 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/actiimport { buildDigest } from '@server/helpers/peertube-crypto'import { HTTP_SIGNATURE } from '@server/initializers/constants'import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'-import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/server-commands'import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared'+import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.tsindex 58167cbab9..c4b051723b 100644--- a/server/tests/api/check-params/abuses.ts+++ b/server/tests/api/check-params/abuses.ts@@ -1,11 +1,10 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models'import {AbusesCommand,- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,doubleFollow,@@ -15,7 +14,6 @@ import {setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models'describe('Test abuses API validators', function () {const basePath = '/api/v1/abuses/'diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.tsindex fc8e63ed4f..07f879e0ec 100644--- a/server/tests/api/check-params/accounts.ts+++ b/server/tests/api/check-params/accounts.ts@@ -1,15 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,- cleanupTests,- createSingleServer,- PeerTubeServer-} from '@shared/server-commands'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands'describe('Test accounts API validators', function () {const path = '/api/v1/accounts/'diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.tsindex 2dc3a166de..36526d4944 100644--- a/server/tests/api/check-params/blocklist.ts+++ b/server/tests/api/check-params/blocklist.ts@@ -1,10 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createMultipleServers,doubleFollow,@@ -14,7 +13,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode } from '@shared/models'describe('Test blocklist API validators', function () {let servers: PeerTubeServer[]diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.tsindex a2e51e14d3..9db442b0be 100644--- a/server/tests/api/check-params/contact-form.ts+++ b/server/tests/api/check-params/contact-form.ts@@ -1,15 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { MockSmtpServer } from '@server/tests/shared'import { HttpStatusCode } from '@shared/models'-import {- cleanupTests,- ContactFormCommand,- createSingleServer,- killallServers,- MockSmtpServer,- PeerTubeServer-} from '@shared/server-commands'+import { cleanupTests, ContactFormCommand, createSingleServer, killallServers, PeerTubeServer } from '@shared/server-commands'describe('Test contact form API validators', function () {let server: PeerTubeServerdiff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.tsindex 6121d22022..d4dae5a754 100644--- a/server/tests/api/check-params/follows.ts+++ b/server/tests/api/check-params/follows.ts@@ -1,10 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeDeleteRequest,@@ -13,7 +12,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode } from '@shared/models'describe('Test server follows API validators', function () {let server: PeerTubeServerdiff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.tsindex b7c603755f..d85961d626 100644--- a/server/tests/api/check-params/jobs.ts+++ b/server/tests/api/check-params/jobs.ts@@ -1,17 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,- cleanupTests,- createSingleServer,- makeGetRequest,- PeerTubeServer,- setAccessTokensToServers-} from '@shared/server-commands'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'describe('Test jobs API validators', function () {const path = '/api/v1/jobs/failed'diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.tsindex 8b79d97e09..8aee6164c3 100644--- a/server/tests/api/check-params/live.ts+++ b/server/tests/api/check-params/live.ts@@ -2,8 +2,9 @@import 'mocha'import { omit } from 'lodash'+import { buildAbsoluteFixturePath } from '@shared/core-utils'+import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'import {- buildAbsoluteFixturePath,cleanupTests,createSingleServer,LiveCommand,@@ -14,7 +15,6 @@ import {setAccessTokensToServers,stopFfmpeg} from '@shared/server-commands'-import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'describe('Test video lives API validator', function () {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.tsindex c8ac71476e..95f2122aeb 100644--- a/server/tests/api/check-params/my-user.ts+++ b/server/tests/api/check-params/my-user.ts@@ -1,22 +1,19 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared'+import { buildAbsoluteFixturePath } from '@shared/core-utils'+import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models'import {- buildAbsoluteFixturePath,- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeGetRequest,makePutBodyRequest,makeUploadRequest,- MockSmtpServer,PeerTubeServer,setAccessTokensToServers,UsersCommand} from '@shared/server-commands'-import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models'describe('Test my user API validators', function () {const path = '/api/v1/users/'diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.tsindex 79e4875901..c3f15b86e4 100644--- a/server/tests/api/check-params/plugins.ts+++ b/server/tests/api/check-params/plugins.ts@@ -1,10 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeGetRequest,@@ -13,7 +12,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models'describe('Test server plugins API validators', function () {let server: PeerTubeServerdiff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.tsindex f3bfcb16ca..04519cf23c 100644--- a/server/tests/api/check-params/redundancy.ts+++ b/server/tests/api/check-params/redundancy.ts@@ -1,10 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode, VideoCreateResult } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createMultipleServers,doubleFollow,@@ -16,7 +15,6 @@ import {setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoCreateResult } from '@shared/models'describe('Test server redundancy API validators', function () {let servers: PeerTubeServer[]diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.tsindex edeeed571e..ca0fbf31db 100644--- a/server/tests/api/check-params/search.ts+++ b/server/tests/api/check-params/search.ts@@ -1,17 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,- cleanupTests,- createSingleServer,- makeGetRequest,- PeerTubeServer,- setAccessTokensToServers-} from '@shared/server-commands'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) {return server.config.updateCustomSubConfig({diff --git a/server/tests/api/check-params/transcoding.ts b/server/tests/api/check-params/transcoding.tsindex 11ade9071c..333012940e 100644--- a/server/tests/api/check-params/transcoding.ts+++ b/server/tests/api/check-params/transcoding.ts@@ -1,8 +1,15 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'import { HttpStatusCode, UserRole } from '@shared/models'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'describe('Test transcoding API validators', function () {let servers: PeerTubeServer[]diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.tsindex 02898bb877..deb4a7aa3d 100644--- a/server/tests/api/check-params/upload-quota.ts+++ b/server/tests/api/check-params/upload-quota.ts@@ -2,18 +2,18 @@import 'mocha'import { expect } from 'chai'+import { FIXTURE_URLS } from '@server/tests/shared'import { randomInt } from '@shared/core-utils'+import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'import {cleanupTests,createSingleServer,- FIXTURE_URLS,PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,VideosCommand,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'describe('Test upload quota', function () {let server: PeerTubeServerdiff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.tsindex 912d4a992e..4bc8084a1d 100644--- a/server/tests/api/check-params/user-notifications.ts+++ b/server/tests/api/check-params/user-notifications.ts@@ -2,20 +2,18 @@import 'mocha'import { io } from 'socket.io-client'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeGetRequest,makePostBodyRequest,makePutBodyRequest,PeerTubeServer,- setAccessTokensToServers,- wait+ setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'describe('Test user notifications API validators', function () {let server: PeerTubeServerdiff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.tsindex 95226dff58..a13ed5aa3e 100644--- a/server/tests/api/check-params/user-subscriptions.ts+++ b/server/tests/api/check-params/user-subscriptions.ts@@ -2,9 +2,6 @@import 'mocha'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeDeleteRequest,@@ -15,6 +12,7 @@ import {waitJobs} from '@shared/server-commands'import { HttpStatusCode } from '@shared/models'+import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@server/tests/shared'describe('Test user subscriptions API validators', function () {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.tsindex c98b5e1893..d8353f83bd 100644--- a/server/tests/api/check-params/users-admin.ts+++ b/server/tests/api/check-params/users-admin.ts@@ -2,21 +2,18 @@import 'mocha'import { omit } from 'lodash'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared'+import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,killallServers,makeGetRequest,makePostBodyRequest,makePutBodyRequest,- MockSmtpServer,PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models'describe('Test users admin API validators', function () {const path = '/api/v1/users/'diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.tsindex 254177afd3..84254945c3 100644--- a/server/tests/api/check-params/users.ts+++ b/server/tests/api/check-params/users.ts@@ -2,15 +2,9 @@import 'mocha'import { omit } from 'lodash'-import {- cleanupTests,- createSingleServer,- makePostBodyRequest,- MockSmtpServer,- PeerTubeServer,- setAccessTokensToServers-} from '@shared/server-commands'+import { MockSmtpServer } from '@server/tests/shared'import { HttpStatusCode, UserRole } from '@shared/models'+import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'describe('Test users API validators', function () {const path = '/api/v1/users/'diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.tsindex 7eb3c1cae5..1aab608268 100644--- a/server/tests/api/check-params/video-blacklist.ts+++ b/server/tests/api/check-params/video-blacklist.ts@@ -2,11 +2,10 @@import 'mocha'import { expect } from 'chai'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode, VideoBlacklistType } from '@shared/models'import {BlacklistCommand,- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createMultipleServers,doubleFollow,@@ -16,7 +15,6 @@ import {setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoBlacklistType } from '@shared/models'describe('Test video blacklist API validators', function () {let servers: PeerTubeServer[]diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.tsindex 34c1a9673d..8a88407936 100644--- a/server/tests/api/check-params/video-captions.ts+++ b/server/tests/api/check-params/video-captions.ts@@ -1,8 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { buildAbsoluteFixturePath } from '@shared/core-utils'+import { HttpStatusCode, VideoCreateResult } from '@shared/models'import {- buildAbsoluteFixturePath,cleanupTests,createSingleServer,makeDeleteRequest,@@ -11,7 +12,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, VideoCreateResult } from '@shared/models'describe('Test video captions API validator', function () {const path = '/api/v1/videos/'diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.tsindex 747a5d3ec1..1e9732fe9b 100644--- a/server/tests/api/check-params/video-channels.ts+++ b/server/tests/api/check-params/video-channels.ts@@ -3,12 +3,11 @@import 'mocha'import * as chai from 'chai'import { omit } from 'lodash'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { buildAbsoluteFixturePath } from '@shared/core-utils'+import { HttpStatusCode, VideoChannelUpdate } from '@shared/models'import {- buildAbsoluteFixturePath,ChannelsCommand,- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeGetRequest,@@ -18,7 +17,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, VideoChannelUpdate } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.tsindex 05cf61cba2..63c3582e91 100644--- a/server/tests/api/check-params/video-comments.ts+++ b/server/tests/api/check-params/video-comments.ts@@ -2,10 +2,9 @@import 'mocha'import * as chai from 'chai'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode, VideoCreateResult } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeDeleteRequest,@@ -14,7 +13,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, VideoCreateResult } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/check-params/video-files.ts b/server/tests/api/check-params/video-files.tsindex 90ab4460c5..8c07950923 100644--- a/server/tests/api/check-params/video-files.ts+++ b/server/tests/api/check-params/video-files.ts@@ -1,8 +1,15 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'import { HttpStatusCode, UserRole } from '@shared/models'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'describe('Test videos files', function () {let servers: PeerTubeServer[]diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.tsindex 7cefb2a540..ddea68db4a 100644--- a/server/tests/api/check-params/video-imports.ts+++ b/server/tests/api/check-params/video-imports.ts@@ -2,21 +2,18 @@import 'mocha'import { omit } from 'lodash'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared'+import { buildAbsoluteFixturePath } from '@shared/core-utils'+import { HttpStatusCode, VideoPrivacy } from '@shared/models'import {- buildAbsoluteFixturePath,- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,cleanupTests,createSingleServer,- FIXTURE_URLS,makeGetRequest,makePostBodyRequest,makeUploadRequest,PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, VideoPrivacy } from '@shared/models'describe('Test video imports API validator', function () {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.tsindex ac3c13f78c..4b17ce7db6 100644--- a/server/tests/api/check-params/video-playlists.ts+++ b/server/tests/api/check-params/video-playlists.ts@@ -1,18 +1,7 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,- cleanupTests,- createSingleServer,- makeGetRequest,- PeerTubeServer,- PlaylistsCommand,- setAccessTokensToServers,- setDefaultVideoChannel-} from '@shared/server-commands'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'import {HttpStatusCode,VideoPlaylistCreate,@@ -23,6 +12,15 @@ import {VideoPlaylistReorder,VideoPlaylistType} from '@shared/models'+import {+ cleanupTests,+ createSingleServer,+ makeGetRequest,+ PeerTubeServer,+ PlaylistsCommand,+ setAccessTokensToServers,+ setDefaultVideoChannel+} from '@shared/server-commands'describe('Test video playlists API validator', function () {let server: PeerTubeServerdiff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.tsindex e4b4c4b2ad..31a0752c7b 100644--- a/server/tests/api/check-params/videos-history.ts+++ b/server/tests/api/check-params/videos-history.ts@@ -1,9 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'+import { checkBadCountPagination, checkBadStartPagination } from '@server/tests/shared'+import { HttpStatusCode } from '@shared/models'import {- checkBadCountPagination,- checkBadStartPagination,cleanupTests,createSingleServer,makeGetRequest,@@ -12,7 +12,6 @@ import {PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode } from '@shared/models'describe('Test videos history API validator', function () {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.tsindex 3b2607eed2..4cc70f5cc4 100644--- a/server/tests/api/check-params/videos.ts+++ b/server/tests/api/check-params/videos.ts@@ -4,12 +4,10 @@ import 'mocha'import * as chai from 'chai'import { omit } from 'lodash'import { join } from 'path'-import { randomInt } from '@shared/core-utils'+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared'+import { randomInt, root } from '@shared/core-utils'+import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'import {- checkBadCountPagination,- checkBadSortPagination,- checkBadStartPagination,- checkUploadVideoParam,cleanupTests,createSingleServer,makeDeleteRequest,@@ -17,10 +15,8 @@ import {makePutBodyRequest,makeUploadRequest,PeerTubeServer,- root,setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.tsindex 89880c46be..909399836a 100644--- a/server/tests/api/live/live-constraints.ts+++ b/server/tests/api/live/live-constraints.ts@@ -2,9 +2,9 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'import { VideoPrivacy } from '@shared/models'import {- checkLiveCleanupAfterSave,cleanupTests,ConfigCommand,createMultipleServers,@@ -12,9 +12,9 @@ import {PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,- wait,waitJobs-} from '../../../../shared/server-commands'+} from '@shared/server-commands'+import { checkLiveCleanupAfterSave } from '../../shared'const expect = chai.expectdiff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.tsindex 12a4d64d80..c2392603b2 100644--- a/server/tests/api/live/live-permanent.ts+++ b/server/tests/api/live/live-permanent.ts@@ -2,6 +2,7 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'import {cleanupTests,@@ -12,9 +13,8 @@ import {setAccessTokensToServers,setDefaultVideoChannel,stopFfmpeg,- wait,waitJobs-} from '../../../../shared/server-commands'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/live/live-rtmps.ts b/server/tests/api/live/live-rtmps.tsindex 31e8f906eb..9350619718 100644--- a/server/tests/api/live/live-rtmps.ts+++ b/server/tests/api/live/live-rtmps.ts@@ -2,9 +2,9 @@import 'mocha'import * as chai from 'chai'+import { buildAbsoluteFixturePath } from '@shared/core-utils'import { VideoPrivacy } from '@shared/models'import {- buildAbsoluteFixturePath,cleanupTests,createSingleServer,PeerTubeServer,@@ -14,7 +14,7 @@ import {stopFfmpeg,testFfmpegStreamError,waitUntilLivePublishedOnAllServers-} from '../../../../shared/server-commands'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.tsindex 9fb6b4e544..95a342b015 100644--- a/server/tests/api/live/live-save-replay.ts+++ b/server/tests/api/live/live-save-replay.ts@@ -3,8 +3,10 @@import 'mocha'import * as chai from 'chai'import { FfmpegCommand } from 'fluent-ffmpeg'+import { checkLiveCleanupAfterSave } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'import {- checkLiveCleanupAfterSave,cleanupTests,ConfigCommand,createMultipleServers,@@ -14,12 +16,10 @@ import {setDefaultVideoChannel,stopFfmpeg,testFfmpegStreamError,- wait,waitJobs,waitUntilLivePublishedOnAllServers,waitUntilLiveSavedOnAllServers} from '@shared/server-commands'-import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.tsindex 42cf9c5f67..50b16443ee 100644--- a/server/tests/api/live/live-socket-messages.ts+++ b/server/tests/api/live/live-socket-messages.ts@@ -2,6 +2,7 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'import { VideoPrivacy, VideoState } from '@shared/models'import {cleanupTests,@@ -11,10 +12,9 @@ import {setAccessTokensToServers,setDefaultVideoChannel,stopFfmpeg,- wait,waitJobs,waitUntilLivePublishedOnAllServers-} from '../../../../shared/server-commands'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.tsindex 5de4436bec..446d0913cb 100644--- a/server/tests/api/live/live-views.ts+++ b/server/tests/api/live/live-views.ts@@ -3,6 +3,7 @@import 'mocha'import * as chai from 'chai'import { FfmpegCommand } from 'fluent-ffmpeg'+import { wait } from '@shared/core-utils'import { VideoPrivacy } from '@shared/models'import {cleanupTests,@@ -12,10 +13,9 @@ import {setAccessTokensToServers,setDefaultVideoChannel,stopFfmpeg,- wait,waitJobs,waitUntilLivePublishedOnAllServers-} from '../../../../shared/server-commands'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.tsindex 3869fd6c7d..3f9355d2de 100644--- a/server/tests/api/live/live.ts+++ b/server/tests/api/live/live.ts@@ -4,10 +4,18 @@ import 'mocha'import * as chai from 'chai'import { basename, join } from 'path'import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'+import { checkLiveCleanupAfterSave, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import {+ HttpStatusCode,+ LiveVideo,+ LiveVideoCreate,+ VideoDetails,+ VideoPrivacy,+ VideoState,+ VideoStreamingPlaylistType+} from '@shared/models'import {- checkLiveCleanupAfterSave,- checkLiveSegmentHash,- checkResolutionsInMasterPlaylist,cleanupTests,createMultipleServers,doubleFollow,@@ -20,20 +28,9 @@ import {setDefaultVideoChannel,stopFfmpeg,testFfmpegStreamError,- testImage,- wait,waitJobs,waitUntilLivePublishedOnAllServers} from '@shared/server-commands'-import {- HttpStatusCode,- LiveVideo,- LiveVideoCreate,- VideoDetails,- VideoPrivacy,- VideoState,- VideoStreamingPlaylistType-} from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.tsindex d1e2ea56e8..87d1479987 100644--- a/server/tests/api/moderation/blocklist-notification.ts+++ b/server/tests/api/moderation/blocklist-notification.ts@@ -2,8 +2,15 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'import { UserNotificationType } from '@shared/models'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.tsindex 4e2887fa0c..322e938158 100644--- a/server/tests/api/moderation/video-blacklist.ts+++ b/server/tests/api/moderation/video-blacklist.ts@@ -3,18 +3,18 @@import 'mocha'import * as chai from 'chai'import { orderBy } from 'lodash'+import { FIXTURE_URLS } from '@server/tests/shared'+import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'import {BlacklistCommand,cleanupTests,createMultipleServers,doubleFollow,- FIXTURE_URLS,killallServers,PeerTubeServer,setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.tsindex 18962a71e7..f037e7aaec 100644--- a/server/tests/api/notifications/admin-notifications.ts+++ b/server/tests/api/notifications/admin-notifications.ts@@ -6,14 +6,13 @@ import {CheckerBaseParams,checkNewPeerTubeVersion,checkNewPluginVersion,- cleanupTests,MockJoinPeerTubeVersions,MockSmtpServer,- PeerTubeServer,- prepareNotificationsTest,- wait-} from '@shared/server-commands'+ prepareNotificationsTest+} from '@server/tests/shared'+import { wait } from '@shared/core-utils'import { PluginType, UserNotification, UserNotificationType } from '@shared/models'+import { cleanupTests, PeerTubeServer } from '@shared/server-commands'describe('Test admin notifications', function () {let server: PeerTubeServerdiff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.tsindex 919be4bcaa..b82f1712a0 100644--- a/server/tests/api/notifications/comments-notifications.ts+++ b/server/tests/api/notifications/comments-notifications.ts@@ -6,13 +6,11 @@ import {checkCommentMention,CheckerBaseParams,checkNewCommentOnMyVideo,- cleanupTests,MockSmtpServer,- PeerTubeServer,- prepareNotificationsTest,- waitJobs-} from '@shared/server-commands'+ prepareNotificationsTest+} from '@server/tests/shared'import { UserNotification } from '@shared/models'+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.tsindex 4da9d26840..e6e1d5f7b4 100644--- a/server/tests/api/notifications/moderation-notifications.ts+++ b/server/tests/api/notifications/moderation-notifications.ts@@ -1,7 +1,6 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-import { buildUUID } from '@shared/core-utils/uuid'import {checkAbuseStateChange,checkAutoInstanceFollowing,@@ -16,15 +15,13 @@ import {checkUserRegistered,checkVideoAutoBlacklistForModerators,checkVideoIsPublished,- cleanupTests,MockInstancesIndex,MockSmtpServer,- PeerTubeServer,- prepareNotificationsTest,- wait,- waitJobs-} from '@shared/server-commands'+ prepareNotificationsTest+} from '@server/tests/shared'+import { buildUUID, wait } from '@shared/core-utils'import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models'+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'describe('Test moderation notifications', function () {let servers: PeerTubeServer[] = []diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.tsindex aeb73350bd..ac08449f89 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'import {CheckerBaseParams,checkNewVideoFromSubscription,- cleanupTests,getAllNotificationsSettings,MockSmtpServer,- PeerTubeServer,- prepareNotificationsTest,- waitJobs-} from '@shared/server-commands'+ prepareNotificationsTest+} from '@server/tests/shared'import { UserNotification, UserNotificationSettingValue } from '@shared/models'+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.tsindex a2fcdf2ef5..bb3024617f 100644--- a/server/tests/api/notifications/user-notifications.ts+++ b/server/tests/api/notifications/user-notifications.ts@@ -2,23 +2,20 @@import 'mocha'import * as chai from 'chai'-import { buildUUID } from '@shared/core-utils/uuid'import {CheckerBaseParams,checkMyVideoImportIsFinished,checkNewActorFollow,checkNewVideoFromSubscription,checkVideoIsPublished,- cleanupTests,FIXTURE_URLS,MockSmtpServer,- PeerTubeServer,prepareNotificationsTest,- uploadRandomVideoOnServers,- wait,- waitJobs-} from '@shared/server-commands'+ uploadRandomVideoOnServers+} from '@server/tests/shared'+import { buildUUID, wait } from '@shared/core-utils'import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.tsindex 2c341c139d..0cb0a6e340 100644--- a/server/tests/api/object-storage/live.ts+++ b/server/tests/api/object-storage/live.ts@@ -3,11 +3,12 @@import 'mocha'import * as chai from 'chai'import { FfmpegCommand } from 'fluent-ffmpeg'+import { expectStartWith } from '@server/tests/shared'+import { areObjectStorageTestsDisabled } from '@shared/core-utils'+import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models'import {- areObjectStorageTestsDisabled,createMultipleServers,doubleFollow,- expectStartWith,killallServers,makeRawRequest,ObjectStorageCommand,@@ -19,7 +20,6 @@ import {waitUntilLivePublishedOnAllServers,waitUntilLiveSavedOnAllServers} from '@shared/server-commands'-import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/object-storage/video-imports.ts b/server/tests/api/object-storage/video-imports.tsindex adca16e8f9..fb81832afb 100644--- a/server/tests/api/object-storage/video-imports.ts+++ b/server/tests/api/object-storage/video-imports.ts@@ -2,11 +2,11 @@import 'mocha'import * as chai from 'chai'+import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared'+import { areObjectStorageTestsDisabled } from '@shared/core-utils'+import { HttpStatusCode, VideoPrivacy } from '@shared/models'import {- areObjectStorageTestsDisabled,createSingleServer,- expectStartWith,- FIXTURE_URLS,killallServers,makeRawRequest,ObjectStorageCommand,@@ -15,7 +15,6 @@ import {setDefaultVideoChannel,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.tsindex bf469015f8..498efcb17e 100644--- a/server/tests/api/object-storage/videos.ts+++ b/server/tests/api/object-storage/videos.ts@@ -3,25 +3,22 @@import 'mocha'import * as chai from 'chai'import { merge } from 'lodash'+import { checkTmpIsEmpty, expectLogDoesNotContain, expectStartWith, MockObjectStorage } from '@server/tests/shared'+import { areObjectStorageTestsDisabled } from '@shared/core-utils'+import { HttpStatusCode, VideoDetails } from '@shared/models'import {- areObjectStorageTestsDisabled,- checkTmpIsEmpty,cleanupTests,createMultipleServers,createSingleServer,doubleFollow,- expectLogDoesNotContain,- expectStartWith,killallServers,makeRawRequest,- MockObjectStorage,ObjectStorageCommand,PeerTubeServer,setAccessTokensToServers,waitJobs,webtorrentAdd} from '@shared/server-commands'-import { HttpStatusCode, VideoDetails } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.tsindex 1a8d8183b6..17c6b25a59 100644--- a/server/tests/api/redundancy/redundancy-constraints.ts+++ b/server/tests/api/redundancy/redundancy-constraints.ts@@ -2,8 +2,15 @@import 'mocha'import { expect } from 'chai'-import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'import { VideoPrivacy } from '@shared/models'+import {+ cleanupTests,+ createSingleServer,+ killallServers,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'describe('Test redundancy constraints', function () {let remoteServer: PeerTubeServerdiff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.tsindex 556cfbc31f..3f22862780 100644--- a/server/tests/api/redundancy/redundancy.ts+++ b/server/tests/api/redundancy/redundancy.ts@@ -5,29 +5,26 @@ import * as chai from 'chai'import { readdir } from 'fs-extra'import magnetUtil from 'magnet-uri'import { basename, join } from 'path'+import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared'+import { root, wait } from '@shared/core-utils'+import {+ HttpStatusCode,+ VideoDetails,+ VideoFile,+ VideoPrivacy,+ VideoRedundancyStrategy,+ VideoRedundancyStrategyWithManual+} from '@shared/models'import {- checkSegmentHash,- checkVideoFilesWereRemoved,cleanupTests,createMultipleServers,doubleFollow,killallServers,makeRawRequest,PeerTubeServer,- root,- saveVideoInServers,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import {- HttpStatusCode,- VideoDetails,- VideoFile,- VideoPrivacy,- VideoRedundancyStrategy,- VideoRedundancyStrategyWithManual-} from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.tsindex 1f29f840a5..2e0abc6ba7 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 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'+import { VideoChannel } from '@shared/models'import {cleanupTests,createMultipleServers,PeerTubeServer,SearchCommand,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import { VideoChannel } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.tsindex 550af8ed20..d9243ac535 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 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'+import { VideoPlaylistPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,@@ -9,10 +11,8 @@ import {SearchCommand,setAccessTokensToServers,setDefaultVideoChannel,- wait,waitJobs} from '@shared/server-commands'-import { VideoPlaylistPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.tsindex 5aa3738c9a..60b95ae4c8 100644--- a/server/tests/api/search/search-activitypub-videos.ts+++ b/server/tests/api/search/search-activitypub-videos.ts@@ -2,16 +2,16 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'+import { VideoPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,PeerTubeServer,SearchCommand,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import { VideoPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.tsindex bf2375ffa4..c544705d37 100644--- a/server/tests/api/search/search-videos.ts+++ b/server/tests/api/search/search-videos.ts@@ -10,10 +10,10 @@ import {SearchCommand,setAccessTokensToServers,setDefaultVideoChannel,- stopFfmpeg,- wait+ stopFfmpeg} from '@shared/server-commands'import { VideoPrivacy } from '@shared/models'+import { wait } from '@shared/core-utils'const expect = chai.expectdiff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.tsindex 74bb96040e..6d2333a6bc 100644--- a/server/tests/api/server/auto-follows.ts+++ b/server/tests/api/server/auto-follows.ts@@ -2,15 +2,9 @@import 'mocha'import * as chai from 'chai'-import {- cleanupTests,- createMultipleServers,- MockInstancesIndex,- PeerTubeServer,- setAccessTokensToServers,- wait,- waitJobs-} from '@shared/server-commands'+import { MockInstancesIndex } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/server/config-defaults.ts b/server/tests/api/server/config-defaults.tsindex 4ceda7de3c..3ff09bf7ea 100644--- a/server/tests/api/server/config-defaults.ts+++ b/server/tests/api/server/config-defaults.ts@@ -2,15 +2,9 @@import 'mocha'import * as chai from 'chai'-import {- cleanupTests,- createSingleServer,- FIXTURE_URLS,- PeerTubeServer,- setAccessTokensToServers,- setDefaultVideoChannel-} from '@shared/server-commands'+import { FIXTURE_URLS } from '@server/tests/shared'import { VideoDetails, VideoPrivacy } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.tsindex 2e6617a154..2356f701c4 100644--- a/server/tests/api/server/config.ts+++ b/server/tests/api/server/config.ts@@ -2,16 +2,16 @@import 'mocha'import * as chai from 'chai'+import { parallelTests } from '@shared/core-utils'+import { CustomConfig, HttpStatusCode } from '@shared/models'import {cleanupTests,createSingleServer,killallServers,makeGetRequest,- parallelTests,PeerTubeServer,setAccessTokensToServers} from '@shared/server-commands'-import { CustomConfig, HttpStatusCode } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.tsindex 1092514531..f3facb04a1 100644--- a/server/tests/api/server/contact-form.ts+++ b/server/tests/api/server/contact-form.ts@@ -2,17 +2,17 @@import 'mocha'import * as chai from 'chai'+import { MockSmtpServer } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { HttpStatusCode } from '@shared/models'import {cleanupTests,ContactFormCommand,createSingleServer,- MockSmtpServer,PeerTubeServer,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import { HttpStatusCode } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.tsindex 6fa6053cb3..20b5e378c9 100644--- a/server/tests/api/server/email.ts+++ b/server/tests/api/server/email.ts@@ -2,8 +2,9 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'+import { MockSmtpServer } from '@server/tests/shared'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.tsindex e128c36a5b..cd34df15de 100644--- a/server/tests/api/server/follows.ts+++ b/server/tests/api/server/follows.ts@@ -2,19 +2,9 @@import 'mocha'import * as chai from 'chai'-import {- cleanupTests,- createMultipleServers,- dateIsValid,- expectAccountFollows,- expectChannelsFollows,- PeerTubeServer,- setAccessTokensToServers,- testCaptionFile,- waitJobs-} from '@shared/server-commands'+import { completeVideoCheck, dateIsValid, expectAccountFollows, expectChannelsFollows, testCaptionFile } from '@server/tests/shared'import { VideoCreateResult, VideoPrivacy } from '@shared/models'-import { completeVideoCheck } from '@server/tests/shared/video'+import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.tsindex b134e074be..7c3836681d 100644--- a/server/tests/api/server/handle-down.ts+++ b/server/tests/api/server/handle-down.ts@@ -2,6 +2,9 @@import 'mocha'import * as chai from 'chai'+import { completeVideoCheck } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models'import {cleanupTests,CommentsCommand,@@ -9,11 +12,8 @@ import {killallServers,PeerTubeServer,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models'-import { completeVideoCheck } from '@server/tests/shared/video'const expect = chai.expectdiff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.tsindex 5b38f67415..4294e1fd52 100644--- a/server/tests/api/server/jobs.ts+++ b/server/tests/api/server/jobs.ts@@ -2,10 +2,10 @@import 'mocha'import * as chai from 'chai'+import { dateIsValid } from '@server/tests/shared'import {cleanupTests,createMultipleServers,- dateIsValid,doubleFollow,PeerTubeServer,setAccessTokensToServers,diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.tsindex fbcd891019..e82096c481 100644--- a/server/tests/api/server/plugins.ts+++ b/server/tests/api/server/plugins.ts@@ -2,17 +2,17 @@import 'mocha'import * as chai from 'chai'+import { testHelloWorldRegisteredSettings } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, PluginType } from '@shared/models'import {cleanupTests,createSingleServer,killallServers,PeerTubeServer,PluginsCommand,- setAccessTokensToServers,- testHelloWorldRegisteredSettings,- wait+ setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, PluginType } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.tsindex 626a0d8603..c40a4f9b8f 100644--- a/server/tests/api/server/proxy.ts+++ b/server/tests/api/server/proxy.ts@@ -2,18 +2,17 @@import 'mocha'import * as chai from 'chai'+import { FIXTURE_URLS, MockProxy } from '@server/tests/shared'+import { HttpStatusCode, VideoPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,doubleFollow,- FIXTURE_URLS,PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,waitJobs} from '@shared/server-commands'-import { MockProxy } from '@shared/server-commands/mock-servers/mock-proxy'-import { HttpStatusCode, VideoPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.tsindex fc9b88a6a8..968d98e968 100644--- a/server/tests/api/server/reverse-proxy.ts+++ b/server/tests/api/server/reverse-proxy.ts@@ -1,8 +1,9 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import { expect } from 'chai'-import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/server-commands'+import { wait } from '@shared/core-utils'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'describe('Test application behind a reverse proxy', function () {let server: PeerTubeServerdiff --git a/server/tests/api/server/slow-follows.ts b/server/tests/api/server/slow-follows.tsindex 5f24c351be..666a7c2e60 100644--- a/server/tests/api/server/slow-follows.ts+++ b/server/tests/api/server/slow-follows.ts@@ -2,8 +2,15 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'import { Job } from '@shared/models'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.tsindex 65ef4607bd..f0334532bf 100644--- a/server/tests/api/server/stats.ts+++ b/server/tests/api/server/stats.ts@@ -2,16 +2,16 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'+import { ActivityType, VideoPlaylistPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,doubleFollow,PeerTubeServer,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import { ActivityType, VideoPlaylistPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.tsindex e6699a059a..5b2bbc520e 100644--- a/server/tests/api/users/users-multiple-servers.ts+++ b/server/tests/api/users/users-multiple-servers.ts@@ -6,16 +6,18 @@ import {checkActorFilesWereRemoved,checkTmpIsEmpty,checkVideoFilesWereRemoved,+ saveVideoInServers,+ testImage+} from '@server/tests/shared'+import { MyUser } from '@shared/models'+import {cleanupTests,createMultipleServers,doubleFollow,PeerTubeServer,- saveVideoInServers,setAccessTokensToServers,- testImage,waitJobs} from '@shared/server-commands'-import { MyUser } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.tsindex 9b23ba7972..0f3cc401a4 100644--- a/server/tests/api/users/users-verification.ts+++ b/server/tests/api/users/users-verification.ts@@ -2,8 +2,9 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'+import { MockSmtpServer } from '@server/tests/shared'import { HttpStatusCode } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.tsindex fc44a6acd3..ff9172a82e 100644--- a/server/tests/api/users/users.ts+++ b/server/tests/api/users/users.ts@@ -2,6 +2,8 @@import 'mocha'import * as chai from 'chai'+import { testImage } from '@server/tests/shared'+import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'import {cleanupTests,createSingleServer,@@ -9,10 +11,8 @@ import {makePutBodyRequest,PeerTubeServer,setAccessTokensToServers,- testImage,waitJobs} from '@shared/server-commands'-import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.tsindex 4b27f2fbe2..e58360ffe5 100644--- a/server/tests/api/videos/audio-only.ts+++ b/server/tests/api/videos/audio-only.ts@@ -3,7 +3,14 @@import 'mocha'import * as chai from 'chai'import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.tsindex cb83fa0f07..9fa03f1a9c 100644--- a/server/tests/api/videos/multiple-servers.ts+++ b/server/tests/api/videos/multiple-servers.ts@@ -4,23 +4,24 @@ import 'mocha'import * as chai from 'chai'import request from 'supertest'import {- buildAbsoluteFixturePath,checkTmpIsEmpty,checkVideoFilesWereRemoved,+ completeVideoCheck,+ dateIsValid,+ saveVideoInServers,+ testImage+} from '@server/tests/shared'+import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'+import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'+import {cleanupTests,createMultipleServers,- dateIsValid,doubleFollow,PeerTubeServer,- saveVideoInServers,setAccessTokensToServers,- testImage,- wait,waitJobs,webtorrentAdd} from '@shared/server-commands'-import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'-import { completeVideoCheck } from '@server/tests/shared/video'const expect = chai.expectdiff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.tsindex 0842817dc7..d6f4da6305 100644--- a/server/tests/api/videos/resumable-upload.ts+++ b/server/tests/api/videos/resumable-upload.ts@@ -4,15 +4,9 @@ import 'mocha'import * as chai from 'chai'import { pathExists, readdir, stat } from 'fs-extra'import { join } from 'path'-import {- buildAbsoluteFixturePath,- cleanupTests,- createSingleServer,- PeerTubeServer,- setAccessTokensToServers,- setDefaultVideoChannel-} from '@shared/server-commands'+import { buildAbsoluteFixturePath } from '@shared/core-utils'import { HttpStatusCode, VideoPrivacy } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.tsindex e5e12dd191..28bf018c5a 100644--- a/server/tests/api/videos/single-server.ts+++ b/server/tests/api/videos/single-server.ts@@ -2,17 +2,10 @@import 'mocha'import * as chai from 'chai'-import {- checkVideoFilesWereRemoved,- cleanupTests,- createSingleServer,- PeerTubeServer,- setAccessTokensToServers,- testImage,- wait-} from '@shared/server-commands'+import { checkVideoFilesWereRemoved, completeVideoCheck, testImage } from '@server/tests/shared'+import { wait } from '@shared/core-utils'import { Video, VideoPrivacy } from '@shared/models'-import { completeVideoCheck } from '@server/tests/shared/video'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.tsindex 9f00312aa3..b7f26c35fc 100644--- a/server/tests/api/videos/video-captions.ts+++ b/server/tests/api/videos/video-captions.ts@@ -2,15 +2,14 @@import 'mocha'import * as chai from 'chai'+import { checkVideoFilesWereRemoved, testCaptionFile } from '@server/tests/shared'+import { wait } from '@shared/core-utils'import {- checkVideoFilesWereRemoved,cleanupTests,createMultipleServers,doubleFollow,PeerTubeServer,setAccessTokensToServers,- testCaptionFile,- wait,waitJobs} from '@shared/server-commands'diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.tsindex 2ac577a599..d435f36820 100644--- a/server/tests/api/videos/video-channels.ts+++ b/server/tests/api/videos/video-channels.ts@@ -4,6 +4,9 @@ import 'mocha'import * as chai from 'chai'import { basename } from 'path'import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'+import { testFileExistsOrNot, testImage } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import { User, VideoChannel } from '@shared/models'import {cleanupTests,createMultipleServers,@@ -11,12 +14,8 @@ import {PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,- testFileExistsOrNot,- testImage,- wait,waitJobs} from '@shared/server-commands'-import { User, VideoChannel } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.tsindex bb4f92a9bd..2ae5239702 100644--- a/server/tests/api/videos/video-comments.ts+++ b/server/tests/api/videos/video-comments.ts@@ -2,15 +2,8 @@import 'mocha'import * as chai from 'chai'-import {- cleanupTests,- CommentsCommand,- createSingleServer,- dateIsValid,- PeerTubeServer,- setAccessTokensToServers,- testImage-} from '@shared/server-commands'+import { dateIsValid, testImage } from '@server/tests/shared'+import { cleanupTests, CommentsCommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/video-create-transcoding.ts b/server/tests/api/videos/video-create-transcoding.tsindex e81f547145..62a6bab0d6 100644--- a/server/tests/api/videos/video-create-transcoding.ts+++ b/server/tests/api/videos/video-create-transcoding.ts@@ -2,20 +2,20 @@import 'mocha'import * as chai from 'chai'+import { expectStartWith } from '@server/tests/shared'+import { areObjectStorageTestsDisabled } from '@shared/core-utils'+import { HttpStatusCode, VideoDetails } from '@shared/models'import {- areObjectStorageTestsDisabled,cleanupTests,createMultipleServers,doubleFollow,expectNoFailedTranscodingJob,- expectStartWith,makeRawRequest,ObjectStorageCommand,PeerTubeServer,setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoDetails } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.tsindex 23c55f7280..20b20488f2 100644--- a/server/tests/api/videos/video-description.ts+++ b/server/tests/api/videos/video-description.ts@@ -2,7 +2,14 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/video-files.ts b/server/tests/api/videos/video-files.tsindex 0b51217401..b0ef4a2e93 100644--- a/server/tests/api/videos/video-files.ts+++ b/server/tests/api/videos/video-files.ts@@ -2,7 +2,14 @@import 'mocha'import { expect } from 'chai'-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'+import {+ cleanupTests,+ createMultipleServers,+ doubleFollow,+ PeerTubeServer,+ setAccessTokensToServers,+ waitJobs+} from '@shared/server-commands'describe('Test videos files', function () {let servers: PeerTubeServer[]diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.tsindex d050a7a7e2..218ec08ae6 100644--- a/server/tests/api/videos/video-hls.ts+++ b/server/tests/api/videos/video-hls.ts@@ -3,18 +3,20 @@import 'mocha'import * as chai from 'chai'import { basename, join } from 'path'-import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils'import {- areObjectStorageTestsDisabled,checkDirectoryIsEmpty,checkResolutionsInMasterPlaylist,checkSegmentHash,checkTmpIsEmpty,+ expectStartWith,+ hlsInfohashExist+} from '@server/tests/shared'+import { areObjectStorageTestsDisabled, removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils'+import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models'+import {cleanupTests,createMultipleServers,doubleFollow,- expectStartWith,- hlsInfohashExist,makeRawRequest,ObjectStorageCommand,PeerTubeServer,@@ -22,7 +24,6 @@ import {waitJobs,webtorrentAdd} from '@shared/server-commands'-import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models'import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'const expect = chai.expectdiff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.tsindex 2518743f7d..e8e0f01f18 100644--- a/server/tests/api/videos/video-imports.ts+++ b/server/tests/api/videos/video-imports.ts@@ -4,21 +4,19 @@ import 'mocha'import { expect } from 'chai'import { pathExists, readdir, remove } from 'fs-extra'import { join } from 'path'+import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared'+import { areHttpImportTestsDisabled } from '@shared/core-utils'+import { VideoPrivacy, VideoResolution } from '@shared/models'import {- areHttpImportTestsDisabled,cleanupTests,createMultipleServers,createSingleServer,doubleFollow,- FIXTURE_URLS,PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,- testCaptionFile,- testImage,waitJobs} from '@shared/server-commands'-import { VideoPrivacy, VideoResolution } from '@shared/models'async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) {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.tsindex e6b6c34eb4..5fdb0fc036 100644--- a/server/tests/api/videos/video-playlist-thumbnails.ts+++ b/server/tests/api/videos/video-playlist-thumbnails.ts@@ -2,6 +2,8 @@import 'mocha'import * as chai from 'chai'+import { testImage } from '@server/tests/shared'+import { VideoPlaylistPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,@@ -9,10 +11,8 @@ import {PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,- testImage,waitJobs-} from '../../../../shared/server-commands'-import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.tsindex 6279f5cd05..34327334f1 100644--- a/server/tests/api/videos/video-playlists.ts+++ b/server/tests/api/videos/video-playlists.ts@@ -2,8 +2,18 @@import 'mocha'import * as chai from 'chai'+import { checkPlaylistFilesWereRemoved, testImage } from '@server/tests/shared'+import { wait } from '@shared/core-utils'+import {+ HttpStatusCode,+ VideoPlaylist,+ VideoPlaylistCreateResult,+ VideoPlaylistElementType,+ VideoPlaylistPrivacy,+ VideoPlaylistType,+ VideoPrivacy+} from '@shared/models'import {- checkPlaylistFilesWereRemoved,cleanupTests,createMultipleServers,doubleFollow,@@ -11,19 +21,8 @@ import {PlaylistsCommand,setAccessTokensToServers,setDefaultVideoChannel,- testImage,- wait,waitJobs} from '@shared/server-commands'-import {- HttpStatusCode,- VideoPlaylist,- VideoPlaylistCreateResult,- VideoPlaylistElementType,- VideoPlaylistPrivacy,- VideoPlaylistType,- VideoPrivacy-} from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.tsindex 13eb941eae..3051a443d8 100644--- a/server/tests/api/videos/video-privacy.ts+++ b/server/tests/api/videos/video-privacy.ts@@ -2,16 +2,9 @@import 'mocha'import * as chai from 'chai'-import {- cleanupTests,- createSingleServer,- doubleFollow,- PeerTubeServer,- setAccessTokensToServers,- wait,- waitJobs-} from '@shared/server-commands'+import { wait } from '@shared/core-utils'import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'+import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.tsindex 9408574ad5..00b4f6cbc7 100644--- a/server/tests/api/videos/video-schedule-update.ts+++ b/server/tests/api/videos/video-schedule-update.ts@@ -2,16 +2,16 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'+import { VideoPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,doubleFollow,PeerTubeServer,setAccessTokensToServers,- wait,waitJobs} from '@shared/server-commands'-import { VideoPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.tsindex f4b0bc53a8..d24a8f4e15 100644--- a/server/tests/api/videos/video-transcoder.ts+++ b/server/tests/api/videos/video-transcoder.ts@@ -3,29 +3,21 @@import 'mocha'import * as chai from 'chai'import { omit } from 'lodash'-import { getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'+import { canDoQuickTranscode } from '@server/helpers/ffprobe-utils'+import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared'+import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'+import { getAudioStream, getMetadataFromFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils'+import { HttpStatusCode, VideoState } from '@shared/models'import {- buildAbsoluteFixturePath,cleanupTests,createMultipleServers,doubleFollow,- generateHighBitrateVideo,- generateVideoWithFramerate,makeGetRequest,PeerTubeServer,setAccessTokensToServers,waitJobs,webtorrentAdd} from '@shared/server-commands'-import { HttpStatusCode, VideoState } from '@shared/models'-import {- canDoQuickTranscode,- getAudioStream,- getMetadataFromFile,- getVideoFileBitrate,- getVideoFileFPS,- getVideoFileResolution-} from '../../../helpers/ffprobe-utils'const expect = chai.expectdiff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.tsindex 813fc4f45d..4e5ba13aa4 100644--- a/server/tests/api/videos/videos-history.ts+++ b/server/tests/api/videos/videos-history.ts@@ -2,16 +2,16 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, Video } from '@shared/models'import {cleanupTests,createSingleServer,HistoryCommand,killallServers,PeerTubeServer,- setAccessTokensToServers,- wait+ setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, Video } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.tsindex 08a4efb634..61fc0cb200 100644--- a/server/tests/api/videos/videos-overview.ts+++ b/server/tests/api/videos/videos-overview.ts@@ -2,8 +2,9 @@import 'mocha'import * as chai from 'chai'-import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/server-commands'+import { wait } from '@shared/core-utils'import { VideosOverview } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.tsindex 7f7597af4c..e6815a4a83 100644--- a/server/tests/api/videos/videos-views-cleaner.ts+++ b/server/tests/api/videos/videos-views-cleaner.ts@@ -2,6 +2,7 @@import 'mocha'import * as chai from 'chai'+import { wait } from '@shared/core-utils'import {cleanupTests,createMultipleServers,@@ -9,9 +10,8 @@ import {killallServers,PeerTubeServer,setAccessTokensToServers,- wait,waitJobs-} from '../../../../shared/server-commands'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.tsindex 5973272e5d..8ef0545d07 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 @@import 'mocha'import * as chai from 'chai'+import { areObjectStorageTestsDisabled } from '@shared/core-utils'+import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'import {- areObjectStorageTestsDisabled,cleanupTests,createMultipleServers,doubleFollow,- expectStartWith,makeRawRequest,ObjectStorageCommand,PeerTubeServer,setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'+import { expectStartWith } from '../shared'const expect = chai.expectdiff --git a/server/tests/cli/create-move-video-storage-job.ts b/server/tests/cli/create-move-video-storage-job.tsindex 8b66f24bfe..c674d28d29 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 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import 'mocha'-+import { areObjectStorageTestsDisabled } from '@shared/core-utils'+import { HttpStatusCode, VideoDetails } from '@shared/models'import {- areObjectStorageTestsDisabled,cleanupTests,createMultipleServers,doubleFollow,- expectStartWith,makeRawRequest,ObjectStorageCommand,PeerTubeServer,setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoDetails } from '@shared/models'+import { expectStartWith } from '../shared'async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) {for (const file of video.files) {diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.tsindex ea34286627..c85130fef8 100644--- a/server/tests/cli/create-transcoding-job.ts+++ b/server/tests/cli/create-transcoding-job.ts@@ -2,19 +2,19 @@import 'mocha'import * as chai from 'chai'+import { areObjectStorageTestsDisabled } from '@shared/core-utils'import { HttpStatusCode, VideoFile } from '@shared/models'import {- areObjectStorageTestsDisabled,cleanupTests,createMultipleServers,doubleFollow,- expectStartWith,makeRawRequest,ObjectStorageCommand,PeerTubeServer,setAccessTokensToServers,waitJobs-} from '../../../shared/server-commands'+} from '@shared/server-commands'+import { expectStartWith } from '../shared'const expect = chai.expectdiff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.tsindex 72213473b5..034d216e36 100644--- a/server/tests/cli/peertube.ts+++ b/server/tests/cli/peertube.ts@@ -2,19 +2,17 @@import 'mocha'import { expect } from 'chai'+import { areHttpImportTestsDisabled, buildAbsoluteFixturePath } from '@shared/core-utils'import {- areHttpImportTestsDisabled,- buildAbsoluteFixturePath,cleanupTests,CLICommand,createSingleServer,doubleFollow,- FIXTURE_URLS,PeerTubeServer,setAccessTokensToServers,- testHelloWorldRegisteredSettings,waitJobs-} from '../../../shared/server-commands'+} from '@shared/server-commands'+import { FIXTURE_URLS, testHelloWorldRegisteredSettings } from '../shared'describe('Test CLI wrapper', function () {let server: PeerTubeServerdiff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.tsindex d9cf9465c3..cd9f4e1c3e 100644--- a/server/tests/cli/plugins.ts+++ b/server/tests/cli/plugins.ts@@ -9,7 +9,7 @@ import {PeerTubeServer,PluginsCommand,setAccessTokensToServers-} from '../../../shared/server-commands'+} from '@shared/server-commands'describe('Test plugin scripts', function () {let server: PeerTubeServerdiff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.tsindex 36c43c6df3..27896f0310 100644--- a/server/tests/cli/print-transcode-command.ts+++ b/server/tests/cli/print-transcode-command.ts@@ -2,7 +2,8 @@import 'mocha'import * as chai from 'chai'-import { buildAbsoluteFixturePath, CLICommand } from '@shared/server-commands'+import { buildAbsoluteFixturePath } from '@shared/core-utils'+import { CLICommand } from '@shared/server-commands'import { VideoResolution } from '../../../shared/models/videos'const expect = chai.expectdiff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.tsindex e0bc6a5897..8e8fc7e20c 100644--- a/server/tests/cli/prune-storage.ts+++ b/server/tests/cli/prune-storage.ts@@ -4,7 +4,8 @@ import 'mocha'import * as chai from 'chai'import { createFile, readdir } from 'fs-extra'import { join } from 'path'-import { buildUUID } from '@shared/core-utils/uuid'+import { buildUUID, wait } from '@shared/core-utils'+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'import {cleanupTests,CLICommand,@@ -15,10 +16,8 @@ import {PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,- wait,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'const expect = chai.expectdiff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.tsindex 34dedb1136..018e9d788b 100644--- a/server/tests/cli/reset-password.ts+++ b/server/tests/cli/reset-password.ts@@ -1,5 +1,5 @@import 'mocha'-import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '../../../shared/server-commands'+import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'describe('Test reset password scripts', function () {let server: PeerTubeServerdiff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.tsindex 2f75ad25b5..bc5c936215 100644--- a/server/tests/external-plugins/auto-block-videos.ts+++ b/server/tests/external-plugins/auto-block-videos.ts@@ -2,17 +2,17 @@import 'mocha'import { expect } from 'chai'+import { wait } from '@shared/core-utils'+import { Video } from '@shared/models'import {cleanupTests,createMultipleServers,doubleFollow,killallServers,- MockBlocklist,PeerTubeServer,- setAccessTokensToServers,- wait+ setAccessTokensToServers} from '@shared/server-commands'-import { Video } from '@shared/models'+import { MockBlocklist } from '../shared'async function check (server: PeerTubeServer, videoUUID: string, exists = true) {const { data } = await server.videos.list()diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.tsindex bfa67e7ad1..375ccf91a3 100644--- a/server/tests/external-plugins/auto-mute.ts+++ b/server/tests/external-plugins/auto-mute.ts@@ -2,18 +2,18 @@import 'mocha'import { expect } from 'chai'+import { wait } from '@shared/core-utils'+import { HttpStatusCode } from '@shared/models'import {cleanupTests,createMultipleServers,doubleFollow,killallServers,makeGetRequest,- MockBlocklist,PeerTubeServer,- setAccessTokensToServers,- wait+ setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode } from '@shared/models'+import { MockBlocklist } from '../shared'describe('Official plugin auto-mute', function () {const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list'diff --git a/server/tests/helpers/image.ts b/server/tests/helpers/image.tsindex 330139ee4e..64bd373cc9 100644--- a/server/tests/helpers/image.ts+++ b/server/tests/helpers/image.ts@@ -4,8 +4,8 @@ import 'mocha'import { expect } from 'chai'import { readFile, remove } from 'fs-extra'import { join } from 'path'+import { buildAbsoluteFixturePath, root } from '@shared/core-utils'import { processImage } from '../../../server/helpers/image-utils'-import { buildAbsoluteFixturePath, root } from '../../../shared/server-commands'async function checkBuffers (path1: string, path2: string, equals: boolean) {const [ buf1, buf2 ] = await Promise.all([diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.tsindex db0cca3905..de507ba35f 100644--- a/server/tests/helpers/request.ts+++ b/server/tests/helpers/request.ts@@ -4,9 +4,9 @@ import 'mocha'import { expect } from 'chai'import { pathExists, remove } from 'fs-extra'import { join } from 'path'-import { Mock429 } from '@shared/server-commands/mock-servers/mock-429'-import { FIXTURE_URLS, root, wait } from '../../../shared/server-commands'+import { root, wait } from '@shared/core-utils'import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'+import { FIXTURE_URLS, Mock429 } from '../shared'describe('Request helpers', function () {const destPath1 = join(root(), 'test-output-1.txt')diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.tsindex a4a3764f55..583100671c 100644--- a/server/tests/plugins/external-auth.ts+++ b/server/tests/plugins/external-auth.ts@@ -2,16 +2,16 @@import 'mocha'import { expect } from 'chai'+import { wait } from '@shared/core-utils'+import { HttpStatusCode, UserRole } from '@shared/models'import {cleanupTests,createSingleServer,decodeQueryString,PeerTubeServer,PluginsCommand,- setAccessTokensToServers,- wait+ setAccessTokensToServers} from '@shared/server-commands'-import { HttpStatusCode, UserRole } from '@shared/models'async function loginExternal (options: {server: PeerTubeServerdiff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.tsindex a84edfac68..52ba396e55 100644--- a/server/tests/plugins/filter-hooks.ts+++ b/server/tests/plugins/filter-hooks.ts@@ -2,11 +2,11 @@import 'mocha'import * as chai from 'chai'+import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'import {cleanupTests,createMultipleServers,doubleFollow,- FIXTURE_URLS,makeRawRequest,PeerTubeServer,PluginsCommand,@@ -14,7 +14,7 @@ import {setDefaultVideoChannel,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'+import { FIXTURE_URLS } from '../shared'const expect = chai.expectdiff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.tsindex 9e10d33020..0a3a9c25f5 100644--- a/server/tests/plugins/html-injection.ts+++ b/server/tests/plugins/html-injection.ts@@ -9,7 +9,7 @@ import {PeerTubeServer,PluginsCommand,setAccessTokensToServers-} from '../../../shared/server-commands'+} from '@shared/server-commands'const expect = chai.expectdiff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.tsindex ea3b0f6ab2..e72046ce25 100644--- a/server/tests/plugins/id-and-pass-auth.ts+++ b/server/tests/plugins/id-and-pass-auth.ts@@ -2,8 +2,9 @@import 'mocha'import { expect } from 'chai'-import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers, wait } from '@shared/server-commands'+import { wait } from '@shared/core-utils'import { HttpStatusCode, UserRole } from '@shared/models'+import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands'describe('Test id and pass auth plugins', function () {let server: PeerTubeServerdiff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.tsindex 4ab4acd584..167429ef46 100644--- a/server/tests/plugins/plugin-helpers.ts+++ b/server/tests/plugins/plugin-helpers.ts@@ -3,8 +3,8 @@import 'mocha'import { expect } from 'chai'import { pathExists } from 'fs-extra'+import { HttpStatusCode, ThumbnailType } from '@shared/models'import {- checkVideoFilesWereRemoved,cleanupTests,createMultipleServers,doubleFollow,@@ -16,7 +16,7 @@ import {setAccessTokensToServers,waitJobs} from '@shared/server-commands'-import { HttpStatusCode, ThumbnailType } from '@shared/models'+import { checkVideoFilesWereRemoved } from '../shared'function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) {const body = { command }diff --git a/shared/server-commands/users/actors.ts b/server/tests/shared/actors.tssimilarity index 97%rename from shared/server-commands/users/actors.tsrename to server/tests/shared/actors.tsindex 12c3e078a6..f8f4a51370 100644--- a/shared/server-commands/users/actors.ts+++ b/server/tests/shared/actors.ts@@ -5,7 +5,7 @@ import { pathExists, readdir } from 'fs-extra'import { join } from 'path'import { root } from '@shared/core-utils'import { Account, VideoChannel } from '@shared/models'-import { PeerTubeServer } from '../server'+import { PeerTubeServer } from '@shared/server-commands'async function expectChannelsFollows (options: {server: PeerTubeServerdiff --git a/shared/server-commands/videos/captions.ts b/server/tests/shared/captions.tssimilarity index 100%rename from shared/server-commands/videos/captions.tsrename to server/tests/shared/captions.tsdiff --git a/shared/server-commands/miscs/checks.ts b/server/tests/shared/checks.tssimilarity index 63%rename from shared/server-commands/miscs/checks.tsrename to server/tests/shared/checks.tsindex 5899289978..9ecc84b5d8 100644--- a/shared/server-commands/miscs/checks.ts+++ b/server/tests/shared/checks.ts@@ -5,8 +5,7 @@ import { pathExists, readFile } from 'fs-extra'import { join } from 'path'import { root } from '@shared/core-utils'import { HttpStatusCode } from '@shared/models'-import { makeGetRequest } from '../requests'-import { PeerTubeServer } from '../server'+import { makeGetRequest, PeerTubeServer } from '@shared/server-commands'// Default interval -> 5 minutesfunction dateIsValid (dateString: string, interval = 300000) {@@ -49,10 +48,51 @@ async function testFileExistsOrNot (server: PeerTubeServer, directory: string, fexpect(await pathExists(join(base, filePath))).to.equal(exist)}+function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {+ return makeGetRequest({+ url,+ path,+ token,+ query: { ...query, start: 'hello' },+ expectedStatus: HttpStatusCode.BAD_REQUEST_400+ })+}++async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {+ await makeGetRequest({+ url,+ path,+ token,+ query: { ...query, count: 'hello' },+ expectedStatus: HttpStatusCode.BAD_REQUEST_400+ })++ await makeGetRequest({+ url,+ path,+ token,+ query: { ...query, count: 2000 },+ expectedStatus: HttpStatusCode.BAD_REQUEST_400+ })+}++function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {+ return makeGetRequest({+ url,+ path,+ token,+ query: { ...query, sort: 'hello' },+ expectedStatus: HttpStatusCode.BAD_REQUEST_400+ })+}+export {dateIsValid,testImage,expectLogDoesNotContain,testFileExistsOrNot,- expectStartWith+ expectStartWith,+ checkBadStartPagination,+ checkBadCountPagination,+ checkBadSortPagination}diff --git a/shared/server-commands/server/directories.ts b/server/tests/shared/directories.tssimilarity index 95%rename from shared/server-commands/server/directories.tsrename to server/tests/shared/directories.tsindex e6f72d6fcb..c7065a767f 100644--- a/shared/server-commands/server/directories.ts+++ b/server/tests/shared/directories.ts@@ -4,7 +4,7 @@ import { expect } from 'chai'import { pathExists, readdir } from 'fs-extra'import { join } from 'path'import { root } from '@shared/core-utils'-import { PeerTubeServer } from './server'+import { PeerTubeServer } from '@shared/server-commands'async function checkTmpIsEmpty (server: PeerTubeServer) {await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ])diff --git a/shared/server-commands/miscs/generate.ts b/server/tests/shared/generate.tssimilarity index 94%rename from shared/server-commands/miscs/generate.tsrename to server/tests/shared/generate.tsindex 93673a0632..f806df2f58 100644--- a/shared/server-commands/miscs/generate.ts+++ b/server/tests/shared/generate.ts@@ -2,9 +2,8 @@ import { expect } from 'chai'import ffmpeg from 'fluent-ffmpeg'import { ensureDir, pathExists } from 'fs-extra'import { dirname } from 'path'-import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils/ffprobe'-import { getMaxBitrate } from '@shared/core-utils'-import { buildAbsoluteFixturePath } from './tests'+import { buildAbsoluteFixturePath, getMaxBitrate } from '@shared/core-utils'+import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils'async function ensureHasTooBigBitrate (fixturePath: string) {const bitrate = await getVideoFileBitrate(fixturePath)diff --git a/server/tests/shared/index.ts b/server/tests/shared/index.tsindex 9388172684..47019d6a8b 100644--- a/server/tests/shared/index.ts+++ b/server/tests/shared/index.ts@@ -1,2 +1,15 @@+export * from './mock-servers'+export * from './actors'+export * from './captions'+export * from './checks'+export * from './directories'+export * from './generate'+export * from './live'+export * from './notifications'+export * from './playlists'+export * from './plugins'export * from './requests'-export * from './video'+export * from './streaming-playlists'+export * from './tests'+export * from './tracker'+export * from './videos'diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.tsnew file mode 100644index 0000000000..72e3e27f61--- /dev/null+++ b/server/tests/shared/live.ts@@ -0,0 +1,41 @@+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */++import { expect } from 'chai'+import { pathExists, readdir } from 'fs-extra'+import { join } from 'path'+import { PeerTubeServer } from '@shared/server-commands'++async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) {+ const basePath = server.servers.buildDirectory('streaming-playlists')+ const hlsPath = join(basePath, 'hls', videoUUID)++ if (resolutions.length === 0) {+ const result = await pathExists(hlsPath)+ expect(result).to.be.false++ return+ }++ const files = await readdir(hlsPath)++ // fragmented file and playlist per resolution + master playlist + segments sha256 json file+ expect(files).to.have.lengthOf(resolutions.length * 2 + 2)++ for (const resolution of resolutions) {+ const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`))+ expect(fragmentedFile).to.exist++ const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`))+ expect(playlistFile).to.exist+ }++ const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8'))+ expect(masterPlaylistFile).to.exist++ const shaFile = files.find(f => f.endsWith('-segments-sha256.json'))+ expect(shaFile).to.exist+}++export {+ checkLiveCleanupAfterSave+}diff --git a/shared/server-commands/mock-servers/index.ts b/server/tests/shared/mock-servers/index.tssimilarity index 77%rename from shared/server-commands/mock-servers/index.tsrename to server/tests/shared/mock-servers/index.tsindex 93c00c7882..abf4a8203b 100644--- a/shared/server-commands/mock-servers/index.ts+++ b/server/tests/shared/mock-servers/index.ts@@ -1,5 +1,7 @@+export * from './mock-429'export * from './mock-email'export * from './mock-instances-index'export * from './mock-joinpeertube-versions'-export * from './mock-plugin-blocklist'export * from './mock-object-storage'+export * from './mock-plugin-blocklist'+export * from './mock-proxy'diff --git a/shared/server-commands/mock-servers/mock-429.ts b/server/tests/shared/mock-servers/mock-429.tssimilarity index 90%rename from shared/server-commands/mock-servers/mock-429.tsrename to server/tests/shared/mock-servers/mock-429.tsindex 9e0d1281aa..1fc20b079c 100644--- a/shared/server-commands/mock-servers/mock-429.ts+++ b/server/tests/shared/mock-servers/mock-429.ts@@ -1,6 +1,6 @@import express from 'express'import { Server } from 'http'-import { getPort, randomListen, terminateServer } from './utils'+import { getPort, randomListen, terminateServer } from './shared'export class Mock429 {private server: Serverdiff --git a/shared/server-commands/mock-servers/mock-email.ts b/server/tests/shared/mock-servers/mock-email.tssimilarity index 93%rename from shared/server-commands/mock-servers/mock-email.tsrename to server/tests/shared/mock-servers/mock-email.tsindex f646c1621f..c518679c94 100644--- a/shared/server-commands/mock-servers/mock-email.ts+++ b/server/tests/shared/mock-servers/mock-email.ts@@ -1,7 +1,6 @@import { ChildProcess } from 'child_process'import MailDev from '@peertube/maildev'-import { randomInt } from '@shared/core-utils'-import { parallelTests } from '../miscs'+import { parallelTests, randomInt } from '@shared/core-utils'class MockSmtpServer {diff --git a/shared/server-commands/mock-servers/mock-instances-index.ts b/server/tests/shared/mock-servers/mock-instances-index.tssimilarity index 94%rename from shared/server-commands/mock-servers/mock-instances-index.tsrename to server/tests/shared/mock-servers/mock-instances-index.tsindex 92b12d6f3d..598b007f12 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 @@import express from 'express'import { Server } from 'http'-import { getPort, randomListen, terminateServer } from './utils'+import { getPort, randomListen, terminateServer } from './shared'export class MockInstancesIndex {private server: Serverdiff --git a/shared/server-commands/mock-servers/mock-joinpeertube-versions.ts b/server/tests/shared/mock-servers/mock-joinpeertube-versions.tssimilarity index 94%rename from shared/server-commands/mock-servers/mock-joinpeertube-versions.tsrename to server/tests/shared/mock-servers/mock-joinpeertube-versions.tsindex e7906ea56f..502f4e2f54 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 @@import express from 'express'import { Server } from 'http'-import { getPort, randomListen } from './utils'+import { getPort, randomListen } from './shared'export class MockJoinPeerTubeVersions {private server: Serverdiff --git a/shared/server-commands/mock-servers/mock-object-storage.ts b/server/tests/shared/mock-servers/mock-object-storage.tssimilarity index 88%rename from shared/server-commands/mock-servers/mock-object-storage.tsrename to server/tests/shared/mock-servers/mock-object-storage.tsindex d135c2631f..99d68e0145 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'import got, { RequestError } from 'got'import { Server } from 'http'import { pipeline } from 'stream'-import { ObjectStorageCommand } from '../server'-import { getPort, randomListen, terminateServer } from './utils'+import { ObjectStorageCommand } from '@shared/server-commands'+import { getPort, randomListen, terminateServer } from './shared'export class MockObjectStorage {private server: Serverdiff --git a/shared/server-commands/mock-servers/mock-plugin-blocklist.ts b/server/tests/shared/mock-servers/mock-plugin-blocklist.tssimilarity index 90%rename from shared/server-commands/mock-servers/mock-plugin-blocklist.tsrename to server/tests/shared/mock-servers/mock-plugin-blocklist.tsindex f8a271cba1..5d6e018164 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 @@import express, { Request, Response } from 'express'import { Server } from 'http'-import { getPort, randomListen, terminateServer } from './utils'+import { getPort, randomListen, terminateServer } from './shared'type BlocklistResponse = {data: {diff --git a/shared/server-commands/mock-servers/mock-proxy.ts b/server/tests/shared/mock-servers/mock-proxy.tssimilarity index 89%rename from shared/server-commands/mock-servers/mock-proxy.tsrename to server/tests/shared/mock-servers/mock-proxy.tsindex 75ac790551..cbc7c44662 100644--- a/shared/server-commands/mock-servers/mock-proxy.ts+++ b/server/tests/shared/mock-servers/mock-proxy.ts@@ -1,7 +1,6 @@-import { createServer, Server } from 'http'import proxy from 'proxy'-import { getPort, terminateServer } from './utils'+import { getPort, terminateServer } from './shared'class MockProxy {private server: Serverdiff --git a/shared/server-commands/mock-servers/utils.ts b/server/tests/shared/mock-servers/shared.tssimilarity index 100%rename from shared/server-commands/mock-servers/utils.tsrename to server/tests/shared/mock-servers/shared.tsdiff --git a/shared/server-commands/users/notifications.ts b/server/tests/shared/notifications.tssimilarity index 98%rename from shared/server-commands/users/notifications.tsrename to server/tests/shared/notifications.tsindex 07ccb0f8dc..cdc21fdc86 100644--- a/shared/server-commands/users/notifications.ts+++ b/server/tests/shared/notifications.ts@@ -2,13 +2,16 @@import { expect } from 'chai'import { inspect } from 'util'-import { AbuseState, PluginType } from '@shared/models'-import { UserNotification, UserNotificationSetting, UserNotificationSettingValue, UserNotificationType } from '../../models/users'-import { MockSmtpServer } from '../mock-servers/mock-email'-import { PeerTubeServer } from '../server'-import { doubleFollow } from '../server/follows'-import { createMultipleServers } from '../server/servers'-import { setAccessTokensToServers } from './login'+import {+ AbuseState,+ PluginType,+ UserNotification,+ UserNotificationSetting,+ UserNotificationSettingValue,+ UserNotificationType+} from '@shared/models'+import { createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'+import { MockSmtpServer } from './mock-servers'type CheckerBaseParams = {server: PeerTubeServerdiff --git a/shared/server-commands/videos/playlists.ts b/server/tests/shared/playlists.tssimilarity index 93%rename from shared/server-commands/videos/playlists.tsrename to server/tests/shared/playlists.tsindex 3dde52bb94..fdd541d20e 100644--- a/shared/server-commands/videos/playlists.ts+++ b/server/tests/shared/playlists.ts@@ -1,7 +1,7 @@import { expect } from 'chai'import { readdir } from 'fs-extra'import { join } from 'path'-import { root } from '../miscs'+import { root } from '@shared/core-utils'async function checkPlaylistFilesWereRemoved (playlistUUID: string,diff --git a/shared/server-commands/server/plugins.ts b/server/tests/shared/plugins.tssimilarity index 91%rename from shared/server-commands/server/plugins.tsrename to server/tests/shared/plugins.tsindex c6316898df..036fce2ff9 100644--- a/shared/server-commands/server/plugins.ts+++ b/server/tests/shared/plugins.ts@@ -1,7 +1,7 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */import { expect } from 'chai'-import { PeerTubeServer } from './server'+import { PeerTubeServer } from '@shared/server-commands'async function testHelloWorldRegisteredSettings (server: PeerTubeServer) {const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })diff --git a/server/tests/shared/requests.ts b/server/tests/shared/requests.tsindex 9eb5960298..7f1acc0e13 100644--- a/server/tests/shared/requests.ts+++ b/server/tests/shared/requests.ts@@ -1,7 +1,7 @@-import { doRequest } from '@server/helpers/requests'import { activityPubContextify } from '@server/helpers/activitypub'-import { HTTP_SIGNATURE } from '@server/initializers/constants'-import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'+import { buildDigest } from '@server/helpers/peertube-crypto'+import { doRequest } from '@server/helpers/requests'+import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants'export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {const options = {@@ -31,7 +31,11 @@ export async function makeFollowRequest (to: { url: string }, by: { url: string,key: by.privateKey,headers: HTTP_SIGNATURE.HEADERS_TO_SIGN}- const headers = buildGlobalHeaders(body)+ const headers = {+ 'digest': buildDigest(body),+ 'content-type': 'application/activity+json',+ 'accept': ACTIVITY_PUB.ACCEPT_HEADER+ }return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers)}diff --git a/shared/server-commands/videos/streaming-playlists.ts b/server/tests/shared/streaming-playlists.tssimilarity index 95%rename from shared/server-commands/videos/streaming-playlists.tsrename to server/tests/shared/streaming-playlists.tsindex 0451c0efef..738dc90e13 100644--- a/shared/server-commands/videos/streaming-playlists.ts+++ b/server/tests/shared/streaming-playlists.ts@@ -1,9 +1,9 @@import { expect } from 'chai'import { basename } from 'path'-import { sha256 } from '@shared/core-utils/crypto'import { removeFragmentedMP4Ext } from '@shared/core-utils'+import { sha256 } from '@shared/core-utils/common/crypto'import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'-import { PeerTubeServer } from '../server'+import { PeerTubeServer } from '@shared/server-commands'async function checkSegmentHash (options: {server: PeerTubeServerdiff --git a/server/tests/shared/tests.ts b/server/tests/shared/tests.tsnew file mode 100644index 0000000000..3abaf833d5--- /dev/null+++ b/server/tests/shared/tests.ts@@ -0,0 +1,37 @@+const FIXTURE_URLS = {+ peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e',+ peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',++ youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM',++ /**+ * The video is used to check format-selection correctness wrt. HDR,+ * which brings its own set of oddities outside of a MediaSource.+ *+ * The video needs to have the following format_ids:+ * (which you can check by using `youtube-dl <url> -F`):+ * - (webm vp9)+ * - (mp4 avc1)+ * - (webm vp9.2 HDR)+ */+ youtubeHDR: 'https://www.youtube.com/watch?v=RQgnBB9z_N4',++ // eslint-disable-next-line max-len+ 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',++ badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',+ goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',+ goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4',++ file4K: 'https://download.cpy.re/peertube/4k_file.txt'+}++function buildRequestStub (): any {+ return { }+}++export {+ FIXTURE_URLS,++ buildRequestStub+}diff --git a/shared/server-commands/server/tracker.ts b/server/tests/shared/tracker.tssimilarity index 87%rename from shared/server-commands/server/tracker.tsrename to server/tests/shared/tracker.tsindex ed43a59245..699895d5f3 100644--- a/shared/server-commands/server/tracker.ts+++ b/server/tests/shared/tracker.ts@@ -1,6 +1,6 @@import { expect } from 'chai'-import { sha1 } from '@shared/core-utils/crypto'-import { makeGetRequest } from '../requests'+import { sha1 } from '@shared/core-utils'+import { makeGetRequest } from '@shared/server-commands'async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) {const path = '/tracker/announce'diff --git a/server/tests/shared/video.ts b/server/tests/shared/videos.tssimilarity index 64%rename from server/tests/shared/video.tsrename to server/tests/shared/videos.tsindex cf923d4cd4..6be094f2bf 100644--- a/server/tests/shared/video.ts+++ b/server/tests/shared/videos.ts@@ -1,12 +1,17 @@-/* eslint-disable @typescript-eslint/no-unused-expressions */-import { dateIsValid, makeRawRequest, PeerTubeServer, testImage, webtorrentAdd } from '@shared/server-commands'+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */+import { expect } from 'chai'+import { pathExists, readdir } from 'fs-extra'+import { basename, join } from 'path'import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '@server/initializers/constants'import { getLowercaseExtension, uuidRegex } from '@shared/core-utils'+import { HttpStatusCode, VideoCaption, VideoDetails } from '@shared/models'+import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs, webtorrentAdd } from '@shared/server-commands'+import { dateIsValid, testImage } from './checks'loadLanguages()-export async function completeVideoCheck (+async function completeVideoCheck (server: PeerTubeServer,video: any,attributes: {@@ -148,3 +153,99 @@ export async function completeVideoCheck (await testImage(server.url, attributes.previewfile, videoDetails.previewPath)}}++async function checkVideoFilesWereRemoved (options: {+ server: PeerTubeServer+ video: VideoDetails+ captions?: VideoCaption[]+ onlyVideoFiles?: boolean // default false+}) {+ const { video, server, captions = [], onlyVideoFiles = false } = options++ const webtorrentFiles = video.files || []+ const hlsFiles = video.streamingPlaylists[0]?.files || []++ const thumbnailName = basename(video.thumbnailPath)+ const previewName = basename(video.previewPath)++ const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl))++ const captionNames = captions.map(c => basename(c.captionPath))++ const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl))+ const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl))++ let directories: { [ directory: string ]: string[] } = {+ videos: webtorrentFilenames,+ redundancy: webtorrentFilenames,+ [join('playlists', 'hls')]: hlsFilenames,+ [join('redundancy', 'hls')]: hlsFilenames+ }++ if (onlyVideoFiles !== true) {+ directories = {+ ...directories,++ thumbnails: [ thumbnailName ],+ previews: [ previewName ],+ torrents: torrentNames,+ captions: captionNames+ }+ }++ for (const directory of Object.keys(directories)) {+ const directoryPath = server.servers.buildDirectory(directory)++ const directoryExists = await pathExists(directoryPath)+ if (directoryExists === false) continue++ const existingFiles = await readdir(directoryPath)+ for (const existingFile of existingFiles) {+ for (const shouldNotExist of directories[directory]) {+ expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist)+ }+ }+ }+}++async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) {+ for (const server of servers) {+ server.store.videoDetails = await server.videos.get({ id: uuid })+ }+}++function checkUploadVideoParam (+ server: PeerTubeServer,+ token: string,+ attributes: Partial<VideoEdit>,+ expectedStatus = HttpStatusCode.OK_200,+ mode: 'legacy' | 'resumable' = 'legacy'+) {+ return mode === 'legacy'+ ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus })+ : server.videos.buildResumeUpload({ token, attributes, expectedStatus })+}++// serverNumber starts from 1+async function uploadRandomVideoOnServers (+ servers: PeerTubeServer[],+ serverNumber: number,+ additionalParams?: VideoEdit & { prefixName?: string }+) {+ const server = servers.find(s => s.serverNumber === serverNumber)+ const res = await server.videos.randomUpload({ wait: false, additionalParams })++ await waitJobs(servers)++ return res+}++// ---------------------------------------------------------------------------++export {+ completeVideoCheck,+ checkUploadVideoParam,+ uploadRandomVideoOnServers,+ checkVideoFilesWereRemoved,+ saveVideoInServers+}diff --git a/shared/core-utils/utils/array.ts b/shared/core-utils/common/array.tssimilarity index 100%rename from shared/core-utils/utils/array.tsrename to shared/core-utils/common/array.tsdiff --git a/shared/core-utils/crypto.ts b/shared/core-utils/common/crypto.tssimilarity index 72%rename from shared/core-utils/crypto.tsrename to shared/core-utils/common/crypto.tsindex d6d1150d0a..1a583f1a09 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') {return createHash('sha1').update(str).digest(encoding)}+// high excluded+function randomInt (low: number, high: number) {+ return Math.floor(Math.random() * (high - low) + low)+}+export {+ randomInt,sha256,sha1}diff --git a/shared/core-utils/common/env.ts b/shared/core-utils/common/env.tsnew file mode 100644index 0000000000..38c96b1520--- /dev/null+++ b/shared/core-utils/common/env.ts@@ -0,0 +1,30 @@+function parallelTests () {+ return process.env.MOCHA_PARALLEL === 'true'+}++function isGithubCI () {+ return !!process.env.GITHUB_WORKSPACE+}++function areHttpImportTestsDisabled () {+ const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'++ if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled')++ return disabled+}++function areObjectStorageTestsDisabled () {+ const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'++ if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled')++ return disabled+}++export {+ parallelTests,+ isGithubCI,+ areHttpImportTestsDisabled,+ areObjectStorageTestsDisabled+}diff --git a/shared/core-utils/common/index.ts b/shared/core-utils/common/index.tsindex 5d35121484..f9ba10d5e0 100644--- a/shared/core-utils/common/index.ts+++ b/shared/core-utils/common/index.ts@@ -1,5 +1,11 @@+export * from './array'+export * from './crypto'export * from './date'-export * from './miscs'+export * from './env'+export * from './object'+export * from './path'export * from './regexp'+export * from './time'export * from './promises'export * from './url'+export * from './version'diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.tsnew file mode 100644index 0000000000..88d6b7514d--- /dev/null+++ b/shared/core-utils/common/object.ts@@ -0,0 +1,30 @@+function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {+ const result: any = {}++ for (const key of keys) {+ if (Object.prototype.hasOwnProperty.call(object, key)) {+ result[key] = object[key]+ }+ }++ return result+}++function sortObjectComparator (key: string, order: 'asc' | 'desc') {+ return (a: any, b: any) => {+ if (a[key] < b[key]) {+ return order === 'asc' ? -1 : 1+ }++ if (a[key] > b[key]) {+ return order === 'asc' ? 1 : -1+ }++ return 0+ }+}++export {+ pick,+ sortObjectComparator+}diff --git a/shared/core-utils/path.ts b/shared/core-utils/common/path.tssimilarity index 65%rename from shared/core-utils/path.tsrename to shared/core-utils/common/path.tsindex b1a45d69ba..ec507538b2 100644--- a/shared/core-utils/path.ts+++ b/shared/core-utils/common/path.ts@@ -7,6 +7,7 @@ function root () {rootPath = __dirname+ if (basename(rootPath) === 'common') rootPath = resolve(rootPath, '..')if (basename(rootPath) === 'core-utils') rootPath = resolve(rootPath, '..')if (basename(rootPath) === 'shared') rootPath = resolve(rootPath, '..')if (basename(rootPath) === 'server') rootPath = resolve(rootPath, '..')@@ -27,8 +28,19 @@ function getLowercaseExtension (filename: string) {return ext.toLowerCase()}+function buildAbsoluteFixturePath (path: string, customCIPath = false) {+ if (isAbsolute(path)) return path++ if (customCIPath && process.env.GITHUB_WORKSPACE) {+ return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)+ }++ return join(root(), 'server', 'tests', 'fixtures', path)+}+export {root,buildPath,+ buildAbsoluteFixturePath,getLowercaseExtension}diff --git a/shared/core-utils/common/time.ts b/shared/core-utils/common/time.tsnew file mode 100644index 0000000000..2992609caa--- /dev/null+++ b/shared/core-utils/common/time.ts@@ -0,0 +1,7 @@+function wait (milliseconds: number) {+ return new Promise(resolve => setTimeout(resolve, milliseconds))+}++export {+ wait+}diff --git a/shared/core-utils/common/miscs.ts b/shared/core-utils/common/version.tssimilarity index 53%rename from shared/core-utils/common/miscs.tsrename to shared/core-utils/common/version.tsindex bc65dc3386..8a64f8c4d0 100644--- a/shared/core-utils/common/miscs.ts+++ b/shared/core-utils/common/version.ts@@ -1,8 +1,3 @@-// high excluded-function randomInt (low: number, high: number) {- return Math.floor(Math.random() * (high - low) + low)-}-// Thanks https://stackoverflow.com/a/16187766function compareSemVer (a: string, b: string) {const regExStrip0 = /(\.0+)+$/@@ -20,22 +15,6 @@ function compareSemVer (a: string, b: string) {return segmentsA.length - segmentsB.length}-function sortObjectComparator (key: string, order: 'asc' | 'desc') {- return (a: any, b: any) => {- if (a[key] < b[key]) {- return order === 'asc' ? -1 : 1- }-- if (a[key] > b[key]) {- return order === 'asc' ? 1 : -1- }-- return 0- }-}-export {- randomInt,- compareSemVer,- sortObjectComparator+ compareSemVer}diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.tsindex ee5cd4412a..8daaa2d04a 100644--- a/shared/core-utils/index.ts+++ b/shared/core-utils/index.ts@@ -1,10 +1,7 @@export * from './abuse'export * from './common'export * from './i18n'-export * from './path'export * from './plugins'export * from './renderer'export * from './users'-export * from './utils'export * from './videos'-export * from './uuid'diff --git a/shared/core-utils/utils/index.ts b/shared/core-utils/utils/index.tsdeleted file mode 100644index 8d16365a87..0000000000--- a/shared/core-utils/utils/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './array'-export * from './object'diff --git a/shared/core-utils/utils/object.ts b/shared/core-utils/utils/object.tsdeleted file mode 100644index 9a8a98f9b9..0000000000--- a/shared/core-utils/utils/object.ts+++ /dev/null@@ -1,15 +0,0 @@-function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {- const result: any = {}-- for (const key of keys) {- if (Object.prototype.hasOwnProperty.call(object, key)) {- result[key] = object[key]- }- }-- return result-}--export {- pick-}diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.tsindex 620e3a716f..8f6736d39d 100644--- a/shared/core-utils/videos/index.ts+++ b/shared/core-utils/videos/index.ts@@ -1,2 +1,3 @@export * from './bitrate'export * from './privacy'+export * from './uuid'diff --git a/shared/core-utils/uuid.ts b/shared/core-utils/videos/uuid.tssimilarity index 100%rename from shared/core-utils/uuid.tsrename to shared/core-utils/videos/uuid.tsdiff --git a/shared/extra-utils/file.ts b/shared/extra-utils/file.tsnew file mode 100644index 0000000000..8060ab5209--- /dev/null+++ b/shared/extra-utils/file.ts@@ -0,0 +1,11 @@+import { stat } from 'fs-extra'++async function getFileSize (path: string) {+ const stats = await stat(path)++ return stats.size+}++export {+ getFileSize+}diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.tsindex 5710c5ab50..38303cf1fa 100644--- a/shared/extra-utils/index.ts+++ b/shared/extra-utils/index.ts@@ -1 +1,2 @@export * from './ffprobe'+export * from './file'diff --git a/shared/models/users/index.ts b/shared/models/users/index.tsindex b61a8cd40a..a24ffee962 100644--- a/shared/models/users/index.ts+++ b/shared/models/users/index.ts@@ -8,6 +8,7 @@ export * from './user-refresh-token.model'export * from './user-register.model'export * from './user-right.enum'export * from './user-role'+export * from './user-scoped-token'export * from './user-update-me.model'export * from './user-update.model'export * from './user-video-quota.model'diff --git a/shared/server-commands/index.ts b/shared/server-commands/index.tsindex 4b3636d068..c24ebb2df2 100644--- a/shared/server-commands/index.ts+++ b/shared/server-commands/index.ts@@ -4,7 +4,6 @@ export * from './custom-pages'export * from './feeds'export * from './logs'export * from './miscs'-export * from './mock-servers'export * from './moderation'export * from './overviews'export * from './requests'diff --git a/shared/server-commands/logs/logs-command.ts b/shared/server-commands/logs/logs-command.tsindex 7b5c66c0cc..8f63383ea2 100644--- a/shared/server-commands/logs/logs-command.ts+++ b/shared/server-commands/logs/logs-command.ts@@ -1,5 +1,4 @@-import { HttpStatusCode } from '@shared/models'-import { LogLevel } from '../../models/server/log-level.type'+import { HttpStatusCode, LogLevel } from '@shared/models'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class LogsCommand extends AbstractCommand {diff --git a/shared/server-commands/miscs/index.ts b/shared/server-commands/miscs/index.tsindex 4474661de8..a1d14e9987 100644--- a/shared/server-commands/miscs/index.ts+++ b/shared/server-commands/miscs/index.ts@@ -1,5 +1,2 @@-export * from './checks'-export * from './generate'export * from './sql-command'-export * from './tests'export * from './webtorrent'diff --git a/shared/server-commands/miscs/sql-command.ts b/shared/server-commands/miscs/sql-command.tsindex bedb3349b4..09a99f8340 100644--- a/shared/server-commands/miscs/sql-command.ts+++ b/shared/server-commands/miscs/sql-command.ts@@ -1,5 +1,5 @@import { QueryTypes, Sequelize } from 'sequelize'-import { AbstractCommand } from '../shared/abstract-command'+import { AbstractCommand } from '../shared'export class SQLCommand extends AbstractCommand {private sequelize: Sequelizediff --git a/shared/server-commands/miscs/tests.ts b/shared/server-commands/miscs/tests.tsdeleted file mode 100644index 658fe5fd35..0000000000--- a/shared/server-commands/miscs/tests.ts+++ /dev/null@@ -1,101 +0,0 @@-import { stat } from 'fs-extra'-import { basename, isAbsolute, join, resolve } from 'path'--const FIXTURE_URLS = {- peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e',- peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',-- youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM',-- /**- * The video is used to check format-selection correctness wrt. HDR,- * which brings its own set of oddities outside of a MediaSource.- *- * The video needs to have the following format_ids:- * (which you can check by using `youtube-dl <url> -F`):- * - (webm vp9)- * - (mp4 avc1)- * - (webm vp9.2 HDR)- */- youtubeHDR: 'https://www.youtube.com/watch?v=RQgnBB9z_N4',-- // eslint-disable-next-line max-len- 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',-- badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',- goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',- goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4',-- file4K: 'https://download.cpy.re/peertube/4k_file.txt'-}--function parallelTests () {- return process.env.MOCHA_PARALLEL === 'true'-}--function isGithubCI () {- return !!process.env.GITHUB_WORKSPACE-}--function areHttpImportTestsDisabled () {- const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'-- if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled')-- return disabled-}--function areObjectStorageTestsDisabled () {- const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'-- if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled')-- return disabled-}--function buildAbsoluteFixturePath (path: string, customCIPath = false) {- if (isAbsolute(path)) return path-- if (customCIPath && process.env.GITHUB_WORKSPACE) {- return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)- }-- return join(root(), 'server', 'tests', 'fixtures', path)-}--function root () {- // We are in /miscs- let root = join(__dirname, '..', '..', '..')-- if (basename(root) === 'dist') root = resolve(root, '..')-- return root-}--function wait (milliseconds: number) {- return new Promise(resolve => setTimeout(resolve, milliseconds))-}--async function getFileSize (path: string) {- const stats = await stat(path)-- return stats.size-}--function buildRequestStub (): any {- return { }-}--export {- FIXTURE_URLS,-- parallelTests,- isGithubCI,- areHttpImportTestsDisabled,- buildAbsoluteFixturePath,- getFileSize,- buildRequestStub,- areObjectStorageTestsDisabled,- wait,- root-}diff --git a/shared/server-commands/requests/check-api-params.ts b/shared/server-commands/requests/check-api-params.tsdeleted file mode 100644index 26ba1e9132..0000000000--- a/shared/server-commands/requests/check-api-params.ts+++ /dev/null@@ -1,48 +0,0 @@-import { HttpStatusCode } from '@shared/models'-import { makeGetRequest } from './requests'--function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {- return makeGetRequest({- url,- path,- token,- query: { ...query, start: 'hello' },- expectedStatus: HttpStatusCode.BAD_REQUEST_400- })-}--async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {- await makeGetRequest({- url,- path,- token,- query: { ...query, count: 'hello' },- expectedStatus: HttpStatusCode.BAD_REQUEST_400- })-- await makeGetRequest({- url,- path,- token,- query: { ...query, count: 2000 },- expectedStatus: HttpStatusCode.BAD_REQUEST_400- })-}--function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {- return makeGetRequest({- url,- path,- token,- query: { ...query, sort: 'hello' },- expectedStatus: HttpStatusCode.BAD_REQUEST_400- })-}--// -----------------------------------------------------------------------------export {- checkBadStartPagination,- checkBadCountPagination,- checkBadSortPagination-}diff --git a/shared/server-commands/requests/index.ts b/shared/server-commands/requests/index.tsindex 501163f92b..8029823012 100644--- a/shared/server-commands/requests/index.ts+++ b/shared/server-commands/requests/index.ts@@ -1,3 +1 @@-// Don't include activitypub that import stuff from server-export * from './check-api-params'export * from './requests'diff --git a/shared/server-commands/requests/requests.ts b/shared/server-commands/requests/requests.tsindex b6b9024ed1..95e4fe6b1e 100644--- a/shared/server-commands/requests/requests.ts+++ b/shared/server-commands/requests/requests.ts@@ -3,8 +3,8 @@import { decode } from 'querystring'import request from 'supertest'import { URL } from 'url'+import { buildAbsoluteFixturePath } from '@shared/core-utils'import { HttpStatusCode } from '@shared/models'-import { buildAbsoluteFixturePath } from '../miscs/tests'export type CommonRequestParams = {url: stringdiff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.tsindex 89ae8eb4f6..797231b1d2 100644--- a/shared/server-commands/server/config-command.ts+++ b/shared/server-commands/server/config-command.ts@@ -1,8 +1,7 @@import { merge } from 'lodash'+import { About, CustomConfig, HttpStatusCode, ServerConfig } from '@shared/models'import { DeepPartial } from '@shared/typescript-utils'-import { About, HttpStatusCode, ServerConfig } from '@shared/models'-import { CustomConfig } from '../../models/server/custom-config.model'-import { AbstractCommand, OverrideCommandOptions } from '../shared'+import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command'export class ConfigCommand extends AbstractCommand {diff --git a/shared/server-commands/server/index.ts b/shared/server-commands/server/index.tsindex 76a2099da6..0a4b21fc46 100644--- a/shared/server-commands/server/index.ts+++ b/shared/server-commands/server/index.ts@@ -1,17 +1,14 @@export * from './config-command'export * from './contact-form-command'export * from './debug-command'-export * from './directories'export * from './follows-command'export * from './follows'export * from './jobs'export * from './jobs-command'export * from './object-storage-command'export * from './plugins-command'-export * from './plugins'export * from './redundancy-command'export * from './server'export * from './servers-command'export * from './servers'export * from './stats-command'-export * from './tracker'diff --git a/shared/server-commands/server/jobs-command.ts b/shared/server-commands/server/jobs-command.tsindex 6636e7e4d3..ac62157d1d 100644--- a/shared/server-commands/server/jobs-command.ts+++ b/shared/server-commands/server/jobs-command.ts@@ -1,6 +1,5 @@import { pick } from '@shared/core-utils'-import { HttpStatusCode } from '@shared/models'-import { Job, JobState, JobType, ResultList } from '../../models'+import { HttpStatusCode, Job, JobState, JobType, ResultList } from '@shared/models'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class JobsCommand extends AbstractCommand {diff --git a/shared/server-commands/server/jobs.ts b/shared/server-commands/server/jobs.tsindex 34fefd4442..fc65a873b1 100644--- a/shared/server-commands/server/jobs.ts+++ b/shared/server-commands/server/jobs.ts@@ -1,7 +1,7 @@import { expect } from 'chai'+import { wait } from '@shared/core-utils'import { JobState, JobType } from '../../models'-import { wait } from '../miscs'import { PeerTubeServer } from './server'async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) {diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.tsindex 339b9cabb8..617069b11f 100644--- a/shared/server-commands/server/server.ts+++ b/shared/server-commands/server/server.ts@@ -1,14 +1,14 @@import { ChildProcess, fork } from 'child_process'import { copy } from 'fs-extra'import { join } from 'path'-import { root, randomInt } from '@shared/core-utils'-import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '../../models/videos'+import { parallelTests, randomInt, root } from '@shared/core-utils'+import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '@shared/models'import { BulkCommand } from '../bulk'import { CLICommand } from '../cli'import { CustomPagesCommand } from '../custom-pages'import { FeedCommand } from '../feeds'import { LogsCommand } from '../logs'-import { parallelTests, SQLCommand } from '../miscs'+import { SQLCommand } from '../miscs'import { AbusesCommand } from '../moderation'import { OverviewsCommand } from '../overviews'import { SearchCommand } from '../search'@@ -33,11 +33,11 @@ import { ContactFormCommand } from './contact-form-command'import { DebugCommand } from './debug-command'import { FollowsCommand } from './follows-command'import { JobsCommand } from './jobs-command'+import { ObjectStorageCommand } from './object-storage-command'import { PluginsCommand } from './plugins-command'import { RedundancyCommand } from './redundancy-command'import { ServersCommand } from './servers-command'import { StatsCommand } from './stats-command'-import { ObjectStorageCommand } from './object-storage-command'export type RunServerOptions = {hideLogs?: booleandiff --git a/shared/server-commands/server/servers-command.ts b/shared/server-commands/server/servers-command.tsindex 47420c95f2..c5d8d18dcf 100644--- a/shared/server-commands/server/servers-command.ts+++ b/shared/server-commands/server/servers-command.ts@@ -1,9 +1,9 @@import { exec } from 'child_process'import { copy, ensureDir, readFile, remove } from 'fs-extra'import { basename, join } from 'path'-import { root } from '@shared/core-utils'+import { isGithubCI, root, wait } from '@shared/core-utils'+import { getFileSize } from '@shared/extra-utils'import { HttpStatusCode } from '@shared/models'-import { getFileSize, isGithubCI, wait } from '../miscs'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class ServersCommand extends AbstractCommand {diff --git a/shared/server-commands/server/servers.ts b/shared/server-commands/server/servers.tsindex 21ab9405b5..0faee3a8d4 100644--- a/shared/server-commands/server/servers.ts+++ b/shared/server-commands/server/servers.ts@@ -1,5 +1,5 @@import { ensureDir } from 'fs-extra'-import { isGithubCI } from '../miscs'+import { isGithubCI } from '@shared/core-utils'import { PeerTubeServer, RunServerOptions } from './server'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.tsindex a57c857fcf..1b53a53305 100644--- a/shared/server-commands/shared/abstract-command.ts+++ b/shared/server-commands/shared/abstract-command.ts@@ -1,5 +1,5 @@import { isAbsolute, join } from 'path'-import { root } from '../miscs/tests'+import { root } from '@shared/core-utils'import {makeDeleteRequest,makeGetRequest,diff --git a/shared/server-commands/users/accounts-command.ts b/shared/server-commands/users/accounts-command.tsindex 98d9d59271..5844b330b9 100644--- a/shared/server-commands/users/accounts-command.ts+++ b/shared/server-commands/users/accounts-command.ts@@ -1,6 +1,4 @@-import { HttpStatusCode, ResultList } from '@shared/models'-import { Account, ActorFollow } from '../../models/actors'-import { AccountVideoRate, VideoRateType } from '../../models/videos'+import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@shared/models'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class AccountsCommand extends AbstractCommand {diff --git a/shared/server-commands/users/index.ts b/shared/server-commands/users/index.tsindex 460a06f702..c2bc5c44f6 100644--- a/shared/server-commands/users/index.ts+++ b/shared/server-commands/users/index.ts@@ -1,9 +1,7 @@export * from './accounts-command'-export * from './actors'export * from './blocklist-command'export * from './login'export * from './login-command'-export * from './notifications'export * from './notifications-command'export * from './subscriptions-command'export * from './users-command'diff --git a/shared/server-commands/users/notifications-command.ts b/shared/server-commands/users/notifications-command.tsindex 692420b8b5..6bd815daa2 100644--- a/shared/server-commands/users/notifications-command.ts+++ b/shared/server-commands/users/notifications-command.ts@@ -1,5 +1,4 @@-import { HttpStatusCode, ResultList } from '@shared/models'-import { UserNotification, UserNotificationSetting } from '../../models/users'+import { HttpStatusCode, ResultList, UserNotification, UserNotificationSetting } from '@shared/models'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class NotificationsCommand extends AbstractCommand {diff --git a/shared/server-commands/users/users-command.ts b/shared/server-commands/users/users-command.tsindex 90c5f21834..b5ae9008e4 100644--- a/shared/server-commands/users/users-command.ts+++ b/shared/server-commands/users/users-command.ts@@ -4,6 +4,7 @@ import {HttpStatusCode,MyUser,ResultList,+ ScopedToken,User,UserAdminFlag,UserCreateResult,@@ -13,7 +14,6 @@ import {UserVideoQuota,UserVideoRate} from '@shared/models'-import { ScopedToken } from '@shared/models/users/user-scoped-token'import { unwrapBody } from '../requests'import { AbstractCommand, OverrideCommandOptions } from '../shared'diff --git a/shared/server-commands/videos/blacklist-command.ts b/shared/server-commands/videos/blacklist-command.tsindex 3a2ef89ba1..47e23ebc8e 100644--- a/shared/server-commands/videos/blacklist-command.ts+++ b/shared/server-commands/videos/blacklist-command.ts@@ -1,6 +1,5 @@-import { HttpStatusCode, ResultList } from '@shared/models'-import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'+import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class BlacklistCommand extends AbstractCommand {diff --git a/shared/server-commands/videos/captions-command.ts b/shared/server-commands/videos/captions-command.tsindex a65ea99e33..62bf9c5e60 100644--- a/shared/server-commands/videos/captions-command.ts+++ b/shared/server-commands/videos/captions-command.ts@@ -1,5 +1,5 @@+import { buildAbsoluteFixturePath } from '@shared/core-utils'import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models'-import { buildAbsoluteFixturePath } from '../miscs'import { AbstractCommand, OverrideCommandOptions } from '../shared'export class CaptionsCommand extends AbstractCommand {diff --git a/shared/server-commands/videos/channels-command.ts b/shared/server-commands/videos/channels-command.tsindex e406e570b9..8ab1246581 100644--- a/shared/server-commands/videos/channels-command.ts+++ b/shared/server-commands/videos/channels-command.ts@@ -1,7 +1,13 @@import { pick } from '@shared/core-utils'-import { ActorFollow, HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models'-import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'-import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'+import {+ ActorFollow,+ HttpStatusCode,+ ResultList,+ VideoChannel,+ VideoChannelCreate,+ VideoChannelCreateResult,+ VideoChannelUpdate+} from '@shared/models'import { unwrapBody } from '../requests'import { AbstractCommand, OverrideCommandOptions } from '../shared'diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.tsindex 26e663f466..68a188b211 100644--- a/shared/server-commands/videos/index.ts+++ b/shared/server-commands/videos/index.ts@@ -1,6 +1,5 @@export * from './blacklist-command'export * from './captions-command'-export * from './captions'export * from './change-ownership-command'export * from './channels'export * from './channels-command'@@ -10,10 +9,7 @@ export * from './imports-command'export * from './live-command'export * from './live'export * from './playlists-command'-export * from './playlists'export * from './services-command'export * from './streaming-playlists-command'-export * from './streaming-playlists'export * from './comments-command'export * from './videos-command'-export * from './videos'diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.tsindex 74f5d30899..f7816eca0d 100644--- a/shared/server-commands/videos/live-command.ts+++ b/shared/server-commands/videos/live-command.ts@@ -3,8 +3,8 @@import { readdir } from 'fs-extra'import { omit } from 'lodash'import { join } from 'path'+import { wait } from '@shared/core-utils'import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'-import { wait } from '../miscs'import { unwrapBody } from '../requests'import { AbstractCommand, OverrideCommandOptions } from '../shared'import { sendRTMPStream, testFfmpegStreamError } from './live'diff --git a/shared/server-commands/videos/live.ts b/shared/server-commands/videos/live.tsindex d3665bc908..7a7faa9115 100644--- a/shared/server-commands/videos/live.ts+++ b/shared/server-commands/videos/live.ts@@ -1,10 +1,5 @@-/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */--import { expect } from 'chai'import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'-import { pathExists, readdir } from 'fs-extra'-import { join } from 'path'-import { buildAbsoluteFixturePath, wait } from '../miscs'+import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'import { PeerTubeServer } from '../server/server'function sendRTMPStream (options: {@@ -95,43 +90,11 @@ async function waitUntilLiveSavedOnAllServers (servers: PeerTubeServer[], videoI}}-async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) {- const basePath = server.servers.buildDirectory('streaming-playlists')- const hlsPath = join(basePath, 'hls', videoUUID)-- if (resolutions.length === 0) {- const result = await pathExists(hlsPath)- expect(result).to.be.false-- return- }-- const files = await readdir(hlsPath)-- // fragmented file and playlist per resolution + master playlist + segments sha256 json file- expect(files).to.have.lengthOf(resolutions.length * 2 + 2)-- for (const resolution of resolutions) {- const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`))- expect(fragmentedFile).to.exist-- const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`))- expect(playlistFile).to.exist- }-- const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8'))- expect(masterPlaylistFile).to.exist-- const shaFile = files.find(f => f.endsWith('-segments-sha256.json'))- expect(shaFile).to.exist-}-export {sendRTMPStream,waitFfmpegUntilError,testFfmpegStreamError,stopFfmpeg,waitUntilLivePublishedOnAllServers,- waitUntilLiveSavedOnAllServers,- checkLiveCleanupAfterSave+ waitUntilLiveSavedOnAllServers}diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.tsindex 8ea828b40d..ead57b9aa6 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'import got, { Response as GotResponse } from 'got'import { omit } from 'lodash'import validator from 'validator'-import { buildUUID } from '@shared/core-utils/uuid'-import { pick } from '@shared/core-utils'+import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils'import {HttpStatusCode,ResultList,@@ -20,7 +19,6 @@ import {VideosCommonQuery,VideoTranscodingCreate} from '@shared/models'-import { buildAbsoluteFixturePath, wait } from '../miscs'import { unwrapBody } from '../requests'import { waitJobs } from '../server'import { AbstractCommand, OverrideCommandOptions } from '../shared'diff --git a/shared/server-commands/videos/videos.ts b/shared/server-commands/videos/videos.tsdeleted file mode 100644index 2c3464aa83..0000000000--- a/shared/server-commands/videos/videos.ts+++ /dev/null@@ -1,104 +0,0 @@-/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */--import { expect } from 'chai'-import { pathExists, readdir } from 'fs-extra'-import { basename, join } from 'path'-import { HttpStatusCode, VideoCaption, VideoDetails } from '@shared/models'-import { waitJobs } from '../server'-import { PeerTubeServer } from '../server/server'-import { VideoEdit } from './videos-command'--async function checkVideoFilesWereRemoved (options: {- server: PeerTubeServer- video: VideoDetails- captions?: VideoCaption[]- onlyVideoFiles?: boolean // default false-}) {- const { video, server, captions = [], onlyVideoFiles = false } = options-- const webtorrentFiles = video.files || []- const hlsFiles = video.streamingPlaylists[0]?.files || []-- const thumbnailName = basename(video.thumbnailPath)- const previewName = basename(video.previewPath)-- const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl))-- const captionNames = captions.map(c => basename(c.captionPath))-- const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl))- const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl))-- let directories: { [ directory: string ]: string[] } = {- videos: webtorrentFilenames,- redundancy: webtorrentFilenames,- [join('playlists', 'hls')]: hlsFilenames,- [join('redundancy', 'hls')]: hlsFilenames- }-- if (onlyVideoFiles !== true) {- directories = {- ...directories,-- thumbnails: [ thumbnailName ],- previews: [ previewName ],- torrents: torrentNames,- captions: captionNames- }- }-- for (const directory of Object.keys(directories)) {- const directoryPath = server.servers.buildDirectory(directory)-- const directoryExists = await pathExists(directoryPath)- if (directoryExists === false) continue-- const existingFiles = await readdir(directoryPath)- for (const existingFile of existingFiles) {- for (const shouldNotExist of directories[directory]) {- expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist)- }- }- }-}--async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) {- for (const server of servers) {- server.store.videoDetails = await server.videos.get({ id: uuid })- }-}--function checkUploadVideoParam (- server: PeerTubeServer,- token: string,- attributes: Partial<VideoEdit>,- expectedStatus = HttpStatusCode.OK_200,- mode: 'legacy' | 'resumable' = 'legacy'-) {- return mode === 'legacy'- ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus })- : server.videos.buildResumeUpload({ token, attributes, expectedStatus })-}--// serverNumber starts from 1-async function uploadRandomVideoOnServers (- servers: PeerTubeServer[],- serverNumber: number,- additionalParams?: VideoEdit & { prefixName?: string }-) {- const server = servers.find(s => s.serverNumber === serverNumber)- const res = await server.videos.randomUpload({ wait: false, additionalParams })-- await waitJobs(servers)-- return res-}--// -----------------------------------------------------------------------------export {- checkUploadVideoParam,- uploadRandomVideoOnServers,- checkVideoFilesWereRemoved,- saveVideoInServers-}