]>
Commit | Line | Data |
---|---|---|
5f04dd2f C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
5f04dd2f | 3 | import * as chai from 'chai' |
2422c46b | 4 | import 'mocha' |
0f320037 C |
5 | import { User, Video } from '../../../../shared/index' |
6 | import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo, wait } from '../../utils' | |
5f04dd2f | 7 | import { |
2422c46b C |
8 | addVideoChannel, |
9 | deleteVideoChannel, | |
5f04dd2f | 10 | flushTests, |
2422c46b | 11 | getAccountVideoChannelsList, |
5f04dd2f | 12 | getMyUserInformation, |
2422c46b | 13 | getVideoChannel, |
5f04dd2f | 14 | getVideoChannelsList, |
2422c46b C |
15 | killallServers, |
16 | ServerInfo, | |
17 | setAccessTokensToServers, | |
18 | updateVideoChannel | |
c5d31dba | 19 | } from '../../utils/index' |
5f04dd2f | 20 | |
2422c46b C |
21 | const expect = chai.expect |
22 | ||
23 | describe('Test video channels', function () { | |
24 | let servers: ServerInfo[] | |
5f04dd2f | 25 | let userInfo: User |
6b738c7a | 26 | let accountUUID: string |
0f320037 C |
27 | let firstVideoChannelId: number |
28 | let firstVideoChannelUUID: string | |
29 | let secondVideoChannelId: number | |
30 | let secondVideoChannelUUID: string | |
31 | let videoUUID: string | |
5f04dd2f C |
32 | |
33 | before(async function () { | |
e212f887 | 34 | this.timeout(30000) |
5f04dd2f C |
35 | |
36 | await flushTests() | |
37 | ||
2422c46b C |
38 | servers = await flushAndRunMultipleServers(2) |
39 | ||
40 | await setAccessTokensToServers(servers) | |
41 | await doubleFollow(servers[0], servers[1]) | |
5f04dd2f | 42 | |
48dce1c9 | 43 | { |
6b738c7a C |
44 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
45 | const user: User = res.body | |
46 | accountUUID = user.account.uuid | |
0f320037 C |
47 | |
48 | firstVideoChannelId = user.videoChannels[0].id | |
49 | firstVideoChannelUUID = user.videoChannels[0].uuid | |
48dce1c9 C |
50 | } |
51 | ||
2422c46b | 52 | await wait(5000) |
5f04dd2f C |
53 | }) |
54 | ||
55 | it('Should have one video channel (created with root)', async () => { | |
2422c46b | 56 | const res = await getVideoChannelsList(servers[0].url, 0, 2) |
5f04dd2f C |
57 | |
58 | expect(res.body.total).to.equal(1) | |
59 | expect(res.body.data).to.be.an('array') | |
60 | expect(res.body.data).to.have.lengthOf(1) | |
61 | }) | |
62 | ||
2422c46b C |
63 | it('Should create another video channel', async function () { |
64 | this.timeout(10000) | |
65 | ||
0f320037 C |
66 | { |
67 | const videoChannel = { | |
68 | displayName: 'second video channel', | |
69 | description: 'super video channel description', | |
70 | support: 'super video channel support text' | |
71 | } | |
72 | const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | |
73 | secondVideoChannelId = res.body.videoChannel.id | |
74 | secondVideoChannelUUID = res.body.videoChannel.uuid | |
5f04dd2f | 75 | } |
2422c46b C |
76 | |
77 | // The channel is 1 is propagated to servers 2 | |
0f320037 C |
78 | { |
79 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name', channelId: secondVideoChannelId }) | |
80 | videoUUID = res.body.video.uuid | |
81 | } | |
2422c46b C |
82 | |
83 | await wait(3000) | |
5f04dd2f C |
84 | }) |
85 | ||
86 | it('Should have two video channels when getting my information', async () => { | |
2422c46b | 87 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
5f04dd2f C |
88 | userInfo = res.body |
89 | ||
90 | expect(userInfo.videoChannels).to.be.an('array') | |
91 | expect(userInfo.videoChannels).to.have.lengthOf(2) | |
92 | ||
93 | const videoChannels = userInfo.videoChannels | |
7bc29171 C |
94 | expect(videoChannels[0].displayName).to.equal('Default root channel') |
95 | expect(videoChannels[1].displayName).to.equal('second video channel') | |
5f04dd2f | 96 | expect(videoChannels[1].description).to.equal('super video channel description') |
2422c46b | 97 | expect(videoChannels[1].support).to.equal('super video channel support text') |
5f04dd2f C |
98 | }) |
99 | ||
2422c46b | 100 | it('Should have two video channels when getting account channels on server 1', async function () { |
ad9e39fb | 101 | const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host) |
5f04dd2f C |
102 | expect(res.body.total).to.equal(2) |
103 | expect(res.body.data).to.be.an('array') | |
104 | expect(res.body.data).to.have.lengthOf(2) | |
105 | ||
106 | const videoChannels = res.body.data | |
7bc29171 C |
107 | expect(videoChannels[0].displayName).to.equal('Default root channel') |
108 | expect(videoChannels[1].displayName).to.equal('second video channel') | |
5f04dd2f | 109 | expect(videoChannels[1].description).to.equal('super video channel description') |
2422c46b C |
110 | expect(videoChannels[1].support).to.equal('super video channel support text') |
111 | }) | |
112 | ||
113 | it('Should have one video channel when getting account channels on server 2', async function () { | |
ad9e39fb | 114 | const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host) |
2422c46b C |
115 | expect(res.body.total).to.equal(1) |
116 | expect(res.body.data).to.be.an('array') | |
117 | expect(res.body.data).to.have.lengthOf(1) | |
5f04dd2f | 118 | |
2422c46b C |
119 | const videoChannels = res.body.data |
120 | expect(videoChannels[0].displayName).to.equal('second video channel') | |
121 | expect(videoChannels[0].description).to.equal('super video channel description') | |
122 | expect(videoChannels[0].support).to.equal('super video channel support text') | |
5f04dd2f C |
123 | }) |
124 | ||
2422c46b C |
125 | it('Should list video channels', async function () { |
126 | const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name') | |
5f04dd2f C |
127 | |
128 | expect(res.body.total).to.equal(2) | |
129 | expect(res.body.data).to.be.an('array') | |
130 | expect(res.body.data).to.have.lengthOf(1) | |
7bc29171 | 131 | expect(res.body.data[0].displayName).to.equal('Default root channel') |
5f04dd2f C |
132 | }) |
133 | ||
2422c46b C |
134 | it('Should update video channel', async function () { |
135 | this.timeout(5000) | |
136 | ||
5f04dd2f | 137 | const videoChannelAttributes = { |
08c1efbe | 138 | displayName: 'video channel updated', |
2422c46b C |
139 | description: 'video channel description updated', |
140 | support: 'video channel support text updated' | |
5f04dd2f C |
141 | } |
142 | ||
0f320037 | 143 | await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes) |
2422c46b C |
144 | |
145 | await wait(3000) | |
5f04dd2f C |
146 | }) |
147 | ||
2422c46b C |
148 | it('Should have video channel updated', async function () { |
149 | for (const server of servers) { | |
150 | const res = await getVideoChannelsList(server.url, 0, 1, '-name') | |
5f04dd2f | 151 | |
2422c46b C |
152 | expect(res.body.total).to.equal(2) |
153 | expect(res.body.data).to.be.an('array') | |
154 | expect(res.body.data).to.have.lengthOf(1) | |
155 | expect(res.body.data[0].displayName).to.equal('video channel updated') | |
156 | expect(res.body.data[0].description).to.equal('video channel description updated') | |
157 | expect(res.body.data[0].support).to.equal('video channel support text updated') | |
158 | } | |
5f04dd2f C |
159 | }) |
160 | ||
2422c46b | 161 | it('Should get video channel', async function () { |
0f320037 | 162 | const res = await getVideoChannel(servers[0].url, secondVideoChannelId) |
5f04dd2f C |
163 | |
164 | const videoChannel = res.body | |
7bc29171 | 165 | expect(videoChannel.displayName).to.equal('video channel updated') |
5f04dd2f | 166 | expect(videoChannel.description).to.equal('video channel description updated') |
2422c46b | 167 | expect(videoChannel.support).to.equal('video channel support text updated') |
5f04dd2f C |
168 | }) |
169 | ||
0f320037 | 170 | it('Should list the second video channel videos', async function () { |
6b738c7a C |
171 | this.timeout(10000) |
172 | ||
173 | for (const server of servers) { | |
0f320037 C |
174 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) |
175 | expect(res1.body.total).to.equal(1) | |
176 | expect(res1.body.data).to.be.an('array') | |
177 | expect(res1.body.data).to.have.lengthOf(1) | |
178 | expect(res1.body.data[0].name).to.equal('my video name') | |
179 | } | |
180 | }) | |
181 | ||
182 | it('Should change the video channel of a video', async function () { | |
183 | this.timeout(10000) | |
184 | ||
185 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId }) | |
186 | ||
187 | await wait(5000) | |
188 | }) | |
189 | ||
190 | it('Should list the first video channel videos', async function () { | |
191 | this.timeout(10000) | |
192 | ||
193 | for (const server of servers) { | |
194 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) | |
195 | expect(res1.body.total).to.equal(0) | |
196 | ||
197 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, firstVideoChannelUUID, 0, 5) | |
198 | expect(res2.body.total).to.equal(1) | |
199 | ||
200 | const videos: Video[] = res2.body.data | |
201 | expect(videos).to.be.an('array') | |
202 | expect(videos).to.have.lengthOf(1) | |
203 | expect(videos[0].name).to.equal('my video name') | |
6b738c7a C |
204 | } |
205 | }) | |
206 | ||
2422c46b | 207 | it('Should delete video channel', async function () { |
0f320037 | 208 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId) |
5f04dd2f C |
209 | }) |
210 | ||
2422c46b C |
211 | it('Should have video channel deleted', async function () { |
212 | const res = await getVideoChannelsList(servers[0].url, 0, 10) | |
5f04dd2f C |
213 | |
214 | expect(res.body.total).to.equal(1) | |
215 | expect(res.body.data).to.be.an('array') | |
216 | expect(res.body.data).to.have.lengthOf(1) | |
7bc29171 | 217 | expect(res.body.data[0].displayName).to.equal('Default root channel') |
5f04dd2f C |
218 | }) |
219 | ||
220 | after(async function () { | |
2422c46b | 221 | killallServers(servers) |
5f04dd2f C |
222 | |
223 | // Keep the logs if the test failed | |
224 | if (this['ok']) { | |
225 | await flushTests() | |
226 | } | |
227 | }) | |
228 | }) |