aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/optimize-old-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/cli/optimize-old-videos.ts
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/cli/optimize-old-videos.ts')
-rw-r--r--server/tests/cli/optimize-old-videos.ts47
1 files changed, 19 insertions, 28 deletions
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index e369a3305..ef8603a33 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -8,16 +8,12 @@ import {
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 generateHighBitrateVideo, 10 generateHighBitrateVideo,
11 getVideo,
12 getVideosList,
13 ServerInfo, 11 ServerInfo,
14 setAccessTokensToServers, 12 setAccessTokensToServers,
15 uploadVideo, 13 wait,
16 viewVideo, 14 waitJobs
17 wait 15} from '@shared/extra-utils'
18} from '../../../shared/extra-utils' 16import { getMaxBitrate, VideoResolution } from '@shared/models'
19import { waitJobs } from '../../../shared/extra-utils/server/jobs'
20import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos'
21import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' 17import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils'
22import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' 18import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
23 19
@@ -45,8 +41,8 @@ describe('Test optimize old videos', function () {
45 } 41 }
46 42
47 // Upload two videos for our needs 43 // Upload two videos for our needs
48 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1', fixture: tempFixturePath }) 44 await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
49 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2', fixture: tempFixturePath }) 45 await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
50 46
51 await waitJobs(servers) 47 await waitJobs(servers)
52 }) 48 })
@@ -55,14 +51,12 @@ describe('Test optimize old videos', function () {
55 this.timeout(30000) 51 this.timeout(30000)
56 52
57 for (const server of servers) { 53 for (const server of servers) {
58 const res = await getVideosList(server.url) 54 const { data } = await server.videosCommand.list()
59 const videos = res.body.data 55 expect(data).to.have.lengthOf(2)
60 expect(videos).to.have.lengthOf(2) 56
61 57 for (const video of data) {
62 for (const video of videos) { 58 const videoDetails = await server.videosCommand.get({ id: video.uuid })
63 const res2 = await getVideo(server.url, video.uuid) 59 expect(videoDetails.files).to.have.lengthOf(1)
64 const videoDetail: VideoDetails = res2.body
65 expect(videoDetail.files).to.have.lengthOf(1)
66 } 60 }
67 } 61 }
68 }) 62 })
@@ -74,24 +68,21 @@ describe('Test optimize old videos', function () {
74 await waitJobs(servers) 68 await waitJobs(servers)
75 69
76 for (const server of servers) { 70 for (const server of servers) {
77 const res = await getVideosList(server.url) 71 const { data } = await server.videosCommand.list()
78 const videos: Video[] = res.body.data 72 expect(data).to.have.lengthOf(2)
79
80 expect(videos).to.have.lengthOf(2)
81 73
82 for (const video of videos) { 74 for (const video of data) {
83 await viewVideo(server.url, video.uuid) 75 await server.videosCommand.view({ id: video.uuid })
84 76
85 // Refresh video 77 // Refresh video
86 await waitJobs(servers) 78 await waitJobs(servers)
87 await wait(5000) 79 await wait(5000)
88 await waitJobs(servers) 80 await waitJobs(servers)
89 81
90 const res2 = await getVideo(server.url, video.uuid) 82 const videoDetails = await server.videosCommand.get({ id: video.uuid })
91 const videosDetails: VideoDetails = res2.body
92 83
93 expect(videosDetails.files).to.have.lengthOf(1) 84 expect(videoDetails.files).to.have.lengthOf(1)
94 const file = videosDetails.files[0] 85 const file = videoDetails.files[0]
95 86
96 expect(file.size).to.be.below(8000000) 87 expect(file.size).to.be.below(8000000)
97 88