diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/video-channels.ts | 12 | ||||
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 42 |
2 files changed, 46 insertions, 8 deletions
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index ff04f6b03..de88298d1 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -24,6 +24,7 @@ import { | |||
24 | checkBadStartPagination | 24 | checkBadStartPagination |
25 | } from '../../../../shared/extra-utils/requests/check-api-params' | 25 | } from '../../../../shared/extra-utils/requests/check-api-params' |
26 | import { join } from 'path' | 26 | import { join } from 'path' |
27 | import { VideoChannelUpdate } from '../../../../shared/models/videos' | ||
27 | 28 | ||
28 | const expect = chai.expect | 29 | const expect = chai.expect |
29 | 30 | ||
@@ -169,9 +170,11 @@ describe('Test video channels API validator', function () { | |||
169 | }) | 170 | }) |
170 | 171 | ||
171 | describe('When updating a video channel', function () { | 172 | describe('When updating a video channel', function () { |
172 | const baseCorrectParams = { | 173 | const baseCorrectParams: VideoChannelUpdate = { |
173 | displayName: 'hello', | 174 | displayName: 'hello', |
174 | description: 'super description' | 175 | description: 'super description', |
176 | support: 'toto', | ||
177 | bulkVideosSupportUpdate: false | ||
175 | } | 178 | } |
176 | let path: string | 179 | let path: string |
177 | 180 | ||
@@ -214,6 +217,11 @@ describe('Test video channels API validator', function () { | |||
214 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | 217 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) |
215 | }) | 218 | }) |
216 | 219 | ||
220 | it('Should fail with a bad bulkVideosSupportUpdate field', async function () { | ||
221 | const fields = immutableAssign(baseCorrectParams, { bulkVideosSupportUpdate: 'super' }) | ||
222 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
223 | }) | ||
224 | |||
217 | it('Should succeed with the correct parameters', async function () { | 225 | it('Should succeed with the correct parameters', async function () { |
218 | await makePutBodyRequest({ | 226 | await makePutBodyRequest({ |
219 | url: server.url, | 227 | url: server.url, |
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 2d298dd3f..4f600cae8 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { User, Video, VideoChannel } from '../../../../shared/index' | 5 | import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createUser, | 8 | createUser, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, getVideo, |
11 | getVideoChannelVideos, | 11 | getVideoChannelVideos, |
12 | testImage, | 12 | testImage, |
13 | updateVideo, | 13 | updateVideo, |
@@ -79,7 +79,8 @@ describe('Test video channels', function () { | |||
79 | 79 | ||
80 | // The channel is 1 is propagated to servers 2 | 80 | // The channel is 1 is propagated to servers 2 |
81 | { | 81 | { |
82 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name', channelId: secondVideoChannelId }) | 82 | const videoAttributesArg = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } |
83 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributesArg) | ||
83 | videoUUID = res.body.video.uuid | 84 | videoUUID = res.body.video.uuid |
84 | } | 85 | } |
85 | 86 | ||
@@ -201,12 +202,12 @@ describe('Test video channels', function () { | |||
201 | }) | 202 | }) |
202 | 203 | ||
203 | it('Should update video channel', async function () { | 204 | it('Should update video channel', async function () { |
204 | this.timeout(5000) | 205 | this.timeout(15000) |
205 | 206 | ||
206 | const videoChannelAttributes = { | 207 | const videoChannelAttributes = { |
207 | displayName: 'video channel updated', | 208 | displayName: 'video channel updated', |
208 | description: 'video channel description updated', | 209 | description: 'video channel description updated', |
209 | support: 'video channel support text updated' | 210 | support: 'support updated' |
210 | } | 211 | } |
211 | 212 | ||
212 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) | 213 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) |
@@ -224,7 +225,36 @@ describe('Test video channels', function () { | |||
224 | expect(res.body.data[0].name).to.equal('second_video_channel') | 225 | expect(res.body.data[0].name).to.equal('second_video_channel') |
225 | expect(res.body.data[0].displayName).to.equal('video channel updated') | 226 | expect(res.body.data[0].displayName).to.equal('video channel updated') |
226 | expect(res.body.data[0].description).to.equal('video channel description updated') | 227 | expect(res.body.data[0].description).to.equal('video channel description updated') |
227 | expect(res.body.data[0].support).to.equal('video channel support text updated') | 228 | expect(res.body.data[0].support).to.equal('support updated') |
229 | } | ||
230 | }) | ||
231 | |||
232 | it('Should not have updated the video support field', async function () { | ||
233 | for (const server of servers) { | ||
234 | const res = await getVideo(server.url, videoUUID) | ||
235 | const video: VideoDetails = res.body | ||
236 | |||
237 | expect(video.support).to.equal('video support field') | ||
238 | } | ||
239 | }) | ||
240 | |||
241 | it('Should update the channel support field and update videos too', async function () { | ||
242 | this.timeout(35000) | ||
243 | |||
244 | const videoChannelAttributes = { | ||
245 | support: 'video channel support text updated', | ||
246 | bulkVideosSupportUpdate: true | ||
247 | } | ||
248 | |||
249 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) | ||
250 | |||
251 | await waitJobs(servers) | ||
252 | |||
253 | for (const server of servers) { | ||
254 | const res = await getVideo(server.url, videoUUID) | ||
255 | const video: VideoDetails = res.body | ||
256 | |||
257 | expect(video.support).to.equal(videoChannelAttributes.support) | ||
228 | } | 258 | } |
229 | }) | 259 | }) |
230 | 260 | ||