From 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 26 Feb 2019 10:55:40 +0100 Subject: Playlist server API --- server/tests/api/check-params/video-playlists.ts | 117 ++++++++++++++++ server/tests/api/videos/video-playlists.ts | 161 +++++++++++++++++++++++ 2 files changed, 278 insertions(+) create mode 100644 server/tests/api/check-params/video-playlists.ts create mode 100644 server/tests/api/videos/video-playlists.ts (limited to 'server/tests') diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts new file mode 100644 index 000000000..7004badac --- /dev/null +++ b/server/tests/api/check-params/video-playlists.ts @@ -0,0 +1,117 @@ +/* tslint:disable:no-unused-expression */ + +import { omit } from 'lodash' +import 'mocha' +import { join } from 'path' +import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' +import { + createUser, + flushTests, + getMyUserInformation, + immutableAssign, + killallServers, + makeGetRequest, + makePostBodyRequest, + makeUploadRequest, + runServer, + ServerInfo, + setAccessTokensToServers, + updateCustomSubConfig, + userLogin +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/utils/videos/video-imports' + +describe('Test video playlists API validator', function () { + const path = '/api/v1/videos/video-playlists' + let server: ServerInfo + let userAccessToken = '' + + // --------------------------------------------------------------- + + before(async function () { + this.timeout(30000) + + await flushTests() + + server = await runServer(1) + + await setAccessTokensToServers([ server ]) + + const username = 'user1' + const password = 'my super password' + await createUser(server.url, server.accessToken, username, password) + userAccessToken = await userLogin(server, { username, password }) + }) + + describe('When listing video playlists', function () { + const globalPath = '/api/v1/video-playlists' + const accountPath = '/api/v1/accounts/root/video-playlists' + const videoChannelPath = '/api/v1/video-channels/root_channel/video-playlists' + + it('Should fail with a bad start pagination', async function () { + await checkBadStartPagination(server.url, globalPath, server.accessToken) + await checkBadStartPagination(server.url, accountPath, server.accessToken) + await checkBadStartPagination(server.url, videoChannelPath, server.accessToken) + }) + + it('Should fail with a bad count pagination', async function () { + await checkBadCountPagination(server.url, globalPath, server.accessToken) + await checkBadCountPagination(server.url, accountPath, server.accessToken) + await checkBadCountPagination(server.url, videoChannelPath, server.accessToken) + }) + + it('Should fail with an incorrect sort', async function () { + await checkBadSortPagination(server.url, globalPath, server.accessToken) + await checkBadSortPagination(server.url, accountPath, server.accessToken) + await checkBadSortPagination(server.url, videoChannelPath, server.accessToken) + }) + + it('Should fail with a bad account parameter', async function () { + const accountPath = '/api/v1/accounts/root2/video-playlists' + + await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken }) + }) + + it('Should fail with a bad video channel parameter', async function () { + const accountPath = '/api/v1/video-channels/bad_channel/video-playlists' + + await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken }) + }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: 200, token: server.accessToken }) + await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 200, token: server.accessToken }) + await makeGetRequest({ url: server.url, path: videoChannelPath, statusCodeExpected: 200, token: server.accessToken }) + }) + }) + + describe('When listing videos of a playlist', async function () { + const path = '/api/v1/video-playlists' + + 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) + }) + }) + + after(async function () { + killallServers([ server ]) + + // Keep the logs if the test failed + if (this['ok']) { + await flushTests() + } + }) +}) diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts new file mode 100644 index 000000000..cb23239da --- /dev/null +++ b/server/tests/api/videos/video-playlists.ts @@ -0,0 +1,161 @@ +/* tslint:disable:no-unused-expression */ + +import * as chai from 'chai' +import 'mocha' +import { join } from 'path' +import * as request from 'supertest' +import { VideoPrivacy } from '../../../../shared/models/videos' +import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' +import { + addVideoChannel, + checkTmpIsEmpty, + checkVideoFilesWereRemoved, + completeVideoCheck, + createUser, + dateIsValid, + doubleFollow, + flushAndRunMultipleServers, + flushTests, + getLocalVideos, + getVideo, + getVideoChannelsList, + getVideosList, + killallServers, + rateVideo, + removeVideo, + ServerInfo, + setAccessTokensToServers, + testImage, + updateVideo, + uploadVideo, + userLogin, + viewVideo, + wait, + webtorrentAdd +} from '../../../../shared/utils' +import { + addVideoCommentReply, + addVideoCommentThread, + deleteVideoComment, + getVideoCommentThreads, + getVideoThreadComments +} from '../../../../shared/utils/videos/video-comments' +import { waitJobs } from '../../../../shared/utils/server/jobs' + +const expect = chai.expect + +describe('Test video playlists', function () { + let servers: ServerInfo[] = [] + + before(async function () { + this.timeout(120000) + + servers = await flushAndRunMultipleServers(3) + + // Get the access tokens + await setAccessTokensToServers(servers) + + // Server 1 and server 2 follow each other + await doubleFollow(servers[0], servers[1]) + // Server 1 and server 3 follow each other + await doubleFollow(servers[0], servers[2]) + }) + + it('Should create a playlist on server 1 and have the playlist on server 2 and 3', async function () { + + }) + + it('Should create a playlist on server 2 and have the playlist on server 1 but not on server 3', async function () { + // create 2 playlists (with videos and no videos) + // With thumbnail and no thumbnail + }) + + it('Should have the playlist on server 3 after a new follow', async function () { + // Server 2 and server 3 follow each other + await doubleFollow(servers[1], servers[2]) + }) + + it('Should create some playlists and list them correctly', async function () { + // create 3 playlists with some videos in it + // check pagination + // check sort + // check empty + }) + + it('Should list video channel playlists', async function () { + // check pagination + // check sort + // check empty + }) + + it('Should list account playlists', async function () { + // check pagination + // check sort + // check empty + }) + + it('Should get a playlist', async function () { + // get empty playlist + // get non empty playlist + }) + + it('Should update a playlist', async function () { + // update thumbnail + + // update other details + }) + + it('Should create a playlist containing different startTimestamp/endTimestamp videos', async function () { + + }) + + it('Should correctly list playlist videos', async function () { + // empty + // some filters? + }) + + it('Should reorder the playlist', async function () { + // reorder 1 element + // reorder 3 elements + // reorder at the beginning + // reorder at the end + // reorder before/after + }) + + it('Should update startTimestamp/endTimestamp of some elements', async function () { + + }) + + it('Should delete some elements', async function () { + + }) + + it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () { + + }) + + it('Should have deleted the thumbnail on server 1, 2 and 3', async function () { + + }) + + it('Should unfollow servers 1 and 2 and hide their playlists', async function () { + + }) + + it('Should delete a channel and remove the associated playlist', async function () { + + }) + + it('Should delete an account and delete its playlists', async function () { + + }) + + after(async function () { + killallServers(servers) + + // Keep the logs if the test failed + if (this['ok']) { + await flushTests() + } + }) +}) -- cgit v1.2.3