]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/video-imports.ts
Centralize test URLs
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-imports.ts
index 51260affab3de43f7be9d24af2f225a777968585..0209275ac8116a0f3154a4e645aa688e43b22e37 100644 (file)
@@ -9,21 +9,19 @@ import {
   checkBadSortPagination,
   checkBadStartPagination,
   cleanupTests,
-  createUser,
-  flushAndRunServer,
-  getMyUserInformation,
-  ImportsCommand,
+  createSingleServer,
+  FIXTURE_URLS,
   makeGetRequest,
   makePostBodyRequest,
   makeUploadRequest,
-  ServerInfo,
+  PeerTubeServer,
   setAccessTokensToServers
 } from '@shared/extra-utils'
 import { VideoPrivacy } from '@shared/models'
 
 describe('Test video imports API validator', function () {
   const path = '/api/v1/videos/imports'
-  let server: ServerInfo
+  let server: PeerTubeServer
   let userAccessToken = ''
   let channelId: number
 
@@ -32,18 +30,18 @@ describe('Test video imports API validator', function () {
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
 
     await setAccessTokensToServers([ server ])
 
     const username = 'user1'
     const password = 'my super password'
-    await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
-    userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+    await server.users.create({ username: username, password: password })
+    userAccessToken = await server.login.getAccessToken({ username, password })
 
     {
-      const res = await getMyUserInformation(server.url, server.accessToken)
-      channelId = res.body.videoChannels[0].id
+      const { videoChannels } = await server.users.getMyInfo()
+      channelId = videoChannels[0].id
     }
   })
 
@@ -72,7 +70,7 @@ describe('Test video imports API validator', function () {
 
     before(function () {
       baseCorrectParams = {
-        targetUrl: ImportsCommand.getGoodVideoUrl(),
+        targetUrl: FIXTURE_URLS.goodVideo,
         name: 'my super name',
         category: 5,
         licence: 1,
@@ -164,11 +162,11 @@ describe('Test video imports API validator', function () {
         username: 'fake',
         password: 'fake_password'
       }
-      await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
+      await server.users.create({ username: user.username, password: user.password })
 
-      const accessTokenUser = await server.loginCommand.getAccessToken(user)
-      const res = await getMyUserInformation(server.url, accessTokenUser)
-      const customChannelId = res.body.videoChannels[0].id
+      const accessTokenUser = await server.login.getAccessToken(user)
+      const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
+      const customChannelId = videoChannels[0].id
 
       const fields = { ...baseCorrectParams, channelId: customChannelId }
 
@@ -258,7 +256,7 @@ describe('Test video imports API validator', function () {
     })
 
     it('Should forbid to import http videos', async function () {
-      await server.configCommand.updateCustomSubConfig({
+      await server.config.updateCustomSubConfig({
         newConfig: {
           import: {
             videos: {
@@ -283,7 +281,7 @@ describe('Test video imports API validator', function () {
     })
 
     it('Should forbid to import torrent videos', async function () {
-      await server.configCommand.updateCustomSubConfig({
+      await server.config.updateCustomSubConfig({
         newConfig: {
           import: {
             videos: {
@@ -299,7 +297,7 @@ describe('Test video imports API validator', function () {
       })
 
       let fields = omit(baseCorrectParams, 'targetUrl')
-      fields = { ...fields, magnetUri: ImportsCommand.getMagnetURI() }
+      fields = { ...fields, magnetUri: FIXTURE_URLS.magnet }
 
       await makePostBodyRequest({
         url: server.url,