]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/user-notifications.ts
Introduce channels command
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / user-notifications.ts
index 15be983f290b8f77603b94d61946731e8a71e23b..1d159c48f41b1e792736ddb3c69ee7665bedcb1c 100644 (file)
@@ -11,17 +11,16 @@ import {
   checkVideoIsPublished,
   cleanupTests,
   getLastNotification,
+  ImportsCommand,
   MockSmtpServer,
   prepareNotificationsTest,
   ServerInfo,
   updateMyUser,
   updateVideo,
-  updateVideoChannel,
   uploadRandomVideoOnServers,
   wait,
   waitJobs
 } from '@shared/extra-utils'
-import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports'
 import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'
 
 const expect = chai.expect
@@ -209,14 +208,13 @@ describe('Test user notifications', function () {
         name,
         channelId,
         privacy: VideoPrivacy.PUBLIC,
-        targetUrl: getGoodVideoUrl()
+        targetUrl: ImportsCommand.getGoodVideoUrl()
       }
-      const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
-      const uuid = res.body.video.uuid
+      const { video } = await servers[0].importsCommand.importVideo({ attributes })
 
       await waitJobs(servers)
 
-      await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
+      await checkNewVideoFromSubscription(baseParams, name, video.uuid, 'presence')
     })
   })
 
@@ -280,14 +278,13 @@ describe('Test user notifications', function () {
         name,
         channelId,
         privacy: VideoPrivacy.PUBLIC,
-        targetUrl: getGoodVideoUrl(),
+        targetUrl: ImportsCommand.getGoodVideoUrl(),
         waitTranscoding: true
       }
-      const res = await importVideo(servers[1].url, servers[1].accessToken, attributes)
-      const uuid = res.body.video.uuid
+      const { video } = await servers[1].importsCommand.importVideo({ attributes })
 
       await waitJobs(servers)
-      await checkVideoIsPublished(baseParams, name, uuid, 'presence')
+      await checkVideoIsPublished(baseParams, name, video.uuid, 'presence')
     })
 
     it('Should send a notification when the scheduled update has been proceeded', async function () {
@@ -349,13 +346,12 @@ describe('Test user notifications', function () {
         name,
         channelId,
         privacy: VideoPrivacy.PRIVATE,
-        targetUrl: getBadVideoUrl()
+        targetUrl: ImportsCommand.getBadVideoUrl()
       }
-      const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
-      const uuid = res.body.video.uuid
+      const { video } = await servers[0].importsCommand.importVideo({ attributes })
 
       await waitJobs(servers)
-      await checkMyVideoImportIsFinished(baseParams, name, uuid, getBadVideoUrl(), false, 'presence')
+      await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
     })
 
     it('Should send a notification when the video import succeeded', async function () {
@@ -367,13 +363,12 @@ describe('Test user notifications', function () {
         name,
         channelId,
         privacy: VideoPrivacy.PRIVATE,
-        targetUrl: getGoodVideoUrl()
+        targetUrl: ImportsCommand.getGoodVideoUrl()
       }
-      const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
-      const uuid = res.body.video.uuid
+      const { video } = await servers[0].importsCommand.importVideo({ attributes })
 
       await waitJobs(servers)
-      await checkMyVideoImportIsFinished(baseParams, name, uuid, getGoodVideoUrl(), true, 'presence')
+      await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
     })
   })
 
@@ -408,7 +403,11 @@ describe('Test user notifications', function () {
         displayName: 'super root 2 name'
       })
 
-      await updateVideoChannel(servers[0].url, userAccessToken, 'user_1_channel', { displayName: myChannelName })
+      await servers[0].channelsCommand.update({
+        token: userAccessToken,
+        channelName: 'user_1_channel',
+        attributes: { displayName: myChannelName }
+      })
     })
 
     it('Should notify when a local channel is following one of our channel', async function () {