]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/handle-down.ts
Implement captions/subtitles
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / handle-down.ts
index cc1ff9a9fd799ffe4926a83a71cd222b8d4340cd..84d310ae628e21b4ad7ab92c7acf4ea5c59178cf 100644 (file)
@@ -2,18 +2,25 @@
 
 import * as chai from 'chai'
 import 'mocha'
+import { JobState } from '../../../../shared/models'
 import { VideoPrivacy } from '../../../../shared/models/videos'
 import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
 import { completeVideoCheck, getVideo, immutableAssign, reRunServer, viewVideo } from '../../utils'
-
 import {
-  flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
+  flushAndRunMultipleServers,
+  getVideosList,
+  killallServers,
+  ServerInfo,
+  setAccessTokensToServers,
+  uploadVideo,
   wait
 } from '../../utils/index'
 import { follow, getFollowersListPaginationAndSort } from '../../utils/server/follows'
-import { getJobsListPaginationAndSort } from '../../utils/server/jobs'
+import { getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs'
 import {
-  addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
+  addVideoCommentReply,
+  addVideoCommentThread,
+  getVideoCommentThreads,
   getVideoThreadComments
 } from '../../utils/videos/video-comments'
 
@@ -31,10 +38,11 @@ describe('Test handle downs', function () {
     name: 'my super name for server 1',
     category: 5,
     licence: 4,
-    language: 9,
+    language: 'ja',
     nsfw: true,
     privacy: VideoPrivacy.PUBLIC,
     description: 'my super description for server 1',
+    support: 'my super support text for server 1',
     tags: [ 'tag1p1', 'tag2p1' ],
     fixture: 'video_short1.webm'
   }
@@ -47,11 +55,14 @@ describe('Test handle downs', function () {
     name: 'my super name for server 1',
     category: 5,
     licence: 4,
-    language: 9,
+    language: 'ja',
     nsfw: true,
     description: 'my super description for server 1',
-    host: 'localhost:9001',
-    account: 'root',
+    support: 'my super support text for server 1',
+    account: {
+      name: 'root',
+      host: 'localhost:9001'
+    },
     isLocal: false,
     duration: 10,
     tags: [ 'tag1p1', 'tag2p1' ],
@@ -76,7 +87,7 @@ describe('Test handle downs', function () {
   })
 
   before(async function () {
-    this.timeout(20000)
+    this.timeout(30000)
 
     servers = await flushAndRunMultipleServers(2)
 
@@ -89,11 +100,11 @@ describe('Test handle downs', function () {
 
     await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken)
 
-    await wait(5000)
+    await waitJobs(servers)
 
     await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
 
-    await wait(5000)
+    await waitJobs(servers)
 
     for (const server of servers) {
       const res = await getVideosList(server.url)
@@ -113,6 +124,10 @@ describe('Test handle downs', function () {
       videos.push(resVideo.body.video)
     }
 
+    await waitJobs(servers[0])
+
+    await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
+
     // Add comments to video 2
     {
       const text = 'thread 1'
@@ -127,7 +142,9 @@ describe('Test handle downs', function () {
       commentIdServer1 = resComment.body.comment.id
     }
 
-    await wait(10000)
+    await waitJobs(servers[0])
+    // Wait scheduler
+    await wait(11000)
 
     const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt')
     expect(res.body.data).to.be.an('array')
@@ -135,12 +152,11 @@ describe('Test handle downs', function () {
   })
 
   it('Should not have pending/processing jobs anymore', async function () {
-    const res = await getJobsListPaginationAndSort(servers[0].url, servers[0].accessToken, 0, 50, '-createdAt')
-    const jobs = res.body.data
+    const states: JobState[] = [ 'waiting', 'active' ]
 
-    for (const job of jobs) {
-      expect(job.state).not.to.equal('pending')
-      expect(job.state).not.to.equal('processing')
+    for (const state of states) {
+      const res = await getJobsListPaginationAndSort(servers[ 0 ].url, servers[ 0 ].accessToken, state,0, 50, '-createdAt')
+      expect(res.body.data).to.have.length(0)
     }
   })
 
@@ -151,7 +167,7 @@ describe('Test handle downs', function () {
 
     await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken)
 
-    await wait(5000)
+    await waitJobs(servers)
 
     const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt')
     expect(res.body.data).to.be.an('array')
@@ -163,7 +179,7 @@ describe('Test handle downs', function () {
 
     await viewVideo(servers[0].url, videos[0].uuid)
 
-    await wait(5000)
+    await waitJobs(servers)
 
     const res = await getVideosList(servers[1].url)
     expect(res.body.data).to.be.an('array')
@@ -181,11 +197,7 @@ describe('Test handle downs', function () {
 
     await addVideoCommentReply(servers[0].url, servers[0].accessToken, videos[1].uuid, commentIdServer1, 'comment 1-3')
 
-    await wait(5000)
-
-    const res = await getVideosList(servers[1].url)
-    expect(res.body.data).to.be.an('array')
-    expect(res.body.data).to.have.lengthOf(2)
+    await waitJobs(servers)
 
     const resVideo = await getVideo(servers[1].url, videos[0].uuid)
     expect(resVideo.body).not.to.be.undefined
@@ -226,7 +238,7 @@ describe('Test handle downs', function () {
 
     await addVideoCommentReply(servers[1].url, servers[1].accessToken, videos[1].uuid, commentIdServer2, 'comment 1-4')
 
-    await wait(5000)
+    await waitJobs(servers)
 
     {
       const resComment = await getVideoThreadComments(servers[0].url, videos[1].uuid, threadIdServer1)
@@ -255,10 +267,5 @@ describe('Test handle downs', function () {
 
   after(async function () {
     killallServers(servers)
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
   })
 })