aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-channels.ts')
-rw-r--r--server/tests/api/videos/video-channels.ts61
1 files changed, 44 insertions, 17 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index e4e3ce9d9..8138c65d6 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -4,12 +4,13 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { User, Video } from '../../../../shared/index' 5import { User, Video } from '../../../../shared/index'
6import { 6import {
7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
9 getVideoChannelVideos, testImage, 10 getVideoChannelVideos, serverLogin, testImage,
10 updateVideo, 11 updateVideo,
11 updateVideoChannelAvatar, 12 updateVideoChannelAvatar,
12 uploadVideo, wait 13 uploadVideo, wait, userLogin
13} from '../../utils' 14} from '../../utils'
14import { 15import {
15 addVideoChannel, 16 addVideoChannel,
@@ -33,9 +34,7 @@ describe('Test video channels', function () {
33 let userInfo: User 34 let userInfo: User
34 let accountUUID: string 35 let accountUUID: string
35 let firstVideoChannelId: number 36 let firstVideoChannelId: number
36 let firstVideoChannelUUID: string
37 let secondVideoChannelId: number 37 let secondVideoChannelId: number
38 let secondVideoChannelUUID: string
39 let videoUUID: string 38 let videoUUID: string
40 39
41 before(async function () { 40 before(async function () {
@@ -54,7 +53,6 @@ describe('Test video channels', function () {
54 accountUUID = user.account.uuid 53 accountUUID = user.account.uuid
55 54
56 firstVideoChannelId = user.videoChannels[0].id 55 firstVideoChannelId = user.videoChannels[0].id
57 firstVideoChannelUUID = user.videoChannels[0].uuid
58 } 56 }
59 57
60 await waitJobs(servers) 58 await waitJobs(servers)
@@ -73,13 +71,13 @@ describe('Test video channels', function () {
73 71
74 { 72 {
75 const videoChannel = { 73 const videoChannel = {
74 name: 'second_video_channel',
76 displayName: 'second video channel', 75 displayName: 'second video channel',
77 description: 'super video channel description', 76 description: 'super video channel description',
78 support: 'super video channel support text' 77 support: 'super video channel support text'
79 } 78 }
80 const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) 79 const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
81 secondVideoChannelId = res.body.videoChannel.id 80 secondVideoChannelId = res.body.videoChannel.id
82 secondVideoChannelUUID = res.body.videoChannel.uuid
83 } 81 }
84 82
85 // The channel is 1 is propagated to servers 2 83 // The channel is 1 is propagated to servers 2
@@ -99,7 +97,10 @@ describe('Test video channels', function () {
99 expect(userInfo.videoChannels).to.have.lengthOf(2) 97 expect(userInfo.videoChannels).to.have.lengthOf(2)
100 98
101 const videoChannels = userInfo.videoChannels 99 const videoChannels = userInfo.videoChannels
102 expect(videoChannels[0].displayName).to.equal('Default root channel') 100 expect(videoChannels[0].name).to.equal('root_channel')
101 expect(videoChannels[0].displayName).to.equal('Main root channel')
102
103 expect(videoChannels[1].name).to.equal('second_video_channel')
103 expect(videoChannels[1].displayName).to.equal('second video channel') 104 expect(videoChannels[1].displayName).to.equal('second video channel')
104 expect(videoChannels[1].description).to.equal('super video channel description') 105 expect(videoChannels[1].description).to.equal('super video channel description')
105 expect(videoChannels[1].support).to.equal('super video channel support text') 106 expect(videoChannels[1].support).to.equal('super video channel support text')
@@ -112,7 +113,10 @@ describe('Test video channels', function () {
112 expect(res.body.data).to.have.lengthOf(2) 113 expect(res.body.data).to.have.lengthOf(2)
113 114
114 const videoChannels = res.body.data 115 const videoChannels = res.body.data
115 expect(videoChannels[0].displayName).to.equal('Default root channel') 116 expect(videoChannels[0].name).to.equal('root_channel')
117 expect(videoChannels[0].displayName).to.equal('Main root channel')
118
119 expect(videoChannels[1].name).to.equal('second_video_channel')
116 expect(videoChannels[1].displayName).to.equal('second video channel') 120 expect(videoChannels[1].displayName).to.equal('second video channel')
117 expect(videoChannels[1].description).to.equal('super video channel description') 121 expect(videoChannels[1].description).to.equal('super video channel description')
118 expect(videoChannels[1].support).to.equal('super video channel support text') 122 expect(videoChannels[1].support).to.equal('super video channel support text')
@@ -125,6 +129,7 @@ describe('Test video channels', function () {
125 expect(res.body.data).to.have.lengthOf(1) 129 expect(res.body.data).to.have.lengthOf(1)
126 130
127 const videoChannels = res.body.data 131 const videoChannels = res.body.data
132 expect(videoChannels[0].name).to.equal('second_video_channel')
128 expect(videoChannels[0].displayName).to.equal('second video channel') 133 expect(videoChannels[0].displayName).to.equal('second video channel')
129 expect(videoChannels[0].description).to.equal('super video channel description') 134 expect(videoChannels[0].description).to.equal('super video channel description')
130 expect(videoChannels[0].support).to.equal('super video channel support text') 135 expect(videoChannels[0].support).to.equal('super video channel support text')
@@ -136,7 +141,8 @@ describe('Test video channels', function () {
136 expect(res.body.total).to.equal(2) 141 expect(res.body.total).to.equal(2)
137 expect(res.body.data).to.be.an('array') 142 expect(res.body.data).to.be.an('array')
138 expect(res.body.data).to.have.lengthOf(1) 143 expect(res.body.data).to.have.lengthOf(1)
139 expect(res.body.data[0].displayName).to.equal('Default root channel') 144 expect(res.body.data[0].name).to.equal('root_channel')
145 expect(res.body.data[0].displayName).to.equal('Main root channel')
140 }) 146 })
141 147
142 it('Should update video channel', async function () { 148 it('Should update video channel', async function () {
@@ -148,7 +154,7 @@ describe('Test video channels', function () {
148 support: 'video channel support text updated' 154 support: 'video channel support text updated'
149 } 155 }
150 156
151 await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes) 157 await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes)
152 158
153 await waitJobs(servers) 159 await waitJobs(servers)
154 }) 160 })
@@ -160,6 +166,7 @@ describe('Test video channels', function () {
160 expect(res.body.total).to.equal(2) 166 expect(res.body.total).to.equal(2)
161 expect(res.body.data).to.be.an('array') 167 expect(res.body.data).to.be.an('array')
162 expect(res.body.data).to.have.lengthOf(1) 168 expect(res.body.data).to.have.lengthOf(1)
169 expect(res.body.data[0].name).to.equal('second_video_channel')
163 expect(res.body.data[0].displayName).to.equal('video channel updated') 170 expect(res.body.data[0].displayName).to.equal('video channel updated')
164 expect(res.body.data[0].description).to.equal('video channel description updated') 171 expect(res.body.data[0].description).to.equal('video channel description updated')
165 expect(res.body.data[0].support).to.equal('video channel support text updated') 172 expect(res.body.data[0].support).to.equal('video channel support text updated')
@@ -174,7 +181,7 @@ describe('Test video channels', function () {
174 await updateVideoChannelAvatar({ 181 await updateVideoChannelAvatar({
175 url: servers[0].url, 182 url: servers[0].url,
176 accessToken: servers[0].accessToken, 183 accessToken: servers[0].accessToken,
177 videoChannelId: secondVideoChannelId, 184 videoChannelName: 'second_video_channel',
178 fixture 185 fixture
179 }) 186 })
180 187
@@ -192,9 +199,10 @@ describe('Test video channels', function () {
192 }) 199 })
193 200
194 it('Should get video channel', async function () { 201 it('Should get video channel', async function () {
195 const res = await getVideoChannel(servers[0].url, secondVideoChannelId) 202 const res = await getVideoChannel(servers[0].url, 'second_video_channel')
196 203
197 const videoChannel = res.body 204 const videoChannel = res.body
205 expect(videoChannel.name).to.equal('second_video_channel')
198 expect(videoChannel.displayName).to.equal('video channel updated') 206 expect(videoChannel.displayName).to.equal('video channel updated')
199 expect(videoChannel.description).to.equal('video channel description updated') 207 expect(videoChannel.description).to.equal('video channel description updated')
200 expect(videoChannel.support).to.equal('video channel support text updated') 208 expect(videoChannel.support).to.equal('video channel support text updated')
@@ -204,7 +212,8 @@ describe('Test video channels', function () {
204 this.timeout(10000) 212 this.timeout(10000)
205 213
206 for (const server of servers) { 214 for (const server of servers) {
207 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) 215 const channelURI = 'second_video_channel@localhost:9001'
216 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
208 expect(res1.body.total).to.equal(1) 217 expect(res1.body.total).to.equal(1)
209 expect(res1.body.data).to.be.an('array') 218 expect(res1.body.data).to.be.an('array')
210 expect(res1.body.data).to.have.lengthOf(1) 219 expect(res1.body.data).to.have.lengthOf(1)
@@ -224,10 +233,12 @@ describe('Test video channels', function () {
224 this.timeout(10000) 233 this.timeout(10000)
225 234
226 for (const server of servers) { 235 for (const server of servers) {
227 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) 236 const secondChannelURI = 'second_video_channel@localhost:9001'
237 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
228 expect(res1.body.total).to.equal(0) 238 expect(res1.body.total).to.equal(0)
229 239
230 const res2 = await getVideoChannelVideos(server.url, server.accessToken, firstVideoChannelUUID, 0, 5) 240 const channelURI = 'root_channel@localhost:9001'
241 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
231 expect(res2.body.total).to.equal(1) 242 expect(res2.body.total).to.equal(1)
232 243
233 const videos: Video[] = res2.body.data 244 const videos: Video[] = res2.body.data
@@ -238,7 +249,7 @@ describe('Test video channels', function () {
238 }) 249 })
239 250
240 it('Should delete video channel', async function () { 251 it('Should delete video channel', async function () {
241 await deleteVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId) 252 await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel')
242 }) 253 })
243 254
244 it('Should have video channel deleted', async function () { 255 it('Should have video channel deleted', async function () {
@@ -247,7 +258,23 @@ describe('Test video channels', function () {
247 expect(res.body.total).to.equal(1) 258 expect(res.body.total).to.equal(1)
248 expect(res.body.data).to.be.an('array') 259 expect(res.body.data).to.be.an('array')
249 expect(res.body.data).to.have.lengthOf(1) 260 expect(res.body.data).to.have.lengthOf(1)
250 expect(res.body.data[0].displayName).to.equal('Default root channel') 261 expect(res.body.data[0].displayName).to.equal('Main root channel')
262 })
263
264 it('Should create the main channel with an uuid if there is a conflict', async function () {
265 {
266 const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
267 await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
268 }
269
270 {
271 await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, 'toto', 'password')
272 const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' })
273
274 const res = await getMyUserInformation(servers[ 0 ].url, accessToken)
275 const videoChannel = res.body.videoChannels[ 0 ]
276 expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
277 }
251 }) 278 })
252 279
253 after(async function () { 280 after(async function () {