aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-15 14:46:26 +0100
committerChocobozzz <me@florianbigard.com>2018-02-15 15:29:07 +0100
commit2422c46b27790d94fd29a7092170cee5a1b56008 (patch)
treed5c1942ce20cadb27a551d87c789edfe92f5b105 /server/tests/api
parent34cbef8c6cc912143a421413bdd832c4adcc556a (diff)
downloadPeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip
Implement support field in video and video channel
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/users.ts8
-rw-r--r--server/tests/api/check-params/video-channels.ts15
-rw-r--r--server/tests/api/check-params/videos.ts18
-rw-r--r--server/tests/api/server/follows.ts1
-rw-r--r--server/tests/api/server/handle-down.ts2
-rw-r--r--server/tests/api/users/users-multiple-servers.ts24
-rw-r--r--server/tests/api/users/users.ts21
-rw-r--r--server/tests/api/videos/multiple-servers.ts11
-rw-r--r--server/tests/api/videos/single-server.ts2
-rw-r--r--server/tests/api/videos/video-channels.ts122
10 files changed, 173 insertions, 51 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index d9dea0713..ee591d620 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -255,6 +255,14 @@ describe('Test users API validators', function () {
255 await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 }) 255 await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 })
256 }) 256 })
257 257
258 it('Should fail with a too long description', async function () {
259 const fields = {
260 description: 'super'.repeat(60)
261 }
262
263 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
264 })
265
258 it('Should succeed with the correct params', async function () { 266 it('Should succeed with the correct params', async function () {
259 const fields = { 267 const fields = {
260 password: 'my super password', 268 password: 'my super password',
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index d073e28f0..43c5462ee 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -62,7 +62,8 @@ describe('Test videos API validator', function () {
62 describe('When adding a video channel', function () { 62 describe('When adding a video channel', function () {
63 const baseCorrectParams = { 63 const baseCorrectParams = {
64 name: 'hello', 64 name: 'hello',
65 description: 'super description' 65 description: 'super description',
66 support: 'super support text'
66 } 67 }
67 68
68 it('Should fail with a non authenticated user', async function () { 69 it('Should fail with a non authenticated user', async function () {
@@ -89,13 +90,18 @@ describe('Test videos API validator', function () {
89 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 90 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
90 }) 91 })
91 92
93 it('Should fail with a long support text', async function () {
94 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
95 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
96 })
97
92 it('Should succeed with the correct parameters', async function () { 98 it('Should succeed with the correct parameters', async function () {
93 await makePostBodyRequest({ 99 await makePostBodyRequest({
94 url: server.url, 100 url: server.url,
95 path, 101 path,
96 token: server.accessToken, 102 token: server.accessToken,
97 fields: baseCorrectParams, 103 fields: baseCorrectParams,
98 statusCodeExpected: 204 104 statusCodeExpected: 200
99 }) 105 })
100 }) 106 })
101 }) 107 })
@@ -143,6 +149,11 @@ describe('Test videos API validator', function () {
143 await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields }) 149 await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields })
144 }) 150 })
145 151
152 it('Should fail with a long support text', async function () {
153 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
154 await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields })
155 })
156
146 it('Should succeed with the correct parameters', async function () { 157 it('Should succeed with the correct parameters', async function () {
147 await makePutBodyRequest({ 158 await makePutBodyRequest({
148 url: server.url, 159 url: server.url,
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index aa30b721b..1d5c8543d 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -102,6 +102,7 @@ describe('Test videos API validator', function () {
102 nsfw: false, 102 nsfw: false,
103 commentsEnabled: true, 103 commentsEnabled: true,
104 description: 'my super description', 104 description: 'my super description',
105 support: 'my super support text',
105 tags: [ 'tag1', 'tag2' ], 106 tags: [ 'tag1', 'tag2' ],
106 privacy: VideoPrivacy.PUBLIC, 107 privacy: VideoPrivacy.PUBLIC,
107 channelId 108 channelId
@@ -178,7 +179,14 @@ describe('Test videos API validator', function () {
178 }) 179 })
179 180
180 it('Should fail with a long description', async function () { 181 it('Should fail with a long description', async function () {
181 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) 182 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
183 const attaches = baseCorrectAttaches
184
185 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
186 })
187
188 it('Should fail with a long support text', async function () {
189 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
182 const attaches = baseCorrectAttaches 190 const attaches = baseCorrectAttaches
183 191
184 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 192 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -417,7 +425,13 @@ describe('Test videos API validator', function () {
417 }) 425 })
418 426
419 it('Should fail with a long description', async function () { 427 it('Should fail with a long description', async function () {
420 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) 428 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
429
430 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
431 })
432
433 it('Should fail with a long support text', async function () {
434 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
421 435
422 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 436 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
423 }) 437 })
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 46ad4879e..19b843861 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -280,6 +280,7 @@ describe('Test follows', function () {
280 language: 3, 280 language: 3,
281 nsfw: true, 281 nsfw: true,
282 description: 'my super description', 282 description: 'my super description',
283 support: 'my super support text',
283 host: 'localhost:9003', 284 host: 'localhost:9003',
284 account: 'root', 285 account: 'root',
285 isLocal, 286 isLocal,
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 4cedeb89e..84153b097 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -36,6 +36,7 @@ describe('Test handle downs', function () {
36 nsfw: true, 36 nsfw: true,
37 privacy: VideoPrivacy.PUBLIC, 37 privacy: VideoPrivacy.PUBLIC,
38 description: 'my super description for server 1', 38 description: 'my super description for server 1',
39 support: 'my super support text for server 1',
39 tags: [ 'tag1p1', 'tag2p1' ], 40 tags: [ 'tag1p1', 'tag2p1' ],
40 fixture: 'video_short1.webm' 41 fixture: 'video_short1.webm'
41 } 42 }
@@ -51,6 +52,7 @@ describe('Test handle downs', function () {
51 language: 9, 52 language: 9,
52 nsfw: true, 53 nsfw: true,
53 description: 'my super description for server 1', 54 description: 'my super description for server 1',
55 support: 'my super support text for server 1',
54 host: 'localhost:9001', 56 host: 'localhost:9001',
55 account: 'root', 57 account: 'root',
56 isLocal: false, 58 isLocal: false,
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 3c4eaff14..bb458f7a5 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -3,7 +3,10 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { Account } from '../../../../shared/models/actors' 5import { Account } from '../../../../shared/models/actors'
6import { checkVideoFilesWereRemoved, createUser, doubleFollow, flushAndRunMultipleServers, removeUser, userLogin, wait } from '../../utils' 6import {
7 checkVideoFilesWereRemoved, createUser, doubleFollow, flushAndRunMultipleServers, removeUser, updateMyUser, userLogin,
8 wait
9} from '../../utils'
7import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' 10import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index'
8import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' 11import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts'
9import { setAccessTokensToServers } from '../../utils/users/login' 12import { setAccessTokensToServers } from '../../utils/users/login'
@@ -51,6 +54,22 @@ describe('Test users with multiple servers', function () {
51 await wait(5000) 54 await wait(5000)
52 }) 55 })
53 56
57 it('Should be able to update my description', async function () {
58 this.timeout(10000)
59
60 await updateMyUser({
61 url: servers[0].url,
62 accessToken: servers[0].accessToken,
63 description: 'my super description updated'
64 })
65
66 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
67 user = res.body
68 expect(user.account.description).to.equal('my super description updated')
69
70 await wait(5000)
71 })
72
54 it('Should be able to update my avatar', async function () { 73 it('Should be able to update my avatar', async function () {
55 this.timeout(10000) 74 this.timeout(10000)
56 75
@@ -70,7 +89,7 @@ describe('Test users with multiple servers', function () {
70 await wait(5000) 89 await wait(5000)
71 }) 90 })
72 91
73 it('Should have updated my avatar on other servers too', async function () { 92 it('Should have updated my avatar and my description on other servers too', async function () {
74 for (const server of servers) { 93 for (const server of servers) {
75 const resAccounts = await getAccountsList(server.url, '-createdAt') 94 const resAccounts = await getAccountsList(server.url, '-createdAt')
76 95
@@ -81,6 +100,7 @@ describe('Test users with multiple servers', function () {
81 const rootServer1Get = resAccount.body as Account 100 const rootServer1Get = resAccount.body as Account
82 expect(rootServer1Get.name).to.equal('root') 101 expect(rootServer1Get.name).to.equal('root')
83 expect(rootServer1Get.host).to.equal('localhost:9001') 102 expect(rootServer1Get.host).to.equal('localhost:9001')
103 expect(rootServer1Get.description).to.equal('my super description updated')
84 104
85 await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') 105 await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png')
86 } 106 }
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index ac167d4f9..c650a74f5 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -172,6 +172,7 @@ describe('Test users', function () {
172 expect(user.videoQuota).to.equal(2 * 1024 * 1024) 172 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
173 expect(user.roleLabel).to.equal('User') 173 expect(user.roleLabel).to.equal('User')
174 expect(user.id).to.be.a('number') 174 expect(user.id).to.be.a('number')
175 expect(user.account.description).to.be.null
175 }) 176 })
176 177
177 it('Should be able to upload a video with this user', async function () { 178 it('Should be able to upload a video with this user', async function () {
@@ -315,6 +316,7 @@ describe('Test users', function () {
315 expect(user.displayNSFW).to.be.ok 316 expect(user.displayNSFW).to.be.ok
316 expect(user.videoQuota).to.equal(2 * 1024 * 1024) 317 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
317 expect(user.id).to.be.a('number') 318 expect(user.id).to.be.a('number')
319 expect(user.account.description).to.be.null
318 }) 320 })
319 321
320 it('Should be able to change the autoPlayVideo attribute', async function () { 322 it('Should be able to change the autoPlayVideo attribute', async function () {
@@ -345,6 +347,7 @@ describe('Test users', function () {
345 expect(user.displayNSFW).to.be.ok 347 expect(user.displayNSFW).to.be.ok
346 expect(user.videoQuota).to.equal(2 * 1024 * 1024) 348 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
347 expect(user.id).to.be.a('number') 349 expect(user.id).to.be.a('number')
350 expect(user.account.description).to.be.null
348 }) 351 })
349 352
350 it('Should be able to update my avatar', async function () { 353 it('Should be able to update my avatar', async function () {
@@ -362,6 +365,24 @@ describe('Test users', function () {
362 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') 365 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png')
363 }) 366 })
364 367
368 it('Should be able to update my description', async function () {
369 await updateMyUser({
370 url: server.url,
371 accessToken: accessTokenUser,
372 description: 'my super description updated'
373 })
374
375 const res = await getMyUserInformation(server.url, accessTokenUser)
376 const user = res.body
377
378 expect(user.username).to.equal('user_1')
379 expect(user.email).to.equal('updated@example.com')
380 expect(user.displayNSFW).to.be.ok
381 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
382 expect(user.id).to.be.a('number')
383 expect(user.account.description).to.equal('my super description updated')
384 })
385
365 it('Should be able to update another user', async function () { 386 it('Should be able to update another user', async function () {
366 await updateUser({ 387 await updateUser({
367 url: server.url, 388 url: server.url,
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 85d158d61..c82ac1348 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -70,6 +70,7 @@ describe('Test multiple servers', function () {
70 language: 9, 70 language: 9,
71 nsfw: true, 71 nsfw: true,
72 description: 'my super description for server 1', 72 description: 'my super description for server 1',
73 support: 'my super support text for server 1',
73 tags: [ 'tag1p1', 'tag2p1' ], 74 tags: [ 'tag1p1', 'tag2p1' ],
74 channelId: videoChannelId, 75 channelId: videoChannelId,
75 fixture: 'video_short1.webm' 76 fixture: 'video_short1.webm'
@@ -88,6 +89,7 @@ describe('Test multiple servers', function () {
88 language: 9, 89 language: 9,
89 nsfw: true, 90 nsfw: true,
90 description: 'my super description for server 1', 91 description: 'my super description for server 1',
92 support: 'my super support text for server 1',
91 host: 'localhost:9001', 93 host: 'localhost:9001',
92 account: 'root', 94 account: 'root',
93 isLocal, 95 isLocal,
@@ -136,6 +138,7 @@ describe('Test multiple servers', function () {
136 language: 11, 138 language: 11,
137 nsfw: true, 139 nsfw: true,
138 description: 'my super description for server 2', 140 description: 'my super description for server 2',
141 support: 'my super support text for server 2',
139 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], 142 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
140 fixture: 'video_short2.webm', 143 fixture: 'video_short2.webm',
141 thumbnailfile: 'thumbnail.jpg', 144 thumbnailfile: 'thumbnail.jpg',
@@ -156,6 +159,7 @@ describe('Test multiple servers', function () {
156 language: 11, 159 language: 11,
157 nsfw: true, 160 nsfw: true,
158 description: 'my super description for server 2', 161 description: 'my super description for server 2',
162 support: 'my super support text for server 2',
159 host: 'localhost:9002', 163 host: 'localhost:9002',
160 account: 'user1', 164 account: 'user1',
161 isLocal, 165 isLocal,
@@ -211,6 +215,7 @@ describe('Test multiple servers', function () {
211 language: 11, 215 language: 11,
212 nsfw: true, 216 nsfw: true,
213 description: 'my super description for server 3', 217 description: 'my super description for server 3',
218 support: 'my super support text for server 3',
214 tags: [ 'tag1p3' ], 219 tags: [ 'tag1p3' ],
215 fixture: 'video_short3.webm' 220 fixture: 'video_short3.webm'
216 } 221 }
@@ -223,6 +228,7 @@ describe('Test multiple servers', function () {
223 language: 12, 228 language: 12,
224 nsfw: false, 229 nsfw: false,
225 description: 'my super description for server 3-2', 230 description: 'my super description for server 3-2',
231 support: 'my super support text for server 3-2',
226 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 232 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
227 fixture: 'video_short.webm' 233 fixture: 'video_short.webm'
228 } 234 }
@@ -257,6 +263,7 @@ describe('Test multiple servers', function () {
257 language: 11, 263 language: 11,
258 nsfw: true, 264 nsfw: true,
259 description: 'my super description for server 3', 265 description: 'my super description for server 3',
266 support: 'my super support text for server 3',
260 host: 'localhost:9003', 267 host: 'localhost:9003',
261 account: 'root', 268 account: 'root',
262 isLocal, 269 isLocal,
@@ -286,6 +293,7 @@ describe('Test multiple servers', function () {
286 language: 12, 293 language: 12,
287 nsfw: false, 294 nsfw: false,
288 description: 'my super description for server 3-2', 295 description: 'my super description for server 3-2',
296 support: 'my super support text for server 3-2',
289 host: 'localhost:9003', 297 host: 'localhost:9003',
290 account: 'root', 298 account: 'root',
291 commentsEnabled: true, 299 commentsEnabled: true,
@@ -525,6 +533,7 @@ describe('Test multiple servers', function () {
525 language: 13, 533 language: 13,
526 nsfw: true, 534 nsfw: true,
527 description: 'my super description updated', 535 description: 'my super description updated',
536 support: 'my super support text updated',
528 tags: [ 'tag_up_1', 'tag_up_2' ], 537 tags: [ 'tag_up_1', 'tag_up_2' ],
529 thumbnailfile: 'thumbnail.jpg', 538 thumbnailfile: 'thumbnail.jpg',
530 previewfile: 'preview.jpg' 539 previewfile: 'preview.jpg'
@@ -553,6 +562,7 @@ describe('Test multiple servers', function () {
553 language: 13, 562 language: 13,
554 nsfw: true, 563 nsfw: true,
555 description: 'my super description updated', 564 description: 'my super description updated',
565 support: 'my super support text updated',
556 host: 'localhost:9003', 566 host: 'localhost:9003',
557 account: 'root', 567 account: 'root',
558 isLocal, 568 isLocal,
@@ -841,6 +851,7 @@ describe('Test multiple servers', function () {
841 language: null, 851 language: null,
842 nsfw: false, 852 nsfw: false,
843 description: null, 853 description: null,
854 support: null,
844 host: 'localhost:9002', 855 host: 'localhost:9002',
845 account: 'root', 856 account: 'root',
846 isLocal, 857 isLocal,
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 8f55075fb..83b6a0e9a 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -26,6 +26,7 @@ describe('Test a single server', function () {
26 language: 3, 26 language: 3,
27 nsfw: true, 27 nsfw: true,
28 description: 'my super description', 28 description: 'my super description',
29 support: 'my super support text',
29 host: 'localhost:9001', 30 host: 'localhost:9001',
30 account: 'root', 31 account: 'root',
31 isLocal: true, 32 isLocal: true,
@@ -54,6 +55,7 @@ describe('Test a single server', function () {
54 language: 5, 55 language: 5,
55 nsfw: false, 56 nsfw: false,
56 description: 'my super description updated', 57 description: 'my super description updated',
58 support: 'my super support text updated',
57 host: 'localhost:9001', 59 host: 'localhost:9001',
58 account: 'root', 60 account: 'root',
59 isLocal: true, 61 isLocal: true,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 25b7ad6ab..b9c9bbf3c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -1,27 +1,27 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
5const expect = chai.expect 4import 'mocha'
6 5import { User } from '../../../../shared/index'
6import { doubleFollow, flushAndRunMultipleServers, uploadVideo, wait } from '../../utils'
7import { 7import {
8 ServerInfo, 8 addVideoChannel,
9 deleteVideoChannel,
9 flushTests, 10 flushTests,
10 runServer, 11 getAccountVideoChannelsList,
11 setAccessTokensToServers,
12 killallServers,
13 getMyUserInformation, 12 getMyUserInformation,
13 getVideoChannel,
14 getVideoChannelsList, 14 getVideoChannelsList,
15 addVideoChannel, 15 killallServers,
16 getAccountVideoChannelsList, 16 ServerInfo,
17 updateVideoChannel, 17 setAccessTokensToServers,
18 deleteVideoChannel, 18 updateVideoChannel
19 getVideoChannel
20} from '../../utils/index' 19} from '../../utils/index'
21import { User } from '../../../../shared/index'
22 20
23describe('Test a video channels', function () { 21const expect = chai.expect
24 let server: ServerInfo 22
23describe('Test video channels', function () {
24 let servers: ServerInfo[]
25 let userInfo: User 25 let userInfo: User
26 let videoChannelId: number 26 let videoChannelId: number
27 27
@@ -30,29 +30,41 @@ describe('Test a video channels', function () {
30 30
31 await flushTests() 31 await flushTests()
32 32
33 server = await runServer(1) 33 servers = await flushAndRunMultipleServers(2)
34
35 await setAccessTokensToServers(servers)
36 await doubleFollow(servers[0], servers[1])
34 37
35 await setAccessTokensToServers([ server ]) 38 await wait(5000)
36 }) 39 })
37 40
38 it('Should have one video channel (created with root)', async () => { 41 it('Should have one video channel (created with root)', async () => {
39 const res = await getVideoChannelsList(server.url, 0, 2) 42 const res = await getVideoChannelsList(servers[0].url, 0, 2)
40 43
41 expect(res.body.total).to.equal(1) 44 expect(res.body.total).to.equal(1)
42 expect(res.body.data).to.be.an('array') 45 expect(res.body.data).to.be.an('array')
43 expect(res.body.data).to.have.lengthOf(1) 46 expect(res.body.data).to.have.lengthOf(1)
44 }) 47 })
45 48
46 it('Should create another video channel', async () => { 49 it('Should create another video channel', async function () {
50 this.timeout(10000)
51
47 const videoChannel = { 52 const videoChannel = {
48 name: 'second video channel', 53 name: 'second video channel',
49 description: 'super video channel description' 54 description: 'super video channel description',
55 support: 'super video channel support text'
50 } 56 }
51 await addVideoChannel(server.url, server.accessToken, videoChannel) 57 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
58 videoChannelId = res.body.videoChannel.id
59
60 // The channel is 1 is propagated to servers 2
61 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: videoChannelId })
62
63 await wait(3000)
52 }) 64 })
53 65
54 it('Should have two video channels when getting my information', async () => { 66 it('Should have two video channels when getting my information', async () => {
55 const res = await getMyUserInformation(server.url, server.accessToken) 67 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
56 userInfo = res.body 68 userInfo = res.body
57 69
58 expect(userInfo.videoChannels).to.be.an('array') 70 expect(userInfo.videoChannels).to.be.an('array')
@@ -62,11 +74,11 @@ describe('Test a video channels', function () {
62 expect(videoChannels[0].displayName).to.equal('Default root channel') 74 expect(videoChannels[0].displayName).to.equal('Default root channel')
63 expect(videoChannels[1].displayName).to.equal('second video channel') 75 expect(videoChannels[1].displayName).to.equal('second video channel')
64 expect(videoChannels[1].description).to.equal('super video channel description') 76 expect(videoChannels[1].description).to.equal('super video channel description')
77 expect(videoChannels[1].support).to.equal('super video channel support text')
65 }) 78 })
66 79
67 it('Should have two video channels when getting account channels', async () => { 80 it('Should have two video channels when getting account channels on server 1', async function () {
68 const res = await getAccountVideoChannelsList(server.url, userInfo.account.uuid) 81 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid)
69
70 expect(res.body.total).to.equal(2) 82 expect(res.body.total).to.equal(2)
71 expect(res.body.data).to.be.an('array') 83 expect(res.body.data).to.be.an('array')
72 expect(res.body.data).to.have.lengthOf(2) 84 expect(res.body.data).to.have.lengthOf(2)
@@ -75,12 +87,23 @@ describe('Test a video channels', function () {
75 expect(videoChannels[0].displayName).to.equal('Default root channel') 87 expect(videoChannels[0].displayName).to.equal('Default root channel')
76 expect(videoChannels[1].displayName).to.equal('second video channel') 88 expect(videoChannels[1].displayName).to.equal('second video channel')
77 expect(videoChannels[1].description).to.equal('super video channel description') 89 expect(videoChannels[1].description).to.equal('super video channel description')
90 expect(videoChannels[1].support).to.equal('super video channel support text')
91 })
92
93 it('Should have one video channel when getting account channels on server 2', async function () {
94 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid)
95 expect(res.body.total).to.equal(1)
96 expect(res.body.data).to.be.an('array')
97 expect(res.body.data).to.have.lengthOf(1)
78 98
79 videoChannelId = videoChannels[1].id 99 const videoChannels = res.body.data
100 expect(videoChannels[0].displayName).to.equal('second video channel')
101 expect(videoChannels[0].description).to.equal('super video channel description')
102 expect(videoChannels[0].support).to.equal('super video channel support text')
80 }) 103 })
81 104
82 it('Should list video channels', async () => { 105 it('Should list video channels', async function () {
83 const res = await getVideoChannelsList(server.url, 1, 1, '-name') 106 const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name')
84 107
85 expect(res.body.total).to.equal(2) 108 expect(res.body.total).to.equal(2)
86 expect(res.body.data).to.be.an('array') 109 expect(res.body.data).to.be.an('array')
@@ -88,39 +111,48 @@ describe('Test a video channels', function () {
88 expect(res.body.data[0].displayName).to.equal('Default root channel') 111 expect(res.body.data[0].displayName).to.equal('Default root channel')
89 }) 112 })
90 113
91 it('Should update video channel', async () => { 114 it('Should update video channel', async function () {
115 this.timeout(5000)
116
92 const videoChannelAttributes = { 117 const videoChannelAttributes = {
93 name: 'video channel updated', 118 name: 'video channel updated',
94 description: 'video channel description updated' 119 description: 'video channel description updated',
120 support: 'video channel support text updated'
95 } 121 }
96 122
97 await updateVideoChannel(server.url, server.accessToken, videoChannelId, videoChannelAttributes) 123 await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes)
124
125 await wait(3000)
98 }) 126 })
99 127
100 it('Should have video channel updated', async () => { 128 it('Should have video channel updated', async function () {
101 const res = await getVideoChannelsList(server.url, 0, 1, '-name') 129 for (const server of servers) {
130 const res = await getVideoChannelsList(server.url, 0, 1, '-name')
102 131
103 expect(res.body.total).to.equal(2) 132 expect(res.body.total).to.equal(2)
104 expect(res.body.data).to.be.an('array') 133 expect(res.body.data).to.be.an('array')
105 expect(res.body.data).to.have.lengthOf(1) 134 expect(res.body.data).to.have.lengthOf(1)
106 expect(res.body.data[0].displayName).to.equal('video channel updated') 135 expect(res.body.data[0].displayName).to.equal('video channel updated')
107 expect(res.body.data[0].description).to.equal('video channel description updated') 136 expect(res.body.data[0].description).to.equal('video channel description updated')
137 expect(res.body.data[0].support).to.equal('video channel support text updated')
138 }
108 }) 139 })
109 140
110 it('Should get video channel', async () => { 141 it('Should get video channel', async function () {
111 const res = await getVideoChannel(server.url, videoChannelId) 142 const res = await getVideoChannel(servers[0].url, videoChannelId)
112 143
113 const videoChannel = res.body 144 const videoChannel = res.body
114 expect(videoChannel.displayName).to.equal('video channel updated') 145 expect(videoChannel.displayName).to.equal('video channel updated')
115 expect(videoChannel.description).to.equal('video channel description updated') 146 expect(videoChannel.description).to.equal('video channel description updated')
147 expect(videoChannel.support).to.equal('video channel support text updated')
116 }) 148 })
117 149
118 it('Should delete video channel', async () => { 150 it('Should delete video channel', async function () {
119 await deleteVideoChannel(server.url, server.accessToken, videoChannelId) 151 await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId)
120 }) 152 })
121 153
122 it('Should have video channel deleted', async () => { 154 it('Should have video channel deleted', async function () {
123 const res = await getVideoChannelsList(server.url, 0, 10) 155 const res = await getVideoChannelsList(servers[0].url, 0, 10)
124 156
125 expect(res.body.total).to.equal(1) 157 expect(res.body.total).to.equal(1)
126 expect(res.body.data).to.be.an('array') 158 expect(res.body.data).to.be.an('array')
@@ -129,7 +161,7 @@ describe('Test a video channels', function () {
129 }) 161 })
130 162
131 after(async function () { 163 after(async function () {
132 killallServers([ server ]) 164 killallServers(servers)
133 165
134 // Keep the logs if the test failed 166 // Keep the logs if the test failed
135 if (this['ok']) { 167 if (this['ok']) {