aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-channels.ts
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/videos/video-channels.ts
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/videos/video-channels.ts')
-rw-r--r--server/tests/api/videos/video-channels.ts122
1 files changed, 77 insertions, 45 deletions
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']) {