X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fshared%2Fnotifications.ts;h=f1ddbbbf74de4ead7d01a75e777c77edef54ea57;hb=1808a1f8e4b7b102823492a2007a46929aebf189;hp=78d3787f06b9d5c76454927479f8803594850128;hpb=28dca0a2211524bbf3ad17666c607eb6325763b8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/shared/notifications.ts b/server/tests/shared/notifications.ts index 78d3787f0..f1ddbbbf7 100644 --- a/server/tests/shared/notifications.ts +++ b/server/tests/shared/notifications.ts @@ -47,6 +47,7 @@ function getAllNotificationsSettings (): UserNotificationSetting { abuseStateChange: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, autoInstanceFollowing: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, newPeerTubeVersion: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, + myVideoEditionFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, newPluginVersion: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL } } @@ -109,6 +110,34 @@ async function checkVideoIsPublished (options: CheckerBaseParams & { await checkNotification({ ...options, notificationChecker, emailNotificationFinder }) } +async function checkVideoEditionIsFinished (options: CheckerBaseParams & { + videoName: string + shortUUID: string + checkType: CheckerType +}) { + const { videoName, shortUUID } = options + const notificationType = UserNotificationType.MY_VIDEO_EDITION_FINISHED + + function notificationChecker (notification: UserNotification, checkType: CheckerType) { + if (checkType === 'presence') { + expect(notification).to.not.be.undefined + expect(notification.type).to.equal(notificationType) + + checkVideo(notification.video, videoName, shortUUID) + checkActor(notification.video.channel) + } else { + expect(notification.video).to.satisfy(v => v === undefined || v.name !== videoName) + } + } + + function emailNotificationFinder (email: object) { + const text: string = email['text'] + return text.includes(shortUUID) && text.includes('Edition of your video') + } + + await checkNotification({ ...options, notificationChecker, emailNotificationFinder }) +} + async function checkMyVideoImportIsFinished (options: CheckerBaseParams & { videoName: string shortUUID: string @@ -656,6 +685,8 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an await setDefaultChannelAvatar(servers) await setDefaultAccountAvatar(servers) + await servers[1].config.enableEditor() + if (serversCount > 1) { await doubleFollow(servers[0], servers[1]) } @@ -724,7 +755,8 @@ export { checkNewCommentAbuseForModerators, checkNewAccountAbuseForModerators, checkNewPeerTubeVersion, - checkNewPluginVersion + checkNewPluginVersion, + checkVideoEditionIsFinished } // ---------------------------------------------------------------------------