]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/user-subscriptions.ts
Merge branch 'master' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / user-subscriptions.ts
index cb7d94b0b9aff80a983cc93f83626c672945802e..48811e647d172606b4db54aee8fce30270dd8212 100644 (file)
@@ -2,18 +2,28 @@
 
 import * as chai from 'chai'
 import 'mocha'
-import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, updateVideo, userLogin } from '../../utils'
-import { killallServers, ServerInfo, uploadVideo } from '../../utils/index'
-import { setAccessTokensToServers } from '../../utils/users/login'
+import {
+  cleanupTests,
+  createUser,
+  doubleFollow,
+  flushAndRunMultipleServers,
+  follow,
+  getVideosList,
+  unfollow,
+  updateVideo,
+  userLogin
+} from '../../../../shared/extra-utils'
+import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
+import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
 import { Video, VideoChannel } from '../../../../shared/models/videos'
-import { waitJobs } from '../../utils/server/jobs'
+import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
 import {
   addUserSubscription,
   listUserSubscriptions,
   listUserSubscriptionVideos,
   removeUserSubscription,
-  getUserSubscription
-} from '../../utils/users/user-subscriptions'
+  getUserSubscription, areSubscriptionsExist
+} from '../../../../shared/extra-utils/users/user-subscriptions'
 
 const expect = chai.expect
 
@@ -36,7 +46,7 @@ describe('Test users subscriptions', function () {
     {
       for (const server of servers) {
         const user = { username: 'user' + server.serverNumber, password: 'password' }
-        await createUser(server.url, server.accessToken, user.username, user.password)
+        await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
 
         const accessToken = await userLogin(server, user)
         users.push({ accessToken })
@@ -128,6 +138,23 @@ describe('Test users subscriptions', function () {
     }
   })
 
+  it('Should return the existing subscriptions', async function () {
+    const uris = [
+      'user3_channel@localhost:9003',
+      'root2_channel@localhost:9001',
+      'root_channel@localhost:9001',
+      'user3_channel@localhost:9001'
+    ]
+
+    const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)
+    const body = res.body
+
+    expect(body['user3_channel@localhost:9003']).to.be.true
+    expect(body['root2_channel@localhost:9001']).to.be.false
+    expect(body['root_channel@localhost:9001']).to.be.true
+    expect(body['user3_channel@localhost:9001']).to.be.false
+  })
+
   it('Should list subscription videos', async function () {
     {
       const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken)
@@ -343,6 +370,6 @@ describe('Test users subscriptions', function () {
   })
 
   after(async function () {
-    killallServers(servers)
+    await cleanupTests(servers)
   })
 })