diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/notifications/admin-notifications.ts | 10 | ||||
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 39 | ||||
-rw-r--r-- | server/tests/api/server/auto-follows.ts | 7 |
3 files changed, 29 insertions, 27 deletions
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index e07327d74..cfe0bd2bb 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { MockJoinPeerTubeVersions } from '@shared/extra-utils/mock-servers/joinpeertube-versions' | 5 | import { MockJoinPeerTubeVersions } from '@shared/extra-utils/mock-servers/joinpeertube-versions' |
6 | import { PluginType } from '@shared/models' | ||
6 | import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils' | 7 | import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils' |
7 | import { ServerInfo } from '../../../../shared/extra-utils/index' | 8 | import { ServerInfo } from '../../../../shared/extra-utils/index' |
8 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' | 9 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' |
@@ -13,7 +14,6 @@ import { | |||
13 | prepareNotificationsTest | 14 | prepareNotificationsTest |
14 | } from '../../../../shared/extra-utils/users/user-notifications' | 15 | } from '../../../../shared/extra-utils/users/user-notifications' |
15 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' | 16 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' |
16 | import { PluginType } from '@shared/models' | ||
17 | 17 | ||
18 | describe('Test admin notifications', function () { | 18 | describe('Test admin notifications', function () { |
19 | let server: ServerInfo | 19 | let server: ServerInfo |
@@ -26,11 +26,14 @@ describe('Test admin notifications', function () { | |||
26 | before(async function () { | 26 | before(async function () { |
27 | this.timeout(120000) | 27 | this.timeout(120000) |
28 | 28 | ||
29 | joinPeerTubeServer = new MockJoinPeerTubeVersions() | ||
30 | const port = await joinPeerTubeServer.initialize() | ||
31 | |||
29 | const config = { | 32 | const config = { |
30 | peertube: { | 33 | peertube: { |
31 | check_latest_version: { | 34 | check_latest_version: { |
32 | enabled: true, | 35 | enabled: true, |
33 | url: 'http://localhost:42102/versions.json' | 36 | url: `http://localhost:${port}/versions.json` |
34 | } | 37 | } |
35 | }, | 38 | }, |
36 | plugins: { | 39 | plugins: { |
@@ -66,9 +69,6 @@ describe('Test admin notifications', function () { | |||
66 | accessToken: server.accessToken, | 69 | accessToken: server.accessToken, |
67 | npmName: 'peertube-theme-background-red' | 70 | npmName: 'peertube-theme-background-red' |
68 | }) | 71 | }) |
69 | |||
70 | joinPeerTubeServer = new MockJoinPeerTubeVersions() | ||
71 | await joinPeerTubeServer.initialize() | ||
72 | }) | 72 | }) |
73 | 73 | ||
74 | describe('Latest PeerTube version notification', function () { | 74 | describe('Latest PeerTube version notification', function () { |
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 4c00d97f8..4ce6675b6 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { v4 as uuidv4 } from 'uuid' | 4 | import { v4 as uuidv4 } from 'uuid' |
5 | 5 | import { AbuseState } from '@shared/models' | |
6 | import { | 6 | import { |
7 | addAbuseMessage, | ||
7 | addVideoCommentThread, | 8 | addVideoCommentThread, |
8 | addVideoToBlacklist, | 9 | addVideoToBlacklist, |
9 | cleanupTests, | 10 | cleanupTests, |
@@ -20,18 +21,19 @@ import { | |||
20 | removeVideoFromBlacklist, | 21 | removeVideoFromBlacklist, |
21 | reportAbuse, | 22 | reportAbuse, |
22 | unfollow, | 23 | unfollow, |
24 | updateAbuse, | ||
23 | updateCustomConfig, | 25 | updateCustomConfig, |
24 | updateCustomSubConfig, | 26 | updateCustomSubConfig, |
25 | wait, | 27 | wait |
26 | updateAbuse, | ||
27 | addAbuseMessage | ||
28 | } from '../../../../shared/extra-utils' | 28 | } from '../../../../shared/extra-utils' |
29 | import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' | 29 | import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' |
30 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' | 30 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' |
31 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 31 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
32 | import { | 32 | import { |
33 | checkAbuseStateChange, | ||
33 | checkAutoInstanceFollowing, | 34 | checkAutoInstanceFollowing, |
34 | CheckerBaseParams, | 35 | CheckerBaseParams, |
36 | checkNewAbuseMessage, | ||
35 | checkNewAccountAbuseForModerators, | 37 | checkNewAccountAbuseForModerators, |
36 | checkNewBlacklistOnMyVideo, | 38 | checkNewBlacklistOnMyVideo, |
37 | checkNewCommentAbuseForModerators, | 39 | checkNewCommentAbuseForModerators, |
@@ -41,15 +43,12 @@ import { | |||
41 | checkUserRegistered, | 43 | checkUserRegistered, |
42 | checkVideoAutoBlacklistForModerators, | 44 | checkVideoAutoBlacklistForModerators, |
43 | checkVideoIsPublished, | 45 | checkVideoIsPublished, |
44 | prepareNotificationsTest, | 46 | prepareNotificationsTest |
45 | checkAbuseStateChange, | ||
46 | checkNewAbuseMessage | ||
47 | } from '../../../../shared/extra-utils/users/user-notifications' | 47 | } from '../../../../shared/extra-utils/users/user-notifications' |
48 | import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' | 48 | import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' |
49 | import { CustomConfig } from '../../../../shared/models/server' | 49 | import { CustomConfig } from '../../../../shared/models/server' |
50 | import { UserNotification } from '../../../../shared/models/users' | 50 | import { UserNotification } from '../../../../shared/models/users' |
51 | import { VideoPrivacy } from '../../../../shared/models/videos' | 51 | import { VideoPrivacy } from '../../../../shared/models/videos' |
52 | import { AbuseState } from '@shared/models' | ||
53 | 52 | ||
54 | describe('Test moderation notifications', function () { | 53 | describe('Test moderation notifications', function () { |
55 | let servers: ServerInfo[] = [] | 54 | let servers: ServerInfo[] = [] |
@@ -364,16 +363,7 @@ describe('Test moderation notifications', function () { | |||
364 | 363 | ||
365 | describe('New instance follows', function () { | 364 | describe('New instance follows', function () { |
366 | const instanceIndexServer = new MockInstancesIndex() | 365 | const instanceIndexServer = new MockInstancesIndex() |
367 | const config = { | 366 | let config: any |
368 | followings: { | ||
369 | instance: { | ||
370 | autoFollowIndex: { | ||
371 | indexUrl: 'http://localhost:42101/api/v1/instances/hosts', | ||
372 | enabled: true | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | } | ||
377 | let baseParams: CheckerBaseParams | 367 | let baseParams: CheckerBaseParams |
378 | 368 | ||
379 | before(async () => { | 369 | before(async () => { |
@@ -384,8 +374,19 @@ describe('Test moderation notifications', function () { | |||
384 | token: servers[0].accessToken | 374 | token: servers[0].accessToken |
385 | } | 375 | } |
386 | 376 | ||
387 | await instanceIndexServer.initialize() | 377 | const port = await instanceIndexServer.initialize() |
388 | instanceIndexServer.addInstance(servers[1].host) | 378 | instanceIndexServer.addInstance(servers[1].host) |
379 | |||
380 | config = { | ||
381 | followings: { | ||
382 | instance: { | ||
383 | autoFollowIndex: { | ||
384 | indexUrl: `http://localhost:${port}/api/v1/instances/hosts`, | ||
385 | enabled: true | ||
386 | } | ||
387 | } | ||
388 | } | ||
389 | } | ||
389 | }) | 390 | }) |
390 | 391 | ||
391 | it('Should send a notification only to admin when there is a new instance follower', async function () { | 392 | it('Should send a notification only to admin when there is a new instance follower', async function () { |
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts index e04d70af4..1519b263f 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/server/tests/api/server/auto-follows.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 * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { | 5 | import { |
6 | acceptFollower, | 6 | acceptFollower, |
7 | cleanupTests, | 7 | cleanupTests, |
@@ -153,9 +153,10 @@ describe('Test auto follows', function () { | |||
153 | 153 | ||
154 | describe('Auto follow index', function () { | 154 | describe('Auto follow index', function () { |
155 | const instanceIndexServer = new MockInstancesIndex() | 155 | const instanceIndexServer = new MockInstancesIndex() |
156 | let port: number | ||
156 | 157 | ||
157 | before(async () => { | 158 | before(async () => { |
158 | await instanceIndexServer.initialize() | 159 | port = await instanceIndexServer.initialize() |
159 | }) | 160 | }) |
160 | 161 | ||
161 | it('Should not auto follow index if the option is not enabled', async function () { | 162 | it('Should not auto follow index if the option is not enabled', async function () { |
@@ -177,7 +178,7 @@ describe('Test auto follows', function () { | |||
177 | followings: { | 178 | followings: { |
178 | instance: { | 179 | instance: { |
179 | autoFollowIndex: { | 180 | autoFollowIndex: { |
180 | indexUrl: 'http://localhost:42101/api/v1/instances/hosts', | 181 | indexUrl: `http://localhost:${port}/api/v1/instances/hosts`, |
181 | enabled: true | 182 | enabled: true |
182 | } | 183 | } |
183 | } | 184 | } |