X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fexternal-plugins%2Fauto-mute.ts;h=375ccf91a382293243afd966baa651b7c8029558;hb=63973cd1e17e48630378453857a6b192ac3091da;hp=81a96744e10f7ba7dd064b4beb5b669d7968a274;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index 81a96744e..375ccf91a 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts @@ -2,47 +2,46 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { wait } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, + createMultipleServers, doubleFollow, - flushAndRunMultipleServers, killallServers, makeGetRequest, - MockBlocklist, - reRunServer, - ServerInfo, - setAccessTokensToServers, - wait -} from '@shared/extra-utils' + PeerTubeServer, + setAccessTokensToServers +} from '@shared/server-commands' +import { MockBlocklist } from '../shared' describe('Official plugin auto-mute', function () { const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' - let servers: ServerInfo[] + let servers: PeerTubeServer[] let blocklistServer: MockBlocklist let port: number before(async function () { this.timeout(30000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) for (const server of servers) { - await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-mute' }) + await server.plugins.install({ npmName: 'peertube-plugin-auto-mute' }) } blocklistServer = new MockBlocklist() port = await blocklistServer.initialize() - await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) - await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) + await servers[0].videos.quickUpload({ name: 'video server 1' }) + await servers[1].videos.quickUpload({ name: 'video server 2' }) await doubleFollow(servers[0], servers[1]) }) it('Should update plugin settings', async function () { - await servers[0].pluginsCommand.updateSettings({ + await servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { 'blocklist-urls': `http://localhost:${port}/blocklist`, @@ -64,7 +63,7 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(1) }) @@ -82,7 +81,7 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(2) }) @@ -99,7 +98,7 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(1) }) @@ -117,7 +116,7 @@ describe('Official plugin auto-mute', function () { await wait(2000) - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(2) }) @@ -138,23 +137,23 @@ describe('Official plugin auto-mute', function () { await wait(2000) { - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(1) } - await servers[0].blocklistCommand.removeFromServerBlocklist({ account }) + await servers[0].blocklist.removeFromServerBlocklist({ account }) { - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(2) } await killallServers([ servers[0] ]) - await reRunServer(servers[0]) + await servers[0].run() await wait(2000) { - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(2) } }) @@ -163,12 +162,12 @@ describe('Official plugin auto-mute', function () { await makeGetRequest({ url: servers[0].url, path: '/plugins/auto-mute/router/api/v1/mute-list', - statusCodeExpected: HttpStatusCode.FORBIDDEN_403 + expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should enable auto mute list', async function () { - await servers[0].pluginsCommand.updateSettings({ + await servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { 'blocklist-urls': '', @@ -180,14 +179,14 @@ describe('Official plugin auto-mute', function () { await makeGetRequest({ url: servers[0].url, path: '/plugins/auto-mute/router/api/v1/mute-list', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) }) it('Should mute an account on server 1, and server 2 auto mutes it', async function () { this.timeout(20000) - await servers[1].pluginsCommand.updateSettings({ + await servers[1].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath, @@ -196,13 +195,13 @@ describe('Official plugin auto-mute', function () { } }) - await servers[0].blocklistCommand.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) - await servers[0].blocklistCommand.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) + await servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) + await servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) const res = await makeGetRequest({ url: servers[0].url, path: '/plugins/auto-mute/router/api/v1/mute-list', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) const data = res.body.data @@ -213,7 +212,7 @@ describe('Official plugin auto-mute', function () { await wait(2000) for (const server of servers) { - const { total } = await server.videosCommand.list() + const { total } = await server.videos.list() expect(total).to.equal(1) } })