]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/feeds/feeds.ts
Introduce channels command
[github/Chocobozzz/PeerTube.git] / server / tests / feeds / feeds.ts
index 4d29a2e391ccc5f166bb0a798628e7284f22a6c3..6ee22340b1b353c4ed527d540908403fa7f6de73 100644 (file)
@@ -3,16 +3,9 @@
 import 'mocha'
 import * as chai from 'chai'
 import * as xmlParser from 'fast-xml-parser'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
-  addAccountToAccountBlocklist,
-  addAccountToServerBlocklist,
-  removeAccountFromServerBlocklist
-} from '@shared/extra-utils/users/blocklist'
-import { addUserSubscription, listUserSubscriptionVideos } from '@shared/extra-utils/users/user-subscriptions'
-import { VideoPrivacy } from '@shared/models'
-import { ScopedToken } from '@shared/models/users/user-scoped-token'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-import {
+  addVideoCommentThread,
   cleanupTests,
   createUser,
   doubleFollow,
@@ -25,11 +18,11 @@ import {
   setAccessTokensToServers,
   uploadVideo,
   uploadVideoAndGetId,
-  userLogin
-} from '../../../shared/extra-utils'
-import { waitJobs } from '../../../shared/extra-utils/server/jobs'
-import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
-import { User } from '../../../shared/models/users'
+  userLogin,
+  waitJobs
+} from '@shared/extra-utils'
+import { User, VideoPrivacy } from '@shared/models'
+import { ScopedToken } from '@shared/models/users/user-scoped-token'
 
 chai.use(require('chai-xml'))
 chai.use(require('chai-json-schema'))
@@ -271,7 +264,7 @@ describe('Test syndication feeds', () => {
 
       const remoteHandle = 'root@localhost:' + servers[0].port
 
-      await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
+      await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle })
 
       {
         const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } })
@@ -279,7 +272,7 @@ describe('Test syndication feeds', () => {
         expect(jsonObj.items.length).to.be.equal(0)
       }
 
-      await removeAccountFromServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
+      await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle })
 
       {
         const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })).uuid
@@ -292,7 +285,7 @@ describe('Test syndication feeds', () => {
         expect(jsonObj.items.length).to.be.equal(3)
       }
 
-      await addAccountToAccountBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
+      await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle })
 
       {
         const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } })
@@ -324,8 +317,8 @@ describe('Test syndication feeds', () => {
       }
 
       {
-        const res = await listUserSubscriptionVideos(servers[0].url, feeduserAccessToken)
-        expect(res.body.total).to.equal(0)
+        const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken })
+        expect(body.total).to.equal(0)
 
         const query = { accountId: feeduserAccountId, token: feeduserFeedToken }
         const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
@@ -345,8 +338,8 @@ describe('Test syndication feeds', () => {
     })
 
     it('Should list no videos for a user with videos but no subscriptions', async function () {
-      const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken)
-      expect(res.body.total).to.equal(0)
+      const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+      expect(body.total).to.equal(0)
 
       const query = { accountId: userAccountId, token: userFeedToken }
       const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
@@ -357,13 +350,13 @@ describe('Test syndication feeds', () => {
     it('Should list self videos for a user with a subscription to themselves', async function () {
       this.timeout(30000)
 
-      await addUserSubscription(servers[0].url, userAccessToken, 'john_channel@localhost:' + servers[0].port)
+      await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port })
       await waitJobs(servers)
 
       {
-        const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken)
-        expect(res.body.total).to.equal(1)
-        expect(res.body.data[0].name).to.equal('user video')
+        const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+        expect(body.total).to.equal(1)
+        expect(body.data[0].name).to.equal('user video')
 
         const query = { accountId: userAccountId, token: userFeedToken, version: 1 }
         const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
@@ -375,12 +368,12 @@ describe('Test syndication feeds', () => {
     it('Should list videos of a user\'s subscription', async function () {
       this.timeout(30000)
 
-      await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port)
+      await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
       await waitJobs(servers)
 
       {
-        const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken)
-        expect(res.body.total).to.equal(2, "there should be 2 videos part of the subscription")
+        const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+        expect(body.total).to.equal(2, "there should be 2 videos part of the subscription")
 
         const query = { accountId: userAccountId, token: userFeedToken, version: 2 }
         const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })