diff options
Diffstat (limited to 'server/tests/api/live/live-save-replay.ts')
-rw-r--r-- | server/tests/api/live/live-save-replay.ts | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 363fb561c..a87a2cd12 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -3,26 +3,22 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/core-utils' |
7 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
8 | import { | 7 | import { |
9 | checkLiveCleanup, | 8 | checkLiveCleanup, |
10 | cleanupTests, | 9 | cleanupTests, |
11 | ConfigCommand, | 10 | ConfigCommand, |
12 | doubleFollow, | 11 | doubleFollow, |
13 | flushAndRunMultipleServers, | 12 | flushAndRunMultipleServers, |
14 | getVideo, | ||
15 | getVideosList, | ||
16 | removeVideo, | ||
17 | ServerInfo, | 13 | ServerInfo, |
18 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
19 | setDefaultVideoChannel, | 15 | setDefaultVideoChannel, |
20 | stopFfmpeg, | 16 | stopFfmpeg, |
21 | testFfmpegStreamError, | 17 | testFfmpegStreamError, |
22 | updateVideo, | ||
23 | wait, | 18 | wait, |
24 | waitJobs | 19 | waitJobs |
25 | } from '../../../../shared/extra-utils' | 20 | } from '@shared/extra-utils' |
21 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | ||
26 | 22 | ||
27 | const expect = chai.expect | 23 | const expect = chai.expect |
28 | 24 | ||
@@ -34,7 +30,7 @@ describe('Save replay setting', function () { | |||
34 | async function createLiveWrapper (saveReplay: boolean) { | 30 | async function createLiveWrapper (saveReplay: boolean) { |
35 | if (liveVideoUUID) { | 31 | if (liveVideoUUID) { |
36 | try { | 32 | try { |
37 | await removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) | 33 | await servers[0].videosCommand.remove({ id: liveVideoUUID }) |
38 | await waitJobs(servers) | 34 | await waitJobs(servers) |
39 | } catch {} | 35 | } catch {} |
40 | } | 36 | } |
@@ -50,24 +46,24 @@ describe('Save replay setting', function () { | |||
50 | return uuid | 46 | return uuid |
51 | } | 47 | } |
52 | 48 | ||
53 | async function checkVideosExist (videoId: string, existsInList: boolean, getStatus?: number) { | 49 | async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) { |
54 | for (const server of servers) { | 50 | for (const server of servers) { |
55 | const length = existsInList ? 1 : 0 | 51 | const length = existsInList ? 1 : 0 |
56 | 52 | ||
57 | const resVideos = await getVideosList(server.url) | 53 | const { data, total } = await server.videosCommand.list() |
58 | expect(resVideos.body.data).to.have.lengthOf(length) | 54 | expect(data).to.have.lengthOf(length) |
59 | expect(resVideos.body.total).to.equal(length) | 55 | expect(total).to.equal(length) |
60 | 56 | ||
61 | if (getStatus) { | 57 | if (expectedStatus) { |
62 | await getVideo(server.url, videoId, getStatus) | 58 | await server.videosCommand.get({ id: videoId, expectedStatus }) |
63 | } | 59 | } |
64 | } | 60 | } |
65 | } | 61 | } |
66 | 62 | ||
67 | async function checkVideoState (videoId: string, state: VideoState) { | 63 | async function checkVideoState (videoId: string, state: VideoState) { |
68 | for (const server of servers) { | 64 | for (const server of servers) { |
69 | const res = await getVideo(server.url, videoId) | 65 | const video = await server.videosCommand.get({ id: videoId }) |
70 | expect((res.body as VideoDetails).state.id).to.equal(state) | 66 | expect(video.state.id).to.equal(state) |
71 | } | 67 | } |
72 | } | 68 | } |
73 | 69 | ||
@@ -179,8 +175,8 @@ describe('Save replay setting', function () { | |||
179 | 175 | ||
180 | await checkVideosExist(liveVideoUUID, false) | 176 | await checkVideosExist(liveVideoUUID, false) |
181 | 177 | ||
182 | await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401) | 178 | await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
183 | await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404) | 179 | await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
184 | 180 | ||
185 | await wait(5000) | 181 | await wait(5000) |
186 | await waitJobs(servers) | 182 | await waitJobs(servers) |
@@ -201,7 +197,7 @@ describe('Save replay setting', function () { | |||
201 | 197 | ||
202 | await Promise.all([ | 198 | await Promise.all([ |
203 | testFfmpegStreamError(ffmpegCommand, true), | 199 | testFfmpegStreamError(ffmpegCommand, true), |
204 | removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) | 200 | servers[0].videosCommand.remove({ id: liveVideoUUID }) |
205 | ]) | 201 | ]) |
206 | 202 | ||
207 | await wait(5000) | 203 | await wait(5000) |
@@ -253,13 +249,13 @@ describe('Save replay setting', function () { | |||
253 | it('Should update the saved live and correctly federate the updated attributes', async function () { | 249 | it('Should update the saved live and correctly federate the updated attributes', async function () { |
254 | this.timeout(30000) | 250 | this.timeout(30000) |
255 | 251 | ||
256 | await updateVideo(servers[0].url, servers[0].accessToken, liveVideoUUID, { name: 'video updated' }) | 252 | await servers[0].videosCommand.update({ id: liveVideoUUID, attributes: { name: 'video updated' } }) |
257 | await waitJobs(servers) | 253 | await waitJobs(servers) |
258 | 254 | ||
259 | for (const server of servers) { | 255 | for (const server of servers) { |
260 | const res = await getVideo(server.url, liveVideoUUID) | 256 | const video = await server.videosCommand.get({ id: liveVideoUUID }) |
261 | expect(res.body.name).to.equal('video updated') | 257 | expect(video.name).to.equal('video updated') |
262 | expect(res.body.isLive).to.be.false | 258 | expect(video.isLive).to.be.false |
263 | } | 259 | } |
264 | }) | 260 | }) |
265 | 261 | ||
@@ -287,8 +283,8 @@ describe('Save replay setting', function () { | |||
287 | 283 | ||
288 | await checkVideosExist(liveVideoUUID, false) | 284 | await checkVideosExist(liveVideoUUID, false) |
289 | 285 | ||
290 | await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401) | 286 | await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
291 | await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404) | 287 | await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
292 | 288 | ||
293 | await wait(5000) | 289 | await wait(5000) |
294 | await waitJobs(servers) | 290 | await waitJobs(servers) |
@@ -307,7 +303,7 @@ describe('Save replay setting', function () { | |||
307 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) | 303 | await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) |
308 | 304 | ||
309 | await Promise.all([ | 305 | await Promise.all([ |
310 | removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID), | 306 | servers[0].videosCommand.remove({ id: liveVideoUUID }), |
311 | testFfmpegStreamError(ffmpegCommand, true) | 307 | testFfmpegStreamError(ffmpegCommand, true) |
312 | ]) | 308 | ]) |
313 | 309 | ||