aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/jobs.ts12
-rw-r--r--server/tests/api/server/handle-down.ts9
-rw-r--r--server/tests/api/server/jobs.ts50
-rw-r--r--server/tests/real-world/real-world.ts9
4 files changed, 66 insertions, 14 deletions
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index c70139514..22e237964 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -51,6 +51,17 @@ describe('Test jobs API validators', function () {
51 }) 51 })
52 }) 52 })
53 53
54 it('Should fail with an incorrect job type', async function () {
55 await makeGetRequest({
56 url: server.url,
57 token: server.accessToken,
58 path,
59 query: {
60 jobType: 'toto'
61 }
62 })
63 })
64
54 it('Should fail with a bad start pagination', async function () { 65 it('Should fail with a bad start pagination', async function () {
55 await checkBadStartPagination(server.url, path, server.accessToken) 66 await checkBadStartPagination(server.url, path, server.accessToken)
56 }) 67 })
@@ -79,6 +90,7 @@ describe('Test jobs API validators', function () {
79 statusCodeExpected: 403 90 statusCodeExpected: 403
80 }) 91 })
81 }) 92 })
93
82 }) 94 })
83 95
84 after(async function () { 96 after(async function () {
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index a0f505474..7e36067f1 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -184,7 +184,14 @@ describe('Test handle downs', function () {
184 const states: JobState[] = [ 'waiting', 'active' ] 184 const states: JobState[] = [ 'waiting', 'active' ]
185 185
186 for (const state of states) { 186 for (const state of states) {
187 const res = await getJobsListPaginationAndSort(servers[ 0 ].url, servers[ 0 ].accessToken, state,0, 50, '-createdAt') 187 const res = await getJobsListPaginationAndSort({
188 url: servers[ 0 ].url,
189 accessToken: servers[ 0 ].accessToken,
190 state: state,
191 start: 0,
192 count: 50,
193 sort: '-createdAt'
194 })
188 expect(res.body.data).to.have.length(0) 195 expect(res.body.data).to.have.length(0)
189 } 196 }
190 }) 197 })
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index ceea47a85..58d8c8c10 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -41,20 +41,46 @@ describe('Test jobs', function () {
41 expect(res.body.data).to.have.length.above(2) 41 expect(res.body.data).to.have.length.above(2)
42 }) 42 })
43 43
44 it('Should list jobs with sort and pagination', async function () { 44 it('Should list jobs with sort, pagination and job type', async function () {
45 const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 'completed', 1, 2, 'createdAt') 45 {
46 expect(res.body.total).to.be.above(2) 46 const res = await getJobsListPaginationAndSort({
47 expect(res.body.data).to.have.lengthOf(2) 47 url: servers[ 1 ].url,
48 accessToken: servers[ 1 ].accessToken,
49 state: 'completed',
50 start: 1,
51 count: 2,
52 sort: 'createdAt'
53 })
54 expect(res.body.total).to.be.above(2)
55 expect(res.body.data).to.have.lengthOf(2)
56
57 let job: Job = res.body.data[ 0 ]
58 // Skip repeat jobs
59 if (job.type === 'videos-views') job = res.body.data[ 1 ]
60
61 expect(job.state).to.equal('completed')
62 expect(job.type.startsWith('activitypub-')).to.be.true
63 expect(dateIsValid(job.createdAt as string)).to.be.true
64 expect(dateIsValid(job.processedOn as string)).to.be.true
65 expect(dateIsValid(job.finishedOn as string)).to.be.true
66 }
48 67
49 let job = res.body.data[0] 68 {
50 // Skip repeat jobs 69 const res = await getJobsListPaginationAndSort({
51 if (job.type === 'videos-views') job = res.body.data[1] 70 url: servers[ 1 ].url,
71 accessToken: servers[ 1 ].accessToken,
72 state: 'completed',
73 start: 0,
74 count: 100,
75 sort: 'createdAt',
76 jobType: 'activitypub-http-broadcast'
77 })
78 expect(res.body.total).to.be.above(2)
52 79
53 expect(job.state).to.equal('completed') 80 for (const j of res.body.data as Job[]) {
54 expect(job.type.startsWith('activitypub-')).to.be.true 81 expect(j.type).to.equal('activitypub-http-broadcast')
55 expect(dateIsValid(job.createdAt)).to.be.true 82 }
56 expect(dateIsValid(job.processedOn)).to.be.true 83 }
57 expect(dateIsValid(job.finishedOn)).to.be.true
58 }) 84 })
59 85
60 after(async function () { 86 after(async function () {
diff --git a/server/tests/real-world/real-world.ts b/server/tests/real-world/real-world.ts
index 8b070004d..cba5ac311 100644
--- a/server/tests/real-world/real-world.ts
+++ b/server/tests/real-world/real-world.ts
@@ -354,7 +354,14 @@ async function isTherePendingRequests (servers: ServerInfo[]) {
354 // Check if each server has pending request 354 // Check if each server has pending request
355 for (const server of servers) { 355 for (const server of servers) {
356 for (const state of states) { 356 for (const state of states) {
357 const p = getJobsListPaginationAndSort(server.url, server.accessToken, state, 0, 10, '-createdAt') 357 const p = getJobsListPaginationAndSort({
358 url: server.url,
359 accessToken: server.accessToken,
360 state: state,
361 start: 0,
362 count: 10,
363 sort: '-createdAt'
364 })
358 .then(res => { 365 .then(res => {
359 if (res.body.total > 0) pendingRequests = true 366 if (res.body.total > 0) pendingRequests = true
360 }) 367 })