aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-change-ownership.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-change-ownership.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-change-ownership.ts')
-rw-r--r--server/tests/api/videos/video-change-ownership.ts38
1 files changed, 14 insertions, 24 deletions
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index b0bbd5a0d..b85edd920 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -2,22 +2,19 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 ChangeOwnershipCommand, 7 ChangeOwnershipCommand,
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 flushAndRunServer, 11 flushAndRunServer,
12 getVideo,
13 getVideosList,
14 ServerInfo, 12 ServerInfo,
15 setAccessTokensToServers, 13 setAccessTokensToServers,
16 setDefaultVideoChannel, 14 setDefaultVideoChannel,
17 uploadVideo 15 waitJobs
18} from '../../../../shared/extra-utils' 16} from '@shared/extra-utils'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 17import { VideoPrivacy } from '@shared/models'
20import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
21 18
22const expect = chai.expect 19const expect = chai.expect
23 20
@@ -71,14 +68,13 @@ describe('Test video change ownership - nominal', function () {
71 } 68 }
72 69
73 { 70 {
74 const videoAttributes = { 71 const attributes = {
75 name: 'my super name', 72 name: 'my super name',
76 description: 'my super description' 73 description: 'my super description'
77 } 74 }
78 const res = await uploadVideo(servers[0].url, firstUserToken, videoAttributes) 75 const { id } = await servers[0].videosCommand.upload({ token: firstUserToken, attributes })
79 76
80 const resVideo = await getVideo(servers[0].url, res.body.video.id) 77 servers[0].video = await servers[0].videosCommand.get({ id })
81 servers[0].video = resVideo.body
82 } 78 }
83 79
84 { 80 {
@@ -212,9 +208,7 @@ describe('Test video change ownership - nominal', function () {
212 208
213 it('Should have the channel of the video updated', async function () { 209 it('Should have the channel of the video updated', async function () {
214 for (const server of servers) { 210 for (const server of servers) {
215 const res = await getVideo(server.url, servers[0].video.uuid) 211 const video = await server.videosCommand.get({ id: servers[0].video.uuid })
216
217 const video: VideoDetails = res.body
218 212
219 expect(video.name).to.equal('my super name') 213 expect(video.name).to.equal('my super name')
220 expect(video.channel.displayName).to.equal('Main second channel') 214 expect(video.channel.displayName).to.equal('Main second channel')
@@ -243,9 +237,7 @@ describe('Test video change ownership - nominal', function () {
243 await waitJobs(servers) 237 await waitJobs(servers)
244 238
245 for (const server of servers) { 239 for (const server of servers) {
246 const res = await getVideo(server.url, servers[0].video.uuid) 240 const video = await server.videosCommand.get({ id: servers[0].video.uuid })
247
248 const video: VideoDetails = res.body
249 241
250 expect(video.name).to.equal('my super name') 242 expect(video.name).to.equal('my super name')
251 expect(video.channel.displayName).to.equal('Main second channel') 243 expect(video.channel.displayName).to.equal('Main second channel')
@@ -280,20 +272,18 @@ describe('Test video change ownership - quota too small', function () {
280 secondUserToken = await server.loginCommand.getAccessToken(secondUser) 272 secondUserToken = await server.loginCommand.getAccessToken(secondUser)
281 273
282 // Upload some videos on the server 274 // Upload some videos on the server
283 const video1Attributes = { 275 const attributes = {
284 name: 'my super name', 276 name: 'my super name',
285 description: 'my super description' 277 description: 'my super description'
286 } 278 }
287 await uploadVideo(server.url, firstUserToken, video1Attributes) 279 await server.videosCommand.upload({ token: firstUserToken, attributes })
288 280
289 await waitJobs(server) 281 await waitJobs(server)
290 282
291 const res = await getVideosList(server.url) 283 const { data } = await server.videosCommand.list()
292 const videos = res.body.data 284 expect(data.length).to.equal(1)
293
294 expect(videos.length).to.equal(1)
295 285
296 server.video = videos.find(video => video.name === 'my super name') 286 server.video = data.find(video => video.name === 'my super name')
297 }) 287 })
298 288
299 it('Should send a request to change ownership of a video', async function () { 289 it('Should send a request to change ownership of a video', async function () {