diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:10:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:25:51 +0200 |
commit | 0f320037e689b2778959c12ddd4ce790f6e4ae4f (patch) | |
tree | 425acaa4345442388901c833275bb76b42a8a268 /server/tests | |
parent | 9675333decd0b89b73a4fc67b39272f7296bfe3f (diff) | |
download | PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.gz PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.zst PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.zip |
Add ability to update a video channel
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 78 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 15 |
2 files changed, 66 insertions, 27 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 585b6a2b5..35c418f7c 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { User } from '../../../../shared/index' | 5 | import { User, Video } from '../../../../shared/index' |
6 | import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, uploadVideo, wait } from '../../utils' | 6 | import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo, wait } from '../../utils' |
7 | import { | 7 | import { |
8 | addVideoChannel, | 8 | addVideoChannel, |
9 | deleteVideoChannel, | 9 | deleteVideoChannel, |
@@ -25,8 +25,11 @@ describe('Test video channels', function () { | |||
25 | let servers: ServerInfo[] | 25 | let servers: ServerInfo[] |
26 | let userInfo: User | 26 | let userInfo: User |
27 | let accountUUID: string | 27 | let accountUUID: string |
28 | let videoChannelId: number | 28 | let firstVideoChannelId: number |
29 | let videoChannelUUID: string | 29 | let firstVideoChannelUUID: string |
30 | let secondVideoChannelId: number | ||
31 | let secondVideoChannelUUID: string | ||
32 | let videoUUID: string | ||
30 | 33 | ||
31 | before(async function () { | 34 | before(async function () { |
32 | this.timeout(30000) | 35 | this.timeout(30000) |
@@ -42,6 +45,9 @@ describe('Test video channels', function () { | |||
42 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 45 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
43 | const user: User = res.body | 46 | const user: User = res.body |
44 | accountUUID = user.account.uuid | 47 | accountUUID = user.account.uuid |
48 | |||
49 | firstVideoChannelId = user.videoChannels[0].id | ||
50 | firstVideoChannelUUID = user.videoChannels[0].uuid | ||
45 | } | 51 | } |
46 | 52 | ||
47 | await wait(5000) | 53 | await wait(5000) |
@@ -58,17 +64,22 @@ describe('Test video channels', function () { | |||
58 | it('Should create another video channel', async function () { | 64 | it('Should create another video channel', async function () { |
59 | this.timeout(10000) | 65 | this.timeout(10000) |
60 | 66 | ||
61 | const videoChannel = { | 67 | { |
62 | displayName: 'second video channel', | 68 | const videoChannel = { |
63 | description: 'super video channel description', | 69 | displayName: 'second video channel', |
64 | support: 'super video channel support text' | 70 | description: 'super video channel description', |
71 | support: 'super video channel support text' | ||
72 | } | ||
73 | const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | ||
74 | secondVideoChannelId = res.body.videoChannel.id | ||
75 | secondVideoChannelUUID = res.body.videoChannel.uuid | ||
65 | } | 76 | } |
66 | const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) | ||
67 | videoChannelId = res.body.videoChannel.id | ||
68 | videoChannelUUID = res.body.videoChannel.uuid | ||
69 | 77 | ||
70 | // The channel is 1 is propagated to servers 2 | 78 | // The channel is 1 is propagated to servers 2 |
71 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name', channelId: videoChannelId }) | 79 | { |
80 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name', channelId: secondVideoChannelId }) | ||
81 | videoUUID = res.body.video.uuid | ||
82 | } | ||
72 | 83 | ||
73 | await wait(3000) | 84 | await wait(3000) |
74 | }) | 85 | }) |
@@ -130,7 +141,7 @@ describe('Test video channels', function () { | |||
130 | support: 'video channel support text updated' | 141 | support: 'video channel support text updated' |
131 | } | 142 | } |
132 | 143 | ||
133 | await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes) | 144 | await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes) |
134 | 145 | ||
135 | await wait(3000) | 146 | await wait(3000) |
136 | }) | 147 | }) |
@@ -149,7 +160,7 @@ describe('Test video channels', function () { | |||
149 | }) | 160 | }) |
150 | 161 | ||
151 | it('Should get video channel', async function () { | 162 | it('Should get video channel', async function () { |
152 | const res = await getVideoChannel(servers[0].url, videoChannelId) | 163 | const res = await getVideoChannel(servers[0].url, secondVideoChannelId) |
153 | 164 | ||
154 | const videoChannel = res.body | 165 | const videoChannel = res.body |
155 | expect(videoChannel.displayName).to.equal('video channel updated') | 166 | expect(videoChannel.displayName).to.equal('video channel updated') |
@@ -157,20 +168,45 @@ describe('Test video channels', function () { | |||
157 | expect(videoChannel.support).to.equal('video channel support text updated') | 168 | expect(videoChannel.support).to.equal('video channel support text updated') |
158 | }) | 169 | }) |
159 | 170 | ||
160 | it('Should list the video channel videos', async function () { | 171 | it('Should list the second video channel videos', async function () { |
161 | this.timeout(10000) | 172 | this.timeout(10000) |
162 | 173 | ||
163 | for (const server of servers) { | 174 | for (const server of servers) { |
164 | const res = await getVideoChannelVideos(server.url, server.accessToken, videoChannelUUID, 0, 5) | 175 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) |
165 | expect(res.body.total).to.equal(1) | 176 | expect(res1.body.total).to.equal(1) |
166 | expect(res.body.data).to.be.an('array') | 177 | expect(res1.body.data).to.be.an('array') |
167 | expect(res.body.data).to.have.lengthOf(1) | 178 | expect(res1.body.data).to.have.lengthOf(1) |
168 | expect(res.body.data[0].name).to.equal('my video name') | 179 | expect(res1.body.data[0].name).to.equal('my video name') |
180 | } | ||
181 | }) | ||
182 | |||
183 | it('Should change the video channel of a video', async function () { | ||
184 | this.timeout(10000) | ||
185 | |||
186 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId }) | ||
187 | |||
188 | await wait(5000) | ||
189 | }) | ||
190 | |||
191 | it('Should list the first video channel videos', async function () { | ||
192 | this.timeout(10000) | ||
193 | |||
194 | for (const server of servers) { | ||
195 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) | ||
196 | expect(res1.body.total).to.equal(0) | ||
197 | |||
198 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, firstVideoChannelUUID, 0, 5) | ||
199 | expect(res2.body.total).to.equal(1) | ||
200 | |||
201 | const videos: Video[] = res2.body.data | ||
202 | expect(videos).to.be.an('array') | ||
203 | expect(videos).to.have.lengthOf(1) | ||
204 | expect(videos[0].name).to.equal('my video name') | ||
169 | } | 205 | } |
170 | }) | 206 | }) |
171 | 207 | ||
172 | it('Should delete video channel', async function () { | 208 | it('Should delete video channel', async function () { |
173 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId) | 209 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId) |
174 | }) | 210 | }) |
175 | 211 | ||
176 | it('Should have video channel deleted', async function () { | 212 | it('Should have video channel deleted', async function () { |
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 870dfd21f..07c4ffc77 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | ServerInfo, | 15 | ServerInfo, |
16 | testImage | 16 | testImage |
17 | } from '../' | 17 | } from '../' |
18 | import { VideoPrivacy } from '../../../../shared/models/videos' | 18 | import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' |
19 | import { readdirPromise } from '../../../helpers/core-utils' | 19 | import { readdirPromise } from '../../../helpers/core-utils' |
20 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers' | 20 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers' |
21 | import { dateIsValid, webtorrentAdd } from '../index' | 21 | import { dateIsValid, webtorrentAdd } from '../index' |
@@ -385,6 +385,7 @@ function updateVideo (url: string, accessToken: string, id: number | string, att | |||
385 | if (attributes.description) body['description'] = attributes.description | 385 | if (attributes.description) body['description'] = attributes.description |
386 | if (attributes.tags) body['tags'] = attributes.tags | 386 | if (attributes.tags) body['tags'] = attributes.tags |
387 | if (attributes.privacy) body['privacy'] = attributes.privacy | 387 | if (attributes.privacy) body['privacy'] = attributes.privacy |
388 | if (attributes.channelId) body['channelId'] = attributes.channelId | ||
388 | 389 | ||
389 | // Upload request | 390 | // Upload request |
390 | if (attributes.thumbnailfile || attributes.previewfile) { | 391 | if (attributes.thumbnailfile || attributes.previewfile) { |
@@ -489,6 +490,8 @@ async function completeVideoCheck ( | |||
489 | expect(video.account.uuid).to.be.a('string') | 490 | expect(video.account.uuid).to.be.a('string') |
490 | expect(video.account.host).to.equal(attributes.account.host) | 491 | expect(video.account.host).to.equal(attributes.account.host) |
491 | expect(video.account.name).to.equal(attributes.account.name) | 492 | expect(video.account.name).to.equal(attributes.account.name) |
493 | expect(video.channel.displayName).to.equal(attributes.channel.name) | ||
494 | expect(video.channel.name).to.have.lengthOf(36) | ||
492 | expect(video.likes).to.equal(attributes.likes) | 495 | expect(video.likes).to.equal(attributes.likes) |
493 | expect(video.dislikes).to.equal(attributes.dislikes) | 496 | expect(video.dislikes).to.equal(attributes.dislikes) |
494 | expect(video.isLocal).to.equal(attributes.isLocal) | 497 | expect(video.isLocal).to.equal(attributes.isLocal) |
@@ -498,19 +501,19 @@ async function completeVideoCheck ( | |||
498 | expect(dateIsValid(video.updatedAt)).to.be.true | 501 | expect(dateIsValid(video.updatedAt)).to.be.true |
499 | 502 | ||
500 | const res = await getVideo(url, video.uuid) | 503 | const res = await getVideo(url, video.uuid) |
501 | const videoDetails = res.body | 504 | const videoDetails: VideoDetails = res.body |
502 | 505 | ||
503 | expect(videoDetails.files).to.have.lengthOf(attributes.files.length) | 506 | expect(videoDetails.files).to.have.lengthOf(attributes.files.length) |
504 | expect(videoDetails.tags).to.deep.equal(attributes.tags) | 507 | expect(videoDetails.tags).to.deep.equal(attributes.tags) |
505 | expect(videoDetails.account.name).to.equal(attributes.account.name) | 508 | expect(videoDetails.account.name).to.equal(attributes.account.name) |
506 | expect(videoDetails.account.host).to.equal(attributes.account.host) | 509 | expect(videoDetails.account.host).to.equal(attributes.account.host) |
507 | expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) | ||
508 | |||
509 | expect(videoDetails.channel.displayName).to.equal(attributes.channel.name) | 510 | expect(videoDetails.channel.displayName).to.equal(attributes.channel.name) |
510 | expect(videoDetails.channel.name).to.have.lengthOf(36) | 511 | expect(videoDetails.channel.name).to.have.lengthOf(36) |
512 | expect(videoDetails.channel.host).to.equal(attributes.account.host) | ||
511 | expect(videoDetails.channel.isLocal).to.equal(attributes.channel.isLocal) | 513 | expect(videoDetails.channel.isLocal).to.equal(attributes.channel.isLocal) |
512 | expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true | 514 | expect(dateIsValid(videoDetails.channel.createdAt.toString())).to.be.true |
513 | expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true | 515 | expect(dateIsValid(videoDetails.channel.updatedAt.toString())).to.be.true |
516 | expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) | ||
514 | 517 | ||
515 | for (const attributeFile of attributes.files) { | 518 | for (const attributeFile of attributes.files) { |
516 | const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution) | 519 | const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution) |