aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-hls.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/api/videos/video-hls.ts
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/videos/video-hls.ts')
-rw-r--r--server/tests/api/videos/video-hls.ts32
1 files changed, 13 insertions, 19 deletions
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 428e1316d..d63b81694 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '@shared/core-utils'
7import { 7import {
8 checkDirectoryIsEmpty, 8 checkDirectoryIsEmpty,
9 checkResolutionsInMasterPlaylist, 9 checkResolutionsInMasterPlaylist,
@@ -12,26 +12,20 @@ import {
12 cleanupTests, 12 cleanupTests,
13 doubleFollow, 13 doubleFollow,
14 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
15 getVideo,
16 makeRawRequest, 15 makeRawRequest,
17 removeVideo,
18 ServerInfo, 16 ServerInfo,
19 setAccessTokensToServers, 17 setAccessTokensToServers,
20 updateVideo,
21 uploadVideo,
22 waitJobs, 18 waitJobs,
23 webtorrentAdd 19 webtorrentAdd
24} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
25import { VideoDetails } from '../../../../shared/models/videos' 21import { VideoStreamingPlaylistType } from '@shared/models'
26import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
27import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' 22import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
28 23
29const expect = chai.expect 24const expect = chai.expect
30 25
31async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { 26async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) {
32 for (const server of servers) { 27 for (const server of servers) {
33 const resVideoDetails = await getVideo(server.url, videoUUID) 28 const videoDetails = await server.videosCommand.get({ id: videoUUID })
34 const videoDetails: VideoDetails = resVideoDetails.body
35 const baseUrl = `http://${videoDetails.account.host}` 29 const baseUrl = `http://${videoDetails.account.host}`
36 30
37 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 31 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -113,8 +107,8 @@ describe('Test HLS videos', function () {
113 it('Should upload a video and transcode it to HLS', async function () { 107 it('Should upload a video and transcode it to HLS', async function () {
114 this.timeout(120000) 108 this.timeout(120000)
115 109
116 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) 110 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } })
117 videoUUID = res.body.video.uuid 111 videoUUID = uuid
118 112
119 await waitJobs(servers) 113 await waitJobs(servers)
120 114
@@ -124,8 +118,8 @@ describe('Test HLS videos', function () {
124 it('Should upload an audio file and transcode it to HLS', async function () { 118 it('Should upload an audio file and transcode it to HLS', async function () {
125 this.timeout(120000) 119 this.timeout(120000)
126 120
127 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) 121 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } })
128 videoAudioUUID = res.body.video.uuid 122 videoAudioUUID = uuid
129 123
130 await waitJobs(servers) 124 await waitJobs(servers)
131 125
@@ -135,7 +129,7 @@ describe('Test HLS videos', function () {
135 it('Should update the video', async function () { 129 it('Should update the video', async function () {
136 this.timeout(10000) 130 this.timeout(10000)
137 131
138 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) 132 await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } })
139 133
140 await waitJobs(servers) 134 await waitJobs(servers)
141 135
@@ -145,14 +139,14 @@ describe('Test HLS videos', function () {
145 it('Should delete videos', async function () { 139 it('Should delete videos', async function () {
146 this.timeout(10000) 140 this.timeout(10000)
147 141
148 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) 142 await servers[0].videosCommand.remove({ id: videoUUID })
149 await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID) 143 await servers[0].videosCommand.remove({ id: videoAudioUUID })
150 144
151 await waitJobs(servers) 145 await waitJobs(servers)
152 146
153 for (const server of servers) { 147 for (const server of servers) {
154 await getVideo(server.url, videoUUID, HttpStatusCode.NOT_FOUND_404) 148 await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
155 await getVideo(server.url, videoAudioUUID, HttpStatusCode.NOT_FOUND_404) 149 await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
156 } 150 }
157 }) 151 })
158 152