/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
-import { buildUUID } from '@shared/core-utils/uuid'
import {
checkAbuseStateChange,
checkAutoInstanceFollowing,
checkUserRegistered,
checkVideoAutoBlacklistForModerators,
checkVideoIsPublished,
- cleanupTests,
MockInstancesIndex,
MockSmtpServer,
- PeerTubeServer,
- prepareNotificationsTest,
- wait,
- waitJobs
-} from '@shared/server-commands'
+ prepareNotificationsTest
+} from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { buildUUID } from '@shared/extra-utils'
import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models'
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
describe('Test moderation notifications', function () {
let servers: PeerTubeServer[] = []
followings: {
instance: {
autoFollowIndex: {
- indexUrl: `http://localhost:${port}/api/v1/instances/hosts`,
+ indexUrl: `http://127.0.0.1:${port}/api/v1/instances/hosts`,
enabled: true
}
}
})
it('Should send a notification only to admin when there is a new instance follower', async function () {
- this.timeout(20000)
+ this.timeout(60000)
await servers[2].follows.follow({ hosts: [ servers[0].url ] })
await waitJobs(servers)
- await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' })
+ await checkNewInstanceFollower({ ...baseParams, followerHost: servers[2].host, checkType: 'presence' })
const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } }
- await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' })
+ await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: servers[2].host, checkType: 'absence' })
})
it('Should send a notification on auto follow back', async function () {
autoBlacklistTestsCustomConfig.transcoding.enabled = true
await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
- await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
- await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host })
+ await servers[1].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host })
})
it('Should send notification to moderators on new video with auto-blacklist', async function () {
})
it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
- this.timeout(40000)
+ this.timeout(120000)
const updateAt = new Date(new Date().getTime() + 1000000)
})
it('Should not send a notification to moderators on new video without auto-blacklist', async function () {
- this.timeout(60000)
+ this.timeout(120000)
const name = 'video without auto-blacklist ' + buildUUID()
after(async () => {
await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig })
- await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
- await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host })
+ await servers[1].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host })
})
})