]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/reverse-proxy.ts
Fix dependency errors between modules
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / reverse-proxy.ts
index 4c2655f64215726408c6e75cf257d33039bd8363..d4c08c3467c82115a64f787ae72fe856a9f6998b 100644 (file)
@@ -4,7 +4,18 @@ import 'mocha'
 import * as chai from 'chai'
 import { About } from '../../../../shared/models/server/about.model'
 import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
-import { deleteCustomConfig, getAbout, getVideo, killallServers, login, reRunServer, uploadVideo, userLogin, viewVideo } from '../../utils'
+import {
+  deleteCustomConfig,
+  getAbout,
+  getVideo,
+  killallServers,
+  login,
+  reRunServer,
+  uploadVideo,
+  userLogin,
+  viewVideo,
+  wait
+} from '../../../../shared/utils'
 const expect = chai.expect
 
 import {
@@ -12,7 +23,7 @@ import {
   flushTests,
   runServer,
   registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig
-} from '../../utils/index'
+} from '../../../../shared/utils/index'
 
 describe('Test application behind a reverse proxy', function () {
   let server = null
@@ -30,33 +41,53 @@ describe('Test application behind a reverse proxy', function () {
   })
 
   it('Should view a video only once with the same IP by default', async function () {
+    this.timeout(20000)
+
     await viewVideo(server.url, videoId)
     await viewVideo(server.url, videoId)
 
+    // Wait the repeatable job
+    await wait(8000)
+
     const { body } = await getVideo(server.url, videoId)
     expect(body.views).to.equal(1)
   })
 
   it('Should view a video 2 times with the X-Forwarded-For header set', async function () {
+    this.timeout(20000)
+
     await viewVideo(server.url, videoId, 204, '0.0.0.1,127.0.0.1')
     await viewVideo(server.url, videoId, 204, '0.0.0.2,127.0.0.1')
 
+    // Wait the repeatable job
+    await wait(8000)
+
     const { body } = await getVideo(server.url, videoId)
     expect(body.views).to.equal(3)
   })
 
   it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () {
+    this.timeout(20000)
+
     await viewVideo(server.url, videoId, 204, '0.0.0.4,0.0.0.3,::ffff:127.0.0.1')
     await viewVideo(server.url, videoId, 204, '0.0.0.5,0.0.0.3,127.0.0.1')
 
+    // Wait the repeatable job
+    await wait(8000)
+
     const { body } = await getVideo(server.url, videoId)
     expect(body.views).to.equal(4)
   })
 
   it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () {
+    this.timeout(20000)
+
     await viewVideo(server.url, videoId, 204, '0.0.0.8,0.0.0.6,127.0.0.1')
     await viewVideo(server.url, videoId, 204, '0.0.0.8,0.0.0.7,127.0.0.1')
 
+    // Wait the repeatable job
+    await wait(8000)
+
     const { body } = await getVideo(server.url, videoId)
     expect(body.views).to.equal(6)
   })
@@ -72,11 +103,6 @@ describe('Test application behind a reverse proxy', function () {
   })
 
   after(async function () {
-    process.kill(-server.app.pid)
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    killallServers([ server ])
   })
 })