aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-15 16:52:15 +0200
committerChocobozzz <me@florianbigard.com>2018-06-15 18:20:56 +0200
commitbbe0f0645ca958d33a3f409b15166609733b663f (patch)
treeedcd5d702c73cda74a2177c4bdc08c616334337d /server/tests
parent2baea0c77cc765f7cbca9c9a2f4272268892a35c (diff)
downloadPeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.gz
PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.zst
PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.zip
Add ability to schedule video publication
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/videos.ts29
-rw-r--r--server/tests/api/videos/video-schedule-update.ts26
2 files changed, 46 insertions, 9 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 04bed3b44..abbea6ba3 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -291,6 +291,23 @@ describe('Test videos API validator', function () {
291 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 291 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
292 }) 292 })
293 293
294 it('Should fail with a bad schedule update (miss updateAt)', async function () {
295 const fields = immutableAssign(baseCorrectParams, { 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC })
296 const attaches = baseCorrectAttaches
297
298 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
299 })
300
301 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
302 const fields = immutableAssign(baseCorrectParams, {
303 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC,
304 'scheduleUpdate[updateAt]': 'toto'
305 })
306 const attaches = baseCorrectAttaches
307
308 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
309 })
310
294 it('Should fail without an input file', async function () { 311 it('Should fail without an input file', async function () {
295 const fields = baseCorrectParams 312 const fields = baseCorrectParams
296 const attaches = {} 313 const attaches = {}
@@ -494,6 +511,18 @@ describe('Test videos API validator', function () {
494 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 511 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
495 }) 512 })
496 513
514 it('Should fail with a bad schedule update (miss updateAt)', async function () {
515 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
516
517 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
518 })
519
520 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
521 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } })
522
523 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
524 })
525
497 it('Should fail with an incorrect thumbnail file', async function () { 526 it('Should fail with an incorrect thumbnail file', async function () {
498 const fields = baseCorrectParams 527 const fields = baseCorrectParams
499 const attaches = { 528 const attaches = {
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts
index 8b87ea855..a260fa4da 100644
--- a/server/tests/api/videos/video-schedule-update.ts
+++ b/server/tests/api/videos/video-schedule-update.ts
@@ -5,11 +5,14 @@ import 'mocha'
5import { VideoPrivacy } from '../../../../shared/models/videos' 5import { VideoPrivacy } from '../../../../shared/models/videos'
6import { 6import {
7 doubleFollow, 7 doubleFollow,
8 flushAndRunMultipleServers, getMyVideos, 8 flushAndRunMultipleServers,
9 getMyVideos,
9 getVideosList, 10 getVideosList,
11 getVideoWithToken,
10 killallServers, 12 killallServers,
11 ServerInfo, 13 ServerInfo,
12 setAccessTokensToServers, updateVideo, 14 setAccessTokensToServers,
15 updateVideo,
13 uploadVideo, 16 uploadVideo,
14 wait 17 wait
15} from '../../utils' 18} from '../../utils'
@@ -69,17 +72,22 @@ describe('Test video update scheduler', function () {
69 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) 72 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5)
70 expect(res.body.total).to.equal(1) 73 expect(res.body.total).to.equal(1)
71 74
72 const video = res.body.data[0] 75 const videoFromList = res.body.data[0]
73 expect(video.name).to.equal('video 1') 76 const res2 = await getVideoWithToken(servers[0].url, servers[0].accessToken, videoFromList.uuid)
74 expect(video.privacy.id).to.equal(VideoPrivacy.PRIVATE) 77 const videoFromGet = res2.body
75 expect(new Date(video.scheduledUpdate.updateAt)).to.be.above(new Date()) 78
76 expect(video.scheduledUpdate.privacy).to.equal(VideoPrivacy.PUBLIC) 79 for (const video of [ videoFromList, videoFromGet ]) {
80 expect(video.name).to.equal('video 1')
81 expect(video.privacy.id).to.equal(VideoPrivacy.PRIVATE)
82 expect(new Date(video.scheduledUpdate.updateAt)).to.be.above(new Date())
83 expect(video.scheduledUpdate.privacy).to.equal(VideoPrivacy.PUBLIC)
84 }
77 }) 85 })
78 86
79 it('Should wait some seconds and have the video in public privacy', async function () { 87 it('Should wait some seconds and have the video in public privacy', async function () {
80 this.timeout(20000) 88 this.timeout(20000)
81 89
82 await wait(10000) 90 await wait(15000)
83 await waitJobs(servers) 91 await waitJobs(servers)
84 92
85 for (const server of servers) { 93 for (const server of servers) {
@@ -144,7 +152,7 @@ describe('Test video update scheduler', function () {
144 it('Should wait some seconds and have the updated video in public privacy', async function () { 152 it('Should wait some seconds and have the updated video in public privacy', async function () {
145 this.timeout(20000) 153 this.timeout(20000)
146 154
147 await wait(10000) 155 await wait(15000)
148 await waitJobs(servers) 156 await waitJobs(servers)
149 157
150 for (const server of servers) { 158 for (const server of servers) {