From bbe0f0645ca958d33a3f409b15166609733b663f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Jun 2018 16:52:15 +0200 Subject: Add ability to schedule video publication --- server/tests/api/check-params/videos.ts | 29 ++++++++++++++++++++++++ server/tests/api/videos/video-schedule-update.ts | 26 +++++++++++++-------- 2 files changed, 46 insertions(+), 9 deletions(-) (limited to 'server/tests') 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 () { await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) }) + it('Should fail with a bad schedule update (miss updateAt)', async function () { + const fields = immutableAssign(baseCorrectParams, { 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC }) + const attaches = baseCorrectAttaches + + await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) + }) + + it('Should fail with a bad schedule update (wrong updateAt)', async function () { + const fields = immutableAssign(baseCorrectParams, { + 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC, + 'scheduleUpdate[updateAt]': 'toto' + }) + const attaches = baseCorrectAttaches + + await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) + }) + it('Should fail without an input file', async function () { const fields = baseCorrectParams const attaches = {} @@ -494,6 +511,18 @@ describe('Test videos API validator', function () { await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) }) + it('Should fail with a bad schedule update (miss updateAt)', async function () { + const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) + + await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + }) + + it('Should fail with a bad schedule update (wrong updateAt)', async function () { + const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) + + await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + }) + it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams 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' import { VideoPrivacy } from '../../../../shared/models/videos' import { doubleFollow, - flushAndRunMultipleServers, getMyVideos, + flushAndRunMultipleServers, + getMyVideos, getVideosList, + getVideoWithToken, killallServers, ServerInfo, - setAccessTokensToServers, updateVideo, + setAccessTokensToServers, + updateVideo, uploadVideo, wait } from '../../utils' @@ -69,17 +72,22 @@ describe('Test video update scheduler', function () { const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) expect(res.body.total).to.equal(1) - const video = res.body.data[0] - expect(video.name).to.equal('video 1') - expect(video.privacy.id).to.equal(VideoPrivacy.PRIVATE) - expect(new Date(video.scheduledUpdate.updateAt)).to.be.above(new Date()) - expect(video.scheduledUpdate.privacy).to.equal(VideoPrivacy.PUBLIC) + const videoFromList = res.body.data[0] + const res2 = await getVideoWithToken(servers[0].url, servers[0].accessToken, videoFromList.uuid) + const videoFromGet = res2.body + + for (const video of [ videoFromList, videoFromGet ]) { + expect(video.name).to.equal('video 1') + expect(video.privacy.id).to.equal(VideoPrivacy.PRIVATE) + expect(new Date(video.scheduledUpdate.updateAt)).to.be.above(new Date()) + expect(video.scheduledUpdate.privacy).to.equal(VideoPrivacy.PUBLIC) + } }) it('Should wait some seconds and have the video in public privacy', async function () { this.timeout(20000) - await wait(10000) + await wait(15000) await waitJobs(servers) for (const server of servers) { @@ -144,7 +152,7 @@ describe('Test video update scheduler', function () { it('Should wait some seconds and have the updated video in public privacy', async function () { this.timeout(20000) - await wait(10000) + await wait(15000) await waitJobs(servers) for (const server of servers) { -- cgit v1.2.3