aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/jobs.ts11
-rw-r--r--server/tests/api/server/handle-down.ts10
-rw-r--r--server/tests/api/server/jobs.ts10
-rw-r--r--server/tests/api/videos/multiple-servers.ts21
4 files changed, 31 insertions, 21 deletions
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index b12818bb1..ce3ac8809 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -7,7 +7,7 @@ import { checkBadCountPagination, checkBadSortPagination, checkBadStartPaginatio
7import { makeGetRequest } from '../../utils/requests/requests' 7import { makeGetRequest } from '../../utils/requests/requests'
8 8
9describe('Test jobs API validators', function () { 9describe('Test jobs API validators', function () {
10 const path = '/api/v1/jobs/' 10 const path = '/api/v1/jobs/failed'
11 let server: ServerInfo 11 let server: ServerInfo
12 let userAccessToken = '' 12 let userAccessToken = ''
13 13
@@ -31,6 +31,15 @@ describe('Test jobs API validators', function () {
31 }) 31 })
32 32
33 describe('When listing jobs', function () { 33 describe('When listing jobs', function () {
34
35 it('Should fail with a bad state', async function () {
36 await makeGetRequest({
37 url: server.url,
38 token: server.accessToken,
39 path: path + 'ade'
40 })
41 })
42
34 it('Should fail with a bad start pagination', async function () { 43 it('Should fail with a bad start pagination', async function () {
35 await checkBadStartPagination(server.url, path, server.accessToken) 44 await checkBadStartPagination(server.url, path, server.accessToken)
36 }) 45 })
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index de4e77b2f..4cedeb89e 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -2,6 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { JobState } from '../../../../shared/models'
5import { VideoPrivacy } from '../../../../shared/models/videos' 6import { VideoPrivacy } from '../../../../shared/models/videos'
6import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 7import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
7import { completeVideoCheck, getVideo, immutableAssign, reRunServer, viewVideo } from '../../utils' 8import { completeVideoCheck, getVideo, immutableAssign, reRunServer, viewVideo } from '../../utils'
@@ -139,12 +140,11 @@ describe('Test handle downs', function () {
139 }) 140 })
140 141
141 it('Should not have pending/processing jobs anymore', async function () { 142 it('Should not have pending/processing jobs anymore', async function () {
142 const res = await getJobsListPaginationAndSort(servers[0].url, servers[0].accessToken, 0, 50, '-createdAt') 143 const states: JobState[] = [ 'inactive', 'active' ]
143 const jobs = res.body.data
144 144
145 for (const job of jobs) { 145 for (const state of states) {
146 expect(job.state).not.to.equal('pending') 146 const res = await getJobsListPaginationAndSort(servers[ 0 ].url, servers[ 0 ].accessToken, state,0, 50, '-createdAt')
147 expect(job.state).not.to.equal('processing') 147 expect(res.body.data).to.have.length(0)
148 } 148 }
149 }) 149 })
150 150
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index 2e17e71a4..671498769 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -35,20 +35,20 @@ describe('Test jobs', function () {
35 }) 35 })
36 36
37 it('Should list jobs', async function () { 37 it('Should list jobs', async function () {
38 const res = await getJobsList(servers[1].url, servers[1].accessToken) 38 const res = await getJobsList(servers[1].url, servers[1].accessToken, 'complete')
39 expect(res.body.total).to.be.above(2) 39 expect(res.body.total).to.be.above(2)
40 expect(res.body.data).to.have.length.above(2) 40 expect(res.body.data).to.have.length.above(2)
41 }) 41 })
42 42
43 it('Should list jobs with sort and pagination', async function () { 43 it('Should list jobs with sort and pagination', async function () {
44 const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 4, 1, 'createdAt') 44 const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 'complete', 1, 1, 'createdAt')
45 expect(res.body.total).to.be.above(2) 45 expect(res.body.total).to.be.above(2)
46 expect(res.body.data).to.have.lengthOf(1) 46 expect(res.body.data).to.have.lengthOf(1)
47 47
48 const job = res.body.data[0] 48 const job = res.body.data[0]
49 expect(job.state).to.equal('success') 49
50 expect(job.category).to.equal('transcoding') 50 expect(job.state).to.equal('complete')
51 expect(job.handlerName).to.have.length.above(3) 51 expect(job.type).to.equal('activitypub-http-unicast')
52 expect(dateIsValid(job.createdAt)).to.be.true 52 expect(dateIsValid(job.createdAt)).to.be.true
53 expect(dateIsValid(job.updatedAt)).to.be.true 53 expect(dateIsValid(job.updatedAt)).to.be.true
54 }) 54 })
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 4c4b5123d..0215b3011 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -475,16 +475,17 @@ describe('Test multiple servers', function () {
475 it('Should like and dislikes videos on different services', async function () { 475 it('Should like and dislikes videos on different services', async function () {
476 this.timeout(20000) 476 this.timeout(20000)
477 477
478 const tasks: Promise<any>[] = [] 478 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
479 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')) 479 await wait(200)
480 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')) 480 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
481 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')) 481 await wait(200)
482 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')) 482 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
483 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')) 483 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
484 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')) 484 await wait(200)
485 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')) 485 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
486 486 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
487 await Promise.all(tasks) 487 await wait(200)
488 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
488 489
489 await wait(10000) 490 await wait(10000)
490 491