]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/activitypub/refresher.ts
Introduce server commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / refresher.ts
index 0d5452ea43c2108d9ad81e9794320ba80477531b..af919f2f35d2f78d827ef056b38da9e1ea6484e8 100644 (file)
@@ -4,21 +4,15 @@ import 'mocha'
 import { HttpStatusCode } from '@shared/core-utils'
 import {
   cleanupTests,
-  closeAllSequelize,
-  createVideoPlaylist,
   doubleFollow,
   flushAndRunMultipleServers,
   generateUserAccessToken,
   getVideo,
-  getVideoPlaylist,
   killallServers,
   reRunServer,
   ServerInfo,
   setAccessTokensToServers,
-  setActorField,
   setDefaultVideoChannel,
-  setPlaylistField,
-  setVideoField,
   uploadVideo,
   uploadVideoAndGetId,
   wait,
@@ -58,15 +52,15 @@ describe('Test AP refresher', function () {
     }
 
     {
-      const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
-      const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
-      playlistUUID1 = res.body.videoPlaylist.uuid
+      const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
+      const created = await servers[1].playlistsCommand.create({ attributes })
+      playlistUUID1 = created.uuid
     }
 
     {
-      const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
-      const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
-      playlistUUID2 = res.body.videoPlaylist.uuid
+      const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
+      const created = await servers[1].playlistsCommand.create({ attributes })
+      playlistUUID2 = created.uuid
     }
 
     await doubleFollow(servers[0], servers[1])
@@ -80,7 +74,7 @@ describe('Test AP refresher', function () {
       await wait(10000)
 
       // Change UUID so the remote server returns a 404
-      await setVideoField(servers[1].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
+      await servers[1].sqlCommand.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
 
       await getVideo(servers[0].url, videoUUID1)
       await getVideo(servers[0].url, videoUUID2)
@@ -94,9 +88,9 @@ describe('Test AP refresher', function () {
     it('Should not update a remote video if the remote instance is down', async function () {
       this.timeout(70000)
 
-      killallServers([ servers[1] ])
+      await killallServers([ servers[1] ])
 
-      await setVideoField(servers[1].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
+      await servers[1].sqlCommand.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
 
       // Video will need a refresh
       await wait(10000)
@@ -122,7 +116,7 @@ describe('Test AP refresher', function () {
 
       // Change actor name so the remote server returns a 404
       const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
-      await setActorField(servers[1].internalServerNumber, to, 'preferredUsername', 'toto')
+      await servers[1].sqlCommand.setActorField(to, 'preferredUsername', 'toto')
 
       await command.get({ accountName: 'user1@localhost:' + servers[1].port })
       await command.get({ accountName: 'user2@localhost:' + servers[1].port })
@@ -142,15 +136,15 @@ describe('Test AP refresher', function () {
       await wait(10000)
 
       // Change UUID so the remote server returns a 404
-      await setPlaylistField(servers[1].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
+      await servers[1].sqlCommand.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
 
-      await getVideoPlaylist(servers[0].url, playlistUUID1)
-      await getVideoPlaylist(servers[0].url, playlistUUID2)
+      await servers[0].playlistsCommand.get({ playlistId: playlistUUID1 })
+      await servers[0].playlistsCommand.get({ playlistId: playlistUUID2 })
 
       await waitJobs(servers)
 
-      await getVideoPlaylist(servers[0].url, playlistUUID1, HttpStatusCode.OK_200)
-      await getVideoPlaylist(servers[0].url, playlistUUID2, HttpStatusCode.NOT_FOUND_404)
+      await servers[0].playlistsCommand.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
+      await servers[0].playlistsCommand.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
     })
   })
 
@@ -158,7 +152,5 @@ describe('Test AP refresher', function () {
     this.timeout(10000)
 
     await cleanupTests(servers)
-
-    await closeAllSequelize(servers)
   })
 })