]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/video-comments.ts
Introduce login command
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-comments.ts
index a38420851f8d109b394898a7ad9539755b69a1c4..c21aebaaea92762e34e075bce9b423ed005e76e9 100644 (file)
@@ -2,9 +2,11 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { VideoCreateResult } from '@shared/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
+  checkBadCountPagination,
+  checkBadSortPagination,
+  checkBadStartPagination,
   cleanupTests,
   createUser,
   flushAndRunServer,
@@ -13,15 +15,9 @@ import {
   makePostBodyRequest,
   ServerInfo,
   setAccessTokensToServers,
-  uploadVideo,
-  userLogin
-} from '../../../../shared/extra-utils'
-import {
-  checkBadCountPagination,
-  checkBadSortPagination,
-  checkBadStartPagination
-} from '../../../../shared/extra-utils/requests/check-api-params'
-import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
+  uploadVideo
+} from '@shared/extra-utils'
+import { VideoCreateResult } from '@shared/models'
 
 const expect = chai.expect
 
@@ -50,21 +46,21 @@ describe('Test video comments API validator', function () {
     }
 
     {
-      const res = await addVideoCommentThread(server.url, server.accessToken, video.uuid, 'coucou')
-      commentId = res.body.comment.id
+      const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'coucou' })
+      commentId = created.id
       pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
     }
 
     {
       const user = { username: 'user1', password: 'my super password' }
       await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
-      userAccessToken = await userLogin(server, user)
+      userAccessToken = await server.loginCommand.getAccessToken(user)
     }
 
     {
       const user = { username: 'user2', password: 'my super password' }
       await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
-      userAccessToken2 = await userLogin(server, user)
+      userAccessToken2 = await server.loginCommand.getAccessToken(user)
     }
   })
 
@@ -281,8 +277,8 @@ describe('Test video comments API validator', function () {
       let commentToDelete: number
 
       {
-        const res = await addVideoCommentThread(server.url, userAccessToken, video.uuid, 'hello')
-        commentToDelete = res.body.comment.id
+        const created = await server.commentsCommand.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
+        commentToDelete = created.id
       }
 
       const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
@@ -301,8 +297,8 @@ describe('Test video comments API validator', function () {
       }
 
       {
-        const res = await addVideoCommentThread(server.url, server.accessToken, anotherVideoUUID, 'hello')
-        commentToDelete = res.body.comment.id
+        const created = await server.commentsCommand.createThread({ videoId: anotherVideoUUID, text: 'hello' })
+        commentToDelete = created.id
       }
 
       const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete