X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fsearch%2Fsearch-activitypub-video-channels.ts;h=426cbc8e1bec1f61eb4489c2a69d1280b3e344fb;hb=9e8789497377cac5554a622da605f5b89587aa9c;hp=3cba2b0191c69929b020bef36596367737ccc469;hpb=41d1d075011174e73dccb74006181a92a618d7b4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 3cba2b019..426cbc8e1 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -4,15 +4,10 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - createUser, - flushAndRunMultipleServers, - getVideoChannelVideos, + createMultipleServers, + PeerTubeServer, SearchCommand, - ServerInfo, setAccessTokensToServers, - updateMyUser, - updateVideo, - uploadVideo, wait, waitJobs } from '@shared/extra-utils' @@ -21,7 +16,7 @@ import { VideoChannel } from '@shared/models' const expect = chai.expect describe('Test ActivityPub video channels search', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let userServer2Token: string let videoServer2UUID: string let channelIdServer2: number @@ -30,38 +25,39 @@ describe('Test ActivityPub video channels search', function () { before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) { - await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'user1_server1', password: 'password' }) + await servers[0].users.create({ username: 'user1_server1', password: 'password' }) const channel = { name: 'channel1_server1', displayName: 'Channel 1 server 1' } - await servers[0].channelsCommand.create({ attributes: channel }) + await servers[0].channels.create({ attributes: channel }) } { const user = { username: 'user1_server2', password: 'password' } - await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) - userServer2Token = await servers[1].loginCommand.getAccessToken(user) + await servers[1].users.create({ username: user.username, password: user.password }) + userServer2Token = await servers[1].login.getAccessToken(user) const channel = { name: 'channel1_server2', displayName: 'Channel 1 server 2' } - const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel }) + const created = await servers[1].channels.create({ token: userServer2Token, attributes: channel }) channelIdServer2 = created.id - const res = await uploadVideo(servers[1].url, userServer2Token, { name: 'video 1 server 2', channelId: channelIdServer2 }) - videoServer2UUID = res.body.video.uuid + const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 } + const { uuid } = await servers[1].videos.upload({ token: userServer2Token, attributes }) + videoServer2UUID = uuid } await waitJobs(servers) - command = servers[0].searchCommand + command = servers[0].search }) it('Should not find a remote video channel', async function () { @@ -138,7 +134,7 @@ describe('Test ActivityPub video channels search', function () { }) it('Should not list this remote video channel', async function () { - const body = await servers[0].channelsCommand.list() + const body = await servers[0].channels.list() expect(body.total).to.equal(3) expect(body.data).to.have.lengthOf(3) expect(body.data[0].name).to.equal('channel1_server1') @@ -151,27 +147,32 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[1].port, 0, 5) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + const { total, data } = await servers[0].videos.listByChannel({ + token: null, + handle: 'channel1_server2@localhost:' + servers[1].port + }) + expect(total).to.equal(0) + expect(data).to.have.lengthOf(0) }) it('Should list video channel videos of server 2 with token', async function () { - const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[1].port, 0, 5) + const { total, data } = await servers[0].videos.listByChannel({ + handle: 'channel1_server2@localhost:' + servers[1].port + }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('video 1 server 2') + expect(total).to.equal(1) + expect(data[0].name).to.equal('video 1 server 2') }) it('Should update video channel of server 2, and refresh it on server 1', async function () { this.timeout(60000) - await servers[1].channelsCommand.update({ + await servers[1].channels.update({ token: userServer2Token, channelName: 'channel1_server2', attributes: { displayName: 'channel updated' } }) - await updateMyUser({ url: servers[1].url, accessToken: userServer2Token, displayName: 'user updated' }) + await servers[1].users.updateMe({ token: userServer2Token, displayName: 'user updated' }) await waitJobs(servers) // Expire video channel @@ -192,8 +193,8 @@ describe('Test ActivityPub video channels search', function () { it('Should update and add a video on server 2, and update it on server 1 after a search', async function () { this.timeout(60000) - await updateVideo(servers[1].url, userServer2Token, videoServer2UUID, { name: 'video 1 updated' }) - await uploadVideo(servers[1].url, userServer2Token, { name: 'video 2 server 2', channelId: channelIdServer2 }) + await servers[1].videos.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } }) + await servers[1].videos.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } }) await waitJobs(servers) @@ -205,18 +206,18 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const videoChannelName = 'channel1_server2@localhost:' + servers[1].port - const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, videoChannelName, 0, 5, '-createdAt') + const handle = 'channel1_server2@localhost:' + servers[1].port + const { total, data } = await servers[0].videos.listByChannel({ handle, sort: '-createdAt' }) - expect(res.body.total).to.equal(2) - expect(res.body.data[0].name).to.equal('video 2 server 2') - expect(res.body.data[1].name).to.equal('video 1 updated') + expect(total).to.equal(2) + expect(data[0].name).to.equal('video 2 server 2') + expect(data[1].name).to.equal('video 1 updated') }) it('Should delete video channel of server 2, and delete it on server 1', async function () { this.timeout(60000) - await servers[1].channelsCommand.delete({ token: userServer2Token, channelName: 'channel1_server2' }) + await servers[1].channels.delete({ token: userServer2Token, channelName: 'channel1_server2' }) await waitJobs(servers) // Expire video