Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Tests directories refractor

Chocobozzzc5d31dba56d6
diff --git a/server/tests/activitypub.ts b/server/tests/activitypub.ts
index 333e02e846..94615c63f0 100644
--- a/server/tests/activitypub.ts
+++ b/server/tests/activitypub.ts
@@ -2,9 +2,7 @@
import * as chai from 'chai'
import 'mocha'
-import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from './utils'
-import { runServer } from './utils/servers'
-import { makeActivityPubGetRequest } from './utils/activitypub'
+import { flushTests, killallServers, makeActivityPubGetRequest, runServer, ServerInfo, setAccessTokensToServers } from './utils'
const expect = chai.expect
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index 780254df5c..f82520574e 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -9,7 +9,7 @@ import {
setAccessTokensToServers,
killallServers
} from '../../utils'
-import { getVideosList, uploadVideo } from '../../utils/videos'
+import { getVideosList, uploadVideo } from '../../utils/videos/videos'
describe('Test services API validators', function () {
let server
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index e8d7ddf382..f3832bd2cb 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as request from 'supertest'
import { flushTests, killallServers, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils'
-import { addVideoCommentThread } from '../../utils/video-comments'
+import { addVideoCommentThread } from '../../utils/videos/video-comments'
describe('Test video comments API validator', function () {
let pathThread: string
diff --git a/server/tests/api/index-fast.ts b/server/tests/api/index-fast.ts
index 35b4143837..e591d0fd24 100644
--- a/server/tests/api/index-fast.ts
+++ b/server/tests/api/index-fast.ts
@@ -1,11 +1,11 @@
// Order of the tests we want to execute
-import './config'
+import './server/config'
import './check-params'
-import './users'
-import './single-server'
-import './video-abuse'
-import './video-blacklist'
-import './video-blacklist-management'
-import './video-description'
-import './video-privacy'
-import './services'
+import './users/users'
+import './videos/single-server'
+import './videos/video-abuse'
+import './videos/video-blacklist'
+import './videos/video-blacklist-management'
+import './videos/video-description'
+import './videos/video-privacy'
+import './videos/services'
diff --git a/server/tests/api/index-slow.ts b/server/tests/api/index-slow.ts
index b525d6f012..23b6526c7d 100644
--- a/server/tests/api/index-slow.ts
+++ b/server/tests/api/index-slow.ts
@@ -1,7 +1,7 @@
// Order of the tests we want to execute
// import './multiple-servers'
-import './video-transcoder'
-import './multiple-servers'
-import './follows'
-import './jobs'
-import './video-comments'
+import './videos/video-transcoder'
+import './videos/multiple-servers'
+import './server/follows'
+import './server/jobs'
+import './videos/video-comments'
diff --git a/server/tests/api/config.ts b/server/tests/api/server/config.ts
similarity index 97%
rename from server/tests/api/config.ts
rename to server/tests/api/server/config.ts
index 61ae579777..e8846c8db7 100644
--- a/server/tests/api/config.ts
+++ b/server/tests/api/server/config.ts
@@ -9,7 +9,7 @@ import {
flushTests,
runServer,
registerUser
-} from '../utils'
+} from '../../utils/index'
describe('Test config', function () {
let server = null
diff --git a/server/tests/api/follows.ts b/server/tests/api/server/follows.ts
similarity index 94%
rename from server/tests/api/follows.ts
rename to server/tests/api/server/follows.ts
index 2ffa426a06..f77c0c67c1 100644
--- a/server/tests/api/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -2,18 +2,21 @@
import * as chai from 'chai'
import 'mocha'
-import { VideoComment, VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
+import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import {
flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
wait
-} from '../utils'
-import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows'
-import { getUserAccessToken } from '../utils/login'
-import { dateIsValid, webtorrentAdd } from '../utils/miscs'
-import { createUser } from '../utils/users'
-import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments } from '../utils/video-comments'
-import { getVideo, rateVideo, testVideoImage } from '../utils/videos'
+} from '../../utils/index'
+import { dateIsValid, webtorrentAdd } from '../../utils/miscs/miscs'
+import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows'
+import { getUserAccessToken } from '../../utils/users/login'
+import { createUser } from '../../utils/users/users'
+import {
+ addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
+ getVideoThreadComments
+} from '../../utils/videos/video-comments'
+import { getVideo, rateVideo, testVideoImage } from '../../utils/videos/videos'
const expect = chai.expect
diff --git a/server/tests/api/jobs.ts b/server/tests/api/server/jobs.ts
similarity index 82%
rename from server/tests/api/jobs.ts
rename to server/tests/api/server/jobs.ts
index 4d9b613925..2e17e71a42 100644
--- a/server/tests/api/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -2,12 +2,12 @@
import * as chai from 'chai'
import 'mocha'
-import { flushTests, killallServers, ServerInfo, setAccessTokensToServers, wait } from '../utils'
-import { doubleFollow } from '../utils/follows'
-import { getJobsList, getJobsListPaginationAndSort } from '../utils/jobs'
-import { flushAndRunMultipleServers } from '../utils/servers'
-import { uploadVideo } from '../utils/videos'
-import { dateIsValid } from '../utils/miscs'
+import { flushTests, killallServers, ServerInfo, setAccessTokensToServers, wait } from '../../utils/index'
+import { doubleFollow } from '../../utils/server/follows'
+import { getJobsList, getJobsListPaginationAndSort } from '../../utils/server/jobs'
+import { flushAndRunMultipleServers } from '../../utils/server/servers'
+import { uploadVideo } from '../../utils/videos/videos'
+import { dateIsValid } from '../../utils/miscs/miscs'
const expect = chai.expect
diff --git a/server/tests/api/users.ts b/server/tests/api/users/users.ts
similarity index 98%
rename from server/tests/api/users.ts
rename to server/tests/api/users/users.ts
index 67e4cc8c6c..2e3a0b94fc 100644
--- a/server/tests/api/users.ts
+++ b/server/tests/api/users/users.ts
@@ -2,7 +2,7 @@
import * as chai from 'chai'
import 'mocha'
-import { UserRole } from '../../../shared'
+import { UserRole } from '../../../../shared/index'
import {
createUser,
flushTests,
@@ -26,10 +26,10 @@ import {
updateMyUser,
updateUser,
uploadVideo
-} from '../utils'
-import { follow } from '../utils/follows'
-import { getMyVideos } from '../utils/videos'
-import { setAccessTokensToServers } from '../utils/login'
+} from '../../utils/index'
+import { follow } from '../../utils/server/follows'
+import { getMyVideos } from '../../utils/videos/videos'
+import { setAccessTokensToServers } from '../../utils/users/login'
const expect = chai.expect
diff --git a/server/tests/api/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
similarity index 98%
rename from server/tests/api/multiple-servers.ts
rename to server/tests/api/videos/multiple-servers.ts
index 06274d4cc1..84f730a8e9 100644
--- a/server/tests/api/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -4,16 +4,19 @@ import * as chai from 'chai'
import 'mocha'
import { join } from 'path'
import * as request from 'supertest'
-import { VideoComment, VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
+import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import {
addVideoChannel, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, getUserAccessToken, getVideo,
getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage,
updateVideo, uploadVideo, wait, webtorrentAdd
-} from '../utils'
-import { createUser } from '../utils/users'
-import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments } from '../utils/video-comments'
-import { viewVideo } from '../utils/videos'
+} from '../../utils/index'
+import { createUser } from '../../utils/users/users'
+import {
+ addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
+ getVideoThreadComments
+} from '../../utils/videos/video-comments'
+import { viewVideo } from '../../utils/videos/videos'
const expect = chai.expect
diff --git a/server/tests/api/services.ts b/server/tests/api/videos/services.ts
similarity index 97%
rename from server/tests/api/services.ts
rename to server/tests/api/videos/services.ts
index 4d480c3054..1cda464d92 100644
--- a/server/tests/api/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -12,8 +12,8 @@ import {
setAccessTokensToServers,
killallServers,
getOEmbed
-} from '../utils'
-import { runServer } from '../utils/servers'
+} from '../../utils/index'
+import { runServer } from '../../utils/server/servers'
describe('Test services', function () {
let server: ServerInfo = null
diff --git a/server/tests/api/single-server.ts b/server/tests/api/videos/single-server.ts
similarity index 99%
rename from server/tests/api/single-server.ts
rename to server/tests/api/videos/single-server.ts
index 7f4351f5ee..02723654dc 100644
--- a/server/tests/api/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -30,8 +30,8 @@ import {
uploadVideo,
wait,
webtorrentAdd
-} from '../utils'
-import { viewVideo } from '../utils/videos'
+} from '../../utils/index'
+import { viewVideo } from '../../utils/videos/videos'
const expect = chai.expect
diff --git a/server/tests/api/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
similarity index 98%
rename from server/tests/api/video-abuse.ts
rename to server/tests/api/videos/video-abuse.ts
index 4a0b6b5041..3fcf5d8c79 100644
--- a/server/tests/api/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -13,8 +13,8 @@ import {
setAccessTokensToServers,
uploadVideo,
wait
-} from '../utils'
-import { doubleFollow } from '../utils/follows'
+} from '../../utils/index'
+import { doubleFollow } from '../../utils/server/follows'
const expect = chai.expect
diff --git a/server/tests/api/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts
similarity index 98%
rename from server/tests/api/video-blacklist-management.ts
rename to server/tests/api/videos/video-blacklist-management.ts
index 0c636e094e..db79784c27 100644
--- a/server/tests/api/video-blacklist-management.ts
+++ b/server/tests/api/videos/video-blacklist-management.ts
@@ -16,8 +16,8 @@ import {
setAccessTokensToServers,
uploadVideo,
wait
-} from '../utils'
-import { doubleFollow } from '../utils/follows'
+} from '../../utils/index'
+import { doubleFollow } from '../../utils/server/follows'
const expect = chai.expect
const orderBy = lodash.orderBy
diff --git a/server/tests/api/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts
similarity index 96%
rename from server/tests/api/video-blacklist.ts
rename to server/tests/api/videos/video-blacklist.ts
index 3afd8c5103..d1cefa5d70 100644
--- a/server/tests/api/video-blacklist.ts
+++ b/server/tests/api/videos/video-blacklist.ts
@@ -13,8 +13,8 @@ import {
setAccessTokensToServers,
uploadVideo,
wait
-} from '../utils'
-import { doubleFollow } from '../utils/follows'
+} from '../../utils/index'
+import { doubleFollow } from '../../utils/server/follows'
const expect = chai.expect
diff --git a/server/tests/api/video-channels.ts b/server/tests/api/videos/video-channels.ts
similarity index 98%
rename from server/tests/api/video-channels.ts
rename to server/tests/api/videos/video-channels.ts
index 2d8efb3202..454a96da69 100644
--- a/server/tests/api/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -17,8 +17,8 @@ import {
updateVideoChannel,
deleteVideoChannel,
getVideoChannel
-} from '../utils'
-import { User } from '../../../shared'
+} from '../../utils/index'
+import { User } from '../../../../shared/index'
describe('Test a video channels', function () {
let server: ServerInfo
diff --git a/server/tests/api/video-comments.ts b/server/tests/api/videos/video-comments.ts
similarity index 94%
rename from server/tests/api/video-comments.ts
rename to server/tests/api/videos/video-comments.ts
index f05ca5e817..3b6578f041 100644
--- a/server/tests/api/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -2,9 +2,12 @@
import * as chai from 'chai'
import 'mocha'
-import { VideoComment, VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
-import { dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../utils'
-import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments } from '../utils/video-comments'
+import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
+import { dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index'
+import {
+ addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
+ getVideoThreadComments
+} from '../../utils/videos/video-comments'
const expect = chai.expect
diff --git a/server/tests/api/video-description.ts b/server/tests/api/videos/video-description.ts
similarity index 97%
rename from server/tests/api/video-description.ts
rename to server/tests/api/videos/video-description.ts
index 7ad1c63ae8..c2985194c5 100644
--- a/server/tests/api/video-description.ts
+++ b/server/tests/api/videos/video-description.ts
@@ -14,8 +14,8 @@ import {
updateVideo,
uploadVideo,
wait
-} from '../utils'
-import { doubleFollow } from '../utils/follows'
+} from '../../utils/index'
+import { doubleFollow } from '../../utils/server/follows'
const expect = chai.expect
diff --git a/server/tests/api/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
similarity index 93%
rename from server/tests/api/video-privacy.ts
rename to server/tests/api/videos/video-privacy.ts
index 26847efce5..de709f8f17 100644
--- a/server/tests/api/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -2,7 +2,7 @@
import * as chai from 'chai'
import 'mocha'
-import { VideoPrivacy } from '../../../shared/models/videos/video-privacy.enum'
+import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import {
flushAndRunMultipleServers,
flushTests,
@@ -12,11 +12,11 @@ import {
setAccessTokensToServers,
uploadVideo,
wait
-} from '../utils'
-import { doubleFollow } from '../utils/follows'
-import { getUserAccessToken } from '../utils/login'
-import { createUser } from '../utils/users'
-import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../utils/videos'
+} from '../../utils/index'
+import { doubleFollow } from '../../utils/server/follows'
+import { getUserAccessToken } from '../../utils/users/login'
+import { createUser } from '../../utils/users/users'
+import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos'
const expect = chai.expect
diff --git a/server/tests/api/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
similarity index 98%
rename from server/tests/api/video-transcoder.ts
rename to server/tests/api/videos/video-transcoder.ts
index 9a6e91b767..27927a5946 100644
--- a/server/tests/api/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -15,7 +15,7 @@ import {
killallServers,
webtorrentAdd,
getVideo
-} from '../utils'
+} from '../../utils/index'
describe('Test video transcoding', function () {
let servers: ServerInfo[] = []
diff --git a/server/tests/utils/cli.ts b/server/tests/utils/cli/cli.ts
similarity index 90%
rename from server/tests/utils/cli.ts
rename to server/tests/utils/cli/cli.ts
index 4098fdf6f7..54d05e9c62 100644
--- a/server/tests/utils/cli.ts
+++ b/server/tests/utils/cli/cli.ts
@@ -1,6 +1,6 @@
import { exec } from 'child_process'
-import { ServerInfo } from './servers'
+import { ServerInfo } from '../server/servers'
function getEnvCli (server?: ServerInfo) {
return `NODE_ENV=test NODE_APP_INSTANCE=${server.serverNumber}`
diff --git a/server/tests/utils/index.ts b/server/tests/utils/index.ts
index b918ee83d2..d7789e5173 100644
--- a/server/tests/utils/index.ts
+++ b/server/tests/utils/index.ts
@@ -1,15 +1,15 @@
-export * from './activitypub'
-export * from './cli'
-export * from './clients'
-export * from './config'
-export * from './login'
-export * from './miscs'
-export * from './follows'
-export * from './requests'
-export * from './servers'
-export * from './services'
-export * from './users'
-export * from './video-abuses'
-export * from './video-blacklist'
-export * from './video-channels'
-export * from './videos'
+export * from './server/activitypub'
+export * from './cli/cli'
+export * from './server/clients'
+export * from './server/config'
+export * from './users/login'
+export * from './miscs/miscs'
+export * from './server/follows'
+export * from './requests/requests'
+export * from './server/servers'
+export * from './videos/services'
+export * from './users/users'
+export * from './videos/video-abuses'
+export * from './videos/video-blacklist'
+export * from './videos/video-channels'
+export * from './videos/videos'
diff --git a/server/tests/utils/miscs.ts b/server/tests/utils/miscs/miscs.ts
similarity index 100%
rename from server/tests/utils/miscs.ts
rename to server/tests/utils/miscs/miscs.ts
diff --git a/server/tests/utils/requests.ts b/server/tests/utils/requests/requests.ts
similarity index 100%
rename from server/tests/utils/requests.ts
rename to server/tests/utils/requests/requests.ts
diff --git a/server/tests/utils/activitypub.ts b/server/tests/utils/server/activitypub.ts
similarity index 100%
rename from server/tests/utils/activitypub.ts
rename to server/tests/utils/server/activitypub.ts
diff --git a/server/tests/utils/clients.ts b/server/tests/utils/server/clients.ts
similarity index 100%
rename from server/tests/utils/clients.ts
rename to server/tests/utils/server/clients.ts
diff --git a/server/tests/utils/config.ts b/server/tests/utils/server/config.ts
similarity index 100%
rename from server/tests/utils/config.ts
rename to server/tests/utils/server/config.ts
diff --git a/server/tests/utils/follows.ts b/server/tests/utils/server/follows.ts
similarity index 98%
rename from server/tests/utils/follows.ts
rename to server/tests/utils/server/follows.ts
index a9f798bcbb..82e89175cf 100644
--- a/server/tests/utils/follows.ts
+++ b/server/tests/utils/server/follows.ts
@@ -1,5 +1,5 @@
import * as request from 'supertest'
-import { wait } from './miscs'
+import { wait } from '../miscs/miscs'
import { ServerInfo } from './servers'
function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
diff --git a/server/tests/utils/jobs.ts b/server/tests/utils/server/jobs.ts
similarity index 100%
rename from server/tests/utils/jobs.ts
rename to server/tests/utils/server/jobs.ts
diff --git a/server/tests/utils/servers.ts b/server/tests/utils/server/servers.ts
similarity index 100%
rename from server/tests/utils/servers.ts
rename to server/tests/utils/server/servers.ts
diff --git a/server/tests/utils/login.ts b/server/tests/utils/users/login.ts
similarity index 96%
rename from server/tests/utils/login.ts
rename to server/tests/utils/users/login.ts
index 22d37c46f4..855c4828d1 100644
--- a/server/tests/utils/login.ts
+++ b/server/tests/utils/users/login.ts
@@ -1,6 +1,6 @@
import * as request from 'supertest'
-import { ServerInfo } from './servers'
+import { ServerInfo } from '../server/servers'
type Client = { id: string, secret: string }
type User = { username: string, password: string }
diff --git a/server/tests/utils/users.ts b/server/tests/utils/users/users.ts
similarity index 98%
rename from server/tests/utils/users.ts
rename to server/tests/utils/users/users.ts
index a37d84ab47..bd8d7ab04c 100644
--- a/server/tests/utils/users.ts
+++ b/server/tests/utils/users/users.ts
@@ -1,6 +1,6 @@
import * as request from 'supertest'
-import { UserRole } from '../../../shared'
+import { UserRole } from '../../../../shared/index'
function createUser (
url: string,
diff --git a/server/tests/utils/services.ts b/server/tests/utils/videos/services.ts
similarity index 100%
rename from server/tests/utils/services.ts
rename to server/tests/utils/videos/services.ts
diff --git a/server/tests/utils/video-abuses.ts b/server/tests/utils/videos/video-abuses.ts
similarity index 100%
rename from server/tests/utils/video-abuses.ts
rename to server/tests/utils/videos/video-abuses.ts
diff --git a/server/tests/utils/video-blacklist.ts b/server/tests/utils/videos/video-blacklist.ts
similarity index 100%
rename from server/tests/utils/video-blacklist.ts
rename to server/tests/utils/videos/video-blacklist.ts
diff --git a/server/tests/utils/video-channels.ts b/server/tests/utils/videos/video-channels.ts
similarity index 100%
rename from server/tests/utils/video-channels.ts
rename to server/tests/utils/videos/video-channels.ts
diff --git a/server/tests/utils/video-comments.ts b/server/tests/utils/videos/video-comments.ts
similarity index 100%
rename from server/tests/utils/video-comments.ts
rename to server/tests/utils/videos/video-comments.ts
diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos/videos.ts
similarity index 97%
rename from server/tests/utils/videos.ts
rename to server/tests/utils/videos/videos.ts
index fb758cf29b..6de1b8c92c 100644
--- a/server/tests/utils/videos.ts
+++ b/server/tests/utils/videos/videos.ts
@@ -1,13 +1,9 @@
import { readFile } from 'fs'
-import * as request from 'supertest'
-import { join, isAbsolute } from 'path'
import * as parseTorrent from 'parse-torrent'
-
-import { makeGetRequest } from './requests'
-import { readFilePromise } from './miscs'
-import { ServerInfo } from './servers'
-import { getMyUserInformation } from './users'
-import { VideoPrivacy } from '../../../shared'
+import { isAbsolute, join } from 'path'
+import * as request from 'supertest'
+import { getMyUserInformation, makeGetRequest, readFilePromise, ServerInfo } from '../'
+import { VideoPrivacy } from '../../../../shared/models/videos'
type VideoAttributes = {
name?: string