aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/tests/api/activitypub/helpers.ts5
-rw-r--r--server/tests/api/check-params/config.ts28
-rw-r--r--server/tests/api/check-params/live.ts29
-rw-r--r--server/tests/api/check-params/plugins.ts7
-rw-r--r--server/tests/api/check-params/search.ts55
-rw-r--r--server/tests/api/check-params/user-notifications.ts20
-rw-r--r--server/tests/api/check-params/users.ts77
-rw-r--r--server/tests/api/check-params/video-channels.ts31
-rw-r--r--server/tests/api/check-params/video-imports.ts29
-rw-r--r--server/tests/api/check-params/video-playlists.ts5
-rw-r--r--server/tests/api/check-params/videos.ts75
-rw-r--r--server/tests/api/live/live.ts3
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts13
-rw-r--r--server/tests/api/notifications/notifications-api.ts11
-rw-r--r--server/tests/api/redundancy/manage-redundancy.ts7
-rw-r--r--server/tests/api/redundancy/redundancy-constraints.ts11
-rw-r--r--server/tests/api/redundancy/redundancy.ts36
-rw-r--r--server/tests/api/search/search-index.ts24
-rw-r--r--server/tests/api/search/search-videos.ts46
-rw-r--r--server/tests/api/server/handle-down.ts9
-rw-r--r--server/tests/api/server/logs.ts5
-rw-r--r--server/tests/api/server/plugins.ts5
-rw-r--r--server/tests/api/users/users-multiple-servers.ts2
-rw-r--r--server/tests/api/videos/audio-only.ts5
-rw-r--r--server/tests/api/videos/multiple-servers.ts4
-rw-r--r--server/tests/api/videos/resumable-upload.ts5
-rw-r--r--server/tests/api/videos/single-server.ts2
-rw-r--r--server/tests/api/videos/video-captions.ts2
-rw-r--r--server/tests/api/videos/video-imports.ts13
-rw-r--r--server/tests/api/videos/video-transcoder.ts22
-rw-r--r--server/tests/cli/optimize-old-videos.ts3
-rw-r--r--server/tests/cli/prune-storage.ts31
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts5
-rw-r--r--server/tests/plugins/action-hooks.ts5
-rw-r--r--server/tests/plugins/external-auth.ts7
-rw-r--r--server/tests/plugins/filter-hooks.ts39
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts13
-rw-r--r--server/tests/plugins/plugin-helpers.ts19
-rw-r--r--server/tests/plugins/plugin-storage.ts17
-rw-r--r--server/tests/plugins/plugin-transcoding.ts3
40 files changed, 343 insertions, 385 deletions
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts
index 66d7631b7..57b1cab23 100644
--- a/server/tests/api/activitypub/helpers.ts
+++ b/server/tests/api/activitypub/helpers.ts
@@ -2,11 +2,10 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { buildRequestStub } from '../../../../shared/extra-utils/miscs/stubs'
6import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
7import { cloneDeep } from 'lodash' 5import { cloneDeep } from 'lodash'
6import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/extra-utils'
8import { buildSignedActivity } from '../../../helpers/activitypub' 7import { buildSignedActivity } from '../../../helpers/activitypub'
9import { buildAbsoluteFixturePath } from '@shared/extra-utils' 8import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
10 9
11describe('Test activity pub helpers', function () { 10describe('Test activity pub helpers', function () {
12 describe('When checking the Linked Signature', function () { 11 describe('When checking the Linked Signature', function () {
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 9549070ef..291de93ea 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -1,22 +1,20 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { omit } from 'lodash'
4import 'mocha' 3import 'mocha'
5import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 4import { omit } from 'lodash'
6 5import { HttpStatusCode } from '@shared/core-utils'
7import { 6import {
8 cleanupTests, 7 cleanupTests,
9 createUser, 8 createUser,
10 flushAndRunServer, 9 flushAndRunServer,
11 immutableAssign,
12 makeDeleteRequest, 10 makeDeleteRequest,
13 makeGetRequest, 11 makeGetRequest,
14 makePutBodyRequest, 12 makePutBodyRequest,
15 ServerInfo, 13 ServerInfo,
16 setAccessTokensToServers, 14 setAccessTokensToServers,
17 userLogin 15 userLogin
18} from '../../../../shared/extra-utils' 16} from '@shared/extra-utils'
19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 17import { CustomConfig } from '@shared/models'
20 18
21describe('Test config API validators', function () { 19describe('Test config API validators', function () {
22 const path = '/api/v1/config/custom' 20 const path = '/api/v1/config/custom'
@@ -265,11 +263,13 @@ describe('Test config API validators', function () {
265 }) 263 })
266 264
267 it('Should fail with a bad default NSFW policy', async function () { 265 it('Should fail with a bad default NSFW policy', async function () {
268 const newUpdateParams = immutableAssign(updateParams, { 266 const newUpdateParams = {
267 ...updateParams,
268
269 instance: { 269 instance: {
270 defaultNSFWPolicy: 'hello' 270 defaultNSFWPolicy: 'hello'
271 } 271 }
272 }) 272 }
273 273
274 await makePutBodyRequest({ 274 await makePutBodyRequest({
275 url: server.url, 275 url: server.url,
@@ -282,13 +282,15 @@ describe('Test config API validators', function () {
282 282
283 it('Should fail if email disabled and signup requires email verification', async function () { 283 it('Should fail if email disabled and signup requires email verification', async function () {
284 // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts 284 // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
285 const newUpdateParams = immutableAssign(updateParams, { 285 const newUpdateParams = {
286 ...updateParams,
287
286 signup: { 288 signup: {
287 enabled: true, 289 enabled: true,
288 limit: 5, 290 limit: 5,
289 requiresEmailVerification: true 291 requiresEmailVerification: true
290 } 292 }
291 }) 293 }
292 294
293 await makePutBodyRequest({ 295 await makePutBodyRequest({
294 url: server.url, 296 url: server.url,
@@ -300,7 +302,9 @@ describe('Test config API validators', function () {
300 }) 302 })
301 303
302 it('Should fail with a disabled webtorrent & hls transcoding', async function () { 304 it('Should fail with a disabled webtorrent & hls transcoding', async function () {
303 const newUpdateParams = immutableAssign(updateParams, { 305 const newUpdateParams = {
306 ...updateParams,
307
304 transcoding: { 308 transcoding: {
305 hls: { 309 hls: {
306 enabled: false 310 enabled: false
@@ -309,7 +313,7 @@ describe('Test config API validators', function () {
309 enabled: false 313 enabled: false
310 } 314 }
311 } 315 }
312 }) 316 }
313 317
314 await makePutBodyRequest({ 318 await makePutBodyRequest({
315 url: server.url, 319 url: server.url,
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index d851d258d..394967285 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -10,7 +10,6 @@ import {
10 createUser, 10 createUser,
11 flushAndRunServer, 11 flushAndRunServer,
12 getMyUserInformation, 12 getMyUserInformation,
13 immutableAssign,
14 LiveCommand, 13 LiveCommand,
15 makePostBodyRequest, 14 makePostBodyRequest,
16 makeUploadRequest, 15 makeUploadRequest,
@@ -97,37 +96,37 @@ describe('Test video lives API validator', function () {
97 }) 96 })
98 97
99 it('Should fail with a long name', async function () { 98 it('Should fail with a long name', async function () {
100 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 99 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
101 100
102 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 101 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
103 }) 102 })
104 103
105 it('Should fail with a bad category', async function () { 104 it('Should fail with a bad category', async function () {
106 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 105 const fields = { ...baseCorrectParams, category: 125 }
107 106
108 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 107 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
109 }) 108 })
110 109
111 it('Should fail with a bad licence', async function () { 110 it('Should fail with a bad licence', async function () {
112 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 111 const fields = { ...baseCorrectParams, licence: 125 }
113 112
114 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 113 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
115 }) 114 })
116 115
117 it('Should fail with a bad language', async function () { 116 it('Should fail with a bad language', async function () {
118 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 117 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
119 118
120 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 119 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
121 }) 120 })
122 121
123 it('Should fail with a long description', async function () { 122 it('Should fail with a long description', async function () {
124 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 123 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
125 124
126 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 125 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
127 }) 126 })
128 127
129 it('Should fail with a long support text', async function () { 128 it('Should fail with a long support text', async function () {
130 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 129 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
131 130
132 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 131 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
133 }) 132 })
@@ -139,7 +138,7 @@ describe('Test video lives API validator', function () {
139 }) 138 })
140 139
141 it('Should fail with a bad channel', async function () { 140 it('Should fail with a bad channel', async function () {
142 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 141 const fields = { ...baseCorrectParams, channelId: 545454 }
143 142
144 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 143 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
145 }) 144 })
@@ -155,25 +154,25 @@ describe('Test video lives API validator', function () {
155 const res = await getMyUserInformation(server.url, accessTokenUser) 154 const res = await getMyUserInformation(server.url, accessTokenUser)
156 const customChannelId = res.body.videoChannels[0].id 155 const customChannelId = res.body.videoChannels[0].id
157 156
158 const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) 157 const fields = { ...baseCorrectParams, channelId: customChannelId }
159 158
160 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 159 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields })
161 }) 160 })
162 161
163 it('Should fail with too many tags', async function () { 162 it('Should fail with too many tags', async function () {
164 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 163 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
165 164
166 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 165 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
167 }) 166 })
168 167
169 it('Should fail with a tag length too low', async function () { 168 it('Should fail with a tag length too low', async function () {
170 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 169 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
171 170
172 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 171 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
173 }) 172 })
174 173
175 it('Should fail with a tag length too big', async function () { 174 it('Should fail with a tag length too big', async function () {
176 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) 175 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
177 176
178 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 177 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
179 }) 178 })
@@ -215,7 +214,7 @@ describe('Test video lives API validator', function () {
215 }) 214 })
216 215
217 it('Should fail with save replay and permanent live set to true', async function () { 216 it('Should fail with save replay and permanent live set to true', async function () {
218 const fields = immutableAssign(baseCorrectParams, { saveReplay: true, permanentLive: true }) 217 const fields = { ...baseCorrectParams, saveReplay: true, permanentLive: true }
219 218
220 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 219 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
221 }) 220 })
@@ -253,7 +252,7 @@ describe('Test video lives API validator', function () {
253 }) 252 })
254 253
255 it('Should forbid to save replay if not enabled by the admin', async function () { 254 it('Should forbid to save replay if not enabled by the admin', async function () {
256 const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) 255 const fields = { ...baseCorrectParams, saveReplay: true }
257 256
258 await server.configCommand.updateCustomSubConfig({ 257 await server.configCommand.updateCustomSubConfig({
259 newConfig: { 258 newConfig: {
@@ -274,7 +273,7 @@ describe('Test video lives API validator', function () {
274 }) 273 })
275 274
276 it('Should allow to save replay if enabled by the admin', async function () { 275 it('Should allow to save replay if enabled by the admin', async function () {
277 const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) 276 const fields = { ...baseCorrectParams, saveReplay: true }
278 277
279 await server.configCommand.updateCustomSubConfig({ 278 await server.configCommand.updateCustomSubConfig({
280 newConfig: { 279 newConfig: {
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index d372221d0..8509b8ac5 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -9,7 +9,6 @@ import {
9 cleanupTests, 9 cleanupTests,
10 createUser, 10 createUser,
11 flushAndRunServer, 11 flushAndRunServer,
12 immutableAssign,
13 makeGetRequest, 12 makeGetRequest,
14 makePostBodyRequest, 13 makePostBodyRequest,
15 makePutBodyRequest, 14 makePutBodyRequest,
@@ -200,7 +199,7 @@ describe('Test server plugins API validators', function () {
200 }) 199 })
201 200
202 it('Should fail with an invalid plugin type', async function () { 201 it('Should fail with an invalid plugin type', async function () {
203 const query = immutableAssign(baseQuery, { pluginType: 5 }) 202 const query = { ...baseQuery, pluginType: 5 }
204 203
205 await makeGetRequest({ 204 await makeGetRequest({
206 url: server.url, 205 url: server.url,
@@ -211,7 +210,7 @@ describe('Test server plugins API validators', function () {
211 }) 210 })
212 211
213 it('Should fail with an invalid current peertube engine', async function () { 212 it('Should fail with an invalid current peertube engine', async function () {
214 const query = immutableAssign(baseQuery, { currentPeerTubeEngine: '1.0' }) 213 const query = { ...baseQuery, currentPeerTubeEngine: '1.0' }
215 214
216 await makeGetRequest({ 215 await makeGetRequest({
217 url: server.url, 216 url: server.url,
@@ -271,7 +270,7 @@ describe('Test server plugins API validators', function () {
271 }) 270 })
272 271
273 it('Should fail with an invalid plugin type', async function () { 272 it('Should fail with an invalid plugin type', async function () {
274 const query = immutableAssign(baseQuery, { pluginType: 5 }) 273 const query = { ...baseQuery, pluginType: 5 }
275 274
276 await makeGetRequest({ 275 await makeGetRequest({
277 url: server.url, 276 url: server.url,
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 4a2fc1197..7973c112f 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -8,7 +8,6 @@ import {
8 checkBadStartPagination, 8 checkBadStartPagination,
9 cleanupTests, 9 cleanupTests,
10 flushAndRunServer, 10 flushAndRunServer,
11 immutableAssign,
12 makeGetRequest, 11 makeGetRequest,
13 ServerInfo, 12 ServerInfo,
14 setAccessTokensToServers 13 setAccessTokensToServers
@@ -63,78 +62,78 @@ describe('Test videos API validator', function () {
63 }) 62 })
64 63
65 it('Should fail with an invalid category', async function () { 64 it('Should fail with an invalid category', async function () {
66 const customQuery1 = immutableAssign(query, { categoryOneOf: [ 'aa', 'b' ] }) 65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] }
67 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 66 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
68 67
69 const customQuery2 = immutableAssign(query, { categoryOneOf: 'a' }) 68 const customQuery2 = { ...query, categoryOneOf: 'a' }
70 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 69 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
71 }) 70 })
72 71
73 it('Should succeed with a valid category', async function () { 72 it('Should succeed with a valid category', async function () {
74 const customQuery1 = immutableAssign(query, { categoryOneOf: [ 1, 7 ] }) 73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] }
75 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 74 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
76 75
77 const customQuery2 = immutableAssign(query, { categoryOneOf: 1 }) 76 const customQuery2 = { ...query, categoryOneOf: 1 }
78 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 77 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
79 }) 78 })
80 79
81 it('Should fail with an invalid licence', async function () { 80 it('Should fail with an invalid licence', async function () {
82 const customQuery1 = immutableAssign(query, { licenceOneOf: [ 'aa', 'b' ] }) 81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] }
83 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 82 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
84 83
85 const customQuery2 = immutableAssign(query, { licenceOneOf: 'a' }) 84 const customQuery2 = { ...query, licenceOneOf: 'a' }
86 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 85 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
87 }) 86 })
88 87
89 it('Should succeed with a valid licence', async function () { 88 it('Should succeed with a valid licence', async function () {
90 const customQuery1 = immutableAssign(query, { licenceOneOf: [ 1, 2 ] }) 89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] }
91 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 90 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
92 91
93 const customQuery2 = immutableAssign(query, { licenceOneOf: 1 }) 92 const customQuery2 = { ...query, licenceOneOf: 1 }
94 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 93 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
95 }) 94 })
96 95
97 it('Should succeed with a valid language', async function () { 96 it('Should succeed with a valid language', async function () {
98 const customQuery1 = immutableAssign(query, { languageOneOf: [ 'fr', 'en' ] }) 97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] }
99 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 98 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
100 99
101 const customQuery2 = immutableAssign(query, { languageOneOf: 'fr' }) 100 const customQuery2 = { ...query, languageOneOf: 'fr' }
102 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 101 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
103 }) 102 })
104 103
105 it('Should succeed with valid tags', async function () { 104 it('Should succeed with valid tags', async function () {
106 const customQuery1 = immutableAssign(query, { tagsOneOf: [ 'tag1', 'tag2' ] }) 105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] }
107 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 106 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
108 107
109 const customQuery2 = immutableAssign(query, { tagsOneOf: 'tag1' }) 108 const customQuery2 = { ...query, tagsOneOf: 'tag1' }
110 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 109 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
111 110
112 const customQuery3 = immutableAssign(query, { tagsAllOf: [ 'tag1', 'tag2' ] }) 111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] }
113 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) 112 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 })
114 113
115 const customQuery4 = immutableAssign(query, { tagsAllOf: 'tag1' }) 114 const customQuery4 = { ...query, tagsAllOf: 'tag1' }
116 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) 115 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 })
117 }) 116 })
118 117
119 it('Should fail with invalid durations', async function () { 118 it('Should fail with invalid durations', async function () {
120 const customQuery1 = immutableAssign(query, { durationMin: 'hello' }) 119 const customQuery1 = { ...query, durationMin: 'hello' }
121 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 120 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
122 121
123 const customQuery2 = immutableAssign(query, { durationMax: 'hello' }) 122 const customQuery2 = { ...query, durationMax: 'hello' }
124 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 123 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
125 }) 124 })
126 125
127 it('Should fail with invalid dates', async function () { 126 it('Should fail with invalid dates', async function () {
128 const customQuery1 = immutableAssign(query, { startDate: 'hello' }) 127 const customQuery1 = { ...query, startDate: 'hello' }
129 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 128 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
130 129
131 const customQuery2 = immutableAssign(query, { endDate: 'hello' }) 130 const customQuery2 = { ...query, endDate: 'hello' }
132 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 131 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
133 132
134 const customQuery3 = immutableAssign(query, { originallyPublishedStartDate: 'hello' }) 133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' }
135 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 134 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
136 135
137 const customQuery4 = immutableAssign(query, { originallyPublishedEndDate: 'hello' }) 136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
138 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 137 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
139 }) 138 })
140 }) 139 })
@@ -201,41 +200,41 @@ describe('Test videos API validator', function () {
201 200
202 for (const path of paths) { 201 for (const path of paths) {
203 { 202 {
204 const customQuery = immutableAssign(query, { searchTarget: 'hello' }) 203 const customQuery = { ...query, searchTarget: 'hello' }
205 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 204 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
206 } 205 }
207 206
208 { 207 {
209 const customQuery = immutableAssign(query, { searchTarget: undefined }) 208 const customQuery = { ...query, searchTarget: undefined }
210 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 209 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
211 } 210 }
212 211
213 { 212 {
214 const customQuery = immutableAssign(query, { searchTarget: 'local' }) 213 const customQuery = { ...query, searchTarget: 'local' }
215 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 214 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
216 } 215 }
217 216
218 { 217 {
219 const customQuery = immutableAssign(query, { searchTarget: 'search-index' }) 218 const customQuery = { ...query, searchTarget: 'search-index' }
220 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 219 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
221 } 220 }
222 221
223 await updateSearchIndex(server, true, true) 222 await updateSearchIndex(server, true, true)
224 223
225 { 224 {
226 const customQuery = immutableAssign(query, { searchTarget: 'local' }) 225 const customQuery = { ...query, searchTarget: 'local' }
227 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 226 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
228 } 227 }
229 228
230 { 229 {
231 const customQuery = immutableAssign(query, { searchTarget: 'search-index' }) 230 const customQuery = { ...query, searchTarget: 'search-index' }
232 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 231 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
233 } 232 }
234 233
235 await updateSearchIndex(server, true, false) 234 await updateSearchIndex(server, true, false)
236 235
237 { 236 {
238 const customQuery = immutableAssign(query, { searchTarget: 'local' }) 237 const customQuery = { ...query, searchTarget: 'local' }
239 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 238 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
240 } 239 }
241 240
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 26d4423f9..913eca366 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -2,25 +2,21 @@
2 2
3import 'mocha' 3import 'mocha'
4import { io } from 'socket.io-client' 4import { io } from 'socket.io-client'
5 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 checkBadCountPagination,
8 checkBadSortPagination,
9 checkBadStartPagination,
7 cleanupTests, 10 cleanupTests,
8 flushAndRunServer, 11 flushAndRunServer,
9 immutableAssign,
10 makeGetRequest, 12 makeGetRequest,
11 makePostBodyRequest, 13 makePostBodyRequest,
12 makePutBodyRequest, 14 makePutBodyRequest,
13 ServerInfo, 15 ServerInfo,
14 setAccessTokensToServers, 16 setAccessTokensToServers,
15 wait 17 wait
16} from '../../../../shared/extra-utils' 18} from '@shared/extra-utils'
17import { 19import { UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'
18 checkBadCountPagination,
19 checkBadSortPagination,
20 checkBadStartPagination
21} from '../../../../shared/extra-utils/requests/check-api-params'
22import { UserNotificationSetting, UserNotificationSettingValue } from '../../../../shared/models/users'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
24 20
25describe('Test user notifications API validators', function () { 21describe('Test user notifications API validators', function () {
26 let server: ServerInfo 22 let server: ServerInfo
@@ -193,7 +189,7 @@ describe('Test user notifications API validators', function () {
193 189
194 it('Should fail with incorrect field values', async function () { 190 it('Should fail with incorrect field values', async function () {
195 { 191 {
196 const fields = immutableAssign(correctFields, { newCommentOnMyVideo: 15 }) 192 const fields = { ...correctFields, newCommentOnMyVideo: 15 }
197 193
198 await makePutBodyRequest({ 194 await makePutBodyRequest({
199 url: server.url, 195 url: server.url,
@@ -205,7 +201,7 @@ describe('Test user notifications API validators', function () {
205 } 201 }
206 202
207 { 203 {
208 const fields = immutableAssign(correctFields, { newCommentOnMyVideo: 'toto' }) 204 const fields = { ...correctFields, newCommentOnMyVideo: 'toto' }
209 205
210 await makePutBodyRequest({ 206 await makePutBodyRequest({
211 url: server.url, 207 url: server.url,
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index bffe29bce..fda7e9640 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -15,7 +15,6 @@ import {
15 getMyUserVideoRating, 15 getMyUserVideoRating,
16 getUserScopedTokens, 16 getUserScopedTokens,
17 getUsersList, 17 getUsersList,
18 immutableAssign,
19 killallServers, 18 killallServers,
20 makeGetRequest, 19 makeGetRequest,
21 makePostBodyRequest, 20 makePostBodyRequest,
@@ -181,25 +180,25 @@ describe('Test users API validators', function () {
181 } 180 }
182 181
183 it('Should fail with a too small username', async function () { 182 it('Should fail with a too small username', async function () {
184 const fields = immutableAssign(baseCorrectParams, { username: '' }) 183 const fields = { ...baseCorrectParams, username: '' }
185 184
186 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 185 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
187 }) 186 })
188 187
189 it('Should fail with a too long username', async function () { 188 it('Should fail with a too long username', async function () {
190 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) }) 189 const fields = { ...baseCorrectParams, username: 'super'.repeat(50) }
191 190
192 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 191 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
193 }) 192 })
194 193
195 it('Should fail with a not lowercase username', async function () { 194 it('Should fail with a not lowercase username', async function () {
196 const fields = immutableAssign(baseCorrectParams, { username: 'Toto' }) 195 const fields = { ...baseCorrectParams, username: 'Toto' }
197 196
198 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 197 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
199 }) 198 })
200 199
201 it('Should fail with an incorrect username', async function () { 200 it('Should fail with an incorrect username', async function () {
202 const fields = immutableAssign(baseCorrectParams, { username: 'my username' }) 201 const fields = { ...baseCorrectParams, username: 'my username' }
203 202
204 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 203 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
205 }) 204 })
@@ -211,25 +210,25 @@ describe('Test users API validators', function () {
211 }) 210 })
212 211
213 it('Should fail with an invalid email', async function () { 212 it('Should fail with an invalid email', async function () {
214 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' }) 213 const fields = { ...baseCorrectParams, email: 'test_example.com' }
215 214
216 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 215 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
217 }) 216 })
218 217
219 it('Should fail with a too small password', async function () { 218 it('Should fail with a too small password', async function () {
220 const fields = immutableAssign(baseCorrectParams, { password: 'bla' }) 219 const fields = { ...baseCorrectParams, password: 'bla' }
221 220
222 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 221 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
223 }) 222 })
224 223
225 it('Should fail with a too long password', async function () { 224 it('Should fail with a too long password', async function () {
226 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) }) 225 const fields = { ...baseCorrectParams, password: 'super'.repeat(61) }
227 226
228 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 227 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
229 }) 228 })
230 229
231 it('Should fail with empty password and no smtp configured', async function () { 230 it('Should fail with empty password and no smtp configured', async function () {
232 const fields = immutableAssign(baseCorrectParams, { password: '' }) 231 const fields = { ...baseCorrectParams, password: '' }
233 232
234 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 233 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
235 }) 234 })
@@ -239,19 +238,23 @@ describe('Test users API validators', function () {
239 238
240 await killallServers([ server ]) 239 await killallServers([ server ])
241 240
242 const config = immutableAssign(overrideConfig, { 241 const config = {
242 ...overrideConfig,
243
243 smtp: { 244 smtp: {
244 hostname: 'localhost', 245 hostname: 'localhost',
245 port: emailPort 246 port: emailPort
246 } 247 }
247 }) 248 }
248 await reRunServer(server, config) 249 await reRunServer(server, config)
249 250
250 const fields = immutableAssign(baseCorrectParams, { 251 const fields = {
252 ...baseCorrectParams,
253
251 password: '', 254 password: '',
252 username: 'create_password', 255 username: 'create_password',
253 email: 'create_password@example.com' 256 email: 'create_password@example.com'
254 }) 257 }
255 258
256 await makePostBodyRequest({ 259 await makePostBodyRequest({
257 url: server.url, 260 url: server.url,
@@ -263,7 +266,7 @@ describe('Test users API validators', function () {
263 }) 266 })
264 267
265 it('Should fail with invalid admin flags', async function () { 268 it('Should fail with invalid admin flags', async function () {
266 const fields = immutableAssign(baseCorrectParams, { adminFlags: 'toto' }) 269 const fields = { ...baseCorrectParams, adminFlags: 'toto' }
267 270
268 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 271 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
269 }) 272 })
@@ -279,7 +282,7 @@ describe('Test users API validators', function () {
279 }) 282 })
280 283
281 it('Should fail if we add a user with the same username', async function () { 284 it('Should fail if we add a user with the same username', async function () {
282 const fields = immutableAssign(baseCorrectParams, { username: 'user1' }) 285 const fields = { ...baseCorrectParams, username: 'user1' }
283 286
284 await makePostBodyRequest({ 287 await makePostBodyRequest({
285 url: server.url, 288 url: server.url,
@@ -291,7 +294,7 @@ describe('Test users API validators', function () {
291 }) 294 })
292 295
293 it('Should fail if we add a user with the same email', async function () { 296 it('Should fail if we add a user with the same email', async function () {
294 const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' }) 297 const fields = { ...baseCorrectParams, email: 'user1@example.com' }
295 298
296 await makePostBodyRequest({ 299 await makePostBodyRequest({
297 url: server.url, 300 url: server.url,
@@ -315,13 +318,13 @@ describe('Test users API validators', function () {
315 }) 318 })
316 319
317 it('Should fail with an invalid videoQuota', async function () { 320 it('Should fail with an invalid videoQuota', async function () {
318 const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 }) 321 const fields = { ...baseCorrectParams, videoQuota: -5 }
319 322
320 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 323 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
321 }) 324 })
322 325
323 it('Should fail with an invalid videoQuotaDaily', async function () { 326 it('Should fail with an invalid videoQuotaDaily', async function () {
324 const fields = immutableAssign(baseCorrectParams, { videoQuotaDaily: -7 }) 327 const fields = { ...baseCorrectParams, videoQuotaDaily: -7 }
325 328
326 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 329 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
327 }) 330 })
@@ -333,13 +336,13 @@ describe('Test users API validators', function () {
333 }) 336 })
334 337
335 it('Should fail with an invalid user role', async function () { 338 it('Should fail with an invalid user role', async function () {
336 const fields = immutableAssign(baseCorrectParams, { role: 88989 }) 339 const fields = { ...baseCorrectParams, role: 88989 }
337 340
338 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 341 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
339 }) 342 })
340 343
341 it('Should fail with a "peertube" username', async function () { 344 it('Should fail with a "peertube" username', async function () {
342 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' }) 345 const fields = { ...baseCorrectParams, username: 'peertube' }
343 346
344 await makePostBodyRequest({ 347 await makePostBodyRequest({
345 url: server.url, 348 url: server.url,
@@ -352,7 +355,7 @@ describe('Test users API validators', function () {
352 355
353 it('Should fail to create a moderator or an admin with a moderator', async function () { 356 it('Should fail to create a moderator or an admin with a moderator', async function () {
354 for (const role of [ UserRole.MODERATOR, UserRole.ADMINISTRATOR ]) { 357 for (const role of [ UserRole.MODERATOR, UserRole.ADMINISTRATOR ]) {
355 const fields = immutableAssign(baseCorrectParams, { role }) 358 const fields = { ...baseCorrectParams, role }
356 359
357 await makePostBodyRequest({ 360 await makePostBodyRequest({
358 url: server.url, 361 url: server.url,
@@ -365,7 +368,7 @@ describe('Test users API validators', function () {
365 }) 368 })
366 369
367 it('Should succeed to create a user with a moderator', async function () { 370 it('Should succeed to create a user with a moderator', async function () {
368 const fields = immutableAssign(baseCorrectParams, { username: 'a4656', email: 'a4656@example.com', role: UserRole.USER }) 371 const fields = { ...baseCorrectParams, username: 'a4656', email: 'a4656@example.com', role: UserRole.USER }
369 372
370 await makePostBodyRequest({ 373 await makePostBodyRequest({
371 url: server.url, 374 url: server.url,
@@ -937,19 +940,19 @@ describe('Test users API validators', function () {
937 } 940 }
938 941
939 it('Should fail with a too small username', async function () { 942 it('Should fail with a too small username', async function () {
940 const fields = immutableAssign(baseCorrectParams, { username: '' }) 943 const fields = { ...baseCorrectParams, username: '' }
941 944
942 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 945 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
943 }) 946 })
944 947
945 it('Should fail with a too long username', async function () { 948 it('Should fail with a too long username', async function () {
946 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) }) 949 const fields = { ...baseCorrectParams, username: 'super'.repeat(50) }
947 950
948 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 951 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
949 }) 952 })
950 953
951 it('Should fail with an incorrect username', async function () { 954 it('Should fail with an incorrect username', async function () {
952 const fields = immutableAssign(baseCorrectParams, { username: 'my username' }) 955 const fields = { ...baseCorrectParams, username: 'my username' }
953 956
954 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 957 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
955 }) 958 })
@@ -961,25 +964,25 @@ describe('Test users API validators', function () {
961 }) 964 })
962 965
963 it('Should fail with an invalid email', async function () { 966 it('Should fail with an invalid email', async function () {
964 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' }) 967 const fields = { ...baseCorrectParams, email: 'test_example.com' }
965 968
966 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 969 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
967 }) 970 })
968 971
969 it('Should fail with a too small password', async function () { 972 it('Should fail with a too small password', async function () {
970 const fields = immutableAssign(baseCorrectParams, { password: 'bla' }) 973 const fields = { ...baseCorrectParams, password: 'bla' }
971 974
972 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 975 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
973 }) 976 })
974 977
975 it('Should fail with a too long password', async function () { 978 it('Should fail with a too long password', async function () {
976 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) }) 979 const fields = { ...baseCorrectParams, password: 'super'.repeat(61) }
977 980
978 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 981 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
979 }) 982 })
980 983
981 it('Should fail if we register a user with the same username', async function () { 984 it('Should fail if we register a user with the same username', async function () {
982 const fields = immutableAssign(baseCorrectParams, { username: 'root' }) 985 const fields = { ...baseCorrectParams, username: 'root' }
983 986
984 await makePostBodyRequest({ 987 await makePostBodyRequest({
985 url: server.url, 988 url: server.url,
@@ -991,7 +994,7 @@ describe('Test users API validators', function () {
991 }) 994 })
992 995
993 it('Should fail with a "peertube" username', async function () { 996 it('Should fail with a "peertube" username', async function () {
994 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' }) 997 const fields = { ...baseCorrectParams, username: 'peertube' }
995 998
996 await makePostBodyRequest({ 999 await makePostBodyRequest({
997 url: server.url, 1000 url: server.url,
@@ -1003,7 +1006,7 @@ describe('Test users API validators', function () {
1003 }) 1006 })
1004 1007
1005 it('Should fail if we register a user with the same email', async function () { 1008 it('Should fail if we register a user with the same email', async function () {
1006 const fields = immutableAssign(baseCorrectParams, { email: 'admin' + server.internalServerNumber + '@example.com' }) 1009 const fields = { ...baseCorrectParams, email: 'admin' + server.internalServerNumber + '@example.com' }
1007 1010
1008 await makePostBodyRequest({ 1011 await makePostBodyRequest({
1009 url: server.url, 1012 url: server.url,
@@ -1015,26 +1018,26 @@ describe('Test users API validators', function () {
1015 }) 1018 })
1016 1019
1017 it('Should fail with a bad display name', async function () { 1020 it('Should fail with a bad display name', async function () {
1018 const fields = immutableAssign(baseCorrectParams, { displayName: 'a'.repeat(150) }) 1021 const fields = { ...baseCorrectParams, displayName: 'a'.repeat(150) }
1019 1022
1020 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 1023 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
1021 }) 1024 })
1022 1025
1023 it('Should fail with a bad channel name', async function () { 1026 it('Should fail with a bad channel name', async function () {
1024 const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } }) 1027 const fields = { ...baseCorrectParams, channel: { name: '[]azf', displayName: 'toto' } }
1025 1028
1026 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 1029 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
1027 }) 1030 })
1028 1031
1029 it('Should fail with a bad channel display name', async function () { 1032 it('Should fail with a bad channel display name', async function () {
1030 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } }) 1033 const fields = { ...baseCorrectParams, channel: { name: 'toto', displayName: '' } }
1031 1034
1032 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 1035 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
1033 }) 1036 })
1034 1037
1035 it('Should fail with a channel name that is the same as username', async function () { 1038 it('Should fail with a channel name that is the same as username', async function () {
1036 const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } } 1039 const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
1037 const fields = immutableAssign(baseCorrectParams, source) 1040 const fields = { ...baseCorrectParams, ...source }
1038 1041
1039 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 1042 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
1040 }) 1043 })
@@ -1043,7 +1046,7 @@ describe('Test users API validators', function () {
1043 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' } 1046 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
1044 await server.channelsCommand.create({ attributes }) 1047 await server.channelsCommand.create({ attributes })
1045 1048
1046 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } }) 1049 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
1047 1050
1048 await makePostBodyRequest({ 1051 await makePostBodyRequest({
1049 url: server.url, 1052 url: server.url,
@@ -1055,7 +1058,7 @@ describe('Test users API validators', function () {
1055 }) 1058 })
1056 1059
1057 it('Should succeed with the correct params', async function () { 1060 it('Should succeed with the correct params', async function () {
1058 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } }) 1061 const fields = { ...baseCorrectParams, channel: { name: 'super_channel', displayName: 'toto' } }
1059 1062
1060 await makePostBodyRequest({ 1063 await makePostBodyRequest({
1061 url: server.url, 1064 url: server.url,
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index d29346dc3..3b72d3796 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -3,14 +3,16 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '@shared/core-utils'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 ChannelsCommand, 9 ChannelsCommand,
10 checkBadCountPagination,
11 checkBadSortPagination,
12 checkBadStartPagination,
10 cleanupTests, 13 cleanupTests,
11 createUser, 14 createUser,
12 flushAndRunServer, 15 flushAndRunServer,
13 immutableAssign,
14 makeGetRequest, 16 makeGetRequest,
15 makePostBodyRequest, 17 makePostBodyRequest,
16 makePutBodyRequest, 18 makePutBodyRequest,
@@ -18,13 +20,8 @@ import {
18 ServerInfo, 20 ServerInfo,
19 setAccessTokensToServers, 21 setAccessTokensToServers,
20 userLogin 22 userLogin
21} from '../../../../shared/extra-utils' 23} from '@shared/extra-utils'
22import { 24import { VideoChannelUpdate } from '@shared/models'
23 checkBadCountPagination,
24 checkBadSortPagination,
25 checkBadStartPagination
26} from '../../../../shared/extra-utils/requests/check-api-params'
27import { VideoChannelUpdate } from '../../../../shared/models/videos'
28 25
29const expect = chai.expect 26const expect = chai.expect
30 27
@@ -127,7 +124,7 @@ describe('Test video channels API validator', function () {
127 }) 124 })
128 125
129 it('Should fail with a bad name', async function () { 126 it('Should fail with a bad name', async function () {
130 const fields = immutableAssign(baseCorrectParams, { name: 'super name' }) 127 const fields = { ...baseCorrectParams, name: 'super name' }
131 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 128 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
132 }) 129 })
133 130
@@ -137,17 +134,17 @@ describe('Test video channels API validator', function () {
137 }) 134 })
138 135
139 it('Should fail with a long name', async function () { 136 it('Should fail with a long name', async function () {
140 const fields = immutableAssign(baseCorrectParams, { displayName: 'super'.repeat(25) }) 137 const fields = { ...baseCorrectParams, displayName: 'super'.repeat(25) }
141 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 138 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
142 }) 139 })
143 140
144 it('Should fail with a long description', async function () { 141 it('Should fail with a long description', async function () {
145 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(201) }) 142 const fields = { ...baseCorrectParams, description: 'super'.repeat(201) }
146 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 143 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
147 }) 144 })
148 145
149 it('Should fail with a long support text', async function () { 146 it('Should fail with a long support text', async function () {
150 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 147 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
151 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 148 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
152 }) 149 })
153 150
@@ -206,22 +203,22 @@ describe('Test video channels API validator', function () {
206 }) 203 })
207 204
208 it('Should fail with a long name', async function () { 205 it('Should fail with a long name', async function () {
209 const fields = immutableAssign(baseCorrectParams, { displayName: 'super'.repeat(25) }) 206 const fields = { ...baseCorrectParams, displayName: 'super'.repeat(25) }
210 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 207 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
211 }) 208 })
212 209
213 it('Should fail with a long description', async function () { 210 it('Should fail with a long description', async function () {
214 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(201) }) 211 const fields = { ...baseCorrectParams, description: 'super'.repeat(201) }
215 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 212 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
216 }) 213 })
217 214
218 it('Should fail with a long support text', async function () { 215 it('Should fail with a long support text', async function () {
219 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 216 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
220 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 217 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
221 }) 218 })
222 219
223 it('Should fail with a bad bulkVideosSupportUpdate field', async function () { 220 it('Should fail with a bad bulkVideosSupportUpdate field', async function () {
224 const fields = immutableAssign(baseCorrectParams, { bulkVideosSupportUpdate: 'super' }) 221 const fields = { ...baseCorrectParams, bulkVideosSupportUpdate: 'super' }
225 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 222 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
226 }) 223 })
227 224
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index ea473191e..2cc124cc1 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -12,7 +12,6 @@ import {
12 createUser, 12 createUser,
13 flushAndRunServer, 13 flushAndRunServer,
14 getMyUserInformation, 14 getMyUserInformation,
15 immutableAssign,
16 ImportsCommand, 15 ImportsCommand,
17 makeGetRequest, 16 makeGetRequest,
18 makePostBodyRequest, 17 makePostBodyRequest,
@@ -108,43 +107,43 @@ describe('Test video imports API validator', function () {
108 }) 107 })
109 108
110 it('Should fail with a bad target url', async function () { 109 it('Should fail with a bad target url', async function () {
111 const fields = immutableAssign(baseCorrectParams, { targetUrl: 'htt://hello' }) 110 const fields = { ...baseCorrectParams, targetUrl: 'htt://hello' }
112 111
113 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 112 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
114 }) 113 })
115 114
116 it('Should fail with a long name', async function () { 115 it('Should fail with a long name', async function () {
117 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 116 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
118 117
119 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 118 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
120 }) 119 })
121 120
122 it('Should fail with a bad category', async function () { 121 it('Should fail with a bad category', async function () {
123 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 122 const fields = { ...baseCorrectParams, category: 125 }
124 123
125 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 124 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
126 }) 125 })
127 126
128 it('Should fail with a bad licence', async function () { 127 it('Should fail with a bad licence', async function () {
129 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 128 const fields = { ...baseCorrectParams, licence: 125 }
130 129
131 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 130 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
132 }) 131 })
133 132
134 it('Should fail with a bad language', async function () { 133 it('Should fail with a bad language', async function () {
135 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 134 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
136 135
137 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 136 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
138 }) 137 })
139 138
140 it('Should fail with a long description', async function () { 139 it('Should fail with a long description', async function () {
141 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 140 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
142 141
143 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 142 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
144 }) 143 })
145 144
146 it('Should fail with a long support text', async function () { 145 it('Should fail with a long support text', async function () {
147 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 146 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
148 147
149 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 148 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
150 }) 149 })
@@ -156,7 +155,7 @@ describe('Test video imports API validator', function () {
156 }) 155 })
157 156
158 it('Should fail with a bad channel', async function () { 157 it('Should fail with a bad channel', async function () {
159 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 158 const fields = { ...baseCorrectParams, channelId: 545454 }
160 159
161 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 160 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
162 }) 161 })
@@ -172,25 +171,25 @@ describe('Test video imports API validator', function () {
172 const res = await getMyUserInformation(server.url, accessTokenUser) 171 const res = await getMyUserInformation(server.url, accessTokenUser)
173 const customChannelId = res.body.videoChannels[0].id 172 const customChannelId = res.body.videoChannels[0].id
174 173
175 const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) 174 const fields = { ...baseCorrectParams, channelId: customChannelId }
176 175
177 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 176 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields })
178 }) 177 })
179 178
180 it('Should fail with too many tags', async function () { 179 it('Should fail with too many tags', async function () {
181 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 180 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
182 181
183 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 182 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
184 }) 183 })
185 184
186 it('Should fail with a tag length too low', async function () { 185 it('Should fail with a tag length too low', async function () {
187 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 186 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
188 187
189 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 188 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
190 }) 189 })
191 190
192 it('Should fail with a tag length too big', async function () { 191 it('Should fail with a tag length too big', async function () {
193 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) 192 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
194 193
195 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 194 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
196 }) 195 })
@@ -242,7 +241,7 @@ describe('Test video imports API validator', function () {
242 241
243 it('Should fail with an invalid magnet URI', async function () { 242 it('Should fail with an invalid magnet URI', async function () {
244 let fields = omit(baseCorrectParams, 'targetUrl') 243 let fields = omit(baseCorrectParams, 'targetUrl')
245 fields = immutableAssign(fields, { magnetUri: 'blabla' }) 244 fields = { ...fields, magnetUri: 'blabla' }
246 245
247 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 246 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
248 }) 247 })
@@ -301,7 +300,7 @@ describe('Test video imports API validator', function () {
301 }) 300 })
302 301
303 let fields = omit(baseCorrectParams, 'targetUrl') 302 let fields = omit(baseCorrectParams, 'targetUrl')
304 fields = immutableAssign(fields, { magnetUri: ImportsCommand.getMagnetURI() }) 303 fields = { ...fields, magnetUri: ImportsCommand.getMagnetURI() }
305 304
306 await makePostBodyRequest({ 305 await makePostBodyRequest({
307 url: server.url, 306 url: server.url,
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 1c507a047..3799e73b6 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -1,6 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils'
4import { 5import {
5 VideoPlaylistCreate, 6 VideoPlaylistCreate,
6 VideoPlaylistCreateResult, 7 VideoPlaylistCreateResult,
@@ -10,7 +11,6 @@ import {
10 VideoPlaylistReorder, 11 VideoPlaylistReorder,
11 VideoPlaylistType 12 VideoPlaylistType
12} from '@shared/models' 13} from '@shared/models'
13import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
14import { 14import {
15 checkBadCountPagination, 15 checkBadCountPagination,
16 checkBadSortPagination, 16 checkBadSortPagination,
@@ -18,7 +18,6 @@ import {
18 cleanupTests, 18 cleanupTests,
19 flushAndRunServer, 19 flushAndRunServer,
20 generateUserAccessToken, 20 generateUserAccessToken,
21 immutableAssign,
22 makeGetRequest, 21 makeGetRequest,
23 PlaylistsCommand, 22 PlaylistsCommand,
24 ServerInfo, 23 ServerInfo,
@@ -214,7 +213,7 @@ describe('Test video playlists API validator', function () {
214 } 213 }
215 } 214 }
216 const getUpdate = (params: any, playlistId: number | string) => { 215 const getUpdate = (params: any, playlistId: number | string) => {
217 return immutableAssign(params, { playlistId: playlistId }) 216 return { ...params, playlistId: playlistId }
218 } 217 }
219 218
220 it('Should fail with an unauthenticated user', async function () { 219 it('Should fail with an unauthenticated user', async function () {
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 4d7a9a23b..6549063b1 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -15,7 +15,6 @@ import {
15 getMyUserInformation, 15 getMyUserInformation,
16 getVideo, 16 getVideo,
17 getVideosList, 17 getVideosList,
18 immutableAssign,
19 makeDeleteRequest, 18 makeDeleteRequest,
20 makeGetRequest, 19 makeGetRequest,
21 makePutBodyRequest, 20 makePutBodyRequest,
@@ -225,42 +224,42 @@ describe('Test videos API validator', function () {
225 }) 224 })
226 225
227 it('Should fail with a long name', async function () { 226 it('Should fail with a long name', async function () {
228 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 227 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
229 const attaches = baseCorrectAttaches 228 const attaches = baseCorrectAttaches
230 229
231 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 230 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
232 }) 231 })
233 232
234 it('Should fail with a bad category', async function () { 233 it('Should fail with a bad category', async function () {
235 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 234 const fields = { ...baseCorrectParams, category: 125 }
236 const attaches = baseCorrectAttaches 235 const attaches = baseCorrectAttaches
237 236
238 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 237 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
239 }) 238 })
240 239
241 it('Should fail with a bad licence', async function () { 240 it('Should fail with a bad licence', async function () {
242 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 241 const fields = { ...baseCorrectParams, licence: 125 }
243 const attaches = baseCorrectAttaches 242 const attaches = baseCorrectAttaches
244 243
245 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 244 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
246 }) 245 })
247 246
248 it('Should fail with a bad language', async function () { 247 it('Should fail with a bad language', async function () {
249 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 248 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
250 const attaches = baseCorrectAttaches 249 const attaches = baseCorrectAttaches
251 250
252 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 251 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
253 }) 252 })
254 253
255 it('Should fail with a long description', async function () { 254 it('Should fail with a long description', async function () {
256 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 255 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
257 const attaches = baseCorrectAttaches 256 const attaches = baseCorrectAttaches
258 257
259 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 258 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
260 }) 259 })
261 260
262 it('Should fail with a long support text', async function () { 261 it('Should fail with a long support text', async function () {
263 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 262 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
264 const attaches = baseCorrectAttaches 263 const attaches = baseCorrectAttaches
265 264
266 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 265 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
@@ -274,7 +273,7 @@ describe('Test videos API validator', function () {
274 }) 273 })
275 274
276 it('Should fail with a bad channel', async function () { 275 it('Should fail with a bad channel', async function () {
277 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 276 const fields = { ...baseCorrectParams, channelId: 545454 }
278 const attaches = baseCorrectAttaches 277 const attaches = baseCorrectAttaches
279 278
280 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 279 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
@@ -291,54 +290,56 @@ describe('Test videos API validator', function () {
291 const res = await getMyUserInformation(server.url, accessTokenUser) 290 const res = await getMyUserInformation(server.url, accessTokenUser)
292 const customChannelId = res.body.videoChannels[0].id 291 const customChannelId = res.body.videoChannels[0].id
293 292
294 const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) 293 const fields = { ...baseCorrectParams, channelId: customChannelId }
295 const attaches = baseCorrectAttaches 294 const attaches = baseCorrectAttaches
296 295
297 await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 296 await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
298 }) 297 })
299 298
300 it('Should fail with too many tags', async function () { 299 it('Should fail with too many tags', async function () {
301 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 300 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
302 const attaches = baseCorrectAttaches 301 const attaches = baseCorrectAttaches
303 302
304 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 303 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
305 }) 304 })
306 305
307 it('Should fail with a tag length too low', async function () { 306 it('Should fail with a tag length too low', async function () {
308 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 307 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
309 const attaches = baseCorrectAttaches 308 const attaches = baseCorrectAttaches
310 309
311 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 310 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
312 }) 311 })
313 312
314 it('Should fail with a tag length too big', async function () { 313 it('Should fail with a tag length too big', async function () {
315 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) 314 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
316 const attaches = baseCorrectAttaches 315 const attaches = baseCorrectAttaches
317 316
318 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 317 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
319 }) 318 })
320 319
321 it('Should fail with a bad schedule update (miss updateAt)', async function () { 320 it('Should fail with a bad schedule update (miss updateAt)', async function () {
322 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) 321 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
323 const attaches = baseCorrectAttaches 322 const attaches = baseCorrectAttaches
324 323
325 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 324 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
326 }) 325 })
327 326
328 it('Should fail with a bad schedule update (wrong updateAt)', async function () { 327 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
329 const fields = immutableAssign(baseCorrectParams, { 328 const fields = {
329 ...baseCorrectParams,
330
330 scheduleUpdate: { 331 scheduleUpdate: {
331 privacy: VideoPrivacy.PUBLIC, 332 privacy: VideoPrivacy.PUBLIC,
332 updateAt: 'toto' 333 updateAt: 'toto'
333 } 334 }
334 }) 335 }
335 const attaches = baseCorrectAttaches 336 const attaches = baseCorrectAttaches
336 337
337 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 338 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
338 }) 339 })
339 340
340 it('Should fail with a bad originally published at attribute', async function () { 341 it('Should fail with a bad originally published at attribute', async function () {
341 const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) 342 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
342 const attaches = baseCorrectAttaches 343 const attaches = baseCorrectAttaches
343 344
344 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) 345 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
@@ -413,7 +414,7 @@ describe('Test videos API validator', function () {
413 }) 414 })
414 415
415 it('Should report the appropriate error', async function () { 416 it('Should report the appropriate error', async function () {
416 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 417 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
417 const attaches = baseCorrectAttaches 418 const attaches = baseCorrectAttaches
418 419
419 const attributes = { ...fields, ...attaches } 420 const attributes = { ...fields, ...attaches }
@@ -448,17 +449,21 @@ describe('Test videos API validator', function () {
448 } 449 }
449 450
450 { 451 {
451 const attaches = immutableAssign(baseCorrectAttaches, { 452 const attaches = {
453 ...baseCorrectAttaches,
454
452 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') 455 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
453 }) 456 }
454 457
455 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) 458 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
456 } 459 }
457 460
458 { 461 {
459 const attaches = immutableAssign(baseCorrectAttaches, { 462 const attaches = {
463 ...baseCorrectAttaches,
464
460 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') 465 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
461 }) 466 }
462 467
463 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) 468 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
464 } 469 }
@@ -516,79 +521,79 @@ describe('Test videos API validator', function () {
516 }) 521 })
517 522
518 it('Should fail with a long name', async function () { 523 it('Should fail with a long name', async function () {
519 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 524 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
520 525
521 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 526 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
522 }) 527 })
523 528
524 it('Should fail with a bad category', async function () { 529 it('Should fail with a bad category', async function () {
525 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 530 const fields = { ...baseCorrectParams, category: 125 }
526 531
527 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 532 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
528 }) 533 })
529 534
530 it('Should fail with a bad licence', async function () { 535 it('Should fail with a bad licence', async function () {
531 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 536 const fields = { ...baseCorrectParams, licence: 125 }
532 537
533 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 538 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
534 }) 539 })
535 540
536 it('Should fail with a bad language', async function () { 541 it('Should fail with a bad language', async function () {
537 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 542 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
538 543
539 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 544 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
540 }) 545 })
541 546
542 it('Should fail with a long description', async function () { 547 it('Should fail with a long description', async function () {
543 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 548 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
544 549
545 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 550 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
546 }) 551 })
547 552
548 it('Should fail with a long support text', async function () { 553 it('Should fail with a long support text', async function () {
549 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 554 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
550 555
551 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 556 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
552 }) 557 })
553 558
554 it('Should fail with a bad channel', async function () { 559 it('Should fail with a bad channel', async function () {
555 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 560 const fields = { ...baseCorrectParams, channelId: 545454 }
556 561
557 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 562 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
558 }) 563 })
559 564
560 it('Should fail with too many tags', async function () { 565 it('Should fail with too many tags', async function () {
561 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 566 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
562 567
563 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 568 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
564 }) 569 })
565 570
566 it('Should fail with a tag length too low', async function () { 571 it('Should fail with a tag length too low', async function () {
567 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 572 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
568 573
569 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 574 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
570 }) 575 })
571 576
572 it('Should fail with a tag length too big', async function () { 577 it('Should fail with a tag length too big', async function () {
573 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) 578 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
574 579
575 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 580 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
576 }) 581 })
577 582
578 it('Should fail with a bad schedule update (miss updateAt)', async function () { 583 it('Should fail with a bad schedule update (miss updateAt)', async function () {
579 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) 584 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
580 585
581 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 586 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
582 }) 587 })
583 588
584 it('Should fail with a bad schedule update (wrong updateAt)', async function () { 589 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
585 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) 590 const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
586 591
587 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 592 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
588 }) 593 })
589 594
590 it('Should fail with a bad originally published at param', async function () { 595 it('Should fail with a bad originally published at param', async function () {
591 const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) 596 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
592 597
593 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 598 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
594 }) 599 })
@@ -672,7 +677,7 @@ describe('Test videos API validator', function () {
672 it('Should fail with a video of another server') 677 it('Should fail with a video of another server')
673 678
674 it('Shoud report the appropriate error', async function () { 679 it('Shoud report the appropriate error', async function () {
675 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 680 const fields = { ...baseCorrectParams, licence: 125 }
676 681
677 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) 682 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
678 const error = res.body as PeerTubeProblemDocument 683 const error = res.body as PeerTubeProblemDocument
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index f9a162df6..999a49051 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -7,7 +7,6 @@ import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-
7import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' 7import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
9import { 9import {
10 buildServerDirectory,
11 checkLiveCleanup, 10 checkLiveCleanup,
12 checkLiveSegmentHash, 11 checkLiveSegmentHash,
13 checkResolutionsInMasterPlaylist, 12 checkResolutionsInMasterPlaylist,
@@ -532,7 +531,7 @@ describe('Test live', function () {
532 } 531 }
533 532
534 const filename = `${video.uuid}-${resolution}-fragmented.mp4` 533 const filename = `${video.uuid}-${resolution}-fragmented.mp4`
535 const segmentPath = buildServerDirectory(servers[0], join('streaming-playlists', 'hls', video.uuid, filename)) 534 const segmentPath = servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
536 535
537 const probe = await ffprobePromise(segmentPath) 536 const probe = await ffprobePromise(segmentPath)
538 const videoStream = await getVideoStreamFromFile(segmentPath, probe) 537 const videoStream = await getVideoStreamFromFile(segmentPath, probe)
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 229f78811..99b434606 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -20,7 +20,6 @@ import {
20 createUser, 20 createUser,
21 generateUserAccessToken, 21 generateUserAccessToken,
22 getVideoIdFromUUID, 22 getVideoIdFromUUID,
23 immutableAssign,
24 MockInstancesIndex, 23 MockInstancesIndex,
25 MockSmtpServer, 24 MockSmtpServer,
26 prepareNotificationsTest, 25 prepareNotificationsTest,
@@ -347,7 +346,7 @@ describe('Test moderation notifications', function () {
347 await checkUserRegistered(baseParams, 'user_45', 'presence') 346 await checkUserRegistered(baseParams, 'user_45', 'presence')
348 347
349 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 348 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
350 await checkUserRegistered(immutableAssign(baseParams, userOverride), 'user_45', 'absence') 349 await checkUserRegistered({ ...baseParams, ...userOverride }, 'user_45', 'absence')
351 }) 350 })
352 }) 351 })
353 352
@@ -389,7 +388,7 @@ describe('Test moderation notifications', function () {
389 await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence') 388 await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence')
390 389
391 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 390 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
392 await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence') 391 await checkNewInstanceFollower({ ...baseParams, ...userOverride }, 'localhost:' + servers[2].port, 'absence')
393 }) 392 })
394 393
395 it('Should send a notification on auto follow back', async function () { 394 it('Should send a notification on auto follow back', async function () {
@@ -416,7 +415,7 @@ describe('Test moderation notifications', function () {
416 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') 415 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
417 416
418 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 417 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
419 await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence') 418 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
420 419
421 config.followings.instance.autoFollowBack.enabled = false 420 config.followings.instance.autoFollowBack.enabled = false
422 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 421 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
@@ -476,7 +475,9 @@ describe('Test moderation notifications', function () {
476 475
477 currentCustomConfig = await servers[0].configCommand.getCustomConfig() 476 currentCustomConfig = await servers[0].configCommand.getCustomConfig()
478 477
479 const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, { 478 const autoBlacklistTestsCustomConfig = {
479 ...currentCustomConfig,
480
480 autoBlacklist: { 481 autoBlacklist: {
481 videos: { 482 videos: {
482 ofUsers: { 483 ofUsers: {
@@ -484,7 +485,7 @@ describe('Test moderation notifications', function () {
484 } 485 }
485 } 486 }
486 } 487 }
487 }) 488 }
488 489
489 // enable transcoding otherwise own publish notification after transcoding not expected 490 // enable transcoding otherwise own publish notification after transcoding not expected
490 autoBlacklistTestsCustomConfig.transcoding.enabled = true 491 autoBlacklistTestsCustomConfig.transcoding.enabled = true
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index 447492c5f..e5864f1c2 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -8,7 +8,6 @@ import {
8 cleanupTests, 8 cleanupTests,
9 getAllNotificationsSettings, 9 getAllNotificationsSettings,
10 getMyUserInformation, 10 getMyUserInformation,
11 immutableAssign,
12 MockSmtpServer, 11 MockSmtpServer,
13 prepareNotificationsTest, 12 prepareNotificationsTest,
14 ServerInfo, 13 ServerInfo,
@@ -118,7 +117,7 @@ describe('Test notifications API', function () {
118 const { name, uuid } = await uploadRandomVideo(server) 117 const { name, uuid } = await uploadRandomVideo(server)
119 118
120 const check = { web: true, mail: true } 119 const check = { web: true, mail: true }
121 await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence') 120 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence')
122 }) 121 })
123 122
124 it('Should only have web notifications', async function () { 123 it('Should only have web notifications', async function () {
@@ -139,12 +138,12 @@ describe('Test notifications API', function () {
139 138
140 { 139 {
141 const check = { mail: true, web: false } 140 const check = { mail: true, web: false }
142 await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence') 141 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence')
143 } 142 }
144 143
145 { 144 {
146 const check = { mail: false, web: true } 145 const check = { mail: false, web: true }
147 await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence') 146 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence')
148 } 147 }
149 }) 148 })
150 149
@@ -166,12 +165,12 @@ describe('Test notifications API', function () {
166 165
167 { 166 {
168 const check = { mail: false, web: true } 167 const check = { mail: false, web: true }
169 await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence') 168 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence')
170 } 169 }
171 170
172 { 171 {
173 const check = { mail: true, web: false } 172 const check = { mail: true, web: false }
174 await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence') 173 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence')
175 } 174 }
176 }) 175 })
177 176
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts
index 363e4cbfe..03857f512 100644
--- a/server/tests/api/redundancy/manage-redundancy.ts
+++ b/server/tests/api/redundancy/manage-redundancy.ts
@@ -12,8 +12,7 @@ import {
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideo, 13 uploadVideo,
14 uploadVideoAndGetId, 14 uploadVideoAndGetId,
15 waitJobs, 15 waitJobs
16 waitUntilLog
17} from '@shared/extra-utils' 16} from '@shared/extra-utils'
18import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models' 17import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models'
19 18
@@ -91,7 +90,7 @@ describe('Test manage videos redundancy', function () {
91 this.timeout(120000) 90 this.timeout(120000)
92 91
93 await waitJobs(servers) 92 await waitJobs(servers)
94 await waitUntilLog(servers[0], 'Duplicated ', 10) 93 await servers[0].serversCommand.waitUntilLog('Duplicated ', 10)
95 await waitJobs(servers) 94 await waitJobs(servers)
96 95
97 const body = await commands[1].listVideos({ target: 'remote-videos' }) 96 const body = await commands[1].listVideos({ target: 'remote-videos' })
@@ -214,7 +213,7 @@ describe('Test manage videos redundancy', function () {
214 await commands[0].addVideo({ videoId }) 213 await commands[0].addVideo({ videoId })
215 214
216 await waitJobs(servers) 215 await waitJobs(servers)
217 await waitUntilLog(servers[0], 'Duplicated ', 15) 216 await servers[0].serversCommand.waitUntilLog('Duplicated ', 15)
218 await waitJobs(servers) 217 await waitJobs(servers)
219 218
220 { 219 {
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index 82d952471..a31278de7 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -11,8 +11,7 @@ import {
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 updateVideo, 12 updateVideo,
13 uploadVideo, 13 uploadVideo,
14 waitJobs, 14 waitJobs
15 waitUntilLog
16} from '@shared/extra-utils' 15} from '@shared/extra-utils'
17import { VideoPrivacy } from '@shared/models' 16import { VideoPrivacy } from '@shared/models'
18 17
@@ -97,7 +96,7 @@ describe('Test redundancy constraints', function () {
97 this.timeout(120000) 96 this.timeout(120000)
98 97
99 await waitJobs(servers) 98 await waitJobs(servers)
100 await waitUntilLog(remoteServer, 'Duplicated ', 5) 99 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5)
101 await waitJobs(servers) 100 await waitJobs(servers)
102 101
103 { 102 {
@@ -126,7 +125,7 @@ describe('Test redundancy constraints', function () {
126 125
127 await uploadWrapper('video 2 server 2') 126 await uploadWrapper('video 2 server 2')
128 127
129 await waitUntilLog(remoteServer, 'Duplicated ', 10) 128 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10)
130 await waitJobs(servers) 129 await waitJobs(servers)
131 130
132 { 131 {
@@ -155,7 +154,7 @@ describe('Test redundancy constraints', function () {
155 154
156 await uploadWrapper('video 3 server 2') 155 await uploadWrapper('video 3 server 2')
157 156
158 await waitUntilLog(remoteServer, 'Duplicated ', 15) 157 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15)
159 await waitJobs(servers) 158 await waitJobs(servers)
160 159
161 { 160 {
@@ -176,7 +175,7 @@ describe('Test redundancy constraints', function () {
176 await waitJobs(servers) 175 await waitJobs(servers)
177 176
178 await uploadWrapper('video 4 server 2') 177 await uploadWrapper('video 4 server 2')
179 await waitUntilLog(remoteServer, 'Duplicated ', 20) 178 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 20)
180 await waitJobs(servers) 179 await waitJobs(servers)
181 180
182 { 181 {
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 56a2af395..00a5e86cc 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -14,7 +14,6 @@ import {
14 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
15 getVideo, 15 getVideo,
16 getVideoWithToken, 16 getVideoWithToken,
17 immutableAssign,
18 killallServers, 17 killallServers,
19 makeGetRequest, 18 makeGetRequest,
20 removeVideo, 19 removeVideo,
@@ -26,8 +25,7 @@ import {
26 uploadVideo, 25 uploadVideo,
27 viewVideo, 26 viewVideo,
28 wait, 27 wait,
29 waitJobs, 28 waitJobs
30 waitUntilLog
31} from '@shared/extra-utils' 29} from '@shared/extra-utils'
32import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models' 30import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
33 31
@@ -53,11 +51,13 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
53 51
54 if (strategy !== null) { 52 if (strategy !== null) {
55 strategies.push( 53 strategies.push(
56 immutableAssign({ 54 {
57 min_lifetime: '1 hour', 55 min_lifetime: '1 hour',
58 strategy: strategy, 56 strategy: strategy,
59 size: '400KB' 57 size: '400KB',
60 }, additionalParams) 58
59 ...additionalParams
60 }
61 ) 61 )
62 } 62 }
63 63
@@ -316,7 +316,7 @@ describe('Test videos redundancy', function () {
316 this.timeout(80000) 316 this.timeout(80000)
317 317
318 await waitJobs(servers) 318 await waitJobs(servers)
319 await waitUntilLog(servers[0], 'Duplicated ', 5) 319 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
320 await waitJobs(servers) 320 await waitJobs(servers)
321 321
322 await check2Webseeds() 322 await check2Webseeds()
@@ -335,7 +335,7 @@ describe('Test videos redundancy', function () {
335 await check1WebSeed() 335 await check1WebSeed()
336 await check0PlaylistRedundancies() 336 await check0PlaylistRedundancies()
337 337
338 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].internalServerNumber, [ 'videos', join('playlists', 'hls') ]) 338 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos', join('playlists', 'hls') ])
339 }) 339 })
340 340
341 after(async function () { 341 after(async function () {
@@ -366,7 +366,7 @@ describe('Test videos redundancy', function () {
366 this.timeout(80000) 366 this.timeout(80000)
367 367
368 await waitJobs(servers) 368 await waitJobs(servers)
369 await waitUntilLog(servers[0], 'Duplicated ', 5) 369 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
370 await waitJobs(servers) 370 await waitJobs(servers)
371 371
372 await check2Webseeds() 372 await check2Webseeds()
@@ -385,7 +385,7 @@ describe('Test videos redundancy', function () {
385 await check1WebSeed() 385 await check1WebSeed()
386 await check0PlaylistRedundancies() 386 await check0PlaylistRedundancies()
387 387
388 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].internalServerNumber, [ 'videos' ]) 388 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos' ])
389 }) 389 })
390 390
391 after(async function () { 391 after(async function () {
@@ -438,7 +438,7 @@ describe('Test videos redundancy', function () {
438 this.timeout(80000) 438 this.timeout(80000)
439 439
440 await waitJobs(servers) 440 await waitJobs(servers)
441 await waitUntilLog(servers[0], 'Duplicated ', 5) 441 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
442 await waitJobs(servers) 442 await waitJobs(servers)
443 443
444 await check2Webseeds() 444 await check2Webseeds()
@@ -454,7 +454,7 @@ describe('Test videos redundancy', function () {
454 await waitJobs(servers) 454 await waitJobs(servers)
455 455
456 for (const server of servers) { 456 for (const server of servers) {
457 await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber) 457 await checkVideoFilesWereRemoved(video1Server2UUID, server)
458 } 458 }
459 }) 459 })
460 460
@@ -502,7 +502,7 @@ describe('Test videos redundancy', function () {
502 await waitJobs(servers) 502 await waitJobs(servers)
503 503
504 await waitJobs(servers) 504 await waitJobs(servers)
505 await waitUntilLog(servers[0], 'Duplicated ', 1) 505 await servers[0].serversCommand.waitUntilLog('Duplicated ', 1)
506 await waitJobs(servers) 506 await waitJobs(servers)
507 507
508 await check1PlaylistRedundancies() 508 await check1PlaylistRedundancies()
@@ -517,7 +517,7 @@ describe('Test videos redundancy', function () {
517 await waitJobs(servers) 517 await waitJobs(servers)
518 518
519 for (const server of servers) { 519 for (const server of servers) {
520 await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber) 520 await checkVideoFilesWereRemoved(video1Server2UUID, server)
521 } 521 }
522 }) 522 })
523 523
@@ -547,7 +547,7 @@ describe('Test videos redundancy', function () {
547 this.timeout(80000) 547 this.timeout(80000)
548 548
549 await waitJobs(servers) 549 await waitJobs(servers)
550 await waitUntilLog(servers[0], 'Duplicated ', 5) 550 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
551 await waitJobs(servers) 551 await waitJobs(servers)
552 552
553 await check2Webseeds() 553 await check2Webseeds()
@@ -575,7 +575,7 @@ describe('Test videos redundancy', function () {
575 await check1WebSeed() 575 await check1WebSeed()
576 await check0PlaylistRedundancies() 576 await check0PlaylistRedundancies()
577 577
578 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ]) 578 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos' ])
579 }) 579 })
580 580
581 after(async function () { 581 after(async function () {
@@ -658,7 +658,7 @@ describe('Test videos redundancy', function () {
658 await enableRedundancyOnServer1() 658 await enableRedundancyOnServer1()
659 659
660 await waitJobs(servers) 660 await waitJobs(servers)
661 await waitUntilLog(servers[0], 'Duplicated ', 5) 661 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
662 await waitJobs(servers) 662 await waitJobs(servers)
663 663
664 await check2Webseeds(video1Server2UUID) 664 await check2Webseeds(video1Server2UUID)
@@ -715,7 +715,7 @@ describe('Test videos redundancy', function () {
715 715
716 await waitJobs(servers) 716 await waitJobs(servers)
717 717
718 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].internalServerNumber, [ join('redundancy', 'hls') ]) 718 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ join('redundancy', 'hls') ])
719 }) 719 })
720 720
721 after(async function () { 721 after(async function () {
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts
index e4c5f5796..306f84c3a 100644
--- a/server/tests/api/search/search-index.ts
+++ b/server/tests/api/search/search-index.ts
@@ -2,16 +2,8 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils'
6 cleanupTests, 6import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
7 flushAndRunServer,
8 immutableAssign,
9 SearchCommand,
10 ServerInfo,
11 setAccessTokensToServers,
12 uploadVideo
13} from '@shared/extra-utils'
14import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
15 7
16const expect = chai.expect 8const expect = chai.expect
17 9
@@ -174,32 +166,32 @@ describe('Test videos search', function () {
174 } 166 }
175 167
176 { 168 {
177 const search = immutableAssign(baseSearch, { startDate: '2018-10-01T10:54:46.396Z' }) 169 const search = { ...baseSearch, startDate: '2018-10-01T10:54:46.396Z' }
178 await check(search, false) 170 await check(search, false)
179 } 171 }
180 172
181 { 173 {
182 const search = immutableAssign(baseSearch, { tagsAllOf: [ 'toto', 'framasoft' ] }) 174 const search = { ...baseSearch, tagsAllOf: [ 'toto', 'framasoft' ] }
183 await check(search, false) 175 await check(search, false)
184 } 176 }
185 177
186 { 178 {
187 const search = immutableAssign(baseSearch, { durationMin: 2000 }) 179 const search = { ...baseSearch, durationMin: 2000 }
188 await check(search, false) 180 await check(search, false)
189 } 181 }
190 182
191 { 183 {
192 const search = immutableAssign(baseSearch, { nsfw: 'true' }) 184 const search = { ...baseSearch, nsfw: 'true' as BooleanBothQuery }
193 await check(search, false) 185 await check(search, false)
194 } 186 }
195 187
196 { 188 {
197 const search = immutableAssign(baseSearch, { nsfw: 'false' }) 189 const search = { ...baseSearch, nsfw: 'false' as BooleanBothQuery }
198 await check(search, true) 190 await check(search, true)
199 } 191 }
200 192
201 { 193 {
202 const search = immutableAssign(baseSearch, { nsfw: 'both' }) 194 const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery }
203 await check(search, true) 195 await check(search, true)
204 } 196 }
205 }) 197 })
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 513538917..66f5f3182 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 flushAndRunServer,
8 immutableAssign,
9 SearchCommand, 8 SearchCommand,
10 ServerInfo, 9 ServerInfo,
11 setAccessTokensToServers, 10 setAccessTokensToServers,
@@ -44,11 +43,11 @@ describe('Test videos search', function () {
44 } 43 }
45 await uploadVideo(server.url, server.accessToken, attributes1) 44 await uploadVideo(server.url, server.accessToken, attributes1)
46 45
47 const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) 46 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
48 await uploadVideo(server.url, server.accessToken, attributes2) 47 await uploadVideo(server.url, server.accessToken, attributes2)
49 48
50 { 49 {
51 const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined }) 50 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
52 const res = await uploadVideo(server.url, server.accessToken, attributes3) 51 const res = await uploadVideo(server.url, server.accessToken, attributes3)
53 const videoId = res.body.video.id 52 const videoId = res.body.video.id
54 videoUUID = res.body.video.uuid 53 videoUUID = res.body.video.uuid
@@ -68,26 +67,23 @@ describe('Test videos search', function () {
68 }) 67 })
69 } 68 }
70 69
71 const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) 70 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
72 await uploadVideo(server.url, server.accessToken, attributes4) 71 await uploadVideo(server.url, server.accessToken, attributes4)
73 72
74 await wait(1000) 73 await wait(1000)
75 74
76 startDate = new Date().toISOString() 75 startDate = new Date().toISOString()
77 76
78 const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) 77 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
79 await uploadVideo(server.url, server.accessToken, attributes5) 78 await uploadVideo(server.url, server.accessToken, attributes5)
80 79
81 const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }) 80 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
82 await uploadVideo(server.url, server.accessToken, attributes6) 81 await uploadVideo(server.url, server.accessToken, attributes6)
83 82
84 const attributes7 = immutableAssign(attributes1, { 83 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
85 name: attributes1.name + ' - 7',
86 originallyPublishedAt: '2019-02-12T09:58:08.286Z'
87 })
88 await uploadVideo(server.url, server.accessToken, attributes7) 84 await uploadVideo(server.url, server.accessToken, attributes7)
89 85
90 const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) 86 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
91 await uploadVideo(server.url, server.accessToken, attributes8) 87 await uploadVideo(server.url, server.accessToken, attributes8)
92 } 88 }
93 89
@@ -101,7 +97,7 @@ describe('Test videos search', function () {
101 } 97 }
102 await uploadVideo(server.url, server.accessToken, attributes) 98 await uploadVideo(server.url, server.accessToken, attributes)
103 99
104 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes, { name: attributes.name + ' duplicate' })) 100 await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' })
105 } 101 }
106 102
107 { 103 {
@@ -122,10 +118,10 @@ describe('Test videos search', function () {
122 category: 1 118 category: 1
123 } 119 }
124 await uploadVideo(server.url, server.accessToken, attributes1) 120 await uploadVideo(server.url, server.accessToken, attributes1)
125 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) 121 await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 })
126 122
127 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] })) 123 await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] })
128 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] })) 124 await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] })
129 } 125 }
130 126
131 { 127 {
@@ -134,7 +130,7 @@ describe('Test videos search', function () {
134 category: 1 130 category: 1
135 } 131 }
136 await uploadVideo(server.url, server.accessToken, attributes1) 132 await uploadVideo(server.url, server.accessToken, attributes1)
137 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) 133 await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 })
138 } 134 }
139 135
140 command = server.searchCommand 136 command = server.searchCommand
@@ -414,7 +410,7 @@ describe('Test videos search', function () {
414 } 410 }
415 411
416 { 412 {
417 const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) 413 const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }
418 const body = await command.advancedVideoSearch({ search: query }) 414 const body = await command.advancedVideoSearch({ search: query })
419 415
420 expect(body.total).to.equal(1) 416 expect(body.total).to.equal(1)
@@ -422,7 +418,7 @@ describe('Test videos search', function () {
422 } 418 }
423 419
424 { 420 {
425 const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) 421 const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }
426 const body = await command.advancedVideoSearch({ search: query }) 422 const body = await command.advancedVideoSearch({ search: query })
427 423
428 expect(body.total).to.equal(1) 424 expect(body.total).to.equal(1)
@@ -430,34 +426,36 @@ describe('Test videos search', function () {
430 } 426 }
431 427
432 { 428 {
433 const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) 429 const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }
434 const body = await command.advancedVideoSearch({ search: query }) 430 const body = await command.advancedVideoSearch({ search: query })
435 431
436 expect(body.total).to.equal(0) 432 expect(body.total).to.equal(0)
437 } 433 }
438 434
439 { 435 {
440 const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) 436 const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }
441 const body = await command.advancedVideoSearch({ search: query }) 437 const body = await command.advancedVideoSearch({ search: query })
442 438
443 expect(body.total).to.equal(0) 439 expect(body.total).to.equal(0)
444 } 440 }
445 441
446 { 442 {
447 const query = immutableAssign(baseQuery, { 443 const query = {
444 ...baseQuery,
448 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', 445 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
449 originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' 446 originallyPublishedEndDate: '2019-01-10T09:58:08.286Z'
450 }) 447 }
451 const body = await command.advancedVideoSearch({ search: query }) 448 const body = await command.advancedVideoSearch({ search: query })
452 449
453 expect(body.total).to.equal(0) 450 expect(body.total).to.equal(0)
454 } 451 }
455 452
456 { 453 {
457 const query = immutableAssign(baseQuery, { 454 const query = {
455 ...baseQuery,
458 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', 456 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
459 originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' 457 originallyPublishedEndDate: '2019-04-11T09:58:08.286Z'
460 }) 458 }
461 const body = await command.advancedVideoSearch({ search: query }) 459 const body = await command.advancedVideoSearch({ search: query })
462 460
463 expect(body.total).to.equal(1) 461 expect(body.total).to.equal(1)
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index dd06acb5e..d45c3ae8a 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -10,7 +10,6 @@ import {
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getVideo, 11 getVideo,
12 getVideosList, 12 getVideosList,
13 immutableAssign,
14 killallServers, 13 killallServers,
15 reRunServer, 14 reRunServer,
16 ServerInfo, 15 ServerInfo,
@@ -50,9 +49,7 @@ describe('Test handle downs', function () {
50 fixture: 'video_short1.webm' 49 fixture: 'video_short1.webm'
51 } 50 }
52 51
53 const unlistedVideoAttributes = immutableAssign(videoAttributes, { 52 const unlistedVideoAttributes = { ...videoAttributes, privacy: VideoPrivacy.UNLISTED }
54 privacy: VideoPrivacy.UNLISTED
55 })
56 53
57 let checkAttributes: any 54 let checkAttributes: any
58 let unlistedCheckAttributes: any 55 let unlistedCheckAttributes: any
@@ -97,9 +94,7 @@ describe('Test handle downs', function () {
97 } 94 }
98 ] 95 ]
99 } 96 }
100 unlistedCheckAttributes = immutableAssign(checkAttributes, { 97 unlistedCheckAttributes = { ...checkAttributes, privacy: VideoPrivacy.UNLISTED }
101 privacy: VideoPrivacy.UNLISTED
102 })
103 98
104 // Get the access tokens 99 // Get the access tokens
105 await setAccessTokensToServers(servers) 100 await setAccessTokensToServers(servers)
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts
index 365f6cc2b..096d63e21 100644
--- a/server/tests/api/server/logs.ts
+++ b/server/tests/api/server/logs.ts
@@ -7,7 +7,6 @@ import {
7 flushAndRunServer, 7 flushAndRunServer,
8 killallServers, 8 killallServers,
9 LogsCommand, 9 LogsCommand,
10 makePingRequest,
11 reRunServer, 10 reRunServer,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
@@ -102,7 +101,7 @@ describe('Test logs', function () {
102 101
103 const now = new Date() 102 const now = new Date()
104 103
105 await makePingRequest(server) 104 await server.serversCommand.ping()
106 105
107 const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) 106 const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
108 const logsString = JSON.stringify(body) 107 const logsString = JSON.stringify(body)
@@ -119,7 +118,7 @@ describe('Test logs', function () {
119 118
120 const now = new Date() 119 const now = new Date()
121 120
122 await makePingRequest(server) 121 await server.serversCommand.ping()
123 122
124 const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) 123 const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
125 const logsString = JSON.stringify(body) 124 const logsString = JSON.stringify(body)
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index d4a43276f..a81ac961a 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -14,8 +14,7 @@ import {
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 testHelloWorldRegisteredSettings, 15 testHelloWorldRegisteredSettings,
16 updateMyUser, 16 updateMyUser,
17 wait, 17 wait
18 waitUntilLog
19} from '@shared/extra-utils' 18} from '@shared/extra-utils'
20import { PluginType, User } from '@shared/models' 19import { PluginType, User } from '@shared/models'
21 20
@@ -194,7 +193,7 @@ describe('Test plugins', function () {
194 it('Should have watched settings changes', async function () { 193 it('Should have watched settings changes', async function () {
195 this.timeout(10000) 194 this.timeout(10000)
196 195
197 await waitUntilLog(server, 'Settings changed!') 196 await server.serversCommand.waitUntilLog('Settings changed!')
198 }) 197 })
199 198
200 it('Should get a plugin and a theme', async function () { 199 it('Should get a plugin and a theme', async function () {
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 47056be78..7b650cb8f 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -227,7 +227,7 @@ describe('Test users with multiple servers', function () {
227 227
228 it('Should not have video files', async () => { 228 it('Should not have video files', async () => {
229 for (const server of servers) { 229 for (const server of servers) {
230 await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber) 230 await checkVideoFilesWereRemoved(videoUUID, server)
231 } 231 }
232 }) 232 })
233 233
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts
index 7ddbd5cd9..9b516af81 100644
--- a/server/tests/api/videos/audio-only.ts
+++ b/server/tests/api/videos/audio-only.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
7import { 7import {
8 buildServerDirectory,
9 cleanupTests, 8 cleanupTests,
10 doubleFollow, 9 doubleFollow,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -81,8 +80,8 @@ describe('Test audio only video transcoding', function () {
81 80
82 it('0p transcoded video should not have video', async function () { 81 it('0p transcoded video should not have video', async function () {
83 const paths = [ 82 const paths = [
84 buildServerDirectory(servers[0], join('videos', videoUUID + '-0.mp4')), 83 servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')),
85 buildServerDirectory(servers[0], join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) 84 servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
86 ] 85 ]
87 86
88 for (const path of paths) { 87 for (const path of paths) {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 1b6f0f48a..1905aac83 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -689,8 +689,8 @@ describe('Test multiple servers', function () {
689 689
690 it('Should not have files of videos 3 and 3-2 on each server', async function () { 690 it('Should not have files of videos 3 and 3-2 on each server', async function () {
691 for (const server of servers) { 691 for (const server of servers) {
692 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber) 692 await checkVideoFilesWereRemoved(toRemove[0].uuid, server)
693 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber) 693 await checkVideoFilesWereRemoved(toRemove[1].uuid, server)
694 } 694 }
695 }) 695 })
696 696
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 6c01c7e78..5845efc86 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -7,7 +7,6 @@ import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/core-utils'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 buildServerDirectory,
11 cleanupTests, 10 cleanupTests,
12 flushAndRunServer, 11 flushAndRunServer,
13 getMyUserInformation, 12 getMyUserInformation,
@@ -82,7 +81,7 @@ describe('Test resumable upload', function () {
82 const uploadId = uploadIdArg.replace(/^upload_id=/, '') 81 const uploadId = uploadIdArg.replace(/^upload_id=/, '')
83 82
84 const subPath = join('tmp', 'resumable-uploads', uploadId) 83 const subPath = join('tmp', 'resumable-uploads', uploadId)
85 const filePath = buildServerDirectory(server, subPath) 84 const filePath = server.serversCommand.buildDirectory(subPath)
86 const exists = await pathExists(filePath) 85 const exists = await pathExists(filePath)
87 86
88 if (expectedSize === null) { 87 if (expectedSize === null) {
@@ -97,7 +96,7 @@ describe('Test resumable upload', function () {
97 96
98 async function countResumableUploads () { 97 async function countResumableUploads () {
99 const subPath = join('tmp', 'resumable-uploads') 98 const subPath = join('tmp', 'resumable-uploads')
100 const filePath = buildServerDirectory(server, subPath) 99 const filePath = server.serversCommand.buildDirectory(subPath)
101 100
102 const files = await readdir(filePath) 101 const files = await readdir(filePath)
103 return files.length 102 return files.length
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 1058a1e9c..af1703e02 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -230,7 +230,7 @@ describe('Test a single server', function () {
230 it('Should remove the video', async function () { 230 it('Should remove the video', async function () {
231 await removeVideo(server.url, server.accessToken, videoId) 231 await removeVideo(server.url, server.accessToken, videoId)
232 232
233 await checkVideoFilesWereRemoved(videoUUID, 1) 233 await checkVideoFilesWereRemoved(videoUUID, server)
234 }) 234 })
235 235
236 it('Should not have videos', async function () { 236 it('Should not have videos', async function () {
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index 83ee809b8..d4a5385ab 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -182,7 +182,7 @@ describe('Test video captions', function () {
182 it('Should remove the video, and thus all video captions', async function () { 182 it('Should remove the video, and thus all video captions', async function () {
183 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) 183 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
184 184
185 await checkVideoFilesWereRemoved(videoUUID, 1) 185 await checkVideoFilesWereRemoved(videoUUID, servers[0])
186 }) 186 })
187 187
188 after(async function () { 188 after(async function () {
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 4f9ecbe8e..f6ae8cab1 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -11,7 +11,6 @@ import {
11 getMyVideos, 11 getMyVideos,
12 getVideo, 12 getVideo,
13 getVideosList, 13 getVideosList,
14 immutableAssign,
15 ImportsCommand, 14 ImportsCommand,
16 ServerInfo, 15 ServerInfo,
17 setAccessTokensToServers, 16 setAccessTokensToServers,
@@ -119,7 +118,7 @@ describe('Test video imports', function () {
119 } 118 }
120 119
121 { 120 {
122 const attributes = immutableAssign(baseAttributes, { targetUrl: ImportsCommand.getYoutubeVideoUrl() }) 121 const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
123 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 122 const { video } = await servers[0].importsCommand.importVideo({ attributes })
124 expect(video.name).to.equal('small video - youtube') 123 expect(video.name).to.equal('small video - youtube')
125 124
@@ -169,21 +168,23 @@ Ajouter un sous-titre est vraiment facile`)
169 } 168 }
170 169
171 { 170 {
172 const attributes = immutableAssign(baseAttributes, { 171 const attributes = {
172 ...baseAttributes,
173 magnetUri: ImportsCommand.getMagnetURI(), 173 magnetUri: ImportsCommand.getMagnetURI(),
174 description: 'this is a super torrent description', 174 description: 'this is a super torrent description',
175 tags: [ 'tag_torrent1', 'tag_torrent2' ] 175 tags: [ 'tag_torrent1', 'tag_torrent2' ]
176 }) 176 }
177 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 177 const { video } = await servers[0].importsCommand.importVideo({ attributes })
178 expect(video.name).to.equal('super peertube2 video') 178 expect(video.name).to.equal('super peertube2 video')
179 } 179 }
180 180
181 { 181 {
182 const attributes = immutableAssign(baseAttributes, { 182 const attributes = {
183 ...baseAttributes,
183 torrentfile: 'video-720p.torrent' as any, 184 torrentfile: 'video-720p.torrent' as any,
184 description: 'this is a super torrent description', 185 description: 'this is a super torrent description',
185 tags: [ 'tag_torrent1', 'tag_torrent2' ] 186 tags: [ 'tag_torrent1', 'tag_torrent2' ]
186 }) 187 }
187 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 188 const { video } = await servers[0].importsCommand.importVideo({ attributes })
188 expect(video.name).to.equal('你好 世界 720p.mp4') 189 expect(video.name).to.equal('你好 世界 720p.mp4')
189 } 190 }
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index e74fb5bef..f16b22bae 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -9,14 +9,12 @@ import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 10import {
11 buildAbsoluteFixturePath, 11 buildAbsoluteFixturePath,
12 buildServerDirectory,
13 cleanupTests, 12 cleanupTests,
14 doubleFollow, 13 doubleFollow,
15 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
16 generateHighBitrateVideo, 15 generateHighBitrateVideo,
17 generateVideoWithFramerate, 16 generateVideoWithFramerate,
18 getMyVideos, 17 getMyVideos,
19 getServerFileSize,
20 getVideo, 18 getVideo,
21 getVideoFileMetadataUrl, 19 getVideoFileMetadataUrl,
22 getVideosList, 20 getVideosList,
@@ -285,7 +283,7 @@ describe('Test video transcoding', function () {
285 283
286 expect(videoDetails.files).to.have.lengthOf(4) 284 expect(videoDetails.files).to.have.lengthOf(4)
287 285
288 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 286 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
289 const probe = await getAudioStream(path) 287 const probe = await getAudioStream(path)
290 288
291 if (probe.audioStream) { 289 if (probe.audioStream) {
@@ -316,7 +314,7 @@ describe('Test video transcoding', function () {
316 const videoDetails: VideoDetails = res2.body 314 const videoDetails: VideoDetails = res2.body
317 315
318 expect(videoDetails.files).to.have.lengthOf(4) 316 expect(videoDetails.files).to.have.lengthOf(4)
319 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 317 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
320 const probe = await getAudioStream(path) 318 const probe = await getAudioStream(path)
321 expect(probe).to.not.have.property('audioStream') 319 expect(probe).to.not.have.property('audioStream')
322 } 320 }
@@ -344,7 +342,7 @@ describe('Test video transcoding', function () {
344 342
345 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 343 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
346 const fixtureVideoProbe = await getAudioStream(fixturePath) 344 const fixtureVideoProbe = await getAudioStream(fixturePath)
347 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 345 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
348 346
349 const videoProbe = await getAudioStream(path) 347 const videoProbe = await getAudioStream(path)
350 348
@@ -506,13 +504,13 @@ describe('Test video transcoding', function () {
506 expect(videoDetails.files[3].fps).to.be.below(31) 504 expect(videoDetails.files[3].fps).to.be.below(31)
507 505
508 for (const resolution of [ '240', '360', '480' ]) { 506 for (const resolution of [ '240', '360', '480' ]) {
509 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4')) 507 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
510 const fps = await getVideoFileFPS(path) 508 const fps = await getVideoFileFPS(path)
511 509
512 expect(fps).to.be.below(31) 510 expect(fps).to.be.below(31)
513 } 511 }
514 512
515 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4')) 513 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
516 const fps = await getVideoFileFPS(path) 514 const fps = await getVideoFileFPS(path)
517 515
518 expect(fps).to.be.above(58).and.below(62) 516 expect(fps).to.be.above(58).and.below(62)
@@ -547,13 +545,13 @@ describe('Test video transcoding', function () {
547 const video = res.body.data.find(v => v.name === videoAttributes.name) 545 const video = res.body.data.find(v => v.name === videoAttributes.name)
548 546
549 { 547 {
550 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 548 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
551 const fps = await getVideoFileFPS(path) 549 const fps = await getVideoFileFPS(path)
552 expect(fps).to.be.equal(25) 550 expect(fps).to.be.equal(25)
553 } 551 }
554 552
555 { 553 {
556 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4')) 554 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
557 const fps = await getVideoFileFPS(path) 555 const fps = await getVideoFileFPS(path)
558 expect(fps).to.be.equal(59) 556 expect(fps).to.be.equal(59)
559 } 557 }
@@ -590,7 +588,7 @@ describe('Test video transcoding', function () {
590 const video = res.body.data.find(v => v.name === videoAttributes.name) 588 const video = res.body.data.find(v => v.name === videoAttributes.name)
591 589
592 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 590 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
593 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4')) 591 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
594 592
595 const bitrate = await getVideoFileBitrate(path) 593 const bitrate = await getVideoFileBitrate(path)
596 const fps = await getVideoFileFPS(path) 594 const fps = await getVideoFileFPS(path)
@@ -636,7 +634,7 @@ describe('Test video transcoding', function () {
636 const resolutions = [ 240, 360, 480, 720, 1080 ] 634 const resolutions = [ 240, 360, 480, 720, 1080 ]
637 for (const r of resolutions) { 635 for (const r of resolutions) {
638 const path = `videos/${videoUUID}-${r}.mp4` 636 const path = `videos/${videoUUID}-${r}.mp4`
639 const size = await getServerFileSize(servers[1], path) 637 const size = await servers[1].serversCommand.getServerFileSize(path)
640 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 638 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
641 } 639 }
642 }) 640 })
@@ -651,7 +649,7 @@ describe('Test video transcoding', function () {
651 await waitJobs(servers) 649 await waitJobs(servers)
652 650
653 { 651 {
654 const path = buildServerDirectory(servers[1], join('videos', videoUUID + '-240.mp4')) 652 const path = servers[1].serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
655 const metadata = await getMetadataFromFile(path) 653 const metadata = await getMetadataFromFile(path)
656 654
657 // expected format properties 655 // expected format properties
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index bd15012fe..e369a3305 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -4,7 +4,6 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { 6import {
7 buildServerDirectory,
8 cleanupTests, 7 cleanupTests,
9 doubleFollow, 8 doubleFollow,
10 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -96,7 +95,7 @@ describe('Test optimize old videos', function () {
96 95
97 expect(file.size).to.be.below(8000000) 96 expect(file.size).to.be.below(8000000)
98 97
99 const path = buildServerDirectory(servers[0], join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) 98 const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
100 const bitrate = await getVideoFileBitrate(path) 99 const bitrate = await getVideoFileBitrate(path)
101 const fps = await getVideoFileFPS(path) 100 const fps = await getVideoFileFPS(path)
102 const resolution = await getVideoFileResolution(path) 101 const resolution = await getVideoFileResolution(path)
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index d4dbee682..68a59a41d 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -7,7 +7,6 @@ import { join } from 'path'
7import { buildUUID } from '@server/helpers/uuid' 7import { buildUUID } from '@server/helpers/uuid'
8import { HttpStatusCode } from '@shared/core-utils' 8import { HttpStatusCode } from '@shared/core-utils'
9import { 9import {
10 buildServerDirectory,
11 cleanupTests, 10 cleanupTests,
12 CLICommand, 11 CLICommand,
13 doubleFollow, 12 doubleFollow,
@@ -26,14 +25,14 @@ import { VideoPlaylistPrivacy } from '@shared/models'
26 25
27const expect = chai.expect 26const expect = chai.expect
28 27
29async function countFiles (internalServerNumber: number, directory: string) { 28async function countFiles (server: ServerInfo, directory: string) {
30 const files = await readdir(buildServerDirectory({ internalServerNumber }, directory)) 29 const files = await readdir(server.serversCommand.buildDirectory(directory))
31 30
32 return files.length 31 return files.length
33} 32}
34 33
35async function assertNotExists (internalServerNumber: number, directory: string, substring: string) { 34async function assertNotExists (server: ServerInfo, directory: string, substring: string) {
36 const files = await readdir(buildServerDirectory({ internalServerNumber }, directory)) 35 const files = await readdir(server.serversCommand.buildDirectory(directory))
37 36
38 for (const f of files) { 37 for (const f of files) {
39 expect(f).to.not.contain(substring) 38 expect(f).to.not.contain(substring)
@@ -42,19 +41,19 @@ async function assertNotExists (internalServerNumber: number, directory: string,
42 41
43async function assertCountAreOkay (servers: ServerInfo[]) { 42async function assertCountAreOkay (servers: ServerInfo[]) {
44 for (const server of servers) { 43 for (const server of servers) {
45 const videosCount = await countFiles(server.internalServerNumber, 'videos') 44 const videosCount = await countFiles(server, 'videos')
46 expect(videosCount).to.equal(8) 45 expect(videosCount).to.equal(8)
47 46
48 const torrentsCount = await countFiles(server.internalServerNumber, 'torrents') 47 const torrentsCount = await countFiles(server, 'torrents')
49 expect(torrentsCount).to.equal(16) 48 expect(torrentsCount).to.equal(16)
50 49
51 const previewsCount = await countFiles(server.internalServerNumber, 'previews') 50 const previewsCount = await countFiles(server, 'previews')
52 expect(previewsCount).to.equal(2) 51 expect(previewsCount).to.equal(2)
53 52
54 const thumbnailsCount = await countFiles(server.internalServerNumber, 'thumbnails') 53 const thumbnailsCount = await countFiles(server, 'thumbnails')
55 expect(thumbnailsCount).to.equal(6) 54 expect(thumbnailsCount).to.equal(6)
56 55
57 const avatarsCount = await countFiles(server.internalServerNumber, 'avatars') 56 const avatarsCount = await countFiles(server, 'avatars')
58 expect(avatarsCount).to.equal(2) 57 expect(avatarsCount).to.equal(2)
59 } 58 }
60} 59}
@@ -122,7 +121,7 @@ describe('Test prune storage scripts', function () {
122 it('Should create some dirty files', async function () { 121 it('Should create some dirty files', async function () {
123 for (let i = 0; i < 2; i++) { 122 for (let i = 0; i < 2; i++) {
124 { 123 {
125 const base = buildServerDirectory(servers[0], 'videos') 124 const base = servers[0].serversCommand.buildDirectory('videos')
126 125
127 const n1 = buildUUID() + '.mp4' 126 const n1 = buildUUID() + '.mp4'
128 const n2 = buildUUID() + '.webm' 127 const n2 = buildUUID() + '.webm'
@@ -134,7 +133,7 @@ describe('Test prune storage scripts', function () {
134 } 133 }
135 134
136 { 135 {
137 const base = buildServerDirectory(servers[0], 'torrents') 136 const base = servers[0].serversCommand.buildDirectory('torrents')
138 137
139 const n1 = buildUUID() + '-240.torrent' 138 const n1 = buildUUID() + '-240.torrent'
140 const n2 = buildUUID() + '-480.torrent' 139 const n2 = buildUUID() + '-480.torrent'
@@ -146,7 +145,7 @@ describe('Test prune storage scripts', function () {
146 } 145 }
147 146
148 { 147 {
149 const base = buildServerDirectory(servers[0], 'thumbnails') 148 const base = servers[0].serversCommand.buildDirectory('thumbnails')
150 149
151 const n1 = buildUUID() + '.jpg' 150 const n1 = buildUUID() + '.jpg'
152 const n2 = buildUUID() + '.jpg' 151 const n2 = buildUUID() + '.jpg'
@@ -158,7 +157,7 @@ describe('Test prune storage scripts', function () {
158 } 157 }
159 158
160 { 159 {
161 const base = buildServerDirectory(servers[0], 'previews') 160 const base = servers[0].serversCommand.buildDirectory('previews')
162 161
163 const n1 = buildUUID() + '.jpg' 162 const n1 = buildUUID() + '.jpg'
164 const n2 = buildUUID() + '.jpg' 163 const n2 = buildUUID() + '.jpg'
@@ -170,7 +169,7 @@ describe('Test prune storage scripts', function () {
170 } 169 }
171 170
172 { 171 {
173 const base = buildServerDirectory(servers[0], 'avatars') 172 const base = servers[0].serversCommand.buildDirectory('avatars')
174 173
175 const n1 = buildUUID() + '.png' 174 const n1 = buildUUID() + '.png'
176 const n2 = buildUUID() + '.jpg' 175 const n2 = buildUUID() + '.jpg'
@@ -195,7 +194,7 @@ describe('Test prune storage scripts', function () {
195 194
196 for (const directory of Object.keys(badNames)) { 195 for (const directory of Object.keys(badNames)) {
197 for (const name of badNames[directory]) { 196 for (const name of badNames[directory]) {
198 await assertNotExists(servers[0].internalServerNumber, directory, name) 197 await assertNotExists(servers[0], directory, name)
199 } 198 }
200 } 199 }
201 }) 200 })
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index 1b460e9c0..68a4711b6 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -4,7 +4,6 @@ import { writeFile } from 'fs-extra'
4import { basename, join } from 'path' 4import { basename, join } from 'path'
5import { Video, VideoDetails } from '@shared/models' 5import { Video, VideoDetails } from '@shared/models'
6import { 6import {
7 buildServerDirectory,
8 cleanupTests, 7 cleanupTests,
9 doubleFollow, 8 doubleFollow,
10 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -50,7 +49,7 @@ describe('Test regenerate thumbnails script', function () {
50 const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid 49 const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid
51 video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body)) 50 video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body))
52 51
53 thumbnail1Path = join(buildServerDirectory(servers[0], 'thumbnails'), basename(video1.thumbnailPath)) 52 thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
54 53
55 const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid 54 const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid
56 video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body)) 55 video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body))
@@ -62,7 +61,7 @@ describe('Test regenerate thumbnails script', function () {
62 61
63 remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body)) 62 remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body))
64 63
65 thumbnailRemotePath = join(buildServerDirectory(servers[0], 'thumbnails'), basename(remoteVideo.thumbnailPath)) 64 thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
66 } 65 }
67 66
68 await writeFile(thumbnail1Path, '') 67 await writeFile(thumbnail1Path, '')
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index bcf773854..cf81e44b7 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -22,8 +22,7 @@ import {
22 flushAndRunMultipleServers, 22 flushAndRunMultipleServers,
23 killallServers, 23 killallServers,
24 reRunServer, 24 reRunServer,
25 ServerInfo, 25 ServerInfo
26 waitUntilLog
27} from '../../../shared/extra-utils/server/servers' 26} from '../../../shared/extra-utils/server/servers'
28 27
29describe('Test plugin action hooks', function () { 28describe('Test plugin action hooks', function () {
@@ -32,7 +31,7 @@ describe('Test plugin action hooks', function () {
32 let threadId: number 31 let threadId: number
33 32
34 function checkHook (hook: ServerHookName) { 33 function checkHook (hook: ServerHookName) {
35 return waitUntilLog(servers[0], 'Run hook ' + hook) 34 return servers[0].serversCommand.waitUntilLog('Run hook ' + hook)
36 } 35 }
37 36
38 before(async function () { 37 before(async function () {
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 09a107ca2..f7cee588a 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -17,8 +17,7 @@ import {
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 updateMyUser, 18 updateMyUser,
19 userLogin, 19 userLogin,
20 wait, 20 wait
21 waitUntilLog
22} from '@shared/extra-utils' 21} from '@shared/extra-utils'
23import { User, UserRole } from '@shared/models' 22import { User, UserRole } from '@shared/models'
24 23
@@ -127,7 +126,7 @@ describe('Test external auth plugins', function () {
127 126
128 await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400) 127 await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400)
129 128
130 await waitUntilLog(server, 'expired external auth token', 2) 129 await server.serversCommand.waitUntilLog('expired external auth token', 2)
131 }) 130 })
132 131
133 it('Should auto login Cyan, create the user and use the token', async function () { 132 it('Should auto login Cyan, create the user and use the token', async function () {
@@ -217,7 +216,7 @@ describe('Test external auth plugins', function () {
217 }) 216 })
218 217
219 it('Should have logged out Cyan', async function () { 218 it('Should have logged out Cyan', async function () {
220 await waitUntilLog(server, 'On logout cyan') 219 await server.serversCommand.waitUntilLog('On logout cyan')
221 220
222 await getMyUserInformation(server.url, cyanAccessToken, HttpStatusCode.UNAUTHORIZED_401) 221 await getMyUserInformation(server.url, cyanAccessToken, HttpStatusCode.UNAUTHORIZED_401)
223 }) 222 })
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index c235508e8..b5e29d298 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -24,8 +24,7 @@ import {
24 updateVideo, 24 updateVideo,
25 uploadVideo, 25 uploadVideo,
26 uploadVideoAndGetId, 26 uploadVideoAndGetId,
27 waitJobs, 27 waitJobs
28 waitUntilLog
29} from '@shared/extra-utils' 28} from '@shared/extra-utils'
30import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' 29import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
31 30
@@ -475,8 +474,8 @@ describe('Test plugin filter hooks', function () {
475 } 474 }
476 }) 475 })
477 476
478 await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1) 477 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
479 await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.result', 1) 478 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
480 }) 479 })
481 480
482 it('Should run filter:api.search.videos.index.list.{params,result}', async function () { 481 it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
@@ -487,10 +486,10 @@ describe('Test plugin filter hooks', function () {
487 } 486 }
488 }) 487 })
489 488
490 await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1) 489 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
491 await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.result', 1) 490 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
492 await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.index.list.params', 1) 491 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
493 await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.index.list.result', 1) 492 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
494 }) 493 })
495 494
496 it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () { 495 it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
@@ -500,8 +499,8 @@ describe('Test plugin filter hooks', function () {
500 } 499 }
501 }) 500 })
502 501
503 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1) 502 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
504 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.result', 1) 503 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
505 }) 504 })
506 505
507 it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () { 506 it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
@@ -512,10 +511,10 @@ describe('Test plugin filter hooks', function () {
512 } 511 }
513 }) 512 })
514 513
515 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1) 514 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
516 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.result', 1) 515 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
517 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.params', 1) 516 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
518 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.result', 1) 517 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
519 }) 518 })
520 519
521 it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { 520 it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
@@ -525,8 +524,8 @@ describe('Test plugin filter hooks', function () {
525 } 524 }
526 }) 525 })
527 526
528 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) 527 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
529 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) 528 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
530 }) 529 })
531 530
532 it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { 531 it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
@@ -537,10 +536,10 @@ describe('Test plugin filter hooks', function () {
537 } 536 }
538 }) 537 })
539 538
540 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) 539 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
541 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) 540 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
542 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.params', 1) 541 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
543 await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.result', 1) 542 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
544 }) 543 })
545 }) 544 })
546 545
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index 99de28d3f..a0b31bc1f 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -15,8 +15,7 @@ import {
15 setAccessTokensToServers, 15 setAccessTokensToServers,
16 updateMyUser, 16 updateMyUser,
17 userLogin, 17 userLogin,
18 wait, 18 wait
19 waitUntilLog
20} from '@shared/extra-utils' 19} from '@shared/extra-utils'
21import { User, UserRole } from '@shared/models' 20import { User, UserRole } from '@shared/models'
22 21
@@ -137,7 +136,7 @@ describe('Test id and pass auth plugins', function () {
137 }) 136 })
138 137
139 it('Should have logged out Crash', async function () { 138 it('Should have logged out Crash', async function () {
140 await waitUntilLog(server, 'On logout for auth 1 - 2') 139 await server.serversCommand.waitUntilLog('On logout for auth 1 - 2')
141 140
142 await getMyUserInformation(server.url, crashAccessToken, 401) 141 await getMyUserInformation(server.url, crashAccessToken, 401)
143 }) 142 })
@@ -164,16 +163,16 @@ describe('Test id and pass auth plugins', function () {
164 163
165 it('Should reject an invalid username, email, role or display name', async function () { 164 it('Should reject an invalid username, email, role or display name', async function () {
166 await userLogin(server, { username: 'ward', password: 'ward password' }, 400) 165 await userLogin(server, { username: 'ward', password: 'ward password' }, 400)
167 await waitUntilLog(server, 'valid username') 166 await server.serversCommand.waitUntilLog('valid username')
168 167
169 await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400) 168 await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400)
170 await waitUntilLog(server, 'valid display name') 169 await server.serversCommand.waitUntilLog('valid display name')
171 170
172 await userLogin(server, { username: 'raine', password: 'raine password' }, 400) 171 await userLogin(server, { username: 'raine', password: 'raine password' }, 400)
173 await waitUntilLog(server, 'valid role') 172 await server.serversCommand.waitUntilLog('valid role')
174 173
175 await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400) 174 await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400)
176 await waitUntilLog(server, 'valid email') 175 await server.serversCommand.waitUntilLog('valid email')
177 }) 176 })
178 177
179 it('Should unregister spyro-auth and do not login existing Spyro', async function () { 178 it('Should unregister spyro-auth and do not login existing Spyro', async function () {
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 0e0f61638..cbb6887eb 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -17,8 +17,7 @@ import {
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 uploadVideoAndGetId, 18 uploadVideoAndGetId,
19 viewVideo, 19 viewVideo,
20 waitJobs, 20 waitJobs
21 waitUntilLog
22} from '@shared/extra-utils' 21} from '@shared/extra-utils'
23 22
24function postCommand (server: ServerInfo, command: string, bodyArg?: object) { 23function postCommand (server: ServerInfo, command: string, bodyArg?: object) {
@@ -50,22 +49,22 @@ describe('Test plugin helpers', function () {
50 describe('Logger', function () { 49 describe('Logger', function () {
51 50
52 it('Should have logged things', async function () { 51 it('Should have logged things', async function () {
53 await waitUntilLog(servers[0], 'localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false) 52 await servers[0].serversCommand.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
54 await waitUntilLog(servers[0], 'Hello world from plugin four', 1) 53 await servers[0].serversCommand.waitUntilLog('Hello world from plugin four', 1)
55 }) 54 })
56 }) 55 })
57 56
58 describe('Database', function () { 57 describe('Database', function () {
59 58
60 it('Should have made a query', async function () { 59 it('Should have made a query', async function () {
61 await waitUntilLog(servers[0], `root email is admin${servers[0].internalServerNumber}@example.com`) 60 await servers[0].serversCommand.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
62 }) 61 })
63 }) 62 })
64 63
65 describe('Config', function () { 64 describe('Config', function () {
66 65
67 it('Should have the correct webserver url', async function () { 66 it('Should have the correct webserver url', async function () {
68 await waitUntilLog(servers[0], `server url is http://localhost:${servers[0].port}`) 67 await servers[0].serversCommand.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
69 }) 68 })
70 69
71 it('Should have the correct config', async function () { 70 it('Should have the correct config', async function () {
@@ -83,7 +82,7 @@ describe('Test plugin helpers', function () {
83 describe('Server', function () { 82 describe('Server', function () {
84 83
85 it('Should get the server actor', async function () { 84 it('Should get the server actor', async function () {
86 await waitUntilLog(servers[0], 'server actor name is peertube') 85 await servers[0].serversCommand.waitUntilLog('server actor name is peertube')
87 }) 86 })
88 }) 87 })
89 88
@@ -248,7 +247,7 @@ describe('Test plugin helpers', function () {
248 // Should delete the video 247 // Should delete the video
249 await viewVideo(servers[0].url, videoUUID) 248 await viewVideo(servers[0].url, videoUUID)
250 249
251 await waitUntilLog(servers[0], 'Video deleted by plugin four.') 250 await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.')
252 251
253 try { 252 try {
254 // Should throw because the video should have been deleted 253 // Should throw because the video should have been deleted
@@ -258,11 +257,11 @@ describe('Test plugin helpers', function () {
258 if (err.message.includes('exists')) throw err 257 if (err.message.includes('exists')) throw err
259 } 258 }
260 259
261 await checkVideoFilesWereRemoved(videoUUID, servers[0].internalServerNumber) 260 await checkVideoFilesWereRemoved(videoUUID, servers[0])
262 }) 261 })
263 262
264 it('Should have fetched the video by URL', async function () { 263 it('Should have fetched the video by URL', async function () {
265 await waitUntilLog(servers[0], `video from DB uuid is ${videoUUID}`) 264 await servers[0].serversCommand.waitUntilLog(`video from DB uuid is ${videoUUID}`)
266 }) 265 })
267 }) 266 })
268 267
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 4c65463f2..9babfc83e 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -5,16 +5,7 @@ import { expect } from 'chai'
5import { pathExists, readdir, readFile } from 'fs-extra' 5import { pathExists, readdir, readFile } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/core-utils'
8import { 8import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
9 buildServerDirectory,
10 cleanupTests,
11 flushAndRunServer,
12 makeGetRequest,
13 PluginsCommand,
14 ServerInfo,
15 setAccessTokensToServers,
16 waitUntilLog
17} from '@shared/extra-utils'
18 9
19describe('Test plugin storage', function () { 10describe('Test plugin storage', function () {
20 let server: ServerInfo 11 let server: ServerInfo
@@ -31,7 +22,7 @@ describe('Test plugin storage', function () {
31 describe('DB storage', function () { 22 describe('DB storage', function () {
32 23
33 it('Should correctly store a subkey', async function () { 24 it('Should correctly store a subkey', async function () {
34 await waitUntilLog(server, 'superkey stored value is toto') 25 await server.serversCommand.waitUntilLog('superkey stored value is toto')
35 }) 26 })
36 }) 27 })
37 28
@@ -47,12 +38,12 @@ describe('Test plugin storage', function () {
47 } 38 }
48 39
49 before(function () { 40 before(function () {
50 dataPath = buildServerDirectory(server, 'plugins/data') 41 dataPath = server.serversCommand.buildDirectory('plugins/data')
51 pluginDataPath = join(dataPath, 'peertube-plugin-test-six') 42 pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
52 }) 43 })
53 44
54 it('Should have created the directory on install', async function () { 45 it('Should have created the directory on install', async function () {
55 const dataPath = buildServerDirectory(server, 'plugins/data') 46 const dataPath = server.serversCommand.buildDirectory('plugins/data')
56 const pluginDataPath = join(dataPath, 'peertube-plugin-test-six') 47 const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
57 48
58 expect(await pathExists(dataPath)).to.be.true 49 expect(await pathExists(dataPath)).to.be.true
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts
index ca4d9f962..4839e8792 100644
--- a/server/tests/plugins/plugin-transcoding.ts
+++ b/server/tests/plugins/plugin-transcoding.ts
@@ -5,7 +5,6 @@ import { expect } from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
7import { 7import {
8 buildServerDirectory,
9 cleanupTests, 8 cleanupTests,
10 flushAndRunServer, 9 flushAndRunServer,
11 getVideo, 10 getVideo,
@@ -247,7 +246,7 @@ describe('Test transcoding plugins', function () {
247 const videoUUID = (await uploadVideoAndGetId({ server, videoName: 'video', fixture: 'video_short_240p.mp4' })).uuid 246 const videoUUID = (await uploadVideoAndGetId({ server, videoName: 'video', fixture: 'video_short_240p.mp4' })).uuid
248 await waitJobs([ server ]) 247 await waitJobs([ server ])
249 248
250 const path = buildServerDirectory(server, join('videos', videoUUID + '-240.mp4')) 249 const path = server.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
251 const audioProbe = await getAudioStream(path) 250 const audioProbe = await getAudioStream(path)
252 expect(audioProbe.audioStream.codec_name).to.equal('opus') 251 expect(audioProbe.audioStream.codec_name).to.equal('opus')
253 252