]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users.ts
Introduce channels command
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users.ts
index 6bfc7cfe53a1792a7380b414a156e405571a1d66..ed670b3c9270f03baa1e330d72e7638019485a63 100644 (file)
@@ -11,10 +11,6 @@ import {
   createUser,
   deleteMe,
   flushAndRunServer,
-  follow,
-  getAccountRatings,
-  getBlacklistedVideosList,
-  getCustomConfig,
   getMyUserInformation,
   getMyUserVideoQuotaUsed,
   getMyUserVideoRating,
@@ -22,9 +18,7 @@ import {
   getUserInformation,
   getUsersList,
   getUsersListPaginationAndSort,
-  getVideoChannel,
   getVideosList,
-  installPlugin,
   killallServers,
   login,
   logout,
@@ -40,7 +34,6 @@ import {
   setTokenField,
   testImage,
   unblockUser,
-  updateCustomSubConfig,
   updateMyAvatar,
   updateMyUser,
   updateUser,
@@ -48,7 +41,7 @@ import {
   userLogin,
   waitJobs
 } from '@shared/extra-utils'
-import { AbuseState, CustomConfig, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
+import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
 
 const expect = chai.expect
 
@@ -76,7 +69,7 @@ describe('Test users', function () {
 
     await setAccessTokensToServers([ server ])
 
-    await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-theme-background-red' })
+    await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
   })
 
   describe('OAuth client', function () {
@@ -138,7 +131,12 @@ describe('Test users', function () {
 
     it('Should not be able to follow', async function () {
       accessToken = 'my_super_token'
-      await follow(server.url, [ 'http://example.com' ], accessToken, HttpStatusCode.UNAUTHORIZED_401)
+
+      await server.followsCommand.follow({
+        targets: [ 'http://example.com' ],
+        token: accessToken,
+        expectedStatus: HttpStatusCode.UNAUTHORIZED_401
+      })
     })
 
     it('Should not be able to unfollow')
@@ -193,25 +191,22 @@ describe('Test users', function () {
     it('Should retrieve ratings list', async function () {
       await rateVideo(server.url, accessToken, videoId, 'like')
 
-      const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, HttpStatusCode.OK_200)
-      const ratings = res.body
+      const body = await server.accountsCommand.listRatings({ accountName: server.user.username })
 
-      expect(ratings.total).to.equal(1)
-      expect(ratings.data[0].video.id).to.equal(videoId)
-      expect(ratings.data[0].rating).to.equal('like')
+      expect(body.total).to.equal(1)
+      expect(body.data[0].video.id).to.equal(videoId)
+      expect(body.data[0].rating).to.equal('like')
     })
 
     it('Should retrieve ratings list by rating type', async function () {
       {
-        const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like')
-        const ratings = res.body
-        expect(ratings.data.length).to.equal(1)
+        const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'like' })
+        expect(body.data.length).to.equal(1)
       }
 
       {
-        const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike')
-        const ratings = res.body
-        expect(ratings.data.length).to.equal(0)
+        const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'dislike' })
+        expect(body.data.length).to.equal(0)
       }
     })
   })
@@ -415,12 +410,11 @@ describe('Test users', function () {
       this.timeout(60000)
 
       {
-        const res = await getCustomConfig(server.url, server.accessToken)
-        const config = res.body as CustomConfig
+        const config = await server.configCommand.getCustomConfig()
         config.transcoding.webtorrent.enabled = false
         config.transcoding.hls.enabled = true
         config.transcoding.enabled = true
-        await updateCustomSubConfig(server.url, server.accessToken, config)
+        await server.configCommand.updateCustomSubConfig({ newConfig: config })
       }
 
       {
@@ -812,7 +806,7 @@ describe('Test users', function () {
 
   describe('Video blacklists', function () {
     it('Should be able to list video blacklist by a moderator', async function () {
-      await getBlacklistedVideosList({ url: server.url, token: accessTokenUser })
+      await server.blacklistCommand.list({ token: accessTokenUser })
     })
   })
 
@@ -869,9 +863,9 @@ describe('Test users', function () {
     })
 
     it('Should have created the channel', async function () {
-      const res = await getVideoChannel(server.url, 'my_user_15_channel')
+      const { displayName } = await server.channelsCommand.get({ channelName: 'my_user_15_channel' })
 
-      expect(res.body.displayName).to.equal('my channel rocks')
+      expect(displayName).to.equal('my channel rocks')
     })
 
     it('Should remove me', async function () {