From f6eebcb336c067e160a62020a5140d8d992ba384 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Aug 2018 11:51:39 +0200 Subject: Add ability to search a video with an URL --- server/tests/api/check-params/videos.ts | 6 +++--- server/tests/api/server/follows.ts | 3 ++- server/tests/api/server/handle-down.ts | 3 ++- server/tests/api/users/user-subscriptions.ts | 28 +++++++++++++++++++++++----- server/tests/api/videos/multiple-servers.ts | 18 ++++++++++++------ server/tests/api/videos/single-server.ts | 6 ++++-- server/tests/utils/videos/videos.ts | 25 +++++++++++++------------ 7 files changed, 59 insertions(+), 30 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 7fce8ba7c..904d22870 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -20,7 +20,7 @@ describe('Test videos API validator', function () { let userAccessToken = '' let accountName: string let channelId: number - let channelUUID: string + let channelName: string let videoId // --------------------------------------------------------------- @@ -42,7 +42,7 @@ describe('Test videos API validator', function () { { const res = await getMyUserInformation(server.url, server.accessToken) channelId = res.body.videoChannels[ 0 ].id - channelUUID = res.body.videoChannels[ 0 ].uuid + channelName = res.body.videoChannels[ 0 ].name accountName = res.body.account.name + '@' + res.body.account.host } }) @@ -140,7 +140,7 @@ describe('Test videos API validator', function () { let path: string before(async function () { - path = '/api/v1/video-channels/' + channelUUID + '/videos' + path = '/api/v1/video-channels/' + channelName + '/videos' }) it('Should fail with a bad start pagination', async function () { diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 243fcd4e7..310c291bf 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts @@ -311,7 +311,8 @@ describe('Test follows', function () { likes: 1, dislikes: 1, channel: { - name: 'Main root channel', + displayName: 'Main root channel', + name: 'root_channel', description: '', isLocal }, diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index df35b36eb..ed15c8090 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -71,7 +71,8 @@ describe('Test handle downs', function () { privacy: VideoPrivacy.PUBLIC, commentsEnabled: true, channel: { - name: 'Main root channel', + name: 'root_channel', + displayName: 'Main root channel', description: '', isLocal: false }, diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 2fbda6828..cb7d94b0b 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -2,7 +2,7 @@ import * as chai from 'chai' import 'mocha' -import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, userLogin } from '../../utils' +import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, updateVideo, userLogin } from '../../utils' import { killallServers, ServerInfo, uploadVideo } from '../../utils/index' import { setAccessTokensToServers } from '../../utils/users/login' import { Video, VideoChannel } from '../../../../shared/models/videos' @@ -20,6 +20,7 @@ const expect = chai.expect describe('Test users subscriptions', function () { let servers: ServerInfo[] = [] const users: { accessToken: string }[] = [] + let video3UUID: string before(async function () { this.timeout(120000) @@ -65,7 +66,8 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - await uploadVideo(servers[2].url, users[2].accessToken, { name: 'video server 3 added after follow' }) + const res = await uploadVideo(servers[2].url, users[2].accessToken, { name: 'video server 3 added after follow' }) + video3UUID = res.body.video.uuid await waitJobs(servers) }) @@ -247,7 +249,21 @@ describe('Test users subscriptions', function () { } }) + it('Should update a video of server 3 and see the updated video on server 1', async function () { + this.timeout(30000) + + await updateVideo(servers[2].url, users[2].accessToken, video3UUID, { name: 'video server 3 added after follow updated' }) + + await waitJobs(servers) + + const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') + const videos: Video[] = res.body.data + expect(videos[2].name).to.equal('video server 3 added after follow updated') + }) + it('Should remove user of server 3 subscription', async function () { + this.timeout(30000) + await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') await waitJobs(servers) @@ -267,6 +283,8 @@ describe('Test users subscriptions', function () { }) it('Should remove the root subscription and not display the videos anymore', async function () { + this.timeout(30000) + await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') await waitJobs(servers) @@ -288,7 +306,7 @@ describe('Test users subscriptions', function () { for (const video of res.body.data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') - expect(video.name).to.not.contain('video server 3 added after follow') + expect(video.name).to.not.contain('video server 3 added after follow updated') } }) @@ -309,7 +327,7 @@ describe('Test users subscriptions', function () { expect(videos[0].name).to.equal('video 1-3') expect(videos[1].name).to.equal('video 2-3') - expect(videos[2].name).to.equal('video server 3 added after follow') + expect(videos[2].name).to.equal('video server 3 added after follow updated') } { @@ -319,7 +337,7 @@ describe('Test users subscriptions', function () { for (const video of res.body.data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') - expect(video.name).to.not.contain('video server 3 added after follow') + expect(video.name).to.not.contain('video server 3 added after follow updated') } } }) diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 3c3839338..c551ccc59 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -128,7 +128,8 @@ describe('Test multiple servers', function () { privacy: VideoPrivacy.PUBLIC, commentsEnabled: true, channel: { - name: 'my channel', + displayName: 'my channel', + name: 'super_channel_name', description: 'super channel', isLocal }, @@ -201,7 +202,8 @@ describe('Test multiple servers', function () { tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], privacy: VideoPrivacy.PUBLIC, channel: { - name: 'Main user1 channel', + displayName: 'Main user1 channel', + name: 'user1_channel', description: 'super channel', isLocal }, @@ -307,7 +309,8 @@ describe('Test multiple servers', function () { tags: [ 'tag1p3' ], privacy: VideoPrivacy.PUBLIC, channel: { - name: 'Main root channel', + displayName: 'Main root channel', + name: 'root_channel', description: '', isLocal }, @@ -339,7 +342,8 @@ describe('Test multiple servers', function () { tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], privacy: VideoPrivacy.PUBLIC, channel: { - name: 'Main root channel', + displayName: 'Main root channel', + name: 'root_channel', description: '', isLocal }, @@ -647,7 +651,8 @@ describe('Test multiple servers', function () { tags: [ 'tag_up_1', 'tag_up_2' ], privacy: VideoPrivacy.PUBLIC, channel: { - name: 'Main root channel', + displayName: 'Main root channel', + name: 'root_channel', description: '', isLocal }, @@ -967,7 +972,8 @@ describe('Test multiple servers', function () { tags: [ ], privacy: VideoPrivacy.PUBLIC, channel: { - name: 'Main root channel', + displayName: 'Main root channel', + name: 'root_channel', description: '', isLocal }, diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 12181ad67..a757ad9da 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -56,7 +56,8 @@ describe('Test a single server', function () { privacy: VideoPrivacy.PUBLIC, commentsEnabled: true, channel: { - name: 'Main root channel', + displayName: 'Main root channel', + name: 'root_channel', description: '', isLocal: true }, @@ -87,7 +88,8 @@ describe('Test a single server', function () { duration: 5, commentsEnabled: false, channel: { - name: 'Main root channel', + name: 'root_channel', + displayName: 'Main root channel', description: '', isLocal: true }, diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 592248144..674a92df9 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -438,18 +438,19 @@ async function completeVideoCheck ( name: string host: string } - isLocal: boolean, - tags: string[], - privacy: number, - likes?: number, - dislikes?: number, - duration: number, + isLocal: boolean + tags: string[] + privacy: number + likes?: number + dislikes?: number + duration: number channel: { - name: string, + displayName: string + name: string description isLocal: boolean } - fixture: string, + fixture: string files: { resolution: number size: number @@ -476,8 +477,8 @@ async function completeVideoCheck ( expect(video.account.uuid).to.be.a('string') expect(video.account.host).to.equal(attributes.account.host) expect(video.account.name).to.equal(attributes.account.name) - expect(video.channel.displayName).to.equal(attributes.channel.name) - expect(video.channel.name).to.have.lengthOf(36) + expect(video.channel.displayName).to.equal(attributes.channel.displayName) + expect(video.channel.name).to.equal(attributes.channel.name) expect(video.likes).to.equal(attributes.likes) expect(video.dislikes).to.equal(attributes.dislikes) expect(video.isLocal).to.equal(attributes.isLocal) @@ -497,8 +498,8 @@ async function completeVideoCheck ( expect(videoDetails.tags).to.deep.equal(attributes.tags) expect(videoDetails.account.name).to.equal(attributes.account.name) expect(videoDetails.account.host).to.equal(attributes.account.host) - expect(videoDetails.channel.displayName).to.equal(attributes.channel.name) - expect(videoDetails.channel.name).to.have.lengthOf(36) + expect(video.channel.displayName).to.equal(attributes.channel.displayName) + expect(video.channel.name).to.equal(attributes.channel.name) expect(videoDetails.channel.host).to.equal(attributes.account.host) expect(videoDetails.channel.isLocal).to.equal(attributes.channel.isLocal) expect(dateIsValid(videoDetails.channel.createdAt.toString())).to.be.true -- cgit v1.2.3