diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-17 15:45:42 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (patch) | |
tree | 33c93ef19451d7e46d4be74ce0681359d2dcc70e /server/tests/api/videos | |
parent | 965c4b22d0e4d2f853501e844e6ebbb861bd389d (diff) | |
download | PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.gz PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.zst PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.zip |
Add ability to set a name to a channel
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 12 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 61 |
3 files changed, 52 insertions, 25 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index cab096a12..3c3839338 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -6,7 +6,6 @@ import { join } from 'path' | |||
6 | import * as request from 'supertest' | 6 | import * as request from 'supertest' |
7 | import { VideoPrivacy } from '../../../../shared/models/videos' | 7 | import { VideoPrivacy } from '../../../../shared/models/videos' |
8 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' | 8 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' |
9 | |||
10 | import { | 9 | import { |
11 | addVideoChannel, | 10 | addVideoChannel, |
12 | checkVideoFilesWereRemoved, | 11 | checkVideoFilesWereRemoved, |
@@ -60,6 +59,7 @@ describe('Test multiple servers', function () { | |||
60 | 59 | ||
61 | { | 60 | { |
62 | const videoChannel = { | 61 | const videoChannel = { |
62 | name: 'super_channel_name', | ||
63 | displayName: 'my channel', | 63 | displayName: 'my channel', |
64 | description: 'super channel' | 64 | description: 'super channel' |
65 | } | 65 | } |
@@ -201,7 +201,7 @@ describe('Test multiple servers', function () { | |||
201 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], | 201 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], |
202 | privacy: VideoPrivacy.PUBLIC, | 202 | privacy: VideoPrivacy.PUBLIC, |
203 | channel: { | 203 | channel: { |
204 | name: 'Default user1 channel', | 204 | name: 'Main user1 channel', |
205 | description: 'super channel', | 205 | description: 'super channel', |
206 | isLocal | 206 | isLocal |
207 | }, | 207 | }, |
@@ -307,7 +307,7 @@ describe('Test multiple servers', function () { | |||
307 | tags: [ 'tag1p3' ], | 307 | tags: [ 'tag1p3' ], |
308 | privacy: VideoPrivacy.PUBLIC, | 308 | privacy: VideoPrivacy.PUBLIC, |
309 | channel: { | 309 | channel: { |
310 | name: 'Default root channel', | 310 | name: 'Main root channel', |
311 | description: '', | 311 | description: '', |
312 | isLocal | 312 | isLocal |
313 | }, | 313 | }, |
@@ -339,7 +339,7 @@ describe('Test multiple servers', function () { | |||
339 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | 339 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], |
340 | privacy: VideoPrivacy.PUBLIC, | 340 | privacy: VideoPrivacy.PUBLIC, |
341 | channel: { | 341 | channel: { |
342 | name: 'Default root channel', | 342 | name: 'Main root channel', |
343 | description: '', | 343 | description: '', |
344 | isLocal | 344 | isLocal |
345 | }, | 345 | }, |
@@ -647,7 +647,7 @@ describe('Test multiple servers', function () { | |||
647 | tags: [ 'tag_up_1', 'tag_up_2' ], | 647 | tags: [ 'tag_up_1', 'tag_up_2' ], |
648 | privacy: VideoPrivacy.PUBLIC, | 648 | privacy: VideoPrivacy.PUBLIC, |
649 | channel: { | 649 | channel: { |
650 | name: 'Default root channel', | 650 | name: 'Main root channel', |
651 | description: '', | 651 | description: '', |
652 | isLocal | 652 | isLocal |
653 | }, | 653 | }, |
@@ -967,7 +967,7 @@ describe('Test multiple servers', function () { | |||
967 | tags: [ ], | 967 | tags: [ ], |
968 | privacy: VideoPrivacy.PUBLIC, | 968 | privacy: VideoPrivacy.PUBLIC, |
969 | channel: { | 969 | channel: { |
970 | name: 'Default root channel', | 970 | name: 'Main root channel', |
971 | description: '', | 971 | description: '', |
972 | isLocal | 972 | isLocal |
973 | }, | 973 | }, |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index ba4920d1b..12181ad67 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -56,7 +56,7 @@ describe('Test a single server', function () { | |||
56 | privacy: VideoPrivacy.PUBLIC, | 56 | privacy: VideoPrivacy.PUBLIC, |
57 | commentsEnabled: true, | 57 | commentsEnabled: true, |
58 | channel: { | 58 | channel: { |
59 | name: 'Default root channel', | 59 | name: 'Main root channel', |
60 | description: '', | 60 | description: '', |
61 | isLocal: true | 61 | isLocal: true |
62 | }, | 62 | }, |
@@ -87,7 +87,7 @@ describe('Test a single server', function () { | |||
87 | duration: 5, | 87 | duration: 5, |
88 | commentsEnabled: false, | 88 | commentsEnabled: false, |
89 | channel: { | 89 | channel: { |
90 | name: 'Default root channel', | 90 | name: 'Main root channel', |
91 | description: '', | 91 | description: '', |
92 | isLocal: true | 92 | isLocal: true |
93 | }, | 93 | }, |
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' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { User, Video } from '../../../../shared/index' | 5 | import { User, Video } from '../../../../shared/index' |
6 | import { | 6 | import { |
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' |
14 | import { | 15 | import { |
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 () { |