]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/single-server.ts
Fix typo in "user already exist" error message (PR #333 from WildYorkies)
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / single-server.ts
index 0a0c95750af5694e4598dd48623b16e7c5178242..cf27218383aeefe3c7a4a49af8dcc9864caf5042 100644 (file)
@@ -3,12 +3,12 @@
 import * as chai from 'chai'
 import { keyBy } from 'lodash'
 import 'mocha'
-import { join } from 'path'
 import { VideoPrivacy } from '../../../../shared/models/videos'
 import {
-  completeVideoCheck, flushTests, getVideo, getVideoCategories, getVideoLanguages, getVideoLicences, getVideoPrivacies,
-  getVideosList, getVideosListPagination, getVideosListSort, killallServers, rateVideo, readdirPromise, removeVideo, runServer, searchVideo,
-  searchVideoWithPagination, searchVideoWithSort, ServerInfo, setAccessTokensToServers, testVideoImage, updateVideo, uploadVideo, viewVideo
+  checkVideoFilesWereRemoved, completeVideoCheck, flushTests, getVideo, getVideoCategories, getVideoLanguages, getVideoLicences,
+  getVideoPrivacies, getVideosList, getVideosListPagination, getVideosListSort, killallServers, rateVideo, removeVideo, runServer,
+  searchVideo, searchVideoWithPagination, searchVideoWithSort, ServerInfo, setAccessTokensToServers, testImage, updateVideo, uploadVideo,
+  viewVideo, wait
 } from '../../utils'
 
 const expect = chai.expect
@@ -26,6 +26,7 @@ describe('Test a single server', function () {
     language: 3,
     nsfw: true,
     description: 'my super description',
+    support: 'my super support text',
     host: 'localhost:9001',
     account: 'root',
     isLocal: true,
@@ -54,6 +55,7 @@ describe('Test a single server', function () {
     language: 5,
     nsfw: false,
     description: 'my super description updated',
+    support: 'my super support text updated',
     host: 'localhost:9001',
     account: 'root',
     isLocal: true,
@@ -76,7 +78,7 @@ describe('Test a single server', function () {
   }
 
   before(async function () {
-    this.timeout(10000)
+    this.timeout(30000)
 
     await flushTests()
 
@@ -147,8 +149,7 @@ describe('Test a single server', function () {
   })
 
   it('Should get and seed the uploaded video', async function () {
-    // Yes, this could be long
-    this.timeout(60000)
+    this.timeout(5000)
 
     const res = await getVideosList(server.url)
 
@@ -161,8 +162,7 @@ describe('Test a single server', function () {
   })
 
   it('Should get the video by UUID', async function () {
-    // Yes, this could be long
-    this.timeout(60000)
+    this.timeout(5000)
 
     const res = await getVideo(server.url, videoUUID)
 
@@ -171,10 +171,22 @@ describe('Test a single server', function () {
   })
 
   it('Should have the views updated', async function () {
+    this.timeout(10000)
+
     await viewVideo(server.url, videoId)
     await viewVideo(server.url, videoId)
     await viewVideo(server.url, videoId)
 
+    await wait(1500)
+
+    await viewVideo(server.url, videoId)
+    await viewVideo(server.url, videoId)
+
+    await wait(1500)
+
+    await viewVideo(server.url, videoId)
+    await viewVideo(server.url, videoId)
+
     const res = await getVideo(server.url, videoId)
 
     const video = res.body
@@ -276,11 +288,7 @@ describe('Test a single server', function () {
   it('Should remove the video', async function () {
     await removeVideo(server.url, server.accessToken, videoId)
 
-    const files1 = await readdirPromise(join(__dirname, '..', '..', '..', '..', 'test1', 'videos'))
-    expect(files1).to.have.lengthOf(0)
-
-    const files2 = await readdirPromise(join(__dirname, '..', '..', '..', '..', 'test1', 'thumbnails'))
-    expect(files2).to.have.lengthOf(0)
+    await checkVideoFilesWereRemoved(videoUUID, 1)
   })
 
   it('Should not have videos', async function () {
@@ -345,9 +353,7 @@ describe('Test a single server', function () {
 
     for (const video of videos) {
       const videoName = video.name.replace(' name', '')
-      const test = await testVideoImage(server.url, videoName, video.thumbnailPath)
-
-      expect(test).to.equal(true)
+      await testImage(server.url, videoName, video.thumbnailPath)
     }
   })