X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Ffollows-moderation.ts;h=120bd7f885bddafa3e433a2b0a5fe118bcb8648d;hb=64324ac646b0938e35cd88771492623b640bd0d8;hp=4853b647da3465be852ad2bb48bac8f00ab127f3;hpb=c3d29f694bf8c910f917be655626d0f80871124f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts index 4853b647d..120bd7f88 100644 --- a/server/tests/api/server/follows-moderation.ts +++ b/server/tests/api/server/follows-moderation.ts @@ -4,20 +4,19 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunMultipleServers, + createMultipleServers, FollowsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, - updateCustomSubConfig, waitJobs -} from '@shared/extra-utils' +} from '@shared/server-commands' const expect = chai.expect -async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') { +async function checkServer1And2HasFollowers (servers: PeerTubeServer[], state = 'accepted') { const fns = [ - servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand), - servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand) + servers[0].follows.getFollowings.bind(servers[0].follows), + servers[1].follows.getFollowers.bind(servers[1].follows) ] for (const fn of fns) { @@ -31,10 +30,10 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc } } -async function checkNoFollowers (servers: ServerInfo[]) { +async function checkNoFollowers (servers: PeerTubeServer[]) { const fns = [ - servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand), - servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand) + servers[0].follows.getFollowings.bind(servers[0].follows), + servers[1].follows.getFollowers.bind(servers[1].follows) ] for (const fn of fns) { @@ -44,24 +43,24 @@ async function checkNoFollowers (servers: ServerInfo[]) { } describe('Test follows moderation', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let commands: FollowsCommand[] before(async function () { this.timeout(30000) - servers = await flushAndRunMultipleServers(3) + servers = await createMultipleServers(3) // Get the access tokens await setAccessTokensToServers(servers) - commands = servers.map(s => s.followsCommand) + commands = servers.map(s => s.follows) }) it('Should have server 1 following server 2', async function () { this.timeout(30000) - await commands[0].follow({ targets: [ servers[1].url ] }) + await commands[0].follow({ hosts: [ servers[1].url ] }) await waitJobs(servers) }) @@ -94,9 +93,9 @@ describe('Test follows moderation', function () { } } - await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig) + await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) - await commands[0].follow({ targets: [ servers[1].url ] }) + await commands[0].follow({ hosts: [ servers[1].url ] }) await waitJobs(servers) await checkNoFollowers(servers) @@ -114,9 +113,9 @@ describe('Test follows moderation', function () { } } - await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig) + await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) - await commands[0].follow({ targets: [ servers[1].url ] }) + await commands[0].follow({ hosts: [ servers[1].url ] }) await waitJobs(servers) await checkServer1And2HasFollowers(servers) @@ -137,10 +136,10 @@ describe('Test follows moderation', function () { } } - await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig) - await updateCustomSubConfig(servers[2].url, servers[2].accessToken, subConfig) + await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) + await servers[2].config.updateCustomSubConfig({ newConfig: subConfig }) - await commands[0].follow({ targets: [ servers[1].url ] }) + await commands[0].follow({ hosts: [ servers[1].url ] }) await waitJobs(servers) await checkServer1And2HasFollowers(servers, 'pending') @@ -158,7 +157,7 @@ describe('Test follows moderation', function () { it('Should reject another follower', async function () { this.timeout(20000) - await commands[0].follow({ targets: [ servers[2].url ] }) + await commands[0].follow({ hosts: [ servers[2].url ] }) await waitJobs(servers) {