X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fnotifications%2Fmoderation-notifications.ts;h=fa75182e15c42d9d5d581573cde3e9fdf9230e9c;hb=9d1e41e8bbd9afd961f2dd48c791a3be114e878d;hp=e6e1d5f7b4c306bc4b55e51c57c9d2be904b706e;hpb=c55e3d7227fe1453869e309025996b9d75256d5d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index e6e1d5f7b..fa75182e1 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' import { checkAbuseStateChange, checkAutoInstanceFollowing, @@ -12,14 +11,14 @@ import { checkNewInstanceFollower, checkNewVideoAbuseForModerators, checkNewVideoFromSubscription, - checkUserRegistered, checkVideoAutoBlacklistForModerators, checkVideoIsPublished, MockInstancesIndex, MockSmtpServer, prepareNotificationsTest } from '@server/tests/shared' -import { buildUUID, wait } from '@shared/core-utils' +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' @@ -34,7 +33,7 @@ describe('Test moderation notifications', function () { let emails: object[] = [] before(async function () { - this.timeout(120000) + this.timeout(50000) const res = await prepareNotificationsTest(3) emails = res.emails @@ -60,7 +59,7 @@ describe('Test moderation notifications', function () { }) it('Should not send a notification to moderators on local abuse reported by an admin', async function () { - this.timeout(20000) + this.timeout(50000) const name = 'video for abuse ' + buildUUID() const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -72,7 +71,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators on local video abuse', async function () { - this.timeout(20000) + this.timeout(50000) const name = 'video for abuse ' + buildUUID() const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -84,7 +83,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators on remote video abuse', async function () { - this.timeout(20000) + this.timeout(50000) const name = 'video for abuse ' + buildUUID() const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -99,7 +98,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators on local comment abuse', async function () { - this.timeout(20000) + this.timeout(50000) const name = 'video for abuse ' + buildUUID() const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -118,7 +117,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators on remote comment abuse', async function () { - this.timeout(20000) + this.timeout(50000) const name = 'video for abuse ' + buildUUID() const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -140,7 +139,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators on local account abuse', async function () { - this.timeout(20000) + this.timeout(50000) const username = 'user' + new Date().getTime() const { account } = await servers[0].users.create({ username, password: 'donald' }) @@ -153,7 +152,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators on remote account abuse', async function () { - this.timeout(20000) + this.timeout(50000) const username = 'user' + new Date().getTime() const tmpToken = await servers[0].users.generateUserAndToken(username) @@ -189,7 +188,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to reporter if the abuse has been accepted', async function () { - this.timeout(10000) + this.timeout(30000) await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } }) await waitJobs(servers) @@ -198,7 +197,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to reporter if the abuse has been rejected', async function () { - this.timeout(10000) + this.timeout(30000) await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } }) await waitJobs(servers) @@ -243,7 +242,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to reporter on new message', async function () { - this.timeout(10000) + this.timeout(30000) const message = 'my super message to users' await servers[0].abuses.addMessage({ abuseId, message }) @@ -253,7 +252,7 @@ describe('Test moderation notifications', function () { }) it('Should not send a notification to the admin if sent by the admin', async function () { - this.timeout(10000) + this.timeout(30000) const message = 'my super message that should not be sent to the admin' await servers[0].abuses.addMessage({ abuseId, message }) @@ -264,7 +263,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to moderators', async function () { - this.timeout(10000) + this.timeout(30000) const message = 'my super message to moderators' await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message }) @@ -275,7 +274,7 @@ describe('Test moderation notifications', function () { }) it('Should not send a notification to reporter if sent by the reporter', async function () { - this.timeout(10000) + this.timeout(30000) const message = 'my super message that should not be sent to reporter' await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message }) @@ -299,7 +298,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to video owner on blacklist', async function () { - this.timeout(10000) + this.timeout(30000) const name = 'video for abuse ' + buildUUID() const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -311,7 +310,7 @@ describe('Test moderation notifications', function () { }) it('Should send a notification to video owner on unblacklist', async function () { - this.timeout(10000) + this.timeout(30000) const name = 'video for abuse ' + buildUUID() const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) @@ -327,32 +326,6 @@ describe('Test moderation notifications', function () { }) }) - describe('New registration', function () { - let baseParams: CheckerBaseParams - - before(() => { - baseParams = { - server: servers[0], - emails, - socketNotifications: adminNotifications, - token: servers[0].accessToken - } - }) - - it('Should send a notification only to moderators when a user registers on the instance', async function () { - this.timeout(10000) - - await servers[0].users.register({ username: 'user_45' }) - - await waitJobs(servers) - - await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' }) - - const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } - await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' }) - }) - }) - describe('New instance follows', function () { const instanceIndexServer = new MockInstancesIndex() let config: any @@ -373,7 +346,7 @@ describe('Test moderation notifications', function () { followings: { instance: { autoFollowIndex: { - indexUrl: `http://localhost:${port}/api/v1/instances/hosts`, + indexUrl: `http://127.0.0.1:${port}/api/v1/instances/hosts`, enabled: true } } @@ -382,16 +355,16 @@ describe('Test moderation notifications', function () { }) 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 () { @@ -495,8 +468,8 @@ describe('Test moderation notifications', 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 () { @@ -512,10 +485,14 @@ describe('Test moderation notifications', function () { }) it('Should not send video publish notification if auto-blacklisted', async function () { + this.timeout(120000) + await checkVideoIsPublished({ ...userBaseParams, videoName, shortUUID, checkType: 'absence' }) }) it('Should not send a local user subscription notification if auto-blacklisted', async function () { + this.timeout(120000) + await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName, shortUUID, checkType: 'absence' }) }) @@ -524,7 +501,7 @@ describe('Test moderation notifications', function () { }) it('Should send video published and unblacklist after video unblacklisted', async function () { - this.timeout(40000) + this.timeout(120000) await servers[0].blacklist.remove({ videoId: uuid }) @@ -537,15 +514,19 @@ describe('Test moderation notifications', function () { }) it('Should send a local user subscription notification after removed from blacklist', async function () { + this.timeout(120000) + await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName, shortUUID, checkType: 'presence' }) }) it('Should send a remote user subscription notification after removed from blacklist', async function () { + this.timeout(120000) + await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName, shortUUID, checkType: 'presence' }) }) 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) @@ -576,7 +557,7 @@ describe('Test moderation notifications', function () { }) it('Should not send publish/subscription notifications after scheduled update if video still auto-blacklisted', async function () { - this.timeout(40000) + this.timeout(120000) // In 2 seconds const updateAt = new Date(new Date().getTime() + 2000) @@ -601,7 +582,7 @@ describe('Test moderation notifications', function () { }) 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() @@ -615,8 +596,8 @@ describe('Test moderation notifications', function () { 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 }) }) })