diff options
Diffstat (limited to 'server/tests/api')
118 files changed, 1059 insertions, 529 deletions
diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts index 51cf6e599..d0a151f5c 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/server/tests/api/activitypub/cleaner.ts | |||
@@ -2,15 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
8 | doubleFollow, | 9 | doubleFollow, |
9 | PeerTubeServer, | 10 | PeerTubeServer, |
10 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |
16 | 16 | ||
@@ -270,6 +270,66 @@ describe('Test AP cleaner', function () { | |||
270 | await checkRemote('kyle') | 270 | await checkRemote('kyle') |
271 | }) | 271 | }) |
272 | 272 | ||
273 | it('Should remove unavailable remote resources', async function () { | ||
274 | this.timeout(240000) | ||
275 | |||
276 | async function expectNotDeleted () { | ||
277 | { | ||
278 | const video = await servers[0].videos.get({ id: uuid }) | ||
279 | |||
280 | expect(video.likes).to.equal(3) | ||
281 | expect(video.dislikes).to.equal(0) | ||
282 | } | ||
283 | |||
284 | { | ||
285 | const { total } = await servers[0].comments.listThreads({ videoId: uuid }) | ||
286 | expect(total).to.equal(3) | ||
287 | } | ||
288 | } | ||
289 | |||
290 | async function expectDeleted () { | ||
291 | { | ||
292 | const video = await servers[0].videos.get({ id: uuid }) | ||
293 | |||
294 | expect(video.likes).to.equal(2) | ||
295 | expect(video.dislikes).to.equal(0) | ||
296 | } | ||
297 | |||
298 | { | ||
299 | const { total } = await servers[0].comments.listThreads({ videoId: uuid }) | ||
300 | expect(total).to.equal(2) | ||
301 | } | ||
302 | } | ||
303 | |||
304 | const uuid = (await servers[0].videos.quickUpload({ name: 'server 1 video 2' })).uuid | ||
305 | |||
306 | await waitJobs(servers) | ||
307 | |||
308 | for (const server of servers) { | ||
309 | await server.videos.rate({ id: uuid, rating: 'like' }) | ||
310 | await server.comments.createThread({ videoId: uuid, text: 'comment' }) | ||
311 | } | ||
312 | |||
313 | await waitJobs(servers) | ||
314 | |||
315 | await expectNotDeleted() | ||
316 | |||
317 | await servers[1].kill() | ||
318 | |||
319 | await wait(5000) | ||
320 | await expectNotDeleted() | ||
321 | |||
322 | let continueWhile = true | ||
323 | |||
324 | do { | ||
325 | try { | ||
326 | await expectDeleted() | ||
327 | continueWhile = false | ||
328 | } catch { | ||
329 | } | ||
330 | } while (continueWhile) | ||
331 | }) | ||
332 | |||
273 | after(async function () { | 333 | after(async function () { |
274 | await cleanupTests(servers) | 334 | await cleanupTests(servers) |
275 | }) | 335 | }) |
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index c3e4b7f74..e69ab3cb9 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | setDefaultVideoChannel | 12 | setDefaultVideoChannel |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | 14 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' |
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index 422a75d6e..cc71e82ea 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts | |||
@@ -2,7 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | const expect = chai.expect | 14 | const expect = chai.expect |
8 | 15 | ||
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 57b1cab23..25e1d9823 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts | |||
@@ -3,7 +3,8 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cloneDeep } from 'lodash' | 5 | import { cloneDeep } from 'lodash' |
6 | import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/extra-utils' | 6 | import { buildRequestStub } from '@server/tests/shared' |
7 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
7 | import { buildSignedActivity } from '../../../helpers/activitypub' | 8 | import { buildSignedActivity } from '../../../helpers/activitypub' |
8 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' | 9 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' |
9 | 10 | ||
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index 81fee0044..71e1c40ba 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { wait } from '@shared/core-utils' | ||
5 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | cleanupTests, | 7 | cleanupTests, |
6 | createMultipleServers, | 8 | createMultipleServers, |
@@ -9,10 +11,8 @@ import { | |||
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
12 | wait, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | ||
16 | 16 | ||
17 | describe('Test AP refresher', function () { | 17 | describe('Test AP refresher', function () { |
18 | let servers: PeerTubeServer[] = [] | 18 | let servers: PeerTubeServer[] = [] |
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index 94d946563..c4cb5ea0d 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts | |||
@@ -6,9 +6,10 @@ import { activityPubContextify, buildSignedActivity } from '@server/helpers/acti | |||
6 | import { buildDigest } from '@server/helpers/peertube-crypto' | 6 | import { buildDigest } from '@server/helpers/peertube-crypto' |
7 | import { HTTP_SIGNATURE } from '@server/initializers/constants' | 7 | import { HTTP_SIGNATURE } from '@server/initializers/constants' |
8 | import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' | 8 | import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' |
9 | import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/extra-utils' | 9 | import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared' |
10 | import { makeFollowRequest, makePOSTAPRequest } from '@shared/extra-utils/requests/activitypub' | 10 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' |
11 | import { HttpStatusCode } from '@shared/models' | 11 | import { HttpStatusCode } from '@shared/models' |
12 | import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands' | ||
12 | 13 | ||
13 | const expect = chai.expect | 14 | const expect = chai.expect |
14 | 15 | ||
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index fb9a5fd8b..c4b051723 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | AbusesCommand, | 7 | AbusesCommand, |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | doubleFollow, | 10 | doubleFollow, |
@@ -14,8 +13,7 @@ import { | |||
14 | PeerTubeServer, | 13 | PeerTubeServer, |
15 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
16 | waitJobs | 15 | waitJobs |
17 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
18 | import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models' | ||
19 | 17 | ||
20 | describe('Test abuses API validators', function () { | 18 | describe('Test abuses API validators', function () { |
21 | const basePath = '/api/v1/abuses/' | 19 | const basePath = '/api/v1/abuses/' |
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts index 141d869b7..07f879e0e 100644 --- a/server/tests/api/check-params/accounts.ts +++ b/server/tests/api/check-params/accounts.ts | |||
@@ -1,15 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | PeerTubeServer | ||
11 | } from '@shared/extra-utils' | ||
12 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' | ||
13 | 7 | ||
14 | describe('Test accounts API validators', function () { | 8 | describe('Test accounts API validators', function () { |
15 | const path = '/api/v1/accounts/' | 9 | const path = '/api/v1/accounts/' |
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index 7d5fae5cf..36526d494 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createMultipleServers, | 8 | createMultipleServers, |
10 | doubleFollow, | 9 | doubleFollow, |
@@ -13,8 +12,7 @@ import { | |||
13 | makePostBodyRequest, | 12 | makePostBodyRequest, |
14 | PeerTubeServer, | 13 | PeerTubeServer, |
15 | setAccessTokensToServers | 14 | setAccessTokensToServers |
16 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
17 | import { HttpStatusCode } from '@shared/models' | ||
18 | 16 | ||
19 | describe('Test blocklist API validators', function () { | 17 | describe('Test blocklist API validators', function () { |
20 | let servers: PeerTubeServer[] | 18 | let servers: PeerTubeServer[] |
@@ -481,6 +479,78 @@ describe('Test blocklist API validators', function () { | |||
481 | }) | 479 | }) |
482 | }) | 480 | }) |
483 | 481 | ||
482 | describe('When getting blocklist status', function () { | ||
483 | const path = '/api/v1/blocklist/status' | ||
484 | |||
485 | it('Should fail with a bad token', async function () { | ||
486 | await makeGetRequest({ | ||
487 | url: server.url, | ||
488 | path, | ||
489 | token: 'false', | ||
490 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 | ||
491 | }) | ||
492 | }) | ||
493 | |||
494 | it('Should fail with a bad accounts field', async function () { | ||
495 | await makeGetRequest({ | ||
496 | url: server.url, | ||
497 | path, | ||
498 | query: { | ||
499 | accounts: 1 | ||
500 | }, | ||
501 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
502 | }) | ||
503 | |||
504 | await makeGetRequest({ | ||
505 | url: server.url, | ||
506 | path, | ||
507 | query: { | ||
508 | accounts: [ 1 ] | ||
509 | }, | ||
510 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
511 | }) | ||
512 | }) | ||
513 | |||
514 | it('Should fail with a bad hosts field', async function () { | ||
515 | await makeGetRequest({ | ||
516 | url: server.url, | ||
517 | path, | ||
518 | query: { | ||
519 | hosts: 1 | ||
520 | }, | ||
521 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
522 | }) | ||
523 | |||
524 | await makeGetRequest({ | ||
525 | url: server.url, | ||
526 | path, | ||
527 | query: { | ||
528 | hosts: [ 1 ] | ||
529 | }, | ||
530 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
531 | }) | ||
532 | }) | ||
533 | |||
534 | it('Should succeed with the correct parameters', async function () { | ||
535 | await makeGetRequest({ | ||
536 | url: server.url, | ||
537 | path, | ||
538 | query: {}, | ||
539 | expectedStatus: HttpStatusCode.OK_200 | ||
540 | }) | ||
541 | |||
542 | await makeGetRequest({ | ||
543 | url: server.url, | ||
544 | path, | ||
545 | query: { | ||
546 | hosts: [ 'example.com' ], | ||
547 | accounts: [ 'john@example.com' ] | ||
548 | }, | ||
549 | expectedStatus: HttpStatusCode.OK_200 | ||
550 | }) | ||
551 | }) | ||
552 | }) | ||
553 | |||
484 | after(async function () { | 554 | after(async function () { |
485 | await cleanupTests(servers) | 555 | await cleanupTests(servers) |
486 | }) | 556 | }) |
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts index bc9d7784d..9bd0016cf 100644 --- a/server/tests/api/check-params/bulk.ts +++ b/server/tests/api/check-params/bulk.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 4 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
5 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | 6 | ||
7 | describe('Test bulk API validators', function () { | 7 | describe('Test bulk API validators', function () { |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index d0cd7722b..3cccb612a 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | makePutBodyRequest, | 10 | makePutBodyRequest, |
11 | PeerTubeServer, | 11 | PeerTubeServer, |
12 | setAccessTokensToServers | 12 | setAccessTokensToServers |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | import { CustomConfig, HttpStatusCode } from '@shared/models' | 14 | import { CustomConfig, HttpStatusCode } from '@shared/models' |
15 | 15 | ||
16 | describe('Test config API validators', function () { | 16 | describe('Test config API validators', function () { |
@@ -54,6 +54,18 @@ describe('Test config API validators', function () { | |||
54 | whitelisted: true | 54 | whitelisted: true |
55 | } | 55 | } |
56 | }, | 56 | }, |
57 | client: { | ||
58 | videos: { | ||
59 | miniature: { | ||
60 | preferAuthorDisplayName: false | ||
61 | } | ||
62 | }, | ||
63 | menu: { | ||
64 | login: { | ||
65 | redirectOnSingleExternalAuth: false | ||
66 | } | ||
67 | } | ||
68 | }, | ||
57 | cache: { | 69 | cache: { |
58 | previews: { | 70 | previews: { |
59 | size: 2 | 71 | size: 2 |
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts index 9f86fecc6..9db442b0b 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/server/tests/api/check-params/contact-form.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils' | 4 | import { MockSmtpServer } from '@server/tests/shared' |
5 | import { ContactFormCommand } from '@shared/extra-utils/server' | ||
6 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, ContactFormCommand, createSingleServer, killallServers, PeerTubeServer } from '@shared/server-commands' | ||
7 | 7 | ||
8 | describe('Test contact form API validators', function () { | 8 | describe('Test contact form API validators', function () { |
9 | let server: PeerTubeServer | 9 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts index 9fbbea315..a102ee437 100644 --- a/server/tests/api/check-params/custom-pages.ts +++ b/server/tests/api/check-params/custom-pages.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | makePutBodyRequest, | 8 | makePutBodyRequest, |
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | setAccessTokensToServers | 10 | setAccessTokensToServers |
11 | } from '@shared/extra-utils' | 11 | } from '@shared/server-commands' |
12 | import { HttpStatusCode } from '@shared/models' | 12 | import { HttpStatusCode } from '@shared/models' |
13 | 13 | ||
14 | describe('Test custom pages validators', function () { | 14 | describe('Test custom pages validators', function () { |
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index a55786359..cfa44deca 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
5 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | 6 | ||
7 | describe('Test debug API validators', function () { | 7 | describe('Test debug API validators', function () { |
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index 2bc9f6b96..d4dae5a75 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createSingleServer, | 8 | createSingleServer, |
10 | makeDeleteRequest, | 9 | makeDeleteRequest, |
@@ -12,8 +11,7 @@ import { | |||
12 | makePostBodyRequest, | 11 | makePostBodyRequest, |
13 | PeerTubeServer, | 12 | PeerTubeServer, |
14 | setAccessTokensToServers | 13 | setAccessTokensToServers |
15 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
16 | import { HttpStatusCode } from '@shared/models' | ||
17 | 15 | ||
18 | describe('Test server follows API validators', function () { | 16 | describe('Test server follows API validators', function () { |
19 | let server: PeerTubeServer | 17 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index 23d95d8e4..d85961d62 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts | |||
@@ -1,17 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers | ||
13 | } from '@shared/extra-utils' | ||
14 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
15 | 7 | ||
16 | describe('Test jobs API validators', function () { | 8 | describe('Test jobs API validators', function () { |
17 | const path = '/api/v1/jobs/failed' | 9 | const path = '/api/v1/jobs/failed' |
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 8e1d655d4..8aee6164c 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | buildAbsoluteFixturePath, | ||
7 | cleanupTests, | 8 | cleanupTests, |
8 | createSingleServer, | 9 | createSingleServer, |
9 | LiveCommand, | 10 | LiveCommand, |
@@ -13,8 +14,7 @@ import { | |||
13 | sendRTMPStream, | 14 | sendRTMPStream, |
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
15 | stopFfmpeg | 16 | stopFfmpeg |
16 | } from '@shared/extra-utils' | 17 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
18 | 18 | ||
19 | describe('Test video lives API validator', function () { | 19 | describe('Test video lives API validator', function () { |
20 | const path = '/api/v1/videos/live' | 20 | const path = '/api/v1/videos/live' |
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts index 05372257a..970671c15 100644 --- a/server/tests/api/check-params/logs.ts +++ b/server/tests/api/check-params/logs.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
5 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | 6 | ||
7 | describe('Test logs API validators', function () { | 7 | describe('Test logs API validators', function () { |
diff --git a/server/tests/api/check-params/my-user.ts b/server/tests/api/check-params/my-user.ts index d35284d60..95f2122ae 100644 --- a/server/tests/api/check-params/my-user.ts +++ b/server/tests/api/check-params/my-user.ts | |||
@@ -1,22 +1,19 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared' | ||
5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models' | ||
4 | import { | 7 | import { |
5 | buildAbsoluteFixturePath, | ||
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | makeGetRequest, | 10 | makeGetRequest, |
12 | makePutBodyRequest, | 11 | makePutBodyRequest, |
13 | makeUploadRequest, | 12 | makeUploadRequest, |
14 | MockSmtpServer, | ||
15 | PeerTubeServer, | 13 | PeerTubeServer, |
16 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
17 | UsersCommand | 15 | UsersCommand |
18 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models' | ||
20 | 17 | ||
21 | describe('Test my user API validators', function () { | 18 | describe('Test my user API validators', function () { |
22 | const path = '/api/v1/users/' | 19 | const path = '/api/v1/users/' |
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts index 33f84ecbc..c3f15b86e 100644 --- a/server/tests/api/check-params/plugins.ts +++ b/server/tests/api/check-params/plugins.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createSingleServer, | 8 | createSingleServer, |
10 | makeGetRequest, | 9 | makeGetRequest, |
@@ -12,8 +11,7 @@ import { | |||
12 | makePutBodyRequest, | 11 | makePutBodyRequest, |
13 | PeerTubeServer, | 12 | PeerTubeServer, |
14 | setAccessTokensToServers | 13 | setAccessTokensToServers |
15 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models' | ||
17 | 15 | ||
18 | describe('Test server plugins API validators', function () { | 16 | describe('Test server plugins API validators', function () { |
19 | let server: PeerTubeServer | 17 | let server: PeerTubeServer |
@@ -30,7 +28,7 @@ describe('Test server plugins API validators', function () { | |||
30 | // --------------------------------------------------------------- | 28 | // --------------------------------------------------------------- |
31 | 29 | ||
32 | before(async function () { | 30 | before(async function () { |
33 | this.timeout(30000) | 31 | this.timeout(60000) |
34 | 32 | ||
35 | server = await createSingleServer(1) | 33 | server = await createSingleServer(1) |
36 | 34 | ||
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index d9f905549..04519cf23 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createMultipleServers, | 8 | createMultipleServers, |
10 | doubleFollow, | 9 | doubleFollow, |
@@ -15,8 +14,7 @@ import { | |||
15 | PeerTubeServer, | 14 | PeerTubeServer, |
16 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
17 | waitJobs | 16 | waitJobs |
18 | } from '@shared/extra-utils' | 17 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
20 | 18 | ||
21 | describe('Test server redundancy API validators', function () { | 19 | describe('Test server redundancy API validators', function () { |
22 | let servers: PeerTubeServer[] | 20 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index cc15d2593..ca0fbf31d 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -1,17 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers | ||
13 | } from '@shared/extra-utils' | ||
14 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
15 | 7 | ||
16 | function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) { | 8 | function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) { |
17 | return server.config.updateCustomSubConfig({ | 9 | return server.config.updateCustomSubConfig({ |
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts index 8d795fabc..e63f09884 100644 --- a/server/tests/api/check-params/services.ts +++ b/server/tests/api/check-params/services.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | PeerTubeServer, | 8 | PeerTubeServer, |
9 | setAccessTokensToServers, | 9 | setAccessTokensToServers, |
10 | setDefaultVideoChannel | 10 | setDefaultVideoChannel |
11 | } from '@shared/extra-utils' | 11 | } from '@shared/server-commands' |
12 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | 12 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' |
13 | 13 | ||
14 | describe('Test services API validators', function () { | 14 | describe('Test services API validators', function () { |
diff --git a/server/tests/api/check-params/transcoding.ts b/server/tests/api/check-params/transcoding.ts index a8daafe3e..333012940 100644 --- a/server/tests/api/check-params/transcoding.ts +++ b/server/tests/api/check-params/transcoding.ts | |||
@@ -1,8 +1,15 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | ||
5 | import { HttpStatusCode, UserRole } from '@shared/models' | 4 | import { HttpStatusCode, UserRole } from '@shared/models' |
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | describe('Test transcoding API validators', function () { | 14 | describe('Test transcoding API validators', function () { |
8 | let servers: PeerTubeServer[] | 15 | let servers: PeerTubeServer[] |
@@ -16,7 +23,7 @@ describe('Test transcoding API validators', function () { | |||
16 | // --------------------------------------------------------------- | 23 | // --------------------------------------------------------------- |
17 | 24 | ||
18 | before(async function () { | 25 | before(async function () { |
19 | this.timeout(60000) | 26 | this.timeout(120000) |
20 | 27 | ||
21 | servers = await createMultipleServers(2) | 28 | servers = await createMultipleServers(2) |
22 | await setAccessTokensToServers(servers) | 29 | await setAccessTokensToServers(servers) |
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index 322e93d0d..deb4a7aa3 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -2,18 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { FIXTURE_URLS } from '@server/tests/shared' | ||
5 | import { randomInt } from '@shared/core-utils' | 6 | import { randomInt } from '@shared/core-utils' |
7 | import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models' | ||
6 | import { | 8 | import { |
7 | cleanupTests, | 9 | cleanupTests, |
8 | createSingleServer, | 10 | createSingleServer, |
9 | FIXTURE_URLS, | ||
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
13 | VideosCommand, | 14 | VideosCommand, |
14 | waitJobs | 15 | waitJobs |
15 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models' | ||
17 | 17 | ||
18 | describe('Test upload quota', function () { | 18 | describe('Test upload quota', function () { |
19 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 17edf5aa1..4bc8084a1 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts | |||
@@ -2,20 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { io } from 'socket.io-client' | 4 | import { io } from 'socket.io-client' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 9 | cleanupTests, |
10 | createSingleServer, | 10 | createSingleServer, |
11 | makeGetRequest, | 11 | makeGetRequest, |
12 | makePostBodyRequest, | 12 | makePostBodyRequest, |
13 | makePutBodyRequest, | 13 | makePutBodyRequest, |
14 | PeerTubeServer, | 14 | PeerTubeServer, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers |
16 | wait | 16 | } from '@shared/server-commands' |
17 | } from '@shared/extra-utils' | ||
18 | import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' | ||
19 | 17 | ||
20 | describe('Test user notifications API validators', function () { | 18 | describe('Test user notifications API validators', function () { |
21 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 624069c80..a13ed5aa3 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -2,9 +2,6 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | 5 | cleanupTests, |
9 | createSingleServer, | 6 | createSingleServer, |
10 | makeDeleteRequest, | 7 | makeDeleteRequest, |
@@ -13,8 +10,9 @@ import { | |||
13 | PeerTubeServer, | 10 | PeerTubeServer, |
14 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
15 | waitJobs | 12 | waitJobs |
16 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
17 | import { HttpStatusCode } from '@shared/models' | 14 | import { HttpStatusCode } from '@shared/models' |
15 | import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@server/tests/shared' | ||
18 | 16 | ||
19 | describe('Test user subscriptions API validators', function () { | 17 | describe('Test user subscriptions API validators', function () { |
20 | const path = '/api/v1/users/me/subscriptions' | 18 | const path = '/api/v1/users/me/subscriptions' |
diff --git a/server/tests/api/check-params/users-admin.ts b/server/tests/api/check-params/users-admin.ts index f71414a6b..d8353f83b 100644 --- a/server/tests/api/check-params/users-admin.ts +++ b/server/tests/api/check-params/users-admin.ts | |||
@@ -2,21 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | killallServers, | 10 | killallServers, |
12 | makeGetRequest, | 11 | makeGetRequest, |
13 | makePostBodyRequest, | 12 | makePostBodyRequest, |
14 | makePutBodyRequest, | 13 | makePutBodyRequest, |
15 | MockSmtpServer, | ||
16 | PeerTubeServer, | 14 | PeerTubeServer, |
17 | setAccessTokensToServers | 15 | setAccessTokensToServers |
18 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models' | ||
20 | 17 | ||
21 | describe('Test users admin API validators', function () { | 18 | describe('Test users admin API validators', function () { |
22 | const path = '/api/v1/users/' | 19 | const path = '/api/v1/users/' |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 5f9cbc5eb..84254945c 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -2,15 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | makePostBodyRequest, | ||
9 | MockSmtpServer, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers | ||
12 | } from '@shared/extra-utils' | ||
13 | import { HttpStatusCode, UserRole } from '@shared/models' | 6 | import { HttpStatusCode, UserRole } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
14 | 8 | ||
15 | describe('Test users API validators', function () { | 9 | describe('Test users API validators', function () { |
16 | const path = '/api/v1/users/' | 10 | const path = '/api/v1/users/' |
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 1f926d227..1aab60826 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -2,11 +2,10 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, VideoBlacklistType } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | BlacklistCommand, | 8 | BlacklistCommand, |
7 | checkBadCountPagination, | ||
8 | checkBadSortPagination, | ||
9 | checkBadStartPagination, | ||
10 | cleanupTests, | 9 | cleanupTests, |
11 | createMultipleServers, | 10 | createMultipleServers, |
12 | doubleFollow, | 11 | doubleFollow, |
@@ -15,8 +14,7 @@ import { | |||
15 | PeerTubeServer, | 14 | PeerTubeServer, |
16 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
17 | waitJobs | 16 | waitJobs |
18 | } from '@shared/extra-utils' | 17 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, VideoBlacklistType } from '@shared/models' | ||
20 | 18 | ||
21 | describe('Test video blacklist API validators', function () { | 19 | describe('Test video blacklist API validators', function () { |
22 | let servers: PeerTubeServer[] | 20 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 84c6c1355..9881df80c 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
5 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | buildAbsoluteFixturePath, | ||
6 | cleanupTests, | 7 | cleanupTests, |
7 | createSingleServer, | 8 | createSingleServer, |
8 | makeDeleteRequest, | 9 | makeDeleteRequest, |
@@ -10,8 +11,7 @@ import { | |||
10 | makeUploadRequest, | 11 | makeUploadRequest, |
11 | PeerTubeServer, | 12 | PeerTubeServer, |
12 | setAccessTokensToServers | 13 | setAccessTokensToServers |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | describe('Test video captions API validator', function () { | 16 | describe('Test video captions API validator', function () { |
17 | const path = '/api/v1/videos/' | 17 | const path = '/api/v1/videos/' |
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index e86c315fa..1e9732fe9 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -3,12 +3,11 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
7 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, VideoChannelUpdate } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | buildAbsoluteFixturePath, | ||
8 | ChannelsCommand, | 10 | ChannelsCommand, |
9 | checkBadCountPagination, | ||
10 | checkBadSortPagination, | ||
11 | checkBadStartPagination, | ||
12 | cleanupTests, | 11 | cleanupTests, |
13 | createSingleServer, | 12 | createSingleServer, |
14 | makeGetRequest, | 13 | makeGetRequest, |
@@ -17,8 +16,7 @@ import { | |||
17 | makeUploadRequest, | 16 | makeUploadRequest, |
18 | PeerTubeServer, | 17 | PeerTubeServer, |
19 | setAccessTokensToServers | 18 | setAccessTokensToServers |
20 | } from '@shared/extra-utils' | 19 | } from '@shared/server-commands' |
21 | import { HttpStatusCode, VideoChannelUpdate } from '@shared/models' | ||
22 | 20 | ||
23 | const expect = chai.expect | 21 | const expect = chai.expect |
24 | 22 | ||
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 8d63fe70c..829f3c8b1 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -2,10 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | checkBadCountPagination, | ||
7 | checkBadSortPagination, | ||
8 | checkBadStartPagination, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createSingleServer, | 9 | createSingleServer, |
11 | makeDeleteRequest, | 10 | makeDeleteRequest, |
@@ -13,8 +12,7 @@ import { | |||
13 | makePostBodyRequest, | 12 | makePostBodyRequest, |
14 | PeerTubeServer, | 13 | PeerTubeServer, |
15 | setAccessTokensToServers | 14 | setAccessTokensToServers |
16 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
18 | 16 | ||
19 | const expect = chai.expect | 17 | const expect = chai.expect |
20 | 18 | ||
diff --git a/server/tests/api/check-params/video-files.ts b/server/tests/api/check-params/video-files.ts index 3ccdf5f49..8c0795092 100644 --- a/server/tests/api/check-params/video-files.ts +++ b/server/tests/api/check-params/video-files.ts | |||
@@ -1,8 +1,15 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | ||
5 | import { HttpStatusCode, UserRole } from '@shared/models' | 4 | import { HttpStatusCode, UserRole } from '@shared/models' |
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | describe('Test videos files', function () { | 14 | describe('Test videos files', function () { |
8 | let servers: PeerTubeServer[] | 15 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 6c31daa9b..da05793a0 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -2,21 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared' | ||
6 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | buildAbsoluteFixturePath, | ||
7 | checkBadCountPagination, | ||
8 | checkBadSortPagination, | ||
9 | checkBadStartPagination, | ||
10 | cleanupTests, | 9 | cleanupTests, |
11 | createSingleServer, | 10 | createSingleServer, |
12 | FIXTURE_URLS, | ||
13 | makeGetRequest, | 11 | makeGetRequest, |
14 | makePostBodyRequest, | 12 | makePostBodyRequest, |
15 | makeUploadRequest, | 13 | makeUploadRequest, |
16 | PeerTubeServer, | 14 | PeerTubeServer, |
17 | setAccessTokensToServers | 15 | setAccessTokensToServers |
18 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
19 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
20 | 17 | ||
21 | describe('Test video imports API validator', function () { | 18 | describe('Test video imports API validator', function () { |
22 | const path = '/api/v1/videos/imports' | 19 | const path = '/api/v1/videos/imports' |
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index e4d541b48..4b17ce7db 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -1,18 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | PlaylistsCommand, | ||
13 | setAccessTokensToServers, | ||
14 | setDefaultVideoChannel | ||
15 | } from '@shared/extra-utils' | ||
16 | import { | 5 | import { |
17 | HttpStatusCode, | 6 | HttpStatusCode, |
18 | VideoPlaylistCreate, | 7 | VideoPlaylistCreate, |
@@ -23,6 +12,15 @@ import { | |||
23 | VideoPlaylistReorder, | 12 | VideoPlaylistReorder, |
24 | VideoPlaylistType | 13 | VideoPlaylistType |
25 | } from '@shared/models' | 14 | } from '@shared/models' |
15 | import { | ||
16 | cleanupTests, | ||
17 | createSingleServer, | ||
18 | makeGetRequest, | ||
19 | PeerTubeServer, | ||
20 | PlaylistsCommand, | ||
21 | setAccessTokensToServers, | ||
22 | setDefaultVideoChannel | ||
23 | } from '@shared/server-commands' | ||
26 | 24 | ||
27 | describe('Test video playlists API validator', function () { | 25 | describe('Test video playlists API validator', function () { |
28 | let server: PeerTubeServer | 26 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/videos-common-filters.ts b/server/tests/api/check-params/videos-common-filters.ts index f2b5bee8e..6b3ec917e 100644 --- a/server/tests/api/check-params/videos-common-filters.ts +++ b/server/tests/api/check-params/videos-common-filters.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | PeerTubeServer, | 8 | PeerTubeServer, |
9 | setAccessTokensToServers, | 9 | setAccessTokensToServers, |
10 | setDefaultVideoChannel | 10 | setDefaultVideoChannel |
11 | } from '@shared/extra-utils' | 11 | } from '@shared/server-commands' |
12 | import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models' | 12 | import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models' |
13 | 13 | ||
14 | describe('Test video filters validators', function () { | 14 | describe('Test video filters validators', function () { |
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index c3c309ed2..31a0752c7 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { checkBadCountPagination, checkBadStartPagination } from '@server/tests/shared' | ||
5 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 6 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadStartPagination, | ||
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
9 | makeGetRequest, | 9 | makeGetRequest, |
@@ -11,8 +11,7 @@ import { | |||
11 | makePutBodyRequest, | 11 | makePutBodyRequest, |
12 | PeerTubeServer, | 12 | PeerTubeServer, |
13 | setAccessTokensToServers | 13 | setAccessTokensToServers |
14 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
15 | import { HttpStatusCode } from '@shared/models' | ||
16 | 15 | ||
17 | describe('Test videos history API validator', function () { | 16 | describe('Test videos history API validator', function () { |
18 | const myHistoryPath = '/api/v1/users/me/history/videos' | 17 | const myHistoryPath = '/api/v1/users/me/history/videos' |
diff --git a/server/tests/api/check-params/videos-overviews.ts b/server/tests/api/check-params/videos-overviews.ts index c2139d74b..1da15dc43 100644 --- a/server/tests/api/check-params/videos-overviews.ts +++ b/server/tests/api/check-params/videos-overviews.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils' | 4 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' |
5 | 5 | ||
6 | describe('Test videos overview', function () { | 6 | describe('Test videos overview', function () { |
7 | let server: PeerTubeServer | 7 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index d02b6e156..4cc70f5cc 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -4,12 +4,10 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '@shared/core-utils' | 7 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared' |
8 | import { randomInt, root } from '@shared/core-utils' | ||
9 | import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
8 | import { | 10 | import { |
9 | checkBadCountPagination, | ||
10 | checkBadSortPagination, | ||
11 | checkBadStartPagination, | ||
12 | checkUploadVideoParam, | ||
13 | cleanupTests, | 11 | cleanupTests, |
14 | createSingleServer, | 12 | createSingleServer, |
15 | makeDeleteRequest, | 13 | makeDeleteRequest, |
@@ -17,10 +15,8 @@ import { | |||
17 | makePutBodyRequest, | 15 | makePutBodyRequest, |
18 | makeUploadRequest, | 16 | makeUploadRequest, |
19 | PeerTubeServer, | 17 | PeerTubeServer, |
20 | root, | ||
21 | setAccessTokensToServers | 18 | setAccessTokensToServers |
22 | } from '@shared/extra-utils' | 19 | } from '@shared/server-commands' |
23 | import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
24 | 20 | ||
25 | const expect = chai.expect | 21 | const expect = chai.expect |
26 | 22 | ||
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 6a6a11796..909399836 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -2,9 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { VideoPrivacy } from '@shared/models' | 6 | import { VideoPrivacy } from '@shared/models' |
6 | import { | 7 | import { |
7 | checkLiveCleanupAfterSave, | ||
8 | cleanupTests, | 8 | cleanupTests, |
9 | ConfigCommand, | 9 | ConfigCommand, |
10 | createMultipleServers, | 10 | createMultipleServers, |
@@ -12,9 +12,9 @@ import { | |||
12 | PeerTubeServer, | 12 | PeerTubeServer, |
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
15 | wait, | ||
16 | waitJobs | 15 | waitJobs |
17 | } from '../../../../shared/extra-utils' | 16 | } from '@shared/server-commands' |
17 | import { checkLiveCleanupAfterSave } from '../../shared' | ||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index c5f942901..3e6fec453 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | 6 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' |
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
@@ -12,9 +13,8 @@ import { | |||
12 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
14 | stopFfmpeg, | 15 | stopFfmpeg, |
15 | wait, | ||
16 | waitJobs | 16 | waitJobs |
17 | } from '../../../../shared/extra-utils' | 17 | } from '@shared/server-commands' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
@@ -140,7 +140,7 @@ describe('Permanent live', function () { | |||
140 | }) | 140 | }) |
141 | 141 | ||
142 | it('Should be able to stream again in the permanent live', async function () { | 142 | it('Should be able to stream again in the permanent live', async function () { |
143 | this.timeout(20000) | 143 | this.timeout(60000) |
144 | 144 | ||
145 | await servers[0].config.updateCustomSubConfig({ | 145 | await servers[0].config.updateCustomSubConfig({ |
146 | newConfig: { | 146 | newConfig: { |
diff --git a/server/tests/api/live/live-rtmps.ts b/server/tests/api/live/live-rtmps.ts index 378e6df3c..935061971 100644 --- a/server/tests/api/live/live-rtmps.ts +++ b/server/tests/api/live/live-rtmps.ts | |||
@@ -2,9 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildAbsoluteFixturePath } from '@shared/core-utils' | ||
5 | import { VideoPrivacy } from '@shared/models' | 6 | import { VideoPrivacy } from '@shared/models' |
6 | import { | 7 | import { |
7 | buildAbsoluteFixturePath, | ||
8 | cleanupTests, | 8 | cleanupTests, |
9 | createSingleServer, | 9 | createSingleServer, |
10 | PeerTubeServer, | 10 | PeerTubeServer, |
@@ -14,7 +14,7 @@ import { | |||
14 | stopFfmpeg, | 14 | stopFfmpeg, |
15 | testFfmpegStreamError, | 15 | testFfmpegStreamError, |
16 | waitUntilLivePublishedOnAllServers | 16 | waitUntilLivePublishedOnAllServers |
17 | } from '../../../../shared/extra-utils' | 17 | } from '@shared/server-commands' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 6c4ea90ca..95a342b01 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -3,8 +3,10 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { checkLiveCleanupAfterSave } from '@server/tests/shared' | ||
7 | import { wait } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | checkLiveCleanupAfterSave, | ||
8 | cleanupTests, | 10 | cleanupTests, |
9 | ConfigCommand, | 11 | ConfigCommand, |
10 | createMultipleServers, | 12 | createMultipleServers, |
@@ -14,12 +16,10 @@ import { | |||
14 | setDefaultVideoChannel, | 16 | setDefaultVideoChannel, |
15 | stopFfmpeg, | 17 | stopFfmpeg, |
16 | testFfmpegStreamError, | 18 | testFfmpegStreamError, |
17 | wait, | ||
18 | waitJobs, | 19 | waitJobs, |
19 | waitUntilLivePublishedOnAllServers, | 20 | waitUntilLivePublishedOnAllServers, |
20 | waitUntilLiveSavedOnAllServers | 21 | waitUntilLiveSavedOnAllServers |
21 | } from '@shared/extra-utils' | 22 | } from '@shared/server-commands' |
22 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | ||
23 | 23 | ||
24 | const expect = chai.expect | 24 | const expect = chai.expect |
25 | 25 | ||
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts index 33ee2c051..50b16443e 100644 --- a/server/tests/api/live/live-socket-messages.ts +++ b/server/tests/api/live/live-socket-messages.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { VideoPrivacy, VideoState } from '@shared/models' | 6 | import { VideoPrivacy, VideoState } from '@shared/models' |
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
@@ -11,10 +12,9 @@ import { | |||
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
13 | stopFfmpeg, | 14 | stopFfmpeg, |
14 | wait, | ||
15 | waitJobs, | 15 | waitJobs, |
16 | waitUntilLivePublishedOnAllServers | 16 | waitUntilLivePublishedOnAllServers |
17 | } from '../../../../shared/extra-utils' | 17 | } from '@shared/server-commands' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts index 9186af8e7..446d0913c 100644 --- a/server/tests/api/live/live-views.ts +++ b/server/tests/api/live/live-views.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | 7 | import { VideoPrivacy } from '@shared/models' |
7 | import { | 8 | import { |
8 | cleanupTests, | 9 | cleanupTests, |
@@ -12,10 +13,9 @@ import { | |||
12 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
14 | stopFfmpeg, | 15 | stopFfmpeg, |
15 | wait, | ||
16 | waitJobs, | 16 | waitJobs, |
17 | waitUntilLivePublishedOnAllServers | 17 | waitUntilLivePublishedOnAllServers |
18 | } from '../../../../shared/extra-utils' | 18 | } from '@shared/server-commands' |
19 | 19 | ||
20 | const expect = chai.expect | 20 | const expect = chai.expect |
21 | 21 | ||
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index b96c03cf8..3f9355d2d 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -4,10 +4,18 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | 6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' |
7 | import { checkLiveCleanupAfterSave, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' | ||
8 | import { wait } from '@shared/core-utils' | ||
9 | import { | ||
10 | HttpStatusCode, | ||
11 | LiveVideo, | ||
12 | LiveVideoCreate, | ||
13 | VideoDetails, | ||
14 | VideoPrivacy, | ||
15 | VideoState, | ||
16 | VideoStreamingPlaylistType | ||
17 | } from '@shared/models' | ||
7 | import { | 18 | import { |
8 | checkLiveCleanupAfterSave, | ||
9 | checkLiveSegmentHash, | ||
10 | checkResolutionsInMasterPlaylist, | ||
11 | cleanupTests, | 19 | cleanupTests, |
12 | createMultipleServers, | 20 | createMultipleServers, |
13 | doubleFollow, | 21 | doubleFollow, |
@@ -20,20 +28,9 @@ import { | |||
20 | setDefaultVideoChannel, | 28 | setDefaultVideoChannel, |
21 | stopFfmpeg, | 29 | stopFfmpeg, |
22 | testFfmpegStreamError, | 30 | testFfmpegStreamError, |
23 | testImage, | ||
24 | wait, | ||
25 | waitJobs, | 31 | waitJobs, |
26 | waitUntilLivePublishedOnAllServers | 32 | waitUntilLivePublishedOnAllServers |
27 | } from '@shared/extra-utils' | 33 | } from '@shared/server-commands' |
28 | import { | ||
29 | HttpStatusCode, | ||
30 | LiveVideo, | ||
31 | LiveVideoCreate, | ||
32 | VideoDetails, | ||
33 | VideoPrivacy, | ||
34 | VideoState, | ||
35 | VideoStreamingPlaylistType | ||
36 | } from '@shared/models' | ||
37 | 34 | ||
38 | const expect = chai.expect | 35 | const expect = chai.expect |
39 | 36 | ||
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index c258414ce..0c3bed3e7 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' | 14 | import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' |
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
@@ -468,7 +468,7 @@ describe('Test abuses', function () { | |||
468 | }) | 468 | }) |
469 | 469 | ||
470 | it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () { | 470 | it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () { |
471 | const commentServer2 = await getComment(servers[0], servers[1].store.videoCreated.id) | 471 | const commentServer2 = await getComment(servers[0], servers[1].store.videoCreated.shortUUID) |
472 | 472 | ||
473 | { | 473 | { |
474 | const body = await commands[0].getAdminList({ filter: 'comment' }) | 474 | const body = await commands[0].getAdminList({ filter: 'comment' }) |
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index 75b15c298..87d147998 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -2,8 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | ||
6 | import { UserNotificationType } from '@shared/models' | 5 | import { UserNotificationType } from '@shared/models' |
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 089af8b15..b45460bb4 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -11,7 +11,7 @@ import { | |||
11 | PeerTubeServer, | 11 | PeerTubeServer, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | waitJobs | 13 | waitJobs |
14 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
15 | import { UserNotificationType } from '@shared/models' | 15 | import { UserNotificationType } from '@shared/models' |
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
@@ -254,6 +254,45 @@ describe('Test blocklist', function () { | |||
254 | } | 254 | } |
255 | }) | 255 | }) |
256 | 256 | ||
257 | it('Should get blocked status', async function () { | ||
258 | const remoteHandle = 'user2@' + servers[1].host | ||
259 | const localHandle = 'user1@' + servers[0].host | ||
260 | const unknownHandle = 'user5@' + servers[0].host | ||
261 | |||
262 | { | ||
263 | const status = await command.getStatus({ accounts: [ remoteHandle ] }) | ||
264 | expect(Object.keys(status.accounts)).to.have.lengthOf(1) | ||
265 | expect(status.accounts[remoteHandle].blockedByUser).to.be.false | ||
266 | expect(status.accounts[remoteHandle].blockedByServer).to.be.false | ||
267 | |||
268 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
269 | } | ||
270 | |||
271 | { | ||
272 | const status = await command.getStatus({ token: servers[0].accessToken, accounts: [ remoteHandle ] }) | ||
273 | expect(Object.keys(status.accounts)).to.have.lengthOf(1) | ||
274 | expect(status.accounts[remoteHandle].blockedByUser).to.be.true | ||
275 | expect(status.accounts[remoteHandle].blockedByServer).to.be.false | ||
276 | |||
277 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
278 | } | ||
279 | |||
280 | { | ||
281 | const status = await command.getStatus({ token: servers[0].accessToken, accounts: [ localHandle, remoteHandle, unknownHandle ] }) | ||
282 | expect(Object.keys(status.accounts)).to.have.lengthOf(3) | ||
283 | |||
284 | for (const handle of [ localHandle, remoteHandle ]) { | ||
285 | expect(status.accounts[handle].blockedByUser).to.be.true | ||
286 | expect(status.accounts[handle].blockedByServer).to.be.false | ||
287 | } | ||
288 | |||
289 | expect(status.accounts[unknownHandle].blockedByUser).to.be.false | ||
290 | expect(status.accounts[unknownHandle].blockedByServer).to.be.false | ||
291 | |||
292 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
293 | } | ||
294 | }) | ||
295 | |||
257 | it('Should not allow a remote blocked user to comment my videos', async function () { | 296 | it('Should not allow a remote blocked user to comment my videos', async function () { |
258 | this.timeout(60000) | 297 | this.timeout(60000) |
259 | 298 | ||
@@ -434,6 +473,35 @@ describe('Test blocklist', function () { | |||
434 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 473 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
435 | }) | 474 | }) |
436 | 475 | ||
476 | it('Should get blocklist status', async function () { | ||
477 | const blockedServer = servers[1].host | ||
478 | const notBlockedServer = 'example.com' | ||
479 | |||
480 | { | ||
481 | const status = await command.getStatus({ hosts: [ blockedServer, notBlockedServer ] }) | ||
482 | expect(Object.keys(status.accounts)).to.have.lengthOf(0) | ||
483 | |||
484 | expect(Object.keys(status.hosts)).to.have.lengthOf(2) | ||
485 | expect(status.hosts[blockedServer].blockedByUser).to.be.false | ||
486 | expect(status.hosts[blockedServer].blockedByServer).to.be.false | ||
487 | |||
488 | expect(status.hosts[notBlockedServer].blockedByUser).to.be.false | ||
489 | expect(status.hosts[notBlockedServer].blockedByServer).to.be.false | ||
490 | } | ||
491 | |||
492 | { | ||
493 | const status = await command.getStatus({ token: servers[0].accessToken, hosts: [ blockedServer, notBlockedServer ] }) | ||
494 | expect(Object.keys(status.accounts)).to.have.lengthOf(0) | ||
495 | |||
496 | expect(Object.keys(status.hosts)).to.have.lengthOf(2) | ||
497 | expect(status.hosts[blockedServer].blockedByUser).to.be.true | ||
498 | expect(status.hosts[blockedServer].blockedByServer).to.be.false | ||
499 | |||
500 | expect(status.hosts[notBlockedServer].blockedByUser).to.be.false | ||
501 | expect(status.hosts[notBlockedServer].blockedByServer).to.be.false | ||
502 | } | ||
503 | }) | ||
504 | |||
437 | it('Should unblock the remote server', async function () { | 505 | it('Should unblock the remote server', async function () { |
438 | await command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }) | 506 | await command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }) |
439 | }) | 507 | }) |
@@ -575,6 +643,27 @@ describe('Test blocklist', function () { | |||
575 | } | 643 | } |
576 | }) | 644 | }) |
577 | 645 | ||
646 | it('Should get blocked status', async function () { | ||
647 | const remoteHandle = 'user2@' + servers[1].host | ||
648 | const localHandle = 'user1@' + servers[0].host | ||
649 | const unknownHandle = 'user5@' + servers[0].host | ||
650 | |||
651 | for (const token of [ undefined, servers[0].accessToken ]) { | ||
652 | const status = await command.getStatus({ token, accounts: [ localHandle, remoteHandle, unknownHandle ] }) | ||
653 | expect(Object.keys(status.accounts)).to.have.lengthOf(3) | ||
654 | |||
655 | for (const handle of [ localHandle, remoteHandle ]) { | ||
656 | expect(status.accounts[handle].blockedByUser).to.be.false | ||
657 | expect(status.accounts[handle].blockedByServer).to.be.true | ||
658 | } | ||
659 | |||
660 | expect(status.accounts[unknownHandle].blockedByUser).to.be.false | ||
661 | expect(status.accounts[unknownHandle].blockedByServer).to.be.false | ||
662 | |||
663 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
664 | } | ||
665 | }) | ||
666 | |||
578 | it('Should unblock the remote account', async function () { | 667 | it('Should unblock the remote account', async function () { |
579 | await command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) | 668 | await command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) |
580 | }) | 669 | }) |
@@ -620,6 +709,7 @@ describe('Test blocklist', function () { | |||
620 | }) | 709 | }) |
621 | 710 | ||
622 | describe('When managing server blocklist', function () { | 711 | describe('When managing server blocklist', function () { |
712 | |||
623 | it('Should list all videos', async function () { | 713 | it('Should list all videos', async function () { |
624 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { | 714 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { |
625 | await checkAllVideos(servers[0], token) | 715 | await checkAllVideos(servers[0], token) |
@@ -713,6 +803,23 @@ describe('Test blocklist', function () { | |||
713 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 803 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
714 | }) | 804 | }) |
715 | 805 | ||
806 | it('Should get blocklist status', async function () { | ||
807 | const blockedServer = servers[1].host | ||
808 | const notBlockedServer = 'example.com' | ||
809 | |||
810 | for (const token of [ undefined, servers[0].accessToken ]) { | ||
811 | const status = await command.getStatus({ token, hosts: [ blockedServer, notBlockedServer ] }) | ||
812 | expect(Object.keys(status.accounts)).to.have.lengthOf(0) | ||
813 | |||
814 | expect(Object.keys(status.hosts)).to.have.lengthOf(2) | ||
815 | expect(status.hosts[blockedServer].blockedByUser).to.be.false | ||
816 | expect(status.hosts[blockedServer].blockedByServer).to.be.true | ||
817 | |||
818 | expect(status.hosts[notBlockedServer].blockedByUser).to.be.false | ||
819 | expect(status.hosts[notBlockedServer].blockedByServer).to.be.false | ||
820 | } | ||
821 | }) | ||
822 | |||
716 | it('Should unblock the remote server', async function () { | 823 | it('Should unblock the remote server', async function () { |
717 | await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) | 824 | await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) |
718 | }) | 825 | }) |
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts index d5838191a..322e93815 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/server/tests/api/moderation/video-blacklist.ts | |||
@@ -3,18 +3,18 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { orderBy } from 'lodash' | 5 | import { orderBy } from 'lodash' |
6 | import { FIXTURE_URLS } from '@server/tests/shared' | ||
7 | import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' | ||
6 | import { | 8 | import { |
7 | BlacklistCommand, | 9 | BlacklistCommand, |
8 | cleanupTests, | 10 | cleanupTests, |
9 | createMultipleServers, | 11 | createMultipleServers, |
10 | doubleFollow, | 12 | doubleFollow, |
11 | FIXTURE_URLS, | ||
12 | killallServers, | 13 | killallServers, |
13 | PeerTubeServer, | 14 | PeerTubeServer, |
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
15 | waitJobs | 16 | waitJobs |
16 | } from '@shared/extra-utils' | 17 | } from '@shared/server-commands' |
17 | import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' | ||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index c00d4e257..f037e7aae 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts | |||
@@ -6,14 +6,13 @@ import { | |||
6 | CheckerBaseParams, | 6 | CheckerBaseParams, |
7 | checkNewPeerTubeVersion, | 7 | checkNewPeerTubeVersion, |
8 | checkNewPluginVersion, | 8 | checkNewPluginVersion, |
9 | cleanupTests, | ||
10 | MockJoinPeerTubeVersions, | 9 | MockJoinPeerTubeVersions, |
11 | MockSmtpServer, | 10 | MockSmtpServer, |
12 | PeerTubeServer, | 11 | prepareNotificationsTest |
13 | prepareNotificationsTest, | 12 | } from '@server/tests/shared' |
14 | wait | 13 | import { wait } from '@shared/core-utils' |
15 | } from '@shared/extra-utils' | ||
16 | import { PluginType, UserNotification, UserNotificationType } from '@shared/models' | 14 | import { PluginType, UserNotification, UserNotificationType } from '@shared/models' |
15 | import { cleanupTests, PeerTubeServer } from '@shared/server-commands' | ||
17 | 16 | ||
18 | describe('Test admin notifications', function () { | 17 | describe('Test admin notifications', function () { |
19 | let server: PeerTubeServer | 18 | let server: PeerTubeServer |
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index 7cbb21397..b82f1712a 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts | |||
@@ -6,13 +6,11 @@ import { | |||
6 | checkCommentMention, | 6 | checkCommentMention, |
7 | CheckerBaseParams, | 7 | CheckerBaseParams, |
8 | checkNewCommentOnMyVideo, | 8 | checkNewCommentOnMyVideo, |
9 | cleanupTests, | ||
10 | MockSmtpServer, | 9 | MockSmtpServer, |
11 | PeerTubeServer, | 10 | prepareNotificationsTest |
12 | prepareNotificationsTest, | 11 | } from '@server/tests/shared' |
13 | waitJobs | ||
14 | } from '@shared/extra-utils' | ||
15 | import { UserNotification } from '@shared/models' | 12 | import { UserNotification } from '@shared/models' |
13 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
16 | 14 | ||
17 | const expect = chai.expect | 15 | const expect = chai.expect |
18 | 16 | ||
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index f806fed31..9e330bd61 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { buildUUID } from '@server/helpers/uuid' | ||
5 | import { | 4 | import { |
6 | checkAbuseStateChange, | 5 | checkAbuseStateChange, |
7 | checkAutoInstanceFollowing, | 6 | checkAutoInstanceFollowing, |
@@ -16,19 +15,20 @@ import { | |||
16 | checkUserRegistered, | 15 | checkUserRegistered, |
17 | checkVideoAutoBlacklistForModerators, | 16 | checkVideoAutoBlacklistForModerators, |
18 | checkVideoIsPublished, | 17 | checkVideoIsPublished, |
19 | cleanupTests, | ||
20 | MockInstancesIndex, | 18 | MockInstancesIndex, |
21 | MockSmtpServer, | 19 | MockSmtpServer, |
22 | PeerTubeServer, | 20 | prepareNotificationsTest |
23 | prepareNotificationsTest, | 21 | } from '@server/tests/shared' |
24 | wait, | 22 | import { wait } from '@shared/core-utils' |
25 | waitJobs | 23 | import { buildUUID } from '@shared/extra-utils' |
26 | } from '@shared/extra-utils' | 24 | import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models' |
27 | import { AbuseState, CustomConfig, UserNotification, VideoPrivacy } from '@shared/models' | 25 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' |
28 | 26 | ||
29 | describe('Test moderation notifications', function () { | 27 | describe('Test moderation notifications', function () { |
30 | let servers: PeerTubeServer[] = [] | 28 | let servers: PeerTubeServer[] = [] |
31 | let userAccessToken: string | 29 | let userToken1: string |
30 | let userToken2: string | ||
31 | |||
32 | let userNotifications: UserNotification[] = [] | 32 | let userNotifications: UserNotification[] = [] |
33 | let adminNotifications: UserNotification[] = [] | 33 | let adminNotifications: UserNotification[] = [] |
34 | let adminNotificationsServer2: UserNotification[] = [] | 34 | let adminNotificationsServer2: UserNotification[] = [] |
@@ -39,11 +39,13 @@ describe('Test moderation notifications', function () { | |||
39 | 39 | ||
40 | const res = await prepareNotificationsTest(3) | 40 | const res = await prepareNotificationsTest(3) |
41 | emails = res.emails | 41 | emails = res.emails |
42 | userAccessToken = res.userAccessToken | 42 | userToken1 = res.userAccessToken |
43 | servers = res.servers | 43 | servers = res.servers |
44 | userNotifications = res.userNotifications | 44 | userNotifications = res.userNotifications |
45 | adminNotifications = res.adminNotifications | 45 | adminNotifications = res.adminNotifications |
46 | adminNotificationsServer2 = res.adminNotificationsServer2 | 46 | adminNotificationsServer2 = res.adminNotificationsServer2 |
47 | |||
48 | userToken2 = await servers[1].users.generateUserAndToken('user2', UserRole.USER) | ||
47 | }) | 49 | }) |
48 | 50 | ||
49 | describe('Abuse for moderators notification', function () { | 51 | describe('Abuse for moderators notification', function () { |
@@ -58,15 +60,27 @@ describe('Test moderation notifications', function () { | |||
58 | } | 60 | } |
59 | }) | 61 | }) |
60 | 62 | ||
61 | it('Should send a notification to moderators on local video abuse', async function () { | 63 | it('Should not send a notification to moderators on local abuse reported by an admin', async function () { |
62 | this.timeout(20000) | 64 | this.timeout(20000) |
63 | 65 | ||
64 | const name = 'video for abuse ' + buildUUID() | 66 | const name = 'video for abuse ' + buildUUID() |
65 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 67 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
66 | 68 | ||
67 | await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }) | 69 | await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }) |
68 | 70 | ||
69 | await waitJobs(servers) | 71 | await waitJobs(servers) |
72 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'absence' }) | ||
73 | }) | ||
74 | |||
75 | it('Should send a notification to moderators on local video abuse', async function () { | ||
76 | this.timeout(20000) | ||
77 | |||
78 | const name = 'video for abuse ' + buildUUID() | ||
79 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) | ||
80 | |||
81 | await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' }) | ||
82 | |||
83 | await waitJobs(servers) | ||
70 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 84 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
71 | }) | 85 | }) |
72 | 86 | ||
@@ -74,12 +88,12 @@ describe('Test moderation notifications', function () { | |||
74 | this.timeout(20000) | 88 | this.timeout(20000) |
75 | 89 | ||
76 | const name = 'video for abuse ' + buildUUID() | 90 | const name = 'video for abuse ' + buildUUID() |
77 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 91 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
78 | 92 | ||
79 | await waitJobs(servers) | 93 | await waitJobs(servers) |
80 | 94 | ||
81 | const videoId = await servers[1].videos.getId({ uuid: video.uuid }) | 95 | const videoId = await servers[1].videos.getId({ uuid: video.uuid }) |
82 | await servers[1].abuses.report({ videoId, reason: 'super reason' }) | 96 | await servers[1].abuses.report({ token: userToken2, videoId, reason: 'super reason' }) |
83 | 97 | ||
84 | await waitJobs(servers) | 98 | await waitJobs(servers) |
85 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 99 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
@@ -89,16 +103,16 @@ describe('Test moderation notifications', function () { | |||
89 | this.timeout(20000) | 103 | this.timeout(20000) |
90 | 104 | ||
91 | const name = 'video for abuse ' + buildUUID() | 105 | const name = 'video for abuse ' + buildUUID() |
92 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 106 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
93 | const comment = await servers[0].comments.createThread({ | 107 | const comment = await servers[0].comments.createThread({ |
94 | token: userAccessToken, | 108 | token: userToken1, |
95 | videoId: video.id, | 109 | videoId: video.id, |
96 | text: 'comment abuse ' + buildUUID() | 110 | text: 'comment abuse ' + buildUUID() |
97 | }) | 111 | }) |
98 | 112 | ||
99 | await waitJobs(servers) | 113 | await waitJobs(servers) |
100 | 114 | ||
101 | await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' }) | 115 | await servers[0].abuses.report({ token: userToken1, commentId: comment.id, reason: 'super reason' }) |
102 | 116 | ||
103 | await waitJobs(servers) | 117 | await waitJobs(servers) |
104 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 118 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
@@ -108,10 +122,10 @@ describe('Test moderation notifications', function () { | |||
108 | this.timeout(20000) | 122 | this.timeout(20000) |
109 | 123 | ||
110 | const name = 'video for abuse ' + buildUUID() | 124 | const name = 'video for abuse ' + buildUUID() |
111 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 125 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
112 | 126 | ||
113 | await servers[0].comments.createThread({ | 127 | await servers[0].comments.createThread({ |
114 | token: userAccessToken, | 128 | token: userToken1, |
115 | videoId: video.id, | 129 | videoId: video.id, |
116 | text: 'comment abuse ' + buildUUID() | 130 | text: 'comment abuse ' + buildUUID() |
117 | }) | 131 | }) |
@@ -120,7 +134,7 @@ describe('Test moderation notifications', function () { | |||
120 | 134 | ||
121 | const { data } = await servers[1].comments.listThreads({ videoId: video.uuid }) | 135 | const { data } = await servers[1].comments.listThreads({ videoId: video.uuid }) |
122 | const commentId = data[0].id | 136 | const commentId = data[0].id |
123 | await servers[1].abuses.report({ commentId, reason: 'super reason' }) | 137 | await servers[1].abuses.report({ token: userToken2, commentId, reason: 'super reason' }) |
124 | 138 | ||
125 | await waitJobs(servers) | 139 | await waitJobs(servers) |
126 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 140 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
@@ -133,7 +147,7 @@ describe('Test moderation notifications', function () { | |||
133 | const { account } = await servers[0].users.create({ username, password: 'donald' }) | 147 | const { account } = await servers[0].users.create({ username, password: 'donald' }) |
134 | const accountId = account.id | 148 | const accountId = account.id |
135 | 149 | ||
136 | await servers[0].abuses.report({ accountId, reason: 'super reason' }) | 150 | await servers[0].abuses.report({ token: userToken1, accountId, reason: 'super reason' }) |
137 | 151 | ||
138 | await waitJobs(servers) | 152 | await waitJobs(servers) |
139 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) | 153 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) |
@@ -149,7 +163,7 @@ describe('Test moderation notifications', function () { | |||
149 | await waitJobs(servers) | 163 | await waitJobs(servers) |
150 | 164 | ||
151 | const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host }) | 165 | const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host }) |
152 | await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' }) | 166 | await servers[1].abuses.report({ token: userToken2, accountId: account.id, reason: 'super reason' }) |
153 | 167 | ||
154 | await waitJobs(servers) | 168 | await waitJobs(servers) |
155 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) | 169 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) |
@@ -165,13 +179,13 @@ describe('Test moderation notifications', function () { | |||
165 | server: servers[0], | 179 | server: servers[0], |
166 | emails, | 180 | emails, |
167 | socketNotifications: userNotifications, | 181 | socketNotifications: userNotifications, |
168 | token: userAccessToken | 182 | token: userToken1 |
169 | } | 183 | } |
170 | 184 | ||
171 | const name = 'abuse ' + buildUUID() | 185 | const name = 'abuse ' + buildUUID() |
172 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 186 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
173 | 187 | ||
174 | const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) | 188 | const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' }) |
175 | abuseId = body.abuse.id | 189 | abuseId = body.abuse.id |
176 | }) | 190 | }) |
177 | 191 | ||
@@ -205,7 +219,7 @@ describe('Test moderation notifications', function () { | |||
205 | server: servers[0], | 219 | server: servers[0], |
206 | emails, | 220 | emails, |
207 | socketNotifications: userNotifications, | 221 | socketNotifications: userNotifications, |
208 | token: userAccessToken | 222 | token: userToken1 |
209 | } | 223 | } |
210 | 224 | ||
211 | baseParamsAdmin = { | 225 | baseParamsAdmin = { |
@@ -216,15 +230,15 @@ describe('Test moderation notifications', function () { | |||
216 | } | 230 | } |
217 | 231 | ||
218 | const name = 'abuse ' + buildUUID() | 232 | const name = 'abuse ' + buildUUID() |
219 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 233 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
220 | 234 | ||
221 | { | 235 | { |
222 | const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) | 236 | const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' }) |
223 | abuseId = body.abuse.id | 237 | abuseId = body.abuse.id |
224 | } | 238 | } |
225 | 239 | ||
226 | { | 240 | { |
227 | const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) | 241 | const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason 2' }) |
228 | abuseId2 = body.abuse.id | 242 | abuseId2 = body.abuse.id |
229 | } | 243 | } |
230 | }) | 244 | }) |
@@ -254,7 +268,7 @@ describe('Test moderation notifications', function () { | |||
254 | this.timeout(10000) | 268 | this.timeout(10000) |
255 | 269 | ||
256 | const message = 'my super message to moderators' | 270 | const message = 'my super message to moderators' |
257 | await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) | 271 | await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message }) |
258 | await waitJobs(servers) | 272 | await waitJobs(servers) |
259 | 273 | ||
260 | const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com' | 274 | const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com' |
@@ -265,7 +279,7 @@ describe('Test moderation notifications', function () { | |||
265 | this.timeout(10000) | 279 | this.timeout(10000) |
266 | 280 | ||
267 | const message = 'my super message that should not be sent to reporter' | 281 | const message = 'my super message that should not be sent to reporter' |
268 | await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) | 282 | await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message }) |
269 | await waitJobs(servers) | 283 | await waitJobs(servers) |
270 | 284 | ||
271 | const toEmail = 'user_1@example.com' | 285 | const toEmail = 'user_1@example.com' |
@@ -281,7 +295,7 @@ describe('Test moderation notifications', function () { | |||
281 | server: servers[0], | 295 | server: servers[0], |
282 | emails, | 296 | emails, |
283 | socketNotifications: userNotifications, | 297 | socketNotifications: userNotifications, |
284 | token: userAccessToken | 298 | token: userToken1 |
285 | } | 299 | } |
286 | }) | 300 | }) |
287 | 301 | ||
@@ -289,7 +303,7 @@ describe('Test moderation notifications', function () { | |||
289 | this.timeout(10000) | 303 | this.timeout(10000) |
290 | 304 | ||
291 | const name = 'video for abuse ' + buildUUID() | 305 | const name = 'video for abuse ' + buildUUID() |
292 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 306 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
293 | 307 | ||
294 | await servers[0].blacklist.add({ videoId: uuid }) | 308 | await servers[0].blacklist.add({ videoId: uuid }) |
295 | 309 | ||
@@ -301,7 +315,7 @@ describe('Test moderation notifications', function () { | |||
301 | this.timeout(10000) | 315 | this.timeout(10000) |
302 | 316 | ||
303 | const name = 'video for abuse ' + buildUUID() | 317 | const name = 'video for abuse ' + buildUUID() |
304 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 318 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
305 | 319 | ||
306 | await servers[0].blacklist.add({ videoId: uuid }) | 320 | await servers[0].blacklist.add({ videoId: uuid }) |
307 | 321 | ||
@@ -335,7 +349,7 @@ describe('Test moderation notifications', function () { | |||
335 | 349 | ||
336 | await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' }) | 350 | await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' }) |
337 | 351 | ||
338 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 352 | const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } |
339 | await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' }) | 353 | await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' }) |
340 | }) | 354 | }) |
341 | }) | 355 | }) |
@@ -377,7 +391,7 @@ describe('Test moderation notifications', function () { | |||
377 | 391 | ||
378 | await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' }) | 392 | await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' }) |
379 | 393 | ||
380 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 394 | const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } |
381 | await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' }) | 395 | await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' }) |
382 | }) | 396 | }) |
383 | 397 | ||
@@ -404,7 +418,7 @@ describe('Test moderation notifications', function () { | |||
404 | const followingHost = servers[2].host | 418 | const followingHost = servers[2].host |
405 | await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' }) | 419 | await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' }) |
406 | 420 | ||
407 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 421 | const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } |
408 | await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' }) | 422 | await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' }) |
409 | 423 | ||
410 | config.followings.instance.autoFollowBack.enabled = false | 424 | config.followings.instance.autoFollowBack.enabled = false |
@@ -461,7 +475,7 @@ describe('Test moderation notifications', function () { | |||
461 | server: servers[0], | 475 | server: servers[0], |
462 | emails, | 476 | emails, |
463 | socketNotifications: userNotifications, | 477 | socketNotifications: userNotifications, |
464 | token: userAccessToken | 478 | token: userToken1 |
465 | } | 479 | } |
466 | 480 | ||
467 | currentCustomConfig = await servers[0].config.getCustomConfig() | 481 | currentCustomConfig = await servers[0].config.getCustomConfig() |
@@ -490,7 +504,7 @@ describe('Test moderation notifications', function () { | |||
490 | this.timeout(120000) | 504 | this.timeout(120000) |
491 | 505 | ||
492 | videoName = 'video with auto-blacklist ' + buildUUID() | 506 | videoName = 'video with auto-blacklist ' + buildUUID() |
493 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } }) | 507 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name: videoName } }) |
494 | shortUUID = video.shortUUID | 508 | shortUUID = video.shortUUID |
495 | uuid = video.uuid | 509 | uuid = video.uuid |
496 | 510 | ||
@@ -547,7 +561,7 @@ describe('Test moderation notifications', function () { | |||
547 | } | 561 | } |
548 | } | 562 | } |
549 | 563 | ||
550 | const { shortUUID, uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes }) | 564 | const { shortUUID, uuid } = await servers[0].videos.upload({ token: userToken1, attributes }) |
551 | 565 | ||
552 | await servers[0].blacklist.remove({ videoId: uuid }) | 566 | await servers[0].blacklist.remove({ videoId: uuid }) |
553 | 567 | ||
@@ -579,7 +593,7 @@ describe('Test moderation notifications', function () { | |||
579 | } | 593 | } |
580 | } | 594 | } |
581 | 595 | ||
582 | const { shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes }) | 596 | const { shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes }) |
583 | 597 | ||
584 | await wait(6000) | 598 | await wait(6000) |
585 | await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' }) | 599 | await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' }) |
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index a529a9bf7..ac08449f8 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts | |||
@@ -5,14 +5,12 @@ import * as chai from 'chai' | |||
5 | import { | 5 | import { |
6 | CheckerBaseParams, | 6 | CheckerBaseParams, |
7 | checkNewVideoFromSubscription, | 7 | checkNewVideoFromSubscription, |
8 | cleanupTests, | ||
9 | getAllNotificationsSettings, | 8 | getAllNotificationsSettings, |
10 | MockSmtpServer, | 9 | MockSmtpServer, |
11 | PeerTubeServer, | 10 | prepareNotificationsTest |
12 | prepareNotificationsTest, | 11 | } from '@server/tests/shared' |
13 | waitJobs | ||
14 | } from '@shared/extra-utils' | ||
15 | import { UserNotification, UserNotificationSettingValue } from '@shared/models' | 12 | import { UserNotification, UserNotificationSettingValue } from '@shared/models' |
13 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
16 | 14 | ||
17 | const expect = chai.expect | 15 | const expect = chai.expect |
18 | 16 | ||
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 468efdf35..f9f3e0e0e 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -2,23 +2,21 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildUUID } from '@server/helpers/uuid' | ||
6 | import { | 5 | import { |
7 | CheckerBaseParams, | 6 | CheckerBaseParams, |
8 | checkMyVideoImportIsFinished, | 7 | checkMyVideoImportIsFinished, |
9 | checkNewActorFollow, | 8 | checkNewActorFollow, |
10 | checkNewVideoFromSubscription, | 9 | checkNewVideoFromSubscription, |
11 | checkVideoIsPublished, | 10 | checkVideoIsPublished, |
12 | cleanupTests, | ||
13 | FIXTURE_URLS, | 11 | FIXTURE_URLS, |
14 | MockSmtpServer, | 12 | MockSmtpServer, |
15 | PeerTubeServer, | ||
16 | prepareNotificationsTest, | 13 | prepareNotificationsTest, |
17 | uploadRandomVideoOnServers, | 14 | uploadRandomVideoOnServers |
18 | wait, | 15 | } from '@server/tests/shared' |
19 | waitJobs | 16 | import { wait } from '@shared/core-utils' |
20 | } from '@shared/extra-utils' | 17 | import { buildUUID } from '@shared/extra-utils' |
21 | import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' | 18 | import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' |
19 | import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' | ||
22 | 20 | ||
23 | const expect = chai.expect | 21 | const expect = chai.expect |
24 | 22 | ||
@@ -128,7 +126,7 @@ describe('Test user notifications', function () { | |||
128 | }) | 126 | }) |
129 | 127 | ||
130 | it('Should not send a notification before the video is published', async function () { | 128 | it('Should not send a notification before the video is published', async function () { |
131 | this.timeout(50000) | 129 | this.timeout(150000) |
132 | 130 | ||
133 | const updateAt = new Date(new Date().getTime() + 1000000) | 131 | const updateAt = new Date(new Date().getTime() + 1000000) |
134 | 132 | ||
@@ -267,7 +265,7 @@ describe('Test user notifications', function () { | |||
267 | }) | 265 | }) |
268 | 266 | ||
269 | it('Should send a notification when an imported video is transcoded', async function () { | 267 | it('Should send a notification when an imported video is transcoded', async function () { |
270 | this.timeout(50000) | 268 | this.timeout(120000) |
271 | 269 | ||
272 | const name = 'video import ' + buildUUID() | 270 | const name = 'video import ' + buildUUID() |
273 | 271 | ||
diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts index 3726a717b..0cb0a6e34 100644 --- a/server/tests/api/object-storage/live.ts +++ b/server/tests/api/object-storage/live.ts | |||
@@ -3,11 +3,12 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { expectStartWith } from '@server/tests/shared' | ||
7 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | areObjectStorageTestsDisabled, | ||
8 | createMultipleServers, | 10 | createMultipleServers, |
9 | doubleFollow, | 11 | doubleFollow, |
10 | expectStartWith, | ||
11 | killallServers, | 12 | killallServers, |
12 | makeRawRequest, | 13 | makeRawRequest, |
13 | ObjectStorageCommand, | 14 | ObjectStorageCommand, |
@@ -18,8 +19,7 @@ import { | |||
18 | waitJobs, | 19 | waitJobs, |
19 | waitUntilLivePublishedOnAllServers, | 20 | waitUntilLivePublishedOnAllServers, |
20 | waitUntilLiveSavedOnAllServers | 21 | waitUntilLiveSavedOnAllServers |
21 | } from '@shared/extra-utils' | 22 | } from '@shared/server-commands' |
22 | import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models' | ||
23 | 23 | ||
24 | const expect = chai.expect | 24 | const expect = chai.expect |
25 | 25 | ||
diff --git a/server/tests/api/object-storage/video-imports.ts b/server/tests/api/object-storage/video-imports.ts index 363fe3b5b..fb81832af 100644 --- a/server/tests/api/object-storage/video-imports.ts +++ b/server/tests/api/object-storage/video-imports.ts | |||
@@ -2,11 +2,11 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared' | ||
6 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | areObjectStorageTestsDisabled, | ||
7 | createSingleServer, | 9 | createSingleServer, |
8 | expectStartWith, | ||
9 | FIXTURE_URLS, | ||
10 | killallServers, | 10 | killallServers, |
11 | makeRawRequest, | 11 | makeRawRequest, |
12 | ObjectStorageCommand, | 12 | ObjectStorageCommand, |
@@ -14,8 +14,7 @@ import { | |||
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | setDefaultVideoChannel, | 15 | setDefaultVideoChannel, |
16 | waitJobs | 16 | waitJobs |
17 | } from '@shared/extra-utils' | 17 | } from '@shared/server-commands' |
18 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
19 | 18 | ||
20 | const expect = chai.expect | 19 | const expect = chai.expect |
21 | 20 | ||
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index 35a5f19ed..498efcb17 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts | |||
@@ -3,25 +3,22 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { merge } from 'lodash' | 5 | import { merge } from 'lodash' |
6 | import { checkTmpIsEmpty, expectLogDoesNotContain, expectStartWith, MockObjectStorage } from '@server/tests/shared' | ||
7 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
8 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
6 | import { | 9 | import { |
7 | areObjectStorageTestsDisabled, | ||
8 | checkTmpIsEmpty, | ||
9 | cleanupTests, | 10 | cleanupTests, |
10 | createMultipleServers, | 11 | createMultipleServers, |
11 | createSingleServer, | 12 | createSingleServer, |
12 | doubleFollow, | 13 | doubleFollow, |
13 | expectLogDoesNotContain, | ||
14 | expectStartWith, | ||
15 | killallServers, | 14 | killallServers, |
16 | makeRawRequest, | 15 | makeRawRequest, |
17 | MockObjectStorage, | ||
18 | ObjectStorageCommand, | 16 | ObjectStorageCommand, |
19 | PeerTubeServer, | 17 | PeerTubeServer, |
20 | setAccessTokensToServers, | 18 | setAccessTokensToServers, |
21 | waitJobs, | 19 | waitJobs, |
22 | webtorrentAdd | 20 | webtorrentAdd |
23 | } from '@shared/extra-utils' | 21 | } from '@shared/server-commands' |
24 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
25 | 22 | ||
26 | const expect = chai.expect | 23 | const expect = chai.expect |
27 | 24 | ||
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts index 5fd464ded..cbf3106bd 100644 --- a/server/tests/api/redundancy/manage-redundancy.ts +++ b/server/tests/api/redundancy/manage-redundancy.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | RedundancyCommand, | 10 | RedundancyCommand, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models' | 14 | import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models' |
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 933a2c776..17c6b25a5 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts | |||
@@ -2,8 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | 5 | import { VideoPrivacy } from '@shared/models' |
6 | import { | ||
7 | cleanupTests, | ||
8 | createSingleServer, | ||
9 | killallServers, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | describe('Test redundancy constraints', function () { | 15 | describe('Test redundancy constraints', function () { |
9 | let remoteServer: PeerTubeServer | 16 | let remoteServer: PeerTubeServer |
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 86b40cfe6..3f2286278 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -5,29 +5,26 @@ import * as chai from 'chai' | |||
5 | import { readdir } from 'fs-extra' | 5 | import { readdir } from 'fs-extra' |
6 | import magnetUtil from 'magnet-uri' | 6 | import magnetUtil from 'magnet-uri' |
7 | import { basename, join } from 'path' | 7 | import { basename, join } from 'path' |
8 | import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared' | ||
9 | import { root, wait } from '@shared/core-utils' | ||
10 | import { | ||
11 | HttpStatusCode, | ||
12 | VideoDetails, | ||
13 | VideoFile, | ||
14 | VideoPrivacy, | ||
15 | VideoRedundancyStrategy, | ||
16 | VideoRedundancyStrategyWithManual | ||
17 | } from '@shared/models' | ||
8 | import { | 18 | import { |
9 | checkSegmentHash, | ||
10 | checkVideoFilesWereRemoved, | ||
11 | cleanupTests, | 19 | cleanupTests, |
12 | createMultipleServers, | 20 | createMultipleServers, |
13 | doubleFollow, | 21 | doubleFollow, |
14 | killallServers, | 22 | killallServers, |
15 | makeRawRequest, | 23 | makeRawRequest, |
16 | PeerTubeServer, | 24 | PeerTubeServer, |
17 | root, | ||
18 | saveVideoInServers, | ||
19 | setAccessTokensToServers, | 25 | setAccessTokensToServers, |
20 | wait, | ||
21 | waitJobs | 26 | waitJobs |
22 | } from '@shared/extra-utils' | 27 | } from '@shared/server-commands' |
23 | import { | ||
24 | HttpStatusCode, | ||
25 | VideoDetails, | ||
26 | VideoFile, | ||
27 | VideoPrivacy, | ||
28 | VideoRedundancyStrategy, | ||
29 | VideoRedundancyStrategyWithManual | ||
30 | } from '@shared/models' | ||
31 | 28 | ||
32 | const expect = chai.expect | 29 | const expect = chai.expect |
33 | 30 | ||
@@ -307,7 +304,7 @@ describe('Test videos redundancy', function () { | |||
307 | const strategy = 'most-views' | 304 | const strategy = 'most-views' |
308 | 305 | ||
309 | before(function () { | 306 | before(function () { |
310 | this.timeout(120000) | 307 | this.timeout(240000) |
311 | 308 | ||
312 | return createServers(strategy) | 309 | return createServers(strategy) |
313 | }) | 310 | }) |
@@ -357,7 +354,7 @@ describe('Test videos redundancy', function () { | |||
357 | const strategy = 'trending' | 354 | const strategy = 'trending' |
358 | 355 | ||
359 | before(function () { | 356 | before(function () { |
360 | this.timeout(120000) | 357 | this.timeout(240000) |
361 | 358 | ||
362 | return createServers(strategy) | 359 | return createServers(strategy) |
363 | }) | 360 | }) |
@@ -420,7 +417,7 @@ describe('Test videos redundancy', function () { | |||
420 | const strategy = 'recently-added' | 417 | const strategy = 'recently-added' |
421 | 418 | ||
422 | before(function () { | 419 | before(function () { |
423 | this.timeout(120000) | 420 | this.timeout(240000) |
424 | 421 | ||
425 | return createServers(strategy, { min_views: 3 }) | 422 | return createServers(strategy, { min_views: 3 }) |
426 | }) | 423 | }) |
@@ -491,7 +488,7 @@ describe('Test videos redundancy', function () { | |||
491 | const strategy = 'recently-added' | 488 | const strategy = 'recently-added' |
492 | 489 | ||
493 | before(async function () { | 490 | before(async function () { |
494 | this.timeout(120000) | 491 | this.timeout(240000) |
495 | 492 | ||
496 | await createServers(strategy, { min_views: 3 }, false) | 493 | await createServers(strategy, { min_views: 3 }, false) |
497 | }) | 494 | }) |
@@ -553,7 +550,7 @@ describe('Test videos redundancy', function () { | |||
553 | 550 | ||
554 | describe('With manual strategy', function () { | 551 | describe('With manual strategy', function () { |
555 | before(function () { | 552 | before(function () { |
556 | this.timeout(120000) | 553 | this.timeout(240000) |
557 | 554 | ||
558 | return createServers(null) | 555 | return createServers(null) |
559 | }) | 556 | }) |
@@ -632,7 +629,7 @@ describe('Test videos redundancy', function () { | |||
632 | } | 629 | } |
633 | 630 | ||
634 | before(async function () { | 631 | before(async function () { |
635 | this.timeout(120000) | 632 | this.timeout(240000) |
636 | 633 | ||
637 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 634 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
638 | 635 | ||
@@ -674,7 +671,7 @@ describe('Test videos redundancy', function () { | |||
674 | const strategy = 'recently-added' | 671 | const strategy = 'recently-added' |
675 | 672 | ||
676 | before(async function () { | 673 | before(async function () { |
677 | this.timeout(120000) | 674 | this.timeout(240000) |
678 | 675 | ||
679 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 676 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
680 | 677 | ||
@@ -698,7 +695,7 @@ describe('Test videos redundancy', function () { | |||
698 | }) | 695 | }) |
699 | 696 | ||
700 | it('Should cache video 2 webseeds on the first video', async function () { | 697 | it('Should cache video 2 webseeds on the first video', async function () { |
701 | this.timeout(120000) | 698 | this.timeout(240000) |
702 | 699 | ||
703 | await waitJobs(servers) | 700 | await waitJobs(servers) |
704 | 701 | ||
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index efcdb33dc..2e0abc6ba 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoChannel } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | PeerTubeServer, | 10 | PeerTubeServer, |
9 | SearchCommand, | 11 | SearchCommand, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | import { VideoChannel } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 34b318268..d9243ac53 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
@@ -9,10 +11,8 @@ import { | |||
9 | SearchCommand, | 11 | SearchCommand, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
12 | wait, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index a2e6e70fe..60b95ae4c 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | PeerTubeServer, | 10 | PeerTubeServer, |
9 | SearchCommand, | 11 | SearchCommand, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | import { VideoPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 67612537c..8a92def61 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | SearchCommand, | 10 | SearchCommand, |
11 | setAccessTokensToServers | 11 | setAccessTokensToServers |
12 | } from '@shared/extra-utils' | 12 | } from '@shared/server-commands' |
13 | import { VideoChannel } from '@shared/models' | 13 | import { VideoChannel } from '@shared/models' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index 1845c2069..f84d03345 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils' | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/server-commands' |
6 | import { | 6 | import { |
7 | BooleanBothQuery, | 7 | BooleanBothQuery, |
8 | VideoChannelsSearchQuery, | 8 | VideoChannelsSearchQuery, |
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index 15aac029a..1e9c8d4bb 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | SearchCommand, | 10 | SearchCommand, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | setDefaultVideoChannel | 12 | setDefaultVideoChannel |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | import { VideoPlaylistPrivacy } from '@shared/models' | 14 | import { VideoPlaylistPrivacy } from '@shared/models' |
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index ad2a2fddc..c544705d3 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -10,10 +10,10 @@ import { | |||
10 | SearchCommand, | 10 | SearchCommand, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 12 | setDefaultVideoChannel, |
13 | stopFfmpeg, | 13 | stopFfmpeg |
14 | wait | 14 | } from '@shared/server-commands' |
15 | } from '@shared/extra-utils' | ||
16 | import { VideoPrivacy } from '@shared/models' | 15 | import { VideoPrivacy } from '@shared/models' |
16 | import { wait } from '@shared/core-utils' | ||
17 | 17 | ||
18 | const expect = chai.expect | 18 | const expect = chai.expect |
19 | 19 | ||
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts index 90a668edb..6d2333a6b 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/server/tests/api/server/auto-follows.ts | |||
@@ -2,15 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { MockInstancesIndex } from '@server/tests/shared' |
6 | cleanupTests, | 6 | import { wait } from '@shared/core-utils' |
7 | createMultipleServers, | 7 | import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' |
8 | MockInstancesIndex, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | wait, | ||
12 | waitJobs | ||
13 | } from '@shared/extra-utils' | ||
14 | 8 | ||
15 | const expect = chai.expect | 9 | const expect = chai.expect |
16 | 10 | ||
diff --git a/server/tests/api/server/bulk.ts b/server/tests/api/server/bulk.ts index 16cbcd5c3..1b81a6954 100644 --- a/server/tests/api/server/bulk.ts +++ b/server/tests/api/server/bulk.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |
16 | 16 | ||
diff --git a/server/tests/api/server/config-defaults.ts b/server/tests/api/server/config-defaults.ts new file mode 100644 index 000000000..3ff09bf7e --- /dev/null +++ b/server/tests/api/server/config-defaults.ts | |||
@@ -0,0 +1,213 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | import { FIXTURE_URLS } from '@server/tests/shared' | ||
6 | import { VideoDetails, VideoPrivacy } from '@shared/models' | ||
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' | ||
8 | |||
9 | const expect = chai.expect | ||
10 | |||
11 | describe('Test config defaults', function () { | ||
12 | let server: PeerTubeServer | ||
13 | let channelId: number | ||
14 | |||
15 | before(async function () { | ||
16 | this.timeout(30000) | ||
17 | |||
18 | server = await createSingleServer(1) | ||
19 | await setAccessTokensToServers([ server ]) | ||
20 | await setDefaultVideoChannel([ server ]) | ||
21 | |||
22 | channelId = server.store.channel.id | ||
23 | }) | ||
24 | |||
25 | describe('Default publish values', function () { | ||
26 | |||
27 | before(async function () { | ||
28 | const overrideConfig = { | ||
29 | defaults: { | ||
30 | publish: { | ||
31 | comments_enabled: false, | ||
32 | download_enabled: false, | ||
33 | privacy: VideoPrivacy.INTERNAL, | ||
34 | licence: 4 | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | |||
39 | await server.kill() | ||
40 | await server.run(overrideConfig) | ||
41 | }) | ||
42 | |||
43 | const attributes = { | ||
44 | name: 'video', | ||
45 | downloadEnabled: undefined, | ||
46 | commentsEnabled: undefined, | ||
47 | licence: undefined, | ||
48 | privacy: VideoPrivacy.PUBLIC // Privacy is mandatory for server | ||
49 | } | ||
50 | |||
51 | function checkVideo (video: VideoDetails) { | ||
52 | expect(video.downloadEnabled).to.be.false | ||
53 | expect(video.commentsEnabled).to.be.false | ||
54 | expect(video.licence.id).to.equal(4) | ||
55 | } | ||
56 | |||
57 | before(async function () { | ||
58 | await server.config.disableTranscoding() | ||
59 | await server.config.enableImports() | ||
60 | await server.config.enableLive({ allowReplay: false, transcoding: false }) | ||
61 | }) | ||
62 | |||
63 | it('Should have the correct server configuration', async function () { | ||
64 | const config = await server.config.getConfig() | ||
65 | |||
66 | expect(config.defaults.publish.commentsEnabled).to.be.false | ||
67 | expect(config.defaults.publish.downloadEnabled).to.be.false | ||
68 | expect(config.defaults.publish.licence).to.equal(4) | ||
69 | expect(config.defaults.publish.privacy).to.equal(VideoPrivacy.INTERNAL) | ||
70 | }) | ||
71 | |||
72 | it('Should respect default values when uploading a video', async function () { | ||
73 | for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) { | ||
74 | const { id } = await server.videos.upload({ attributes, mode }) | ||
75 | |||
76 | const video = await server.videos.get({ id }) | ||
77 | checkVideo(video) | ||
78 | } | ||
79 | }) | ||
80 | |||
81 | it('Should respect default values when importing a video using URL', async function () { | ||
82 | const { video: { id } } = await server.imports.importVideo({ | ||
83 | attributes: { | ||
84 | ...attributes, | ||
85 | channelId, | ||
86 | targetUrl: FIXTURE_URLS.goodVideo | ||
87 | } | ||
88 | }) | ||
89 | |||
90 | const video = await server.videos.get({ id }) | ||
91 | checkVideo(video) | ||
92 | }) | ||
93 | |||
94 | it('Should respect default values when importing a video using magnet URI', async function () { | ||
95 | const { video: { id } } = await server.imports.importVideo({ | ||
96 | attributes: { | ||
97 | ...attributes, | ||
98 | channelId, | ||
99 | magnetUri: FIXTURE_URLS.magnet | ||
100 | } | ||
101 | }) | ||
102 | |||
103 | const video = await server.videos.get({ id }) | ||
104 | checkVideo(video) | ||
105 | }) | ||
106 | |||
107 | it('Should respect default values when creating a live', async function () { | ||
108 | const { id } = await server.live.create({ | ||
109 | fields: { | ||
110 | ...attributes, | ||
111 | channelId | ||
112 | } | ||
113 | }) | ||
114 | |||
115 | const video = await server.videos.get({ id }) | ||
116 | checkVideo(video) | ||
117 | }) | ||
118 | }) | ||
119 | |||
120 | describe('Default P2P values', function () { | ||
121 | |||
122 | describe('Webapp default value', function () { | ||
123 | |||
124 | before(async function () { | ||
125 | const overrideConfig = { | ||
126 | defaults: { | ||
127 | p2p: { | ||
128 | webapp: { | ||
129 | enabled: false | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | await server.kill() | ||
136 | await server.run(overrideConfig) | ||
137 | }) | ||
138 | |||
139 | it('Should have appropriate P2P config', async function () { | ||
140 | const config = await server.config.getConfig() | ||
141 | |||
142 | expect(config.defaults.p2p.webapp.enabled).to.be.false | ||
143 | expect(config.defaults.p2p.embed.enabled).to.be.true | ||
144 | }) | ||
145 | |||
146 | it('Should create a user with this default setting', async function () { | ||
147 | await server.users.create({ username: 'user_p2p_1' }) | ||
148 | const userToken = await server.login.getAccessToken('user_p2p_1') | ||
149 | |||
150 | const { p2pEnabled } = await server.users.getMyInfo({ token: userToken }) | ||
151 | expect(p2pEnabled).to.be.false | ||
152 | }) | ||
153 | |||
154 | it('Should register a user with this default setting', async function () { | ||
155 | await server.users.register({ username: 'user_p2p_2' }) | ||
156 | |||
157 | const userToken = await server.login.getAccessToken('user_p2p_2') | ||
158 | |||
159 | const { p2pEnabled } = await server.users.getMyInfo({ token: userToken }) | ||
160 | expect(p2pEnabled).to.be.false | ||
161 | }) | ||
162 | }) | ||
163 | |||
164 | describe('Embed default value', function () { | ||
165 | |||
166 | before(async function () { | ||
167 | const overrideConfig = { | ||
168 | defaults: { | ||
169 | p2p: { | ||
170 | embed: { | ||
171 | enabled: false | ||
172 | } | ||
173 | } | ||
174 | }, | ||
175 | signup: { | ||
176 | limit: 15 | ||
177 | } | ||
178 | } | ||
179 | |||
180 | await server.kill() | ||
181 | await server.run(overrideConfig) | ||
182 | }) | ||
183 | |||
184 | it('Should have appropriate P2P config', async function () { | ||
185 | const config = await server.config.getConfig() | ||
186 | |||
187 | expect(config.defaults.p2p.webapp.enabled).to.be.true | ||
188 | expect(config.defaults.p2p.embed.enabled).to.be.false | ||
189 | }) | ||
190 | |||
191 | it('Should create a user with this default setting', async function () { | ||
192 | await server.users.create({ username: 'user_p2p_3' }) | ||
193 | const userToken = await server.login.getAccessToken('user_p2p_3') | ||
194 | |||
195 | const { p2pEnabled } = await server.users.getMyInfo({ token: userToken }) | ||
196 | expect(p2pEnabled).to.be.true | ||
197 | }) | ||
198 | |||
199 | it('Should register a user with this default setting', async function () { | ||
200 | await server.users.register({ username: 'user_p2p_4' }) | ||
201 | |||
202 | const userToken = await server.login.getAccessToken('user_p2p_4') | ||
203 | |||
204 | const { p2pEnabled } = await server.users.getMyInfo({ token: userToken }) | ||
205 | expect(p2pEnabled).to.be.true | ||
206 | }) | ||
207 | }) | ||
208 | }) | ||
209 | |||
210 | after(async function () { | ||
211 | await cleanupTests([ server ]) | ||
212 | }) | ||
213 | }) | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index ea524723c..2356f701c 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { parallelTests } from '@shared/core-utils' | ||
6 | import { CustomConfig, HttpStatusCode } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | killallServers, | 10 | killallServers, |
9 | makeGetRequest, | 11 | makeGetRequest, |
10 | parallelTests, | ||
11 | PeerTubeServer, | 12 | PeerTubeServer, |
12 | setAccessTokensToServers | 13 | setAccessTokensToServers |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | import { CustomConfig, HttpStatusCode } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
@@ -43,6 +43,9 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { | |||
43 | expect(data.services.twitter.username).to.equal('@Chocobozzz') | 43 | expect(data.services.twitter.username).to.equal('@Chocobozzz') |
44 | expect(data.services.twitter.whitelisted).to.be.false | 44 | expect(data.services.twitter.whitelisted).to.be.false |
45 | 45 | ||
46 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.false | ||
47 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.false | ||
48 | |||
46 | expect(data.cache.previews.size).to.equal(1) | 49 | expect(data.cache.previews.size).to.equal(1) |
47 | expect(data.cache.captions.size).to.equal(1) | 50 | expect(data.cache.captions.size).to.equal(1) |
48 | expect(data.cache.torrents.size).to.equal(1) | 51 | expect(data.cache.torrents.size).to.equal(1) |
@@ -138,6 +141,9 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
138 | expect(data.services.twitter.username).to.equal('@Kuja') | 141 | expect(data.services.twitter.username).to.equal('@Kuja') |
139 | expect(data.services.twitter.whitelisted).to.be.true | 142 | expect(data.services.twitter.whitelisted).to.be.true |
140 | 143 | ||
144 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.true | ||
145 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.true | ||
146 | |||
141 | expect(data.cache.previews.size).to.equal(2) | 147 | expect(data.cache.previews.size).to.equal(2) |
142 | expect(data.cache.captions.size).to.equal(3) | 148 | expect(data.cache.captions.size).to.equal(3) |
143 | expect(data.cache.torrents.size).to.equal(4) | 149 | expect(data.cache.torrents.size).to.equal(4) |
@@ -246,6 +252,18 @@ const newCustomConfig: CustomConfig = { | |||
246 | whitelisted: true | 252 | whitelisted: true |
247 | } | 253 | } |
248 | }, | 254 | }, |
255 | client: { | ||
256 | videos: { | ||
257 | miniature: { | ||
258 | preferAuthorDisplayName: true | ||
259 | } | ||
260 | }, | ||
261 | menu: { | ||
262 | login: { | ||
263 | redirectOnSingleExternalAuth: true | ||
264 | } | ||
265 | } | ||
266 | }, | ||
249 | cache: { | 267 | cache: { |
250 | previews: { | 268 | previews: { |
251 | size: 2 | 269 | size: 2 |
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index c555661ad..f3facb04a 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts | |||
@@ -2,17 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { MockSmtpServer } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | cleanupTests, | 9 | cleanupTests, |
7 | ContactFormCommand, | 10 | ContactFormCommand, |
8 | createSingleServer, | 11 | createSingleServer, |
9 | MockSmtpServer, | ||
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
12 | wait, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { HttpStatusCode } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 5f97edbc2..20b5e378c 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
@@ -185,7 +186,7 @@ describe('Test emails', function () { | |||
185 | this.timeout(10000) | 186 | this.timeout(10000) |
186 | 187 | ||
187 | const reason = 'my super bad reason' | 188 | const reason = 'my super bad reason' |
188 | await server.abuses.report({ videoId, reason }) | 189 | await server.abuses.report({ token: userAccessToken, videoId, reason }) |
189 | 190 | ||
190 | await waitJobs(server) | 191 | await waitJobs(server) |
191 | expect(emails).to.have.lengthOf(3) | 192 | expect(emails).to.have.lengthOf(3) |
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts index 471f5d8d0..455fbc762 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/server/tests/api/server/follow-constraints.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
6 | import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' | 6 | import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' |
7 | 7 | ||
8 | const expect = chai.expect | 8 | const expect = chai.expect |
@@ -14,7 +14,7 @@ describe('Test follow constraints', function () { | |||
14 | let userToken: string | 14 | let userToken: string |
15 | 15 | ||
16 | before(async function () { | 16 | before(async function () { |
17 | this.timeout(90000) | 17 | this.timeout(240000) |
18 | 18 | ||
19 | servers = await createMultipleServers(2) | 19 | servers = await createMultipleServers(2) |
20 | 20 | ||
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts index 921f51043..120bd7f88 100644 --- a/server/tests/api/server/follows-moderation.ts +++ b/server/tests/api/server/follows-moderation.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
11 | waitJobs | 11 | waitJobs |
12 | } from '@shared/extra-utils' | 12 | } from '@shared/server-commands' |
13 | 13 | ||
14 | const expect = chai.expect | 14 | const expect = chai.expect |
15 | 15 | ||
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 832ba561a..c588cf664 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -2,19 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { completeVideoCheck, dateIsValid, expectAccountFollows, expectChannelsFollows, testCaptionFile } from '@server/tests/shared' |
6 | cleanupTests, | ||
7 | completeVideoCheck, | ||
8 | createMultipleServers, | ||
9 | dateIsValid, | ||
10 | expectAccountFollows, | ||
11 | expectChannelsFollows, | ||
12 | PeerTubeServer, | ||
13 | setAccessTokensToServers, | ||
14 | testCaptionFile, | ||
15 | waitJobs | ||
16 | } from '@shared/extra-utils' | ||
17 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' | 6 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' |
7 | import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
18 | 8 | ||
19 | const expect = chai.expect | 9 | const expect = chai.expect |
20 | 10 | ||
@@ -22,7 +12,7 @@ describe('Test follows', function () { | |||
22 | let servers: PeerTubeServer[] = [] | 12 | let servers: PeerTubeServer[] = [] |
23 | 13 | ||
24 | before(async function () { | 14 | before(async function () { |
25 | this.timeout(30000) | 15 | this.timeout(120000) |
26 | 16 | ||
27 | servers = await createMultipleServers(3) | 17 | servers = await createMultipleServers(3) |
28 | 18 | ||
@@ -292,7 +282,7 @@ describe('Test follows', function () { | |||
292 | }) | 282 | }) |
293 | 283 | ||
294 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { | 284 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { |
295 | this.timeout(60000) | 285 | this.timeout(120000) |
296 | 286 | ||
297 | await servers[1].videos.upload({ attributes: { name: 'server2' } }) | 287 | await servers[1].videos.upload({ attributes: { name: 'server2' } }) |
298 | await servers[2].videos.upload({ attributes: { name: 'server3' } }) | 288 | await servers[2].videos.upload({ attributes: { name: 'server3' } }) |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index fa1da8fe0..3dcd076f5 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -2,18 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { completeVideoCheck } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | cleanupTests, | 9 | cleanupTests, |
7 | CommentsCommand, | 10 | CommentsCommand, |
8 | completeVideoCheck, | ||
9 | createMultipleServers, | 11 | createMultipleServers, |
10 | killallServers, | 12 | killallServers, |
11 | PeerTubeServer, | 13 | PeerTubeServer, |
12 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
13 | wait, | ||
14 | waitJobs | 15 | waitJobs |
15 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' | ||
17 | 17 | ||
18 | const expect = chai.expect | 18 | const expect = chai.expect |
19 | 19 | ||
@@ -50,7 +50,7 @@ describe('Test handle downs', function () { | |||
50 | let commentCommands: CommentsCommand[] | 50 | let commentCommands: CommentsCommand[] |
51 | 51 | ||
52 | before(async function () { | 52 | before(async function () { |
53 | this.timeout(30000) | 53 | this.timeout(120000) |
54 | 54 | ||
55 | servers = await createMultipleServers(3) | 55 | servers = await createMultipleServers(3) |
56 | commentCommands = servers.map(s => s.comments) | 56 | commentCommands = servers.map(s => s.comments) |
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts index cb3ba5677..552ee98cf 100644 --- a/server/tests/api/server/homepage.ts +++ b/server/tests/api/server/homepage.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | killallServers, | 10 | killallServers, |
11 | PeerTubeServer, | 11 | PeerTubeServer, |
12 | setAccessTokensToServers | 12 | setAccessTokensToServers |
13 | } from '../../../../shared/extra-utils/index' | 13 | } from '../../../../shared/server-commands/index' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |
16 | 16 | ||
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts index 8136fc3c6..45be107ce 100644 --- a/server/tests/api/server/index.ts +++ b/server/tests/api/server/index.ts | |||
@@ -1,4 +1,6 @@ | |||
1 | import './auto-follows' | 1 | import './auto-follows' |
2 | import './bulk' | ||
3 | import './config-defaults' | ||
2 | import './config' | 4 | import './config' |
3 | import './contact-form' | 5 | import './contact-form' |
4 | import './email' | 6 | import './email' |
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts index 5d946f5e8..4294e1fd5 100644 --- a/server/tests/api/server/jobs.ts +++ b/server/tests/api/server/jobs.ts | |||
@@ -2,15 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { dateIsValid } from '@server/tests/shared' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
8 | dateIsValid, | ||
9 | doubleFollow, | 9 | doubleFollow, |
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |
16 | 16 | ||
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts index 4fa13886e..697f10337 100644 --- a/server/tests/api/server/logs.ts +++ b/server/tests/api/server/logs.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |
16 | 16 | ||
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts index 1e0c95a3b..913907788 100644 --- a/server/tests/api/server/no-client.ts +++ b/server/tests/api/server/no-client.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import 'mocha' | 1 | import 'mocha' |
2 | import request from 'supertest' | 2 | import request from 'supertest' |
3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils' | 3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' |
4 | import { HttpStatusCode } from '@shared/models' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | 5 | ||
6 | describe('Start and stop server without web client routes', function () { | 6 | describe('Start and stop server without web client routes', function () { |
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts index 5f9f4ffdd..76d3e2481 100644 --- a/server/tests/api/server/plugins.ts +++ b/server/tests/api/server/plugins.ts | |||
@@ -2,17 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testHelloWorldRegisteredSettings } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, PluginType } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | cleanupTests, | 9 | cleanupTests, |
7 | createSingleServer, | 10 | createSingleServer, |
8 | killallServers, | 11 | killallServers, |
9 | PeerTubeServer, | 12 | PeerTubeServer, |
10 | PluginsCommand, | 13 | PluginsCommand, |
11 | setAccessTokensToServers, | 14 | setAccessTokensToServers |
12 | testHelloWorldRegisteredSettings, | 15 | } from '@shared/server-commands' |
13 | wait | ||
14 | } from '@shared/extra-utils' | ||
15 | import { HttpStatusCode, PluginType } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
@@ -99,9 +99,11 @@ describe('Test plugins', function () { | |||
99 | 99 | ||
100 | const theme = config.theme.registered.find(r => r.name === 'background-red') | 100 | const theme = config.theme.registered.find(r => r.name === 'background-red') |
101 | expect(theme).to.not.be.undefined | 101 | expect(theme).to.not.be.undefined |
102 | expect(theme.npmName).to.equal('peertube-theme-background-red') | ||
102 | 103 | ||
103 | const plugin = config.plugin.registered.find(r => r.name === 'hello-world') | 104 | const plugin = config.plugin.registered.find(r => r.name === 'hello-world') |
104 | expect(plugin).to.not.be.undefined | 105 | expect(plugin).to.not.be.undefined |
106 | expect(plugin.npmName).to.equal('peertube-plugin-hello-world') | ||
105 | }) | 107 | }) |
106 | 108 | ||
107 | it('Should update the default theme in the configuration', async function () { | 109 | it('Should update the default theme in the configuration', async function () { |
diff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.ts index 29f3e10d8..2a8ff56d2 100644 --- a/server/tests/api/server/proxy.ts +++ b/server/tests/api/server/proxy.ts | |||
@@ -2,18 +2,17 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FIXTURE_URLS, MockProxy } from '@server/tests/shared' | ||
6 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | FIXTURE_URLS, | ||
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { MockProxy } from '@shared/extra-utils/mock-servers/mock-proxy' | ||
16 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | ||
17 | 16 | ||
18 | const expect = chai.expect | 17 | const expect = chai.expect |
19 | 18 | ||
@@ -97,7 +96,7 @@ describe('Test proxy', function () { | |||
97 | } | 96 | } |
98 | 97 | ||
99 | it('Should succeed import with the appropriate proxy config', async function () { | 98 | it('Should succeed import with the appropriate proxy config', async function () { |
100 | this.timeout(40000) | 99 | this.timeout(120000) |
101 | 100 | ||
102 | await servers[0].kill() | 101 | await servers[0].kill() |
103 | await servers[0].run({}, { env: goodEnv }) | 102 | await servers[0].run({}, { env: goodEnv }) |
@@ -112,7 +111,7 @@ describe('Test proxy', function () { | |||
112 | }) | 111 | }) |
113 | 112 | ||
114 | it('Should fail import with a wrong proxy config', async function () { | 113 | it('Should fail import with a wrong proxy config', async function () { |
115 | this.timeout(40000) | 114 | this.timeout(120000) |
116 | 115 | ||
117 | await servers[0].kill() | 116 | await servers[0].kill() |
118 | await servers[0].run({}, { env: badEnv }) | 117 | await servers[0].run({}, { env: badEnv }) |
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts index 484f88d67..968d98e96 100644 --- a/server/tests/api/server/reverse-proxy.ts +++ b/server/tests/api/server/reverse-proxy.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' | 4 | import { wait } from '@shared/core-utils' |
5 | import { HttpStatusCode } from '@shared/models' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
6 | 7 | ||
7 | describe('Test application behind a reverse proxy', function () { | 8 | describe('Test application behind a reverse proxy', function () { |
8 | let server: PeerTubeServer | 9 | let server: PeerTubeServer |
diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts index 823630ae4..5fd2abda4 100644 --- a/server/tests/api/server/services.ts +++ b/server/tests/api/server/services.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils' | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' |
6 | import { Video, VideoPlaylistPrivacy } from '@shared/models' | 6 | import { Video, VideoPlaylistPrivacy } from '@shared/models' |
7 | 7 | ||
8 | const expect = chai.expect | 8 | const expect = chai.expect |
diff --git a/server/tests/api/server/slow-follows.ts b/server/tests/api/server/slow-follows.ts index 2bef0c9f2..666a7c2e6 100644 --- a/server/tests/api/server/slow-follows.ts +++ b/server/tests/api/server/slow-follows.ts | |||
@@ -2,8 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | ||
6 | import { Job } from '@shared/models' | 5 | import { Job } from '@shared/models' |
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index efc80463c..f0334532b 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { ActivityType, VideoPlaylistPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | import { ActivityType, VideoPlaylistPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts index 30a9618b3..712bb485f 100644 --- a/server/tests/api/server/tracker.ts +++ b/server/tests/api/server/tracker.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import magnetUtil from 'magnet-uri' | 4 | import magnetUtil from 'magnet-uri' |
5 | import WebTorrent from 'webtorrent' | 5 | import WebTorrent from 'webtorrent' |
6 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
7 | 7 | ||
8 | describe('Test tracker', function () { | 8 | describe('Test tracker', function () { |
9 | let server: PeerTubeServer | 9 | let server: PeerTubeServer |
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index d1d192238..57cca6ad4 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
@@ -10,7 +11,7 @@ import { | |||
10 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
11 | SubscriptionsCommand, | 12 | SubscriptionsCommand, |
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | 15 | ||
15 | const expect = chai.expect | 16 | const expect = chai.expect |
16 | 17 | ||
@@ -32,20 +33,18 @@ describe('Test users subscriptions', function () { | |||
32 | // Server 1 and server 2 follow each other | 33 | // Server 1 and server 2 follow each other |
33 | await doubleFollow(servers[0], servers[1]) | 34 | await doubleFollow(servers[0], servers[1]) |
34 | 35 | ||
35 | { | 36 | for (const server of servers) { |
36 | for (const server of servers) { | 37 | const user = { username: 'user' + server.serverNumber, password: 'password' } |
37 | const user = { username: 'user' + server.serverNumber, password: 'password' } | 38 | await server.users.create({ username: user.username, password: user.password }) |
38 | await server.users.create({ username: user.username, password: user.password }) | ||
39 | 39 | ||
40 | const accessToken = await server.login.getAccessToken(user) | 40 | const accessToken = await server.login.getAccessToken(user) |
41 | users.push({ accessToken }) | 41 | users.push({ accessToken }) |
42 | 42 | ||
43 | const videoName1 = 'video 1-' + server.serverNumber | 43 | const videoName1 = 'video 1-' + server.serverNumber |
44 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) | 44 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) |
45 | 45 | ||
46 | const videoName2 = 'video 2-' + server.serverNumber | 46 | const videoName2 = 'video 2-' + server.serverNumber |
47 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) | 47 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) |
48 | } | ||
49 | } | 48 | } |
50 | 49 | ||
51 | await waitJobs(servers) | 50 | await waitJobs(servers) |
@@ -540,6 +539,40 @@ describe('Test users subscriptions', function () { | |||
540 | } | 539 | } |
541 | }) | 540 | }) |
542 | 541 | ||
542 | it('Should update video as internal and not see from remote server', async function () { | ||
543 | this.timeout(30000) | ||
544 | |||
545 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) | ||
546 | await waitJobs(servers) | ||
547 | |||
548 | { | ||
549 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
550 | expect(data.find(v => v.name === 'internal')).to.not.exist | ||
551 | } | ||
552 | }) | ||
553 | |||
554 | it('Should see internal from local user', async function () { | ||
555 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
556 | expect(data.find(v => v.name === 'internal')).to.exist | ||
557 | }) | ||
558 | |||
559 | it('Should update video as private and not see from anyone server', async function () { | ||
560 | this.timeout(30000) | ||
561 | |||
562 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) | ||
563 | await waitJobs(servers) | ||
564 | |||
565 | { | ||
566 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
567 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
568 | } | ||
569 | |||
570 | { | ||
571 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
572 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
573 | } | ||
574 | }) | ||
575 | |||
543 | after(async function () { | 576 | after(async function () { |
544 | await cleanupTests(servers) | 577 | await cleanupTests(servers) |
545 | }) | 578 | }) |
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index d0ca82b07..5b2bbc520 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -6,16 +6,18 @@ import { | |||
6 | checkActorFilesWereRemoved, | 6 | checkActorFilesWereRemoved, |
7 | checkTmpIsEmpty, | 7 | checkTmpIsEmpty, |
8 | checkVideoFilesWereRemoved, | 8 | checkVideoFilesWereRemoved, |
9 | saveVideoInServers, | ||
10 | testImage | ||
11 | } from '@server/tests/shared' | ||
12 | import { MyUser } from '@shared/models' | ||
13 | import { | ||
9 | cleanupTests, | 14 | cleanupTests, |
10 | createMultipleServers, | 15 | createMultipleServers, |
11 | doubleFollow, | 16 | doubleFollow, |
12 | PeerTubeServer, | 17 | PeerTubeServer, |
13 | saveVideoInServers, | ||
14 | setAccessTokensToServers, | 18 | setAccessTokensToServers, |
15 | testImage, | ||
16 | waitJobs | 19 | waitJobs |
17 | } from '@shared/extra-utils' | 20 | } from '@shared/server-commands' |
18 | import { MyUser } from '@shared/models' | ||
19 | 21 | ||
20 | const expect = chai.expect | 22 | const expect = chai.expect |
21 | 23 | ||
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index f54463359..0f3cc401a 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 6c41e7d56..7023b3f08 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testImage } from '@server/tests/shared' | ||
6 | import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
@@ -9,10 +11,8 @@ import { | |||
9 | makePutBodyRequest, | 11 | makePutBodyRequest, |
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
12 | testImage, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
@@ -230,7 +230,7 @@ describe('Test users', function () { | |||
230 | }) | 230 | }) |
231 | 231 | ||
232 | it('Should have an expired access token', async function () { | 232 | it('Should have an expired access token', async function () { |
233 | this.timeout(15000) | 233 | this.timeout(60000) |
234 | 234 | ||
235 | await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString()) | 235 | await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString()) |
236 | await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString()) | 236 | await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString()) |
@@ -559,6 +559,28 @@ describe('Test users', function () { | |||
559 | expect(user.autoPlayNextVideo).to.be.true | 559 | expect(user.autoPlayNextVideo).to.be.true |
560 | }) | 560 | }) |
561 | 561 | ||
562 | it('Should be able to change the p2p attribute', async function () { | ||
563 | { | ||
564 | await server.users.updateMe({ | ||
565 | token: userToken, | ||
566 | webTorrentEnabled: false | ||
567 | }) | ||
568 | |||
569 | const user = await server.users.getMyInfo({ token: userToken }) | ||
570 | expect(user.p2pEnabled).to.be.false | ||
571 | } | ||
572 | |||
573 | { | ||
574 | await server.users.updateMe({ | ||
575 | token: userToken, | ||
576 | p2pEnabled: true | ||
577 | }) | ||
578 | |||
579 | const user = await server.users.getMyInfo({ token: userToken }) | ||
580 | expect(user.p2pEnabled).to.be.true | ||
581 | } | ||
582 | }) | ||
583 | |||
562 | it('Should be able to change the email attribute', async function () { | 584 | it('Should be able to change the email attribute', async function () { |
563 | await server.users.updateMe({ | 585 | await server.users.updateMe({ |
564 | token: userToken, | 586 | token: userToken, |
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index f4b635bd5..e58360ffe 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts | |||
@@ -3,7 +3,14 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' | 5 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' |
6 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 6 | import { |
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index c6c279064..ecdd36613 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -4,23 +4,24 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import request from 'supertest' | 5 | import request from 'supertest' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | ||
8 | checkTmpIsEmpty, | 7 | checkTmpIsEmpty, |
9 | checkVideoFilesWereRemoved, | 8 | checkVideoFilesWereRemoved, |
10 | cleanupTests, | ||
11 | completeVideoCheck, | 9 | completeVideoCheck, |
12 | createMultipleServers, | ||
13 | dateIsValid, | 10 | dateIsValid, |
11 | saveVideoInServers, | ||
12 | testImage | ||
13 | } from '@server/tests/shared' | ||
14 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' | ||
15 | import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models' | ||
16 | import { | ||
17 | cleanupTests, | ||
18 | createMultipleServers, | ||
14 | doubleFollow, | 19 | doubleFollow, |
15 | PeerTubeServer, | 20 | PeerTubeServer, |
16 | saveVideoInServers, | ||
17 | setAccessTokensToServers, | 21 | setAccessTokensToServers, |
18 | testImage, | ||
19 | wait, | ||
20 | waitJobs, | 22 | waitJobs, |
21 | webtorrentAdd | 23 | webtorrentAdd |
22 | } from '@shared/extra-utils' | 24 | } from '@shared/server-commands' |
23 | import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models' | ||
24 | 25 | ||
25 | const expect = chai.expect | 26 | const expect = chai.expect |
26 | 27 | ||
@@ -379,7 +380,7 @@ describe('Test multiple servers', function () { | |||
379 | 380 | ||
380 | describe('Should seed the uploaded video', function () { | 381 | describe('Should seed the uploaded video', function () { |
381 | it('Should add the file 1 by asking server 3', async function () { | 382 | it('Should add the file 1 by asking server 3', async function () { |
382 | this.timeout(10000) | 383 | this.timeout(30000) |
383 | 384 | ||
384 | const { data } = await servers[2].videos.list() | 385 | const { data } = await servers[2].videos.list() |
385 | 386 | ||
@@ -395,7 +396,7 @@ describe('Test multiple servers', function () { | |||
395 | }) | 396 | }) |
396 | 397 | ||
397 | it('Should add the file 2 by asking server 1', async function () { | 398 | it('Should add the file 2 by asking server 1', async function () { |
398 | this.timeout(10000) | 399 | this.timeout(30000) |
399 | 400 | ||
400 | const { data } = await servers[0].videos.list() | 401 | const { data } = await servers[0].videos.list() |
401 | 402 | ||
@@ -409,7 +410,7 @@ describe('Test multiple servers', function () { | |||
409 | }) | 410 | }) |
410 | 411 | ||
411 | it('Should add the file 3 by asking server 2', async function () { | 412 | it('Should add the file 3 by asking server 2', async function () { |
412 | this.timeout(10000) | 413 | this.timeout(30000) |
413 | 414 | ||
414 | const { data } = await servers[1].videos.list() | 415 | const { data } = await servers[1].videos.list() |
415 | 416 | ||
@@ -423,7 +424,7 @@ describe('Test multiple servers', function () { | |||
423 | }) | 424 | }) |
424 | 425 | ||
425 | it('Should add the file 3-2 by asking server 1', async function () { | 426 | it('Should add the file 3-2 by asking server 1', async function () { |
426 | this.timeout(10000) | 427 | this.timeout(30000) |
427 | 428 | ||
428 | const { data } = await servers[0].videos.list() | 429 | const { data } = await servers[0].videos.list() |
429 | 430 | ||
@@ -437,7 +438,7 @@ describe('Test multiple servers', function () { | |||
437 | }) | 438 | }) |
438 | 439 | ||
439 | it('Should add the file 2 in 360p by asking server 1', async function () { | 440 | it('Should add the file 2 in 360p by asking server 1', async function () { |
440 | this.timeout(10000) | 441 | this.timeout(30000) |
441 | 442 | ||
442 | const { data } = await servers[0].videos.list() | 443 | const { data } = await servers[0].videos.list() |
443 | 444 | ||
@@ -594,7 +595,7 @@ describe('Test multiple servers', function () { | |||
594 | let updatedAtMin: Date | 595 | let updatedAtMin: Date |
595 | 596 | ||
596 | it('Should update video 3', async function () { | 597 | it('Should update video 3', async function () { |
597 | this.timeout(10000) | 598 | this.timeout(30000) |
598 | 599 | ||
599 | const attributes = { | 600 | const attributes = { |
600 | name: 'my super video updated', | 601 | name: 'my super video updated', |
@@ -617,7 +618,7 @@ describe('Test multiple servers', function () { | |||
617 | }) | 618 | }) |
618 | 619 | ||
619 | it('Should have the video 3 updated on each server', async function () { | 620 | it('Should have the video 3 updated on each server', async function () { |
620 | this.timeout(10000) | 621 | this.timeout(30000) |
621 | 622 | ||
622 | for (const server of servers) { | 623 | for (const server of servers) { |
623 | const { data } = await server.videos.list() | 624 | const { data } = await server.videos.list() |
@@ -668,7 +669,7 @@ describe('Test multiple servers', function () { | |||
668 | }) | 669 | }) |
669 | 670 | ||
670 | it('Should only update thumbnail and update updatedAt attribute', async function () { | 671 | it('Should only update thumbnail and update updatedAt attribute', async function () { |
671 | this.timeout(10000) | 672 | this.timeout(30000) |
672 | 673 | ||
673 | const attributes = { | 674 | const attributes = { |
674 | thumbnailfile: 'thumbnail.jpg' | 675 | thumbnailfile: 'thumbnail.jpg' |
@@ -860,7 +861,7 @@ describe('Test multiple servers', function () { | |||
860 | }) | 861 | }) |
861 | 862 | ||
862 | it('Should delete a reply', async function () { | 863 | it('Should delete a reply', async function () { |
863 | this.timeout(10000) | 864 | this.timeout(30000) |
864 | 865 | ||
865 | await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) | 866 | await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) |
866 | 867 | ||
@@ -891,7 +892,7 @@ describe('Test multiple servers', function () { | |||
891 | }) | 892 | }) |
892 | 893 | ||
893 | it('Should delete the thread comments', async function () { | 894 | it('Should delete the thread comments', async function () { |
894 | this.timeout(10000) | 895 | this.timeout(30000) |
895 | 896 | ||
896 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) | 897 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) |
897 | const commentId = data.find(c => c.text === 'my super first comment').id | 898 | const commentId = data.find(c => c.text === 'my super first comment').id |
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index 1ba7cdbcc..d6f4da630 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts | |||
@@ -4,15 +4,9 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { pathExists, readdir, stat } from 'fs-extra' | 5 | import { pathExists, readdir, stat } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { | 7 | import { buildAbsoluteFixturePath } from '@shared/core-utils' |
8 | buildAbsoluteFixturePath, | ||
9 | cleanupTests, | ||
10 | createSingleServer, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers, | ||
13 | setDefaultVideoChannel | ||
14 | } from '@shared/extra-utils' | ||
15 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | 8 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
9 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' | ||
16 | 10 | ||
17 | const expect = chai.expect | 11 | const expect = chai.expect |
18 | 12 | ||
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index a0e4a156c..28bf018c5 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -2,17 +2,10 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { checkVideoFilesWereRemoved, completeVideoCheck, testImage } from '@server/tests/shared' |
6 | checkVideoFilesWereRemoved, | 6 | import { wait } from '@shared/core-utils' |
7 | cleanupTests, | ||
8 | completeVideoCheck, | ||
9 | createSingleServer, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | testImage, | ||
13 | wait | ||
14 | } from '@shared/extra-utils' | ||
15 | import { Video, VideoPrivacy } from '@shared/models' | 7 | import { Video, VideoPrivacy } from '@shared/models' |
8 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
16 | 9 | ||
17 | const expect = chai.expect | 10 | const expect = chai.expect |
18 | 11 | ||
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 3bb0d131c..b7f26c35f 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts | |||
@@ -2,17 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { checkVideoFilesWereRemoved, testCaptionFile } from '@server/tests/shared' | ||
6 | import { wait } from '@shared/core-utils' | ||
5 | import { | 7 | import { |
6 | checkVideoFilesWereRemoved, | ||
7 | cleanupTests, | 8 | cleanupTests, |
8 | createMultipleServers, | 9 | createMultipleServers, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | testCaptionFile, | ||
13 | wait, | ||
14 | waitJobs | 13 | waitJobs |
15 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
16 | 15 | ||
17 | const expect = chai.expect | 16 | const expect = chai.expect |
18 | 17 | ||
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index d6665fe4e..6c229c6cf 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
14 | waitJobs | 14 | waitJobs |
15 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | 16 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
17 | 17 | ||
18 | const expect = chai.expect | 18 | const expect = chai.expect |
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index c25754eb6..d435f3682 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -4,6 +4,9 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename } from 'path' | 5 | import { basename } from 'path' |
6 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' | 6 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' |
7 | import { testFileExistsOrNot, testImage } from '@server/tests/shared' | ||
8 | import { wait } from '@shared/core-utils' | ||
9 | import { User, VideoChannel } from '@shared/models' | ||
7 | import { | 10 | import { |
8 | cleanupTests, | 11 | cleanupTests, |
9 | createMultipleServers, | 12 | createMultipleServers, |
@@ -11,12 +14,8 @@ import { | |||
11 | PeerTubeServer, | 14 | PeerTubeServer, |
12 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 16 | setDefaultVideoChannel, |
14 | testFileExistsOrNot, | ||
15 | testImage, | ||
16 | wait, | ||
17 | waitJobs | 17 | waitJobs |
18 | } from '@shared/extra-utils' | 18 | } from '@shared/server-commands' |
19 | import { User, VideoChannel } from '@shared/models' | ||
20 | 19 | ||
21 | const expect = chai.expect | 20 | const expect = chai.expect |
22 | 21 | ||
@@ -33,6 +32,7 @@ describe('Test video channels', function () { | |||
33 | let totoChannel: number | 32 | let totoChannel: number |
34 | let videoUUID: string | 33 | let videoUUID: string |
35 | let accountName: string | 34 | let accountName: string |
35 | let secondUserChannelName: string | ||
36 | 36 | ||
37 | const avatarPaths: { [ port: number ]: string } = {} | 37 | const avatarPaths: { [ port: number ]: string } = {} |
38 | const bannerPaths: { [ port: number ]: string } = {} | 38 | const bannerPaths: { [ port: number ]: string } = {} |
@@ -219,6 +219,35 @@ describe('Test video channels', function () { | |||
219 | } | 219 | } |
220 | }) | 220 | }) |
221 | 221 | ||
222 | it('Should update another accounts video channel', async function () { | ||
223 | this.timeout(15000) | ||
224 | |||
225 | const result = await servers[0].users.generate('second_user') | ||
226 | secondUserChannelName = result.userChannelName | ||
227 | |||
228 | await servers[0].videos.quickUpload({ name: 'video', token: result.token }) | ||
229 | |||
230 | const videoChannelAttributes = { | ||
231 | displayName: 'video channel updated', | ||
232 | description: 'video channel description updated', | ||
233 | support: 'support updated' | ||
234 | } | ||
235 | |||
236 | await servers[0].channels.update({ channelName: secondUserChannelName, attributes: videoChannelAttributes }) | ||
237 | |||
238 | await waitJobs(servers) | ||
239 | }) | ||
240 | |||
241 | it('Should have another accounts video channel updated', async function () { | ||
242 | for (const server of servers) { | ||
243 | const body = await server.channels.get({ channelName: `${secondUserChannelName}@${servers[0].host}` }) | ||
244 | |||
245 | expect(body.displayName).to.equal('video channel updated') | ||
246 | expect(body.description).to.equal('video channel description updated') | ||
247 | expect(body.support).to.equal('support updated') | ||
248 | } | ||
249 | }) | ||
250 | |||
222 | it('Should update the channel support field and update videos too', async function () { | 251 | it('Should update the channel support field and update videos too', async function () { |
223 | this.timeout(35000) | 252 | this.timeout(35000) |
224 | 253 | ||
@@ -368,12 +397,13 @@ describe('Test video channels', function () { | |||
368 | }) | 397 | }) |
369 | 398 | ||
370 | it('Should have video channel deleted', async function () { | 399 | it('Should have video channel deleted', async function () { |
371 | const body = await servers[0].channels.list({ start: 0, count: 10 }) | 400 | const body = await servers[0].channels.list({ start: 0, count: 10, sort: 'createdAt' }) |
372 | 401 | ||
373 | expect(body.total).to.equal(1) | 402 | expect(body.total).to.equal(2) |
374 | expect(body.data).to.be.an('array') | 403 | expect(body.data).to.be.an('array') |
375 | expect(body.data).to.have.lengthOf(1) | 404 | expect(body.data).to.have.lengthOf(2) |
376 | expect(body.data[0].displayName).to.equal('Main root channel') | 405 | expect(body.data[0].displayName).to.equal('Main root channel') |
406 | expect(body.data[1].displayName).to.equal('video channel updated') | ||
377 | }) | 407 | }) |
378 | 408 | ||
379 | it('Should create the main channel with an uuid if there is a conflict', async function () { | 409 | it('Should create the main channel with an uuid if there is a conflict', async function () { |
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 61ee54540..2ae523970 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts | |||
@@ -2,15 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { dateIsValid, testImage } from '@server/tests/shared' |
6 | cleanupTests, | 6 | import { cleanupTests, CommentsCommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
7 | CommentsCommand, | ||
8 | createSingleServer, | ||
9 | dateIsValid, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | testImage | ||
13 | } from '@shared/extra-utils' | ||
14 | 7 | ||
15 | const expect = chai.expect | 8 | const expect = chai.expect |
16 | 9 | ||
diff --git a/server/tests/api/videos/video-create-transcoding.ts b/server/tests/api/videos/video-create-transcoding.ts index c4627e0c1..62a6bab0d 100644 --- a/server/tests/api/videos/video-create-transcoding.ts +++ b/server/tests/api/videos/video-create-transcoding.ts | |||
@@ -2,20 +2,20 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { expectStartWith } from '@server/tests/shared' | ||
6 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | ||
7 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
5 | import { | 8 | import { |
6 | areObjectStorageTestsDisabled, | ||
7 | cleanupTests, | 9 | cleanupTests, |
8 | createMultipleServers, | 10 | createMultipleServers, |
9 | doubleFollow, | 11 | doubleFollow, |
10 | expectNoFailedTranscodingJob, | 12 | expectNoFailedTranscodingJob, |
11 | expectStartWith, | ||
12 | makeRawRequest, | 13 | makeRawRequest, |
13 | ObjectStorageCommand, | 14 | ObjectStorageCommand, |
14 | PeerTubeServer, | 15 | PeerTubeServer, |
15 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
16 | waitJobs | 17 | waitJobs |
17 | } from '@shared/extra-utils' | 18 | } from '@shared/server-commands' |
18 | import { HttpStatusCode, VideoDetails } from '@shared/models' | ||
19 | 19 | ||
20 | const expect = chai.expect | 20 | const expect = chai.expect |
21 | 21 | ||
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts index d22b4ed96..20b20488f 100644 --- a/server/tests/api/videos/video-description.ts +++ b/server/tests/api/videos/video-description.ts | |||
@@ -2,7 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | const expect = chai.expect | 14 | const expect = chai.expect |
8 | 15 | ||
diff --git a/server/tests/api/videos/video-files.ts b/server/tests/api/videos/video-files.ts index fcb2ca2e4..b0ef4a2e9 100644 --- a/server/tests/api/videos/video-files.ts +++ b/server/tests/api/videos/video-files.ts | |||
@@ -2,7 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
6 | 13 | ||
7 | describe('Test videos files', function () { | 14 | describe('Test videos files', function () { |
8 | let servers: PeerTubeServer[] | 15 | let servers: PeerTubeServer[] |
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index a18c3d672..218ec08ae 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -3,26 +3,27 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils' | ||
7 | import { | 6 | import { |
8 | areObjectStorageTestsDisabled, | ||
9 | checkDirectoryIsEmpty, | 7 | checkDirectoryIsEmpty, |
10 | checkResolutionsInMasterPlaylist, | 8 | checkResolutionsInMasterPlaylist, |
11 | checkSegmentHash, | 9 | checkSegmentHash, |
12 | checkTmpIsEmpty, | 10 | checkTmpIsEmpty, |
11 | expectStartWith, | ||
12 | hlsInfohashExist | ||
13 | } from '@server/tests/shared' | ||
14 | import { areObjectStorageTestsDisabled, removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils' | ||
15 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' | ||
16 | import { | ||
13 | cleanupTests, | 17 | cleanupTests, |
14 | createMultipleServers, | 18 | createMultipleServers, |
15 | doubleFollow, | 19 | doubleFollow, |
16 | expectStartWith, | ||
17 | hlsInfohashExist, | ||
18 | makeRawRequest, | 20 | makeRawRequest, |
19 | ObjectStorageCommand, | 21 | ObjectStorageCommand, |
20 | PeerTubeServer, | 22 | PeerTubeServer, |
21 | setAccessTokensToServers, | 23 | setAccessTokensToServers, |
22 | waitJobs, | 24 | waitJobs, |
23 | webtorrentAdd | 25 | webtorrentAdd |
24 | } from '@shared/extra-utils' | 26 | } from '@shared/server-commands' |
25 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' | ||
26 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | 27 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' |
27 | 28 | ||
28 | const expect = chai.expect | 29 | const expect = chai.expect |
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index b6168b54e..e8e0f01f1 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -4,21 +4,19 @@ import 'mocha' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists, readdir, remove } from 'fs-extra' | 5 | import { pathExists, readdir, remove } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared' | ||
8 | import { areHttpImportTestsDisabled } from '@shared/core-utils' | ||
9 | import { VideoPrivacy, VideoResolution } from '@shared/models' | ||
7 | import { | 10 | import { |
8 | areHttpImportTestsDisabled, | ||
9 | cleanupTests, | 11 | cleanupTests, |
10 | createMultipleServers, | 12 | createMultipleServers, |
11 | createSingleServer, | 13 | createSingleServer, |
12 | doubleFollow, | 14 | doubleFollow, |
13 | FIXTURE_URLS, | ||
14 | PeerTubeServer, | 15 | PeerTubeServer, |
15 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
16 | setDefaultVideoChannel, | 17 | setDefaultVideoChannel, |
17 | testCaptionFile, | ||
18 | testImage, | ||
19 | waitJobs | 18 | waitJobs |
20 | } from '@shared/extra-utils' | 19 | } from '@shared/server-commands' |
21 | import { VideoPrivacy, VideoResolution } from '@shared/models' | ||
22 | 20 | ||
23 | async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { | 21 | async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { |
24 | const videoHttp = await server.videos.get({ id: idHttp }) | 22 | const videoHttp = await server.videos.get({ id: idHttp }) |
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index b5d183d62..99ea67a0f 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
6 | import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models' | 6 | import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models' |
7 | 7 | ||
8 | const expect = chai.expect | 8 | const expect = chai.expect |
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts index f0b2ca169..5fdb0fc03 100644 --- a/server/tests/api/videos/video-playlist-thumbnails.ts +++ b/server/tests/api/videos/video-playlist-thumbnails.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testImage } from '@server/tests/shared' | ||
6 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
@@ -9,10 +11,8 @@ import { | |||
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
12 | testImage, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '../../../../shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index f42aee2ff..34327334f 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -2,19 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { checkPlaylistFilesWereRemoved, testImage } from '@server/tests/shared' |
6 | checkPlaylistFilesWereRemoved, | 6 | import { wait } from '@shared/core-utils' |
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | PeerTubeServer, | ||
11 | PlaylistsCommand, | ||
12 | setAccessTokensToServers, | ||
13 | setDefaultVideoChannel, | ||
14 | testImage, | ||
15 | wait, | ||
16 | waitJobs | ||
17 | } from '@shared/extra-utils' | ||
18 | import { | 7 | import { |
19 | HttpStatusCode, | 8 | HttpStatusCode, |
20 | VideoPlaylist, | 9 | VideoPlaylist, |
@@ -24,6 +13,16 @@ import { | |||
24 | VideoPlaylistType, | 13 | VideoPlaylistType, |
25 | VideoPrivacy | 14 | VideoPrivacy |
26 | } from '@shared/models' | 15 | } from '@shared/models' |
16 | import { | ||
17 | cleanupTests, | ||
18 | createMultipleServers, | ||
19 | doubleFollow, | ||
20 | PeerTubeServer, | ||
21 | PlaylistsCommand, | ||
22 | setAccessTokensToServers, | ||
23 | setDefaultVideoChannel, | ||
24 | waitJobs | ||
25 | } from '@shared/server-commands' | ||
27 | 26 | ||
28 | const expect = chai.expect | 27 | const expect = chai.expect |
29 | 28 | ||
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index b51b3bcdd..3051a443d 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { wait } from '@shared/core-utils' |
6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | 6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
@@ -209,7 +210,7 @@ describe('Test video privacy', function () { | |||
209 | describe('Privacy update', function () { | 210 | describe('Privacy update', function () { |
210 | 211 | ||
211 | it('Should update the private and internal videos to public on server 1', async function () { | 212 | it('Should update the private and internal videos to public on server 1', async function () { |
212 | this.timeout(10000) | 213 | this.timeout(100000) |
213 | 214 | ||
214 | now = Date.now() | 215 | now = Date.now() |
215 | 216 | ||
@@ -230,6 +231,7 @@ describe('Test video privacy', function () { | |||
230 | await servers[0].videos.update({ id: internalVideoId, attributes }) | 231 | await servers[0].videos.update({ id: internalVideoId, attributes }) |
231 | } | 232 | } |
232 | 233 | ||
234 | await wait(10000) | ||
233 | await waitJobs(servers) | 235 | await waitJobs(servers) |
234 | }) | 236 | }) |
235 | 237 | ||
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index 3f7738784..00b4f6cbc 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createMultipleServers, | 9 | createMultipleServers, |
8 | doubleFollow, | 10 | doubleFollow, |
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
11 | wait, | ||
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | import { VideoPrivacy } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 7ed55b8e8..d24a8f4e1 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -3,29 +3,21 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' | 6 | import { canDoQuickTranscode } from '@server/helpers/ffprobe-utils' |
7 | import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared' | ||
8 | import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' | ||
9 | import { getAudioStream, getMetadataFromFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils' | ||
10 | import { HttpStatusCode, VideoState } from '@shared/models' | ||
7 | import { | 11 | import { |
8 | buildAbsoluteFixturePath, | ||
9 | cleanupTests, | 12 | cleanupTests, |
10 | createMultipleServers, | 13 | createMultipleServers, |
11 | doubleFollow, | 14 | doubleFollow, |
12 | generateHighBitrateVideo, | ||
13 | generateVideoWithFramerate, | ||
14 | makeGetRequest, | 15 | makeGetRequest, |
15 | PeerTubeServer, | 16 | PeerTubeServer, |
16 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
17 | waitJobs, | 18 | waitJobs, |
18 | webtorrentAdd | 19 | webtorrentAdd |
19 | } from '@shared/extra-utils' | 20 | } from '@shared/server-commands' |
20 | import { HttpStatusCode, VideoState } from '@shared/models' | ||
21 | import { | ||
22 | canDoQuickTranscode, | ||
23 | getAudioStream, | ||
24 | getMetadataFromFile, | ||
25 | getVideoFileBitrate, | ||
26 | getVideoFileFPS, | ||
27 | getVideoFileResolution | ||
28 | } from '../../../helpers/ffprobe-utils' | ||
29 | 21 | ||
30 | const expect = chai.expect | 22 | const expect = chai.expect |
31 | 23 | ||
diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.ts index ca5f42173..0254662c5 100644 --- a/server/tests/api/videos/videos-common-filters.ts +++ b/server/tests/api/videos/videos-common-filters.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
14 | waitJobs | 14 | waitJobs |
15 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
16 | import { HttpStatusCode, UserRole, Video, VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' | 16 | import { HttpStatusCode, UserRole, Video, VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' |
17 | 17 | ||
18 | describe('Test videos filter', function () { | 18 | describe('Test videos filter', function () { |
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index e4bc0bb3a..4e5ba13aa 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, Video } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | HistoryCommand, | 10 | HistoryCommand, |
9 | killallServers, | 11 | killallServers, |
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
12 | wait | 14 | } from '@shared/server-commands' |
13 | } from '@shared/extra-utils' | ||
14 | import { HttpStatusCode, Video } from '@shared/models' | ||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 70aa66549..61fc0cb20 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' | 5 | import { wait } from '@shared/core-utils' |
6 | import { VideosOverview } from '@shared/models' | 6 | import { VideosOverview } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index 82268b1be..e6815a4a8 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
@@ -9,9 +10,8 @@ import { | |||
9 | killallServers, | 10 | killallServers, |
10 | PeerTubeServer, | 11 | PeerTubeServer, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | wait, | ||
13 | waitJobs | 13 | waitJobs |
14 | } from '../../../../shared/extra-utils' | 14 | } from '@shared/server-commands' |
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||