diff options
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 78 |
1 files changed, 57 insertions, 21 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 585b6a2b5..35c418f7c 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { User } from '../../../../shared/index' | 5 | import { User, Video } from '../../../../shared/index' |
6 | import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, uploadVideo, wait } from '../../utils' | 6 | import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo, wait } from '../../utils' |
7 | import { | 7 | import { |
8 | addVideoChannel, | 8 | addVideoChannel, |
9 | deleteVideoChannel, | 9 | deleteVideoChannel, |
@@ -25,8 +25,11 @@ describe('Test video channels', function () { | |||
25 | let servers: ServerInfo[] | 25 | let servers: ServerInfo[] |
26 | let userInfo: User | 26 | let userInfo: User |
27 | let accountUUID: string | 27 | let accountUUID: string |
28 | let videoChannelId: number | 28 | let firstVideoChannelId: number |
29 | let videoChannelUUID: string | 29 | let firstVideoChannelUUID: string |
30 | let secondVideoChannelId: number | ||
31 | let secondVideoChannelUUID: string | ||
32 | let videoUUID: string | ||
30 | 33 | ||
31 | before(async function () { | 34 | before(async function () { |
32 | this.timeout(30000) | 35 | this.timeout(30000) |
@@ -42,6 +45,9 @@ describe('Test video channels', function () { | |||
42 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 45 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
43 | const user: User = res.body | 46 | const user: User = res.body |
44 | accountUUID = user.account.uuid | 47 | accountUUID = user.account.uuid |
48 | |||
49 | firstVideoChannelId = user.videoChannels[0].id | ||
50 | firstVideoChannelUUID = user.videoChannels[0].uuid | ||
45 | } | 51 | } |
46 | 52 | ||
47 | await wait(5000) | 53 | await wait(5000) |
@@ -58,17 +64,22 @@ describe('Test video channels', function () { | |||
58 | it('Should create another video channel', async function () { | 64 | it('Should create another video channel', async function () { |
59 | this.timeout(10000) | 65 | this.timeout(10000) |
60 | 66 | ||
61 | const videoChannel = { | 67 | { |
62 | displayName: 'second video channel', | 68 | const videoChannel = { |
63 | description: 'super video channel description', | 69 | displayName: 'second video channel', |
64 | support: 'super video channel support text' | 70 | description: 'super video channel description', |
71 | support: 'super video channel support text' | ||
72 | } | ||
73 | const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | ||
74 | secondVideoChannelId = res.body.videoChannel.id | ||
75 | secondVideoChannelUUID = res.body.videoChannel.uuid | ||
65 | } | 76 | } |
66 | const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) | ||
67 | videoChannelId = res.body.videoChannel.id | ||
68 | videoChannelUUID = res.body.videoChannel.uuid | ||
69 | 77 | ||
70 | // The channel is 1 is propagated to servers 2 | 78 | // The channel is 1 is propagated to servers 2 |
71 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name', channelId: videoChannelId }) | 79 | { |
80 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name', channelId: secondVideoChannelId }) | ||
81 | videoUUID = res.body.video.uuid | ||
82 | } | ||
72 | 83 | ||
73 | await wait(3000) | 84 | await wait(3000) |
74 | }) | 85 | }) |
@@ -130,7 +141,7 @@ describe('Test video channels', function () { | |||
130 | support: 'video channel support text updated' | 141 | support: 'video channel support text updated' |
131 | } | 142 | } |
132 | 143 | ||
133 | await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes) | 144 | await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes) |
134 | 145 | ||
135 | await wait(3000) | 146 | await wait(3000) |
136 | }) | 147 | }) |
@@ -149,7 +160,7 @@ describe('Test video channels', function () { | |||
149 | }) | 160 | }) |
150 | 161 | ||
151 | it('Should get video channel', async function () { | 162 | it('Should get video channel', async function () { |
152 | const res = await getVideoChannel(servers[0].url, videoChannelId) | 163 | const res = await getVideoChannel(servers[0].url, secondVideoChannelId) |
153 | 164 | ||
154 | const videoChannel = res.body | 165 | const videoChannel = res.body |
155 | expect(videoChannel.displayName).to.equal('video channel updated') | 166 | expect(videoChannel.displayName).to.equal('video channel updated') |
@@ -157,20 +168,45 @@ describe('Test video channels', function () { | |||
157 | expect(videoChannel.support).to.equal('video channel support text updated') | 168 | expect(videoChannel.support).to.equal('video channel support text updated') |
158 | }) | 169 | }) |
159 | 170 | ||
160 | it('Should list the video channel videos', async function () { | 171 | it('Should list the second video channel videos', async function () { |
161 | this.timeout(10000) | 172 | this.timeout(10000) |
162 | 173 | ||
163 | for (const server of servers) { | 174 | for (const server of servers) { |
164 | const res = await getVideoChannelVideos(server.url, server.accessToken, videoChannelUUID, 0, 5) | 175 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) |
165 | expect(res.body.total).to.equal(1) | 176 | expect(res1.body.total).to.equal(1) |
166 | expect(res.body.data).to.be.an('array') | 177 | expect(res1.body.data).to.be.an('array') |
167 | expect(res.body.data).to.have.lengthOf(1) | 178 | expect(res1.body.data).to.have.lengthOf(1) |
168 | expect(res.body.data[0].name).to.equal('my video name') | 179 | expect(res1.body.data[0].name).to.equal('my video name') |
180 | } | ||
181 | }) | ||
182 | |||
183 | it('Should change the video channel of a video', async function () { | ||
184 | this.timeout(10000) | ||
185 | |||
186 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId }) | ||
187 | |||
188 | await wait(5000) | ||
189 | }) | ||
190 | |||
191 | it('Should list the first video channel videos', async function () { | ||
192 | this.timeout(10000) | ||
193 | |||
194 | for (const server of servers) { | ||
195 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondVideoChannelUUID, 0, 5) | ||
196 | expect(res1.body.total).to.equal(0) | ||
197 | |||
198 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, firstVideoChannelUUID, 0, 5) | ||
199 | expect(res2.body.total).to.equal(1) | ||
200 | |||
201 | const videos: Video[] = res2.body.data | ||
202 | expect(videos).to.be.an('array') | ||
203 | expect(videos).to.have.lengthOf(1) | ||
204 | expect(videos[0].name).to.equal('my video name') | ||
169 | } | 205 | } |
170 | }) | 206 | }) |
171 | 207 | ||
172 | it('Should delete video channel', async function () { | 208 | it('Should delete video channel', async function () { |
173 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId) | 209 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId) |
174 | }) | 210 | }) |
175 | 211 | ||
176 | it('Should have video channel deleted', async function () { | 212 | it('Should have video channel deleted', async function () { |