]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/activitypub/refresher.ts
Introduce playlist command
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / refresher.ts
index c717f1a307676ce0b0fecd90b43dc9d3aa24df2d..f295dfab76a4e879d52e90fa5e8d93740e679971 100644 (file)
@@ -1,14 +1,14 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
-  cleanupTests, closeAllSequelize,
-  createVideoPlaylist,
+  cleanupTests,
+  closeAllSequelize,
   doubleFollow,
   flushAndRunMultipleServers,
   generateUserAccessToken,
   getVideo,
-  getVideoPlaylist,
   killallServers,
   reRunServer,
   ServerInfo,
@@ -21,10 +21,8 @@ import {
   uploadVideoAndGetId,
   wait,
   waitJobs
-} from '../../../../shared/extra-utils'
-import { getAccount } from '../../../../shared/extra-utils/users/accounts'
-import { VideoPlaylistPrivacy } from '../../../../shared/models/videos'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { VideoPlaylistPrivacy } from '@shared/models'
 
 describe('Test AP refresher', function () {
   let servers: ServerInfo[] = []
@@ -58,15 +56,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])
@@ -116,19 +114,21 @@ describe('Test AP refresher', function () {
     it('Should remove a deleted actor', async function () {
       this.timeout(60000)
 
+      const command = servers[0].accountsCommand
+
       await wait(10000)
 
       // 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 getAccount(servers[0].url, 'user1@localhost:' + servers[1].port)
-      await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port)
+      await command.get({ accountName: 'user1@localhost:' + servers[1].port })
+      await command.get({ accountName: 'user2@localhost:' + servers[1].port })
 
       await waitJobs(servers)
 
-      await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, HttpStatusCode.OK_200)
-      await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, HttpStatusCode.NOT_FOUND_404)
+      await command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.OK_200 })
+      await command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
     })
   })
 
@@ -142,13 +142,13 @@ describe('Test AP refresher', function () {
       // Change UUID so the remote server returns a 404
       await setPlaylistField(servers[1].internalServerNumber, 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 })
     })
   })