diff options
Diffstat (limited to 'server/tests/api/videos/video-channels.ts')
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 116 |
1 files changed, 100 insertions, 16 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 345e96f43..4f600cae8 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { User, Video } from '../../../../shared/index' | 5 | import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createUser, | 8 | createUser, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, getVideo, |
11 | getVideoChannelVideos, | 11 | getVideoChannelVideos, |
12 | testImage, | 12 | testImage, |
13 | updateVideo, | 13 | updateVideo, |
@@ -18,12 +18,10 @@ import { | |||
18 | import { | 18 | import { |
19 | addVideoChannel, | 19 | addVideoChannel, |
20 | deleteVideoChannel, | 20 | deleteVideoChannel, |
21 | flushTests, | ||
22 | getAccountVideoChannelsList, | 21 | getAccountVideoChannelsList, |
23 | getMyUserInformation, | 22 | getMyUserInformation, |
24 | getVideoChannel, | 23 | getVideoChannel, |
25 | getVideoChannelsList, | 24 | getVideoChannelsList, |
26 | killallServers, | ||
27 | ServerInfo, | 25 | ServerInfo, |
28 | setAccessTokensToServers, | 26 | setAccessTokensToServers, |
29 | updateVideoChannel | 27 | updateVideoChannel |
@@ -35,13 +33,12 @@ const expect = chai.expect | |||
35 | describe('Test video channels', function () { | 33 | describe('Test video channels', function () { |
36 | let servers: ServerInfo[] | 34 | let servers: ServerInfo[] |
37 | let userInfo: User | 35 | let userInfo: User |
38 | let accountUUID: string | ||
39 | let firstVideoChannelId: number | 36 | let firstVideoChannelId: number |
40 | let secondVideoChannelId: number | 37 | let secondVideoChannelId: number |
41 | let videoUUID: string | 38 | let videoUUID: string |
42 | 39 | ||
43 | before(async function () { | 40 | before(async function () { |
44 | this.timeout(30000) | 41 | this.timeout(60000) |
45 | 42 | ||
46 | servers = await flushAndRunMultipleServers(2) | 43 | servers = await flushAndRunMultipleServers(2) |
47 | 44 | ||
@@ -51,7 +48,6 @@ describe('Test video channels', function () { | |||
51 | { | 48 | { |
52 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 49 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
53 | const user: User = res.body | 50 | const user: User = res.body |
54 | accountUUID = user.account.uuid | ||
55 | 51 | ||
56 | firstVideoChannelId = user.videoChannels[0].id | 52 | firstVideoChannelId = user.videoChannels[0].id |
57 | } | 53 | } |
@@ -83,7 +79,8 @@ describe('Test video channels', function () { | |||
83 | 79 | ||
84 | // The channel is 1 is propagated to servers 2 | 80 | // The channel is 1 is propagated to servers 2 |
85 | { | 81 | { |
86 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name', channelId: secondVideoChannelId }) | 82 | const videoAttributesArg = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } |
83 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributesArg) | ||
87 | videoUUID = res.body.video.uuid | 84 | videoUUID = res.body.video.uuid |
88 | } | 85 | } |
89 | 86 | ||
@@ -108,7 +105,11 @@ describe('Test video channels', function () { | |||
108 | }) | 105 | }) |
109 | 106 | ||
110 | it('Should have two video channels when getting account channels on server 1', async function () { | 107 | it('Should have two video channels when getting account channels on server 1', async function () { |
111 | const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host) | 108 | const res = await getAccountVideoChannelsList({ |
109 | url: servers[ 0 ].url, | ||
110 | accountName: userInfo.account.name + '@' + userInfo.account.host | ||
111 | }) | ||
112 | |||
112 | expect(res.body.total).to.equal(2) | 113 | expect(res.body.total).to.equal(2) |
113 | expect(res.body.data).to.be.an('array') | 114 | expect(res.body.data).to.be.an('array') |
114 | expect(res.body.data).to.have.lengthOf(2) | 115 | expect(res.body.data).to.have.lengthOf(2) |
@@ -123,8 +124,62 @@ describe('Test video channels', function () { | |||
123 | expect(videoChannels[1].support).to.equal('super video channel support text') | 124 | expect(videoChannels[1].support).to.equal('super video channel support text') |
124 | }) | 125 | }) |
125 | 126 | ||
127 | it('Should paginate and sort account channels', async function () { | ||
128 | { | ||
129 | const res = await getAccountVideoChannelsList({ | ||
130 | url: servers[ 0 ].url, | ||
131 | accountName: userInfo.account.name + '@' + userInfo.account.host, | ||
132 | start: 0, | ||
133 | count: 1, | ||
134 | sort: 'createdAt' | ||
135 | }) | ||
136 | |||
137 | expect(res.body.total).to.equal(2) | ||
138 | expect(res.body.data).to.have.lengthOf(1) | ||
139 | |||
140 | const videoChannel: VideoChannel = res.body.data[ 0 ] | ||
141 | expect(videoChannel.name).to.equal('root_channel') | ||
142 | } | ||
143 | |||
144 | { | ||
145 | const res = await getAccountVideoChannelsList({ | ||
146 | url: servers[ 0 ].url, | ||
147 | accountName: userInfo.account.name + '@' + userInfo.account.host, | ||
148 | start: 0, | ||
149 | count: 1, | ||
150 | sort: '-createdAt' | ||
151 | }) | ||
152 | |||
153 | expect(res.body.total).to.equal(2) | ||
154 | expect(res.body.data).to.have.lengthOf(1) | ||
155 | |||
156 | const videoChannel: VideoChannel = res.body.data[ 0 ] | ||
157 | expect(videoChannel.name).to.equal('second_video_channel') | ||
158 | } | ||
159 | |||
160 | { | ||
161 | const res = await getAccountVideoChannelsList({ | ||
162 | url: servers[ 0 ].url, | ||
163 | accountName: userInfo.account.name + '@' + userInfo.account.host, | ||
164 | start: 1, | ||
165 | count: 1, | ||
166 | sort: '-createdAt' | ||
167 | }) | ||
168 | |||
169 | expect(res.body.total).to.equal(2) | ||
170 | expect(res.body.data).to.have.lengthOf(1) | ||
171 | |||
172 | const videoChannel: VideoChannel = res.body.data[ 0 ] | ||
173 | expect(videoChannel.name).to.equal('root_channel') | ||
174 | } | ||
175 | }) | ||
176 | |||
126 | it('Should have one video channel when getting account channels on server 2', async function () { | 177 | it('Should have one video channel when getting account channels on server 2', async function () { |
127 | const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host) | 178 | const res = await getAccountVideoChannelsList({ |
179 | url: servers[ 1 ].url, | ||
180 | accountName: userInfo.account.name + '@' + userInfo.account.host | ||
181 | }) | ||
182 | |||
128 | expect(res.body.total).to.equal(1) | 183 | expect(res.body.total).to.equal(1) |
129 | expect(res.body.data).to.be.an('array') | 184 | expect(res.body.data).to.be.an('array') |
130 | expect(res.body.data).to.have.lengthOf(1) | 185 | expect(res.body.data).to.have.lengthOf(1) |
@@ -147,12 +202,12 @@ describe('Test video channels', function () { | |||
147 | }) | 202 | }) |
148 | 203 | ||
149 | it('Should update video channel', async function () { | 204 | it('Should update video channel', async function () { |
150 | this.timeout(5000) | 205 | this.timeout(15000) |
151 | 206 | ||
152 | const videoChannelAttributes = { | 207 | const videoChannelAttributes = { |
153 | displayName: 'video channel updated', | 208 | displayName: 'video channel updated', |
154 | description: 'video channel description updated', | 209 | description: 'video channel description updated', |
155 | support: 'video channel support text updated' | 210 | support: 'support updated' |
156 | } | 211 | } |
157 | 212 | ||
158 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) | 213 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) |
@@ -170,7 +225,36 @@ describe('Test video channels', function () { | |||
170 | expect(res.body.data[0].name).to.equal('second_video_channel') | 225 | expect(res.body.data[0].name).to.equal('second_video_channel') |
171 | expect(res.body.data[0].displayName).to.equal('video channel updated') | 226 | expect(res.body.data[0].displayName).to.equal('video channel updated') |
172 | expect(res.body.data[0].description).to.equal('video channel description updated') | 227 | expect(res.body.data[0].description).to.equal('video channel description updated') |
173 | expect(res.body.data[0].support).to.equal('video channel support text updated') | 228 | expect(res.body.data[0].support).to.equal('support updated') |
229 | } | ||
230 | }) | ||
231 | |||
232 | it('Should not have updated the video support field', async function () { | ||
233 | for (const server of servers) { | ||
234 | const res = await getVideo(server.url, videoUUID) | ||
235 | const video: VideoDetails = res.body | ||
236 | |||
237 | expect(video.support).to.equal('video support field') | ||
238 | } | ||
239 | }) | ||
240 | |||
241 | it('Should update the channel support field and update videos too', async function () { | ||
242 | this.timeout(35000) | ||
243 | |||
244 | const videoChannelAttributes = { | ||
245 | support: 'video channel support text updated', | ||
246 | bulkVideosSupportUpdate: true | ||
247 | } | ||
248 | |||
249 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) | ||
250 | |||
251 | await waitJobs(servers) | ||
252 | |||
253 | for (const server of servers) { | ||
254 | const res = await getVideo(server.url, videoUUID) | ||
255 | const video: VideoDetails = res.body | ||
256 | |||
257 | expect(video.support).to.equal(videoChannelAttributes.support) | ||
174 | } | 258 | } |
175 | }) | 259 | }) |
176 | 260 | ||
@@ -213,7 +297,7 @@ describe('Test video channels', function () { | |||
213 | this.timeout(10000) | 297 | this.timeout(10000) |
214 | 298 | ||
215 | for (const server of servers) { | 299 | for (const server of servers) { |
216 | const channelURI = 'second_video_channel@localhost:9001' | 300 | const channelURI = 'second_video_channel@localhost:' + servers[0].port |
217 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | 301 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) |
218 | expect(res1.body.total).to.equal(1) | 302 | expect(res1.body.total).to.equal(1) |
219 | expect(res1.body.data).to.be.an('array') | 303 | expect(res1.body.data).to.be.an('array') |
@@ -234,11 +318,11 @@ describe('Test video channels', function () { | |||
234 | this.timeout(10000) | 318 | this.timeout(10000) |
235 | 319 | ||
236 | for (const server of servers) { | 320 | for (const server of servers) { |
237 | const secondChannelURI = 'second_video_channel@localhost:9001' | 321 | const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port |
238 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) | 322 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) |
239 | expect(res1.body.total).to.equal(0) | 323 | expect(res1.body.total).to.equal(0) |
240 | 324 | ||
241 | const channelURI = 'root_channel@localhost:9001' | 325 | const channelURI = 'root_channel@localhost:' + servers[0].port |
242 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | 326 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) |
243 | expect(res2.body.total).to.equal(1) | 327 | expect(res2.body.total).to.equal(1) |
244 | 328 | ||