]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/shared/notifications.ts
Add video edition finished notification
[github/Chocobozzz/PeerTube.git] / server / tests / shared / notifications.ts
index 78d3787f06b9d5c76454927479f8803594850128..f1ddbbbf74de4ead7d01a75e777c77edef54ea57 100644 (file)
@@ -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
 }
 
 // ---------------------------------------------------------------------------