From 08c1efbe32244c321de28b0f2a6aaa3f99f46b58 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 26 Apr 2018 16:11:38 +0200 Subject: Add video channel management --- server/tests/api/check-params/video-channels.ts | 14 +++++++------- server/tests/api/videos/multiple-servers.ts | 2 +- server/tests/api/videos/video-channels.ts | 4 ++-- server/tests/utils/videos/video-channels.ts | 15 +++++---------- 4 files changed, 15 insertions(+), 20 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index 7cda879ed..40a8e97cc 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts @@ -25,7 +25,7 @@ import { User } from '../../../../shared/models/users' const expect = chai.expect -describe('Test videos API validator', function () { +describe('Test video channels API validator', function () { const videoChannelPath = '/api/v1/video-channels' let server: ServerInfo let accessTokenUser: string @@ -85,7 +85,7 @@ describe('Test videos API validator', function () { describe('When adding a video channel', function () { const baseCorrectParams = { - name: 'hello', + displayName: 'hello', description: 'super description', support: 'super support text' } @@ -105,13 +105,13 @@ describe('Test videos API validator', function () { await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) }) - it('Should fail without name', async function () { - const fields = omit(baseCorrectParams, 'name') + it('Should fail without a name', async function () { + const fields = omit(baseCorrectParams, 'displayName') await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) }) it('Should fail with a long name', async function () { - const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(25) }) + const fields = immutableAssign(baseCorrectParams, { displayName: 'super'.repeat(25) }) await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) }) @@ -138,7 +138,7 @@ describe('Test videos API validator', function () { describe('When updating a video channel', function () { const baseCorrectParams = { - name: 'hello', + displayName: 'hello', description: 'super description' } let path: string @@ -168,7 +168,7 @@ describe('Test videos API validator', function () { }) it('Should fail with a long name', async function () { - const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(25) }) + const fields = immutableAssign(baseCorrectParams, { displayName: 'super'.repeat(25) }) await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) }) diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index e462a2d47..94d627e26 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -59,7 +59,7 @@ describe('Test multiple servers', function () { { const videoChannel = { - name: 'my channel', + displayName: 'my channel', description: 'super channel' } await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index d24b8ab0b..585b6a2b5 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -59,7 +59,7 @@ describe('Test video channels', function () { this.timeout(10000) const videoChannel = { - name: 'second video channel', + displayName: 'second video channel', description: 'super video channel description', support: 'super video channel support text' } @@ -125,7 +125,7 @@ describe('Test video channels', function () { this.timeout(5000) const videoChannelAttributes = { - name: 'video channel updated', + displayName: 'video channel updated', description: 'video channel description updated', support: 'video channel support text updated' } diff --git a/server/tests/utils/videos/video-channels.ts b/server/tests/utils/videos/video-channels.ts index 978e21b19..021c4c420 100644 --- a/server/tests/utils/videos/video-channels.ts +++ b/server/tests/utils/videos/video-channels.ts @@ -1,10 +1,5 @@ import * as request from 'supertest' - -type VideoChannelAttributes = { - name?: string - description?: string - support?: string -} +import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared/models/videos' function getVideoChannelsList (url: string, start: number, count: number, sort?: string) { const path = '/api/v1/video-channels' @@ -34,14 +29,14 @@ function getAccountVideoChannelsList (url: string, accountId: number | string, s function addVideoChannel ( url: string, token: string, - videoChannelAttributesArg: VideoChannelAttributes, + videoChannelAttributesArg: VideoChannelCreate, expectedStatus = 200 ) { const path = '/api/v1/video-channels/' // Default attributes let attributes = { - name: 'my super video channel', + displayName: 'my super video channel', description: 'my super channel description', support: 'my super channel support' } @@ -59,13 +54,13 @@ function updateVideoChannel ( url: string, token: string, channelId: number | string, - attributes: VideoChannelAttributes, + attributes: VideoChannelUpdate, expectedStatus = 204 ) { const body = {} const path = '/api/v1/video-channels/' + channelId - if (attributes.name) body['name'] = attributes.name + if (attributes.displayName) body['displayName'] = attributes.displayName if (attributes.description) body['description'] = attributes.description if (attributes.support) body['support'] = attributes.support -- cgit v1.2.3