]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users.ts
Introduce comments command
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users.ts
index 33bcc8701eccf717585ac3ed2109d762f306631e..4d255f3409de4a7487442907ca8d20146246bc20 100644 (file)
@@ -4,15 +4,12 @@ import 'mocha'
 import * as chai from 'chai'
 import { HttpStatusCode } from '@shared/core-utils'
 import {
-  addVideoCommentThread,
   blockUser,
   cleanupTests,
   closeAllSequelize,
   createUser,
   deleteMe,
   flushAndRunServer,
-  getAccountRatings,
-  getBlacklistedVideosList,
   getMyUserInformation,
   getMyUserVideoQuotaUsed,
   getMyUserVideoRating,
@@ -20,7 +17,6 @@ import {
   getUserInformation,
   getUsersList,
   getUsersListPaginationAndSort,
-  getVideoChannel,
   getVideosList,
   killallServers,
   login,
@@ -194,25 +190,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)
       }
     })
   })
@@ -812,7 +805,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 +862,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 () {
@@ -989,7 +982,7 @@ describe('Test users', function () {
 
     it('Should report correct video comments for user', async function () {
       const text = 'super comment'
-      await addVideoCommentThread(server.url, user17AccessToken, videoId, text)
+      await server.commentsCommand.createThread({ token: user17AccessToken, videoId, text })
 
       const res = await getUserInformation(server.url, server.accessToken, user17Id, true)
       const user: User = res.body