aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications/moderation-notifications.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-15 13:52:27 +0200
committerChocobozzz <me@florianbigard.com>2021-04-15 13:52:27 +0200
commitf6500729850549e632399155d0f3b69822e28b16 (patch)
tree7ca40188e38b0281f538c4cddf79ea633745cc4a /server/tests/api/notifications/moderation-notifications.ts
parentf1ac63488c0050fec1c4d713d74db4f4ea944395 (diff)
downloadPeerTube-f6500729850549e632399155d0f3b69822e28b16.tar.gz
PeerTube-f6500729850549e632399155d0f3b69822e28b16.tar.zst
PeerTube-f6500729850549e632399155d0f3b69822e28b16.zip
More robust tests
Diffstat (limited to 'server/tests/api/notifications/moderation-notifications.ts')
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts39
1 files changed, 20 insertions, 19 deletions
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
3import 'mocha' 3import 'mocha'
4import { v4 as uuidv4 } from 'uuid' 4import { v4 as uuidv4 } from 'uuid'
5 5import { AbuseState } from '@shared/models'
6import { 6import {
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'
29import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' 29import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
30import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 30import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
31import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 31import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
32import { 32import {
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'
48import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' 48import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions'
49import { CustomConfig } from '../../../../shared/models/server' 49import { CustomConfig } from '../../../../shared/models/server'
50import { UserNotification } from '../../../../shared/models/users' 50import { UserNotification } from '../../../../shared/models/users'
51import { VideoPrivacy } from '../../../../shared/models/videos' 51import { VideoPrivacy } from '../../../../shared/models/videos'
52import { AbuseState } from '@shared/models'
53 52
54describe('Test moderation notifications', function () { 53describe('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 () {