]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/real-world/real-world.ts
Add ability to schedule video publication
[github/Chocobozzz/PeerTube.git] / server / tests / real-world / real-world.ts
index e41203351a76d8d161741a5dbdaa62effc517948..b7375f77826a84fef48fa2cedfa643ebbda42295 100644 (file)
@@ -3,6 +3,7 @@ process.env.NODE_ENV = 'test'
 
 import * as program from 'commander'
 import { Video, VideoFile, VideoRateType } from '../../../shared'
+import { JobState } from '../../../shared/models'
 import {
   flushAndRunMultipleServers,
   flushTests, follow,
@@ -181,7 +182,7 @@ function upload (servers: ServerInfo[], numServer: number) {
     category: 4,
     nsfw: false,
     licence: 2,
-    language: 1,
+    language: 'en',
     description: Date.now() + ' description',
     tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ],
     fixture: 'video_short1.webm'
@@ -326,7 +327,7 @@ function areDifferences (videos1: Video[], videos2: Video[]) {
             return `Video ${video1.uuid} has missing video file ${videoFile1.magnetUri}.`
           }
 
-          if (videoFile1.size !== videoFile2.size || videoFile1.resolutionLabel !== videoFile2.resolutionLabel) {
+          if (videoFile1.size !== videoFile2.size || videoFile1.resolution.label !== videoFile2.resolution.label) {
             return `Video ${video1.uuid} has different video file ${videoFile1.magnetUri}.`
           }
         })
@@ -346,23 +347,19 @@ function goodbye () {
 }
 
 async function isTherePendingRequests (servers: ServerInfo[]) {
+  const states: JobState[] = [ 'inactive', 'active', 'delayed' ]
   const tasks: Promise<any>[] = []
   let pendingRequests = false
 
   // Check if each server has pending request
   for (const server of servers) {
-    const p = getJobsListPaginationAndSort(server.url, server.accessToken, 0, 10, '-createdAt')
-      .then(res => {
-        const jobs = res.body.data
-
-        for (const job of jobs) {
-          if (job.state === 'pending' || job.state === 'processing') {
-            pendingRequests = true
-          }
-        }
-      })
-
-    tasks.push(p)
+    for (const state of states) {
+      const p = getJobsListPaginationAndSort(server.url, server.accessToken, state, 0, 10, '-createdAt')
+        .then(res => {
+          if (res.body.total > 0) pendingRequests = true
+        })
+      tasks.push(p)
+    }
   }
 
   await Promise.all(tasks)