From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/external-plugins/auth-ldap.ts | 4 +-- server/tests/external-plugins/auto-block-videos.ts | 38 ++++++++++------------ server/tests/external-plugins/auto-mute.ts | 38 ++++++++++------------ 3 files changed, 37 insertions(+), 43 deletions(-) (limited to 'server/tests/external-plugins') diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index d99b3badc..b626ab2bb 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts @@ -3,7 +3,7 @@ import 'mocha' import { expect } from 'chai' import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' +import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' describe('Official plugin auth-ldap', function () { let server: ServerInfo @@ -77,7 +77,7 @@ describe('Official plugin auth-ldap', function () { }) it('Should upload a video', async function () { - await uploadVideo(server.url, accessToken, { name: 'my super video' }) + await server.videosCommand.upload({ token: accessToken, attributes: { name: 'my super video' } }) }) it('Should not be able to login if the user is banned', async function () { diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts index f4b55522a..1cce15a2f 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts @@ -2,27 +2,23 @@ import 'mocha' import { expect } from 'chai' -import { Video } from '@shared/models' -import { - doubleFollow, - getVideosList, - MockBlocklist, - setAccessTokensToServers, - uploadVideoAndGetId, - wait -} from '../../../shared/extra-utils' import { cleanupTests, + doubleFollow, flushAndRunMultipleServers, killallServers, + MockBlocklist, reRunServer, - ServerInfo -} from '../../../shared/extra-utils/server/servers' + ServerInfo, + setAccessTokensToServers, + wait +} from '@shared/extra-utils' +import { Video } from '@shared/models' async function check (server: ServerInfo, videoUUID: string, exists = true) { - const res = await getVideosList(server.url) + const { data } = await server.videosCommand.list() - const video = res.body.data.find(v => v.uuid === videoUUID) + const video = data.find(v => v.uuid === videoUUID) if (exists) expect(video).to.not.be.undefined else expect(video).to.be.undefined @@ -48,19 +44,19 @@ describe('Official plugin auto-block videos', function () { blocklistServer = new MockBlocklist() port = await blocklistServer.initialize() - await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) - await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) - await uploadVideoAndGetId({ server: servers[1], videoName: 'video 2 server 2' }) - await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3 server 2' }) + await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) + await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) + await await servers[1].videosCommand.quickUpload({ name: 'video 2 server 2' }) + await await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2' }) { - const res = await getVideosList(servers[0].url) - server1Videos = res.body.data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) + const { data } = await servers[0].videosCommand.list() + server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) } { - const res = await getVideosList(servers[1].url) - server2Videos = res.body.data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) + const { data } = await servers[1].videosCommand.list() + server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) } await doubleFollow(servers[0], servers[1]) diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index 844023b83..81a96744e 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts @@ -7,14 +7,12 @@ import { cleanupTests, doubleFollow, flushAndRunMultipleServers, - getVideosList, killallServers, makeGetRequest, MockBlocklist, reRunServer, ServerInfo, setAccessTokensToServers, - uploadVideoAndGetId, wait } from '@shared/extra-utils' @@ -37,8 +35,8 @@ describe('Official plugin auto-mute', function () { blocklistServer = new MockBlocklist() port = await blocklistServer.initialize() - await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) - await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) + await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) + await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) await doubleFollow(servers[0], servers[1]) }) @@ -66,8 +64,8 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(1) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(1) }) it('Should remove a server blocklist', async function () { @@ -84,8 +82,8 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(2) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(2) }) it('Should add an account blocklist', async function () { @@ -101,8 +99,8 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(1) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(1) }) it('Should remove an account blocklist', async function () { @@ -119,8 +117,8 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(2) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(2) }) it('Should auto mute an account, manually unmute it and do not remute it automatically', async function () { @@ -140,15 +138,15 @@ describe('Official plugin auto-mute', function () { await wait(2000) { - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(1) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(1) } await servers[0].blocklistCommand.removeFromServerBlocklist({ account }) { - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(2) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(2) } await killallServers([ servers[0] ]) @@ -156,8 +154,8 @@ describe('Official plugin auto-mute', function () { await wait(2000) { - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(2) + const { total } = await servers[0].videosCommand.list() + expect(total).to.equal(2) } }) @@ -215,8 +213,8 @@ describe('Official plugin auto-mute', function () { await wait(2000) for (const server of servers) { - const res = await getVideosList(server.url) - expect(res.body.total).to.equal(1) + const { total } = await server.videosCommand.list() + expect(total).to.equal(1) } }) -- cgit v1.2.3