From 6b738c7a31591a83fdcd9c78b6b1f98e543c378b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Apr 2018 10:21:38 +0200 Subject: Video channel API routes refractor --- server/tests/api/check-params/video-channels.ts | 73 ++++++++------------ server/tests/api/check-params/videos.ts | 73 +++++++++++++++++++- server/tests/api/users/users-multiple-servers.ts | 86 ++++++++++++++++++------ server/tests/api/videos/video-channels.ts | 33 ++++++--- server/tests/api/videos/video-nsfw.ts | 55 +++++++++------ server/tests/utils/videos/video-channels.ts | 10 +-- server/tests/utils/videos/videos.ts | 42 ++++++++++++ 7 files changed, 270 insertions(+), 102 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 acb6bdd57..25b2dc9b9 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts @@ -7,7 +7,7 @@ import { createUser, deleteVideoChannel, flushTests, - getAccountVideoChannelsList, + getAccountVideoChannelsList, getMyUserInformation, getVideoChannelsList, immutableAssign, killallServers, @@ -21,6 +21,7 @@ import { } from '../../utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' import { getAccountsList } from '../../utils/users/accounts' +import { User } from '../../../../shared/models/users' const expect = chai.expect @@ -29,6 +30,8 @@ describe('Test videos API validator', function () { const accountPath = '/api/v1/accounts/' let server: ServerInfo let accessTokenUser: string + let accountUUID: string + let videoChannelUUID: string // --------------------------------------------------------------- @@ -45,8 +48,18 @@ describe('Test videos API validator', function () { username: 'fake', password: 'fake_password' } - await createUser(server.url, server.accessToken, user.username, user.password) - accessTokenUser = await userLogin(server, user) + + { + await createUser(server.url, server.accessToken, user.username, user.password) + accessTokenUser = await userLogin(server, user) + } + + { + const res = await getMyUserInformation(server.url, server.accessToken) + const user: User = res.body + accountUUID = user.account.uuid + videoChannelUUID = user.videoChannels[0].uuid + } }) describe('When listing a video channels', function () { @@ -74,18 +87,15 @@ describe('Test videos API validator', function () { }) describe('When adding a video channel', function () { - let path: string - const baseCorrectParams = { name: 'hello', description: 'super description', support: 'super support text' } + let path: string before(async function () { - const res = await getAccountsList(server.url) - const accountId = res.body.data[0].id - path = accountPath + accountId + '/video-channels' + path = accountPath + accountUUID + '/video-channels' }) it('Should fail with a non authenticated user', async function () { @@ -129,21 +139,14 @@ describe('Test videos API validator', function () { }) describe('When updating a video channel', function () { - let path: string - const baseCorrectParams = { name: 'hello', description: 'super description' } + let path: string before(async function () { - const res1 = await getVideoChannelsList(server.url, 0, 1) - const videoChannelId = res1.body.data[0].id - - const res2 = await getAccountsList(server.url) - const accountId = res2.body.data[0].id - - path = accountPath + accountId + '/video-channels/' + videoChannelId + path = accountPath + accountUUID + '/video-channels/' + videoChannelUUID }) it('Should fail with a non authenticated user', async function () { @@ -194,16 +197,9 @@ describe('Test videos API validator', function () { describe('When getting a video channel', function () { let basePath: string - let videoChannelId: number before(async function () { - const res1 = await getVideoChannelsList(server.url, 0, 1) - videoChannelId = res1.body.data[0].id - - const res2 = await getAccountsList(server.url) - const accountId = res2.body.data[0].id - - basePath = accountPath + accountId + '/video-channels' + basePath = accountPath + accountUUID + '/video-channels' }) it('Should return the list of the video channels with nothing', async function () { @@ -235,49 +231,38 @@ describe('Test videos API validator', function () { it('Should succeed with the correct parameters', async function () { await makeGetRequest({ url: server.url, - path: basePath + '/' + videoChannelId, + path: basePath + '/' + videoChannelUUID, statusCodeExpected: 200 }) }) }) describe('When deleting a video channel', function () { - let videoChannelId: number - let accountId: number - - before(async function () { - const res1 = await getVideoChannelsList(server.url, 0, 1) - videoChannelId = res1.body.data[0].id - - const res2 = await getAccountsList(server.url) - accountId = res2.body.data[0].id - }) - it('Should fail with a non authenticated user', async function () { - await deleteVideoChannel(server.url, 'coucou', accountId, videoChannelId, 401) + await deleteVideoChannel(server.url, 'coucou', accountUUID, videoChannelUUID, 401) }) it('Should fail with another authenticated user', async function () { - await deleteVideoChannel(server.url, accessTokenUser, accountId, videoChannelId, 403) + await deleteVideoChannel(server.url, accessTokenUser, accountUUID, videoChannelUUID, 403) }) it('Should fail with an unknown account id', async function () { - await deleteVideoChannel(server.url, server.accessToken, 454554,videoChannelId, 404) + await deleteVideoChannel(server.url, server.accessToken, 454554,videoChannelUUID, 404) }) it('Should fail with an unknown video channel id', async function () { - await deleteVideoChannel(server.url, server.accessToken, accountId,454554, 404) + await deleteVideoChannel(server.url, server.accessToken, accountUUID,454554, 404) }) it('Should succeed with the correct parameters', async function () { - await deleteVideoChannel(server.url, server.accessToken, accountId, videoChannelId) + await deleteVideoChannel(server.url, server.accessToken, accountUUID, videoChannelUUID) }) it('Should fail to delete the last user video channel', async function () { const res = await getVideoChannelsList(server.url, 0, 1) - videoChannelId = res.body.data[0].id + const lastVideoChannelUUID = res.body.data[0].uuid - await deleteVideoChannel(server.url, server.accessToken, accountId, videoChannelId, 409) + await deleteVideoChannel(server.url, server.accessToken, accountUUID, lastVideoChannelUUID, 409) }) }) diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index da41f515b..850ad12e0 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -10,6 +10,7 @@ import { makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin } from '../../utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +import { getAccountsList } from '../../utils/users/accounts' const expect = chai.expect @@ -17,7 +18,9 @@ describe('Test videos API validator', function () { const path = '/api/v1/videos/' let server: ServerInfo let userAccessToken = '' + let accountUUID: string let channelId: number + let channelUUID: string let videoId // --------------------------------------------------------------- @@ -36,8 +39,12 @@ describe('Test videos API validator', function () { await createUser(server.url, server.accessToken, username, password) userAccessToken = await userLogin(server, { username, password }) - const res = await getMyUserInformation(server.url, server.accessToken) - channelId = res.body.videoChannels[0].id + { + const res = await getMyUserInformation(server.url, server.accessToken) + channelId = res.body.videoChannels[ 0 ].id + channelUUID = res.body.videoChannels[ 0 ].uuid + accountUUID = res.body.account.uuid + } }) describe('When listing a video', function () { @@ -52,6 +59,10 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect sort', async function () { await checkBadSortPagination(server.url, path) }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) + }) }) describe('When searching a video', function () { @@ -75,6 +86,10 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect sort', async function () { await checkBadSortPagination(server.url, join(path, 'search', 'test')) }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) + }) }) describe('When listing my videos', function () { @@ -91,6 +106,58 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect sort', async function () { await checkBadSortPagination(server.url, path, server.accessToken) }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: 200 }) + }) + }) + + describe('When listing account videos', function () { + let path: string + + before(async function () { + path = '/api/v1/accounts/' + accountUUID + '/videos' + }) + + it('Should fail with a bad start pagination', async function () { + await checkBadStartPagination(server.url, path, server.accessToken) + }) + + it('Should fail with a bad count pagination', async function () { + await checkBadCountPagination(server.url, path, server.accessToken) + }) + + it('Should fail with an incorrect sort', async function () { + await checkBadSortPagination(server.url, path, server.accessToken) + }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) + }) + }) + + describe('When listing video channel videos', function () { + let path: string + + before(async function () { + path = '/api/v1/accounts/' + accountUUID + '/video-channels/' + channelUUID + '/videos' + }) + + it('Should fail with a bad start pagination', async function () { + await checkBadStartPagination(server.url, path, server.accessToken) + }) + + it('Should fail with a bad count pagination', async function () { + await checkBadCountPagination(server.url, path, server.accessToken) + }) + + it('Should fail with an incorrect sort', async function () { + await checkBadSortPagination(server.url, path, server.accessToken) + }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) + }) }) describe('When adding a video', function () { @@ -112,7 +179,7 @@ describe('Test videos API validator', function () { support: 'my super support text', tags: [ 'tag1', 'tag2' ], privacy: VideoPrivacy.PUBLIC, - channelId + channelId: channelId } }) diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index bb458f7a5..a7f3aa8d3 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts @@ -4,22 +4,33 @@ import * as chai from 'chai' import 'mocha' import { Account } from '../../../../shared/models/actors' import { - checkVideoFilesWereRemoved, createUser, doubleFollow, flushAndRunMultipleServers, removeUser, updateMyUser, userLogin, + checkVideoFilesWereRemoved, + createUser, + doubleFollow, + flushAndRunMultipleServers, + getAccountVideos, + getVideoChannelsList, + removeUser, + updateMyUser, + userLogin, wait } from '../../utils' import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' import { setAccessTokensToServers } from '../../utils/users/login' +import { User } from '../../../../shared/models/users' +import { VideoChannel } from '../../../../shared/models/videos' const expect = chai.expect describe('Test users with multiple servers', function () { let servers: ServerInfo[] = [] - let user - let userUUID - let userId - let videoUUID - let userAccessToken + let user: User + let userAccountUUID: string + let userVideoChannelUUID: string + let userId: number + let videoUUID: string + let userAccessToken: string before(async function () { this.timeout(120000) @@ -39,17 +50,28 @@ describe('Test users with multiple servers', function () { // The root user of server 1 is propagated to servers 2 and 3 await uploadVideo(servers[0].url, servers[0].accessToken, {}) - const user = { - username: 'user1', - password: 'password' + { + const user = { + username: 'user1', + password: 'password' + } + const res = await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, user.username, user.password) + userAccountUUID = res.body.user.account.uuid + userId = res.body.user.id + + userAccessToken = await userLogin(servers[ 0 ], user) + } + + { + const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken) + const user: User = res.body + userVideoChannelUUID = user.videoChannels[0].uuid } - const resUser = await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) - userUUID = resUser.body.user.uuid - userId = resUser.body.user.id - userAccessToken = await userLogin(servers[0], user) - const resVideo = await uploadVideo(servers[0].url, userAccessToken, {}) - videoUUID = resVideo.body.uuid + { + const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {}) + videoUUID = resVideo.body.video.uuid + } await wait(5000) }) @@ -106,14 +128,31 @@ describe('Test users with multiple servers', function () { } }) + it('Should list account videos', async function () { + for (const server of servers) { + const res = await getAccountVideos(server.url, server.accessToken, userAccountUUID, 0, 5) + + expect(res.body.total).to.equal(1) + expect(res.body.data).to.be.an('array') + expect(res.body.data).to.have.lengthOf(1) + expect(res.body.data[0].uuid).to.equal(videoUUID) + } + }) + it('Should remove the user', async function () { this.timeout(10000) for (const server of servers) { const resAccounts = await getAccountsList(server.url, '-createdAt') - const userServer1List = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account - expect(userServer1List).not.to.be.undefined + const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account + expect(accountDeleted).not.to.be.undefined + + const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) + const videoChannelDeleted = resVideoChannels.body.data.find(a => { + return a.displayName === 'Default user1 channel' && a.host === 'localhost:9001' + }) as VideoChannel + expect(videoChannelDeleted).not.to.be.undefined } await removeUser(servers[0].url, userId, servers[0].accessToken) @@ -123,14 +162,21 @@ describe('Test users with multiple servers', function () { for (const server of servers) { const resAccounts = await getAccountsList(server.url, '-createdAt') - const userServer1List = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account - expect(userServer1List).to.be.undefined + const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account + expect(accountDeleted).to.be.undefined + + const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) + const videoChannelDeleted = resVideoChannels.body.data.find(a => { + return a.name === 'Default user1 channel' && a.host === 'localhost:9001' + }) as VideoChannel + expect(videoChannelDeleted).to.be.undefined } }) it('Should not have actor files', async () => { for (const server of servers) { - await checkActorFilesWereRemoved(userUUID, server.serverNumber) + await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) + await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) } }) diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index a7552a83a..04e7b8c6a 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -3,7 +3,7 @@ import * as chai from 'chai' import 'mocha' import { User } from '../../../../shared/index' -import { doubleFollow, flushAndRunMultipleServers, uploadVideo, wait } from '../../utils' +import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, uploadVideo, wait } from '../../utils' import { addVideoChannel, deleteVideoChannel, @@ -24,8 +24,9 @@ const expect = chai.expect describe('Test video channels', function () { let servers: ServerInfo[] let userInfo: User - let accountId: number + let accountUUID: string let videoChannelId: number + let videoChannelUUID: string before(async function () { this.timeout(30000) @@ -38,8 +39,9 @@ describe('Test video channels', function () { await doubleFollow(servers[0], servers[1]) { - const res = await getAccountsList(servers[0].url) - accountId = res.body.data[0].id + const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) + const user: User = res.body + accountUUID = user.account.uuid } await wait(5000) @@ -61,11 +63,12 @@ describe('Test video channels', function () { description: 'super video channel description', support: 'super video channel support text' } - const res = await addVideoChannel(servers[0].url, servers[0].accessToken, accountId, videoChannel) + const res = await addVideoChannel(servers[0].url, servers[0].accessToken, accountUUID, videoChannel) videoChannelId = res.body.videoChannel.id + videoChannelUUID = res.body.videoChannel.uuid // The channel is 1 is propagated to servers 2 - await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: videoChannelId }) + await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name', channelId: videoChannelId }) await wait(3000) }) @@ -127,7 +130,7 @@ describe('Test video channels', function () { support: 'video channel support text updated' } - await updateVideoChannel(servers[0].url, servers[0].accessToken, accountId, videoChannelId, videoChannelAttributes) + await updateVideoChannel(servers[0].url, servers[0].accessToken, accountUUID, videoChannelId, videoChannelAttributes) await wait(3000) }) @@ -146,7 +149,7 @@ describe('Test video channels', function () { }) it('Should get video channel', async function () { - const res = await getVideoChannel(servers[0].url, accountId, videoChannelId) + const res = await getVideoChannel(servers[0].url, accountUUID, videoChannelId) const videoChannel = res.body expect(videoChannel.displayName).to.equal('video channel updated') @@ -154,8 +157,20 @@ describe('Test video channels', function () { expect(videoChannel.support).to.equal('video channel support text updated') }) + it('Should list the video channel videos', async function () { + this.timeout(10000) + + for (const server of servers) { + const res = await getVideoChannelVideos(server.url, server.accessToken, accountUUID, videoChannelUUID, 0, 5) + expect(res.body.total).to.equal(1) + expect(res.body.data).to.be.an('array') + expect(res.body.data).to.have.lengthOf(1) + expect(res.body.data[0].name).to.equal('my video name') + } + }) + it('Should delete video channel', async function () { - await deleteVideoChannel(servers[0].url, servers[0].accessToken, accountId, videoChannelId) + await deleteVideoChannel(servers[0].url, servers[0].accessToken, accountUUID, videoChannelId) }) it('Should have video channel deleted', async function () { diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index 4e5ab11ce..8901f38f9 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -7,8 +7,9 @@ import { userLogin } from '../../utils/users/login' import { createUser } from '../../utils/users/users' import { getMyVideos } from '../../utils/videos/videos' import { + getAccountVideos, getConfig, getCustomConfig, - getMyUserInformation, + getMyUserInformation, getVideoChannelVideos, getVideosListWithToken, runServer, searchVideo, @@ -17,6 +18,7 @@ import { } from '../../utils' import { ServerConfig } from '../../../../shared/models' import { CustomConfig } from '../../../../shared/models/server/custom-config.model' +import { User } from '../../../../shared/models/users' const expect = chai.expect @@ -25,6 +27,31 @@ describe('Test video NSFW policy', function () { let userAccessToken: string let customConfig: CustomConfig + function getVideosFunctions (token?: string) { + return getMyUserInformation(server.url, server.accessToken) + .then(res => { + const user: User = res.body + const videoChannelUUID = user.videoChannels[0].uuid + const accountUUID = user.account.uuid + + if (token) { + return Promise.all([ + getVideosListWithToken(server.url, token), + searchVideoWithToken(server.url, 'n', token), + getAccountVideos(server.url, token, accountUUID, 0, 5), + getVideoChannelVideos(server.url, token, accountUUID, videoChannelUUID, 0, 5) + ]) + } + + return Promise.all([ + getVideosList(server.url), + searchVideo(server.url, 'n'), + getAccountVideos(server.url, undefined, accountUUID, 0, 5), + getVideoChannelVideos(server.url, undefined, accountUUID, videoChannelUUID, 0, 5) + ]) + }) + } + before(async function () { this.timeout(50000) @@ -56,7 +83,7 @@ describe('Test video NSFW policy', function () { const serverConfig: ServerConfig = resConfig.body expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display') - for (const res of [ await getVideosList(server.url), await searchVideo(server.url, 'n') ]) { + for (const res of await getVideosFunctions()) { expect(res.body.total).to.equal(2) const videos = res.body.data @@ -74,7 +101,7 @@ describe('Test video NSFW policy', function () { const serverConfig: ServerConfig = resConfig.body expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list') - for (const res of [ await getVideosList(server.url), await searchVideo(server.url, 'n') ]) { + for (const res of await getVideosFunctions()) { expect(res.body.total).to.equal(1) const videos = res.body.data @@ -91,7 +118,7 @@ describe('Test video NSFW policy', function () { const serverConfig: ServerConfig = resConfig.body expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur') - for (const res of [ await getVideosList(server.url), await searchVideo(server.url, 'n') ]) { + for (const res of await getVideosFunctions()) { expect(res.body.total).to.equal(2) const videos = res.body.data @@ -118,12 +145,7 @@ describe('Test video NSFW policy', function () { }) it('Should display NSFW videos with blur user NSFW policy', async function () { - const results = [ - await getVideosListWithToken(server.url, userAccessToken), - await searchVideoWithToken(server.url, 'n', userAccessToken) - ] - - for (const res of results) { + for (const res of await getVideosFunctions(userAccessToken)) { expect(res.body.total).to.equal(2) const videos = res.body.data @@ -140,12 +162,7 @@ describe('Test video NSFW policy', function () { nsfwPolicy: 'display' }) - const results = [ - await getVideosListWithToken(server.url, server.accessToken), - await searchVideoWithToken(server.url, 'n', server.accessToken) - ] - - for (const res of results) { + for (const res of await getVideosFunctions(server.accessToken)) { expect(res.body.total).to.equal(2) const videos = res.body.data @@ -162,11 +179,7 @@ describe('Test video NSFW policy', function () { nsfwPolicy: 'do_not_list' }) - const results = [ - await getVideosListWithToken(server.url, server.accessToken), - await searchVideoWithToken(server.url, 'n', server.accessToken) - ] - for (const res of results) { + for (const res of await getVideosFunctions(server.accessToken)) { expect(res.body.total).to.equal(1) const videos = res.body.data diff --git a/server/tests/utils/videos/video-channels.ts b/server/tests/utils/videos/video-channels.ts index cfc541431..0b4fa89b7 100644 --- a/server/tests/utils/videos/video-channels.ts +++ b/server/tests/utils/videos/video-channels.ts @@ -34,7 +34,7 @@ function getAccountVideoChannelsList (url: string, accountId: number | string, s function addVideoChannel ( url: string, token: string, - accountId: number, + accountId: number | string, videoChannelAttributesArg: VideoChannelAttributes, expectedStatus = 200 ) { @@ -59,8 +59,8 @@ function addVideoChannel ( function updateVideoChannel ( url: string, token: string, - accountId: number, - channelId: number, + accountId: number | string, + channelId: number | string, attributes: VideoChannelAttributes, expectedStatus = 204 ) { @@ -79,7 +79,7 @@ function updateVideoChannel ( .expect(expectedStatus) } -function deleteVideoChannel (url: string, token: string, accountId: number, channelId: number, expectedStatus = 204) { +function deleteVideoChannel (url: string, token: string, accountId: number | string, channelId: number | string, expectedStatus = 204) { const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId return request(url) @@ -89,7 +89,7 @@ function deleteVideoChannel (url: string, token: string, accountId: number, chan .expect(expectedStatus) } -function getVideoChannel (url: string, accountId: number, channelId: number) { +function getVideoChannel (url: string, accountId: number | string, channelId: number | string) { const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId return request(url) diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 943c85cc7..2ba3a860b 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -167,6 +167,46 @@ function getMyVideos (url: string, accessToken: string, start: number, count: nu .expect('Content-Type', /json/) } +function getAccountVideos (url: string, accessToken: string, accountId: number | string, start: number, count: number, sort?: string) { + const path = '/api/v1/accounts/' + accountId + '/videos' + + return makeGetRequest({ + url, + path, + query: { + start, + count, + sort + }, + token: accessToken, + statusCodeExpected: 200 + }) +} + +function getVideoChannelVideos ( + url: string, + accessToken: string, + accountId: number | string, + videoChannelId: number | string, + start: number, + count: number, + sort?: string +) { + const path = '/api/v1/accounts/' + accountId + '/video-channels/' + videoChannelId + '/videos' + + return makeGetRequest({ + url, + path, + query: { + start, + count, + sort + }, + token: accessToken, + statusCodeExpected: 200 + }) +} + function getVideosListPagination (url: string, start: number, count: number, sort?: string) { const path = '/api/v1/videos' @@ -514,6 +554,8 @@ export { getVideoPrivacies, getVideoLanguages, getMyVideos, + getAccountVideos, + getVideoChannelVideos, searchVideoWithToken, getVideo, getVideoWithToken, -- cgit v1.2.3