From 2422c46b27790d94fd29a7092170cee5a1b56008 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Feb 2018 14:46:26 +0100 Subject: Implement support field in video and video channel --- server/tests/api/check-params/users.ts | 8 ++++++++ server/tests/api/check-params/video-channels.ts | 15 +++++++++++++-- server/tests/api/check-params/videos.ts | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index d9dea0713..ee591d620 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -255,6 +255,14 @@ describe('Test users API validators', function () { await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 }) }) + it('Should fail with a too long description', async function () { + const fields = { + description: 'super'.repeat(60) + } + + await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) + }) + it('Should succeed with the correct params', async function () { const fields = { password: 'my super password', diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index d073e28f0..43c5462ee 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts @@ -62,7 +62,8 @@ describe('Test videos API validator', function () { describe('When adding a video channel', function () { const baseCorrectParams = { name: 'hello', - description: 'super description' + description: 'super description', + support: 'super support text' } it('Should fail with a non authenticated user', async function () { @@ -89,13 +90,18 @@ describe('Test videos API validator', function () { await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) }) + it('Should fail with a long support text', async function () { + const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) }) + await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) + }) + it('Should succeed with the correct parameters', async function () { await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields: baseCorrectParams, - statusCodeExpected: 204 + statusCodeExpected: 200 }) }) }) @@ -143,6 +149,11 @@ describe('Test videos API validator', function () { await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields }) }) + it('Should fail with a long support text', async function () { + const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) }) + await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields }) + }) + it('Should succeed with the correct parameters', async function () { await makePutBodyRequest({ url: server.url, diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index aa30b721b..1d5c8543d 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -102,6 +102,7 @@ describe('Test videos API validator', function () { nsfw: false, commentsEnabled: true, description: 'my super description', + support: 'my super support text', tags: [ 'tag1', 'tag2' ], privacy: VideoPrivacy.PUBLIC, channelId @@ -178,7 +179,14 @@ describe('Test videos API validator', function () { }) it('Should fail with a long description', async function () { - const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) + const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) + const attaches = baseCorrectAttaches + + await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) + }) + + it('Should fail with a long support text', async function () { + const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) }) const attaches = baseCorrectAttaches await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -417,7 +425,13 @@ describe('Test videos API validator', function () { }) it('Should fail with a long description', async function () { - const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) + const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) + + await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + }) + + it('Should fail with a long support text', async function () { + const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) }) await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) }) -- cgit v1.2.3