X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-change-ownership.ts;h=6c229c6cfa74b6ca00bdd68bff4638de3df35184;hb=c6f8ca4d6596572de981162983bd02eb2613791d;hp=352eb5ea31fc9340edfc9e98c1ca339773f61cd8;hpb=89d241a79c262b9775c233b73cff080043ebb5e6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 352eb5ea3..6c229c6cf 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts @@ -2,24 +2,23 @@ import 'mocha' import * as chai from 'chai' -import { HttpStatusCode } from '@shared/core-utils' import { ChangeOwnershipCommand, cleanupTests, + createMultipleServers, + createSingleServer, doubleFollow, - flushAndRunMultipleServers, - flushAndRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/extra-utils' -import { VideoPrivacy } from '@shared/models' +} from '@shared/server-commands' +import { HttpStatusCode, VideoPrivacy } from '@shared/models' const expect = chai.expect describe('Test video change ownership - nominal', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] const firstUser = 'first' const secondUser = 'second' @@ -39,7 +38,7 @@ describe('Test video change ownership - nominal', function () { before(async function () { this.timeout(50000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) @@ -74,7 +73,7 @@ describe('Test video change ownership - nominal', function () { } const { id } = await servers[0].videos.upload({ token: firstUserToken, attributes }) - servers[0].store.video = await servers[0].videos.get({ id }) + servers[0].store.videoCreated = await servers[0].videos.get({ id }) } { @@ -110,7 +109,7 @@ describe('Test video change ownership - nominal', function () { it('Should send a request to change ownership of a video', async function () { this.timeout(15000) - await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser }) + await command.create({ token: firstUserToken, videoId: servers[0].store.videoCreated.id, username: secondUser }) }) it('Should only return a request to change ownership for the second user', async function () { @@ -136,7 +135,7 @@ describe('Test video change ownership - nominal', function () { it('Should accept the same change ownership request without crashing', async function () { this.timeout(10000) - await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser }) + await command.create({ token: firstUserToken, videoId: servers[0].store.videoCreated.id, username: secondUser }) }) it('Should not create multiple change ownership requests while one is waiting', async function () { @@ -164,7 +163,7 @@ describe('Test video change ownership - nominal', function () { it('Should send a new request to change ownership of a video', async function () { this.timeout(15000) - await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser }) + await command.create({ token: firstUserToken, videoId: servers[0].store.videoCreated.id, username: secondUser }) }) it('Should return two requests to change ownership for the second user', async function () { @@ -208,7 +207,7 @@ describe('Test video change ownership - nominal', function () { it('Should have the channel of the video updated', async function () { for (const server of servers) { - const video = await server.videos.get({ id: servers[0].store.video.uuid }) + const video = await server.videos.get({ id: servers[0].store.videoCreated.uuid }) expect(video.name).to.equal('my super name') expect(video.channel.displayName).to.equal('Main second channel') @@ -237,7 +236,7 @@ describe('Test video change ownership - nominal', function () { await waitJobs(servers) for (const server of servers) { - const video = await server.videos.get({ id: servers[0].store.video.uuid }) + const video = await server.videos.get({ id: servers[0].store.videoCreated.uuid }) expect(video.name).to.equal('my super name') expect(video.channel.displayName).to.equal('Main second channel') @@ -251,7 +250,7 @@ describe('Test video change ownership - nominal', function () { }) describe('Test video change ownership - quota too small', function () { - let server: ServerInfo + let server: PeerTubeServer const firstUser = 'first' const secondUser = 'second' @@ -263,7 +262,7 @@ describe('Test video change ownership - quota too small', function () { this.timeout(50000) // Run one server - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.users.create({ username: secondUser, videoQuota: 10 }) @@ -283,13 +282,13 @@ describe('Test video change ownership - quota too small', function () { const { data } = await server.videos.list() expect(data.length).to.equal(1) - server.store.video = data.find(video => video.name === 'my super name') + server.store.videoCreated = data.find(video => video.name === 'my super name') }) it('Should send a request to change ownership of a video', async function () { this.timeout(15000) - await server.changeOwnership.create({ token: firstUserToken, videoId: server.store.video.id, username: secondUser }) + await server.changeOwnership.create({ token: firstUserToken, videoId: server.store.videoCreated.id, username: secondUser }) }) it('Should only return a request to change ownership for the second user', async function () {