From c3d29f694bf8c910f917be655626d0f80871124f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 09:16:40 +0200 Subject: Introduce follows command --- server/tests/api/users/user-subscriptions.ts | 33 +++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 60676a37b..7e365d797 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -1,30 +1,27 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' import { + addUserSubscription, + areSubscriptionsExist, cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, - follow, - getVideosList, - unfollow, - updateVideo, - userLogin -} from '../../../../shared/extra-utils' -import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' -import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' -import { Video, VideoChannel } from '../../../../shared/models/videos' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { - addUserSubscription, - areSubscriptionsExist, getUserSubscription, + getVideosList, listUserSubscriptions, listUserSubscriptionVideos, - removeUserSubscription -} from '../../../../shared/extra-utils/users/user-subscriptions' + removeUserSubscription, + ServerInfo, + setAccessTokensToServers, + updateVideo, + uploadVideo, + userLogin, + waitJobs +} from '@shared/extra-utils' +import { Video, VideoChannel } from '@shared/models' const expect = chai.expect @@ -250,7 +247,7 @@ describe('Test users subscriptions', function () { it('Should have server 1 follow server 3 and display server 3 videos', async function () { this.timeout(60000) - await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken) + await servers[0].followsCommand.follow({ targets: [ servers[2].url ] }) await waitJobs(servers) @@ -268,7 +265,7 @@ describe('Test users subscriptions', function () { it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { this.timeout(60000) - await unfollow(servers[0].url, servers[0].accessToken, servers[2]) + await servers[0].followsCommand.unfollow({ target: servers[2] }) await waitJobs(servers) -- cgit v1.2.3 From 2c27e70471120c92e0bc8c8114141fbb31ff98ac Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 16:40:49 +0200 Subject: Introduce subscriptions command --- server/tests/api/users/user-subscriptions.ts | 144 ++++++++++++--------------- 1 file changed, 61 insertions(+), 83 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 7e365d797..c119622ad 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -3,25 +3,19 @@ import 'mocha' import * as chai from 'chai' import { - addUserSubscription, - areSubscriptionsExist, cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, - getUserSubscription, getVideosList, - listUserSubscriptions, - listUserSubscriptionVideos, - removeUserSubscription, ServerInfo, setAccessTokensToServers, + SubscriptionsCommand, updateVideo, uploadVideo, userLogin, waitJobs } from '@shared/extra-utils' -import { Video, VideoChannel } from '@shared/models' const expect = chai.expect @@ -30,6 +24,8 @@ describe('Test users subscriptions', function () { const users: { accessToken: string }[] = [] let video3UUID: string + let command: SubscriptionsCommand + before(async function () { this.timeout(120000) @@ -58,6 +54,8 @@ describe('Test users subscriptions', function () { } await waitJobs(servers) + + command = servers[0].subscriptionsCommand }) it('Should display videos of server 2 on server 1', async function () { @@ -69,8 +67,8 @@ describe('Test users subscriptions', function () { it('User of server 1 should follow user of server 3 and root of server 1', async function () { this.timeout(60000) - await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) - await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) + await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) + await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) await waitJobs(servers) @@ -93,17 +91,17 @@ describe('Test users subscriptions', function () { it('Should list subscriptions', async function () { { - const res = await listUserSubscriptions({ url: servers[0].url, token: servers[0].accessToken }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + const body = await command.list() + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { - const res = await listUserSubscriptions({ url: servers[0].url, token: users[0].accessToken, sort: 'createdAt' }) - expect(res.body.total).to.equal(2) + const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(2) - const subscriptions: VideoChannel[] = res.body.data + const subscriptions = body.data expect(subscriptions).to.be.an('array') expect(subscriptions).to.have.lengthOf(2) @@ -114,8 +112,7 @@ describe('Test users subscriptions', function () { it('Should get subscription', async function () { { - const res = await getUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) - const videoChannel: VideoChannel = res.body + const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) expect(videoChannel.name).to.equal('user3_channel') expect(videoChannel.host).to.equal('localhost:' + servers[2].port) @@ -125,8 +122,7 @@ describe('Test users subscriptions', function () { } { - const res = await getUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) - const videoChannel: VideoChannel = res.body + const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) expect(videoChannel.name).to.equal('root_channel') expect(videoChannel.host).to.equal('localhost:' + servers[0].port) @@ -144,8 +140,7 @@ describe('Test users subscriptions', function () { 'user3_channel@localhost:' + servers[0].port ] - const res = await areSubscriptionsExist(servers[0].url, users[0].accessToken, uris) - const body = res.body + const body = await command.exist({ token: users[0].accessToken, uris }) expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false @@ -155,45 +150,31 @@ describe('Test users subscriptions', function () { it('Should search among subscriptions', async function () { { - const res = await listUserSubscriptions({ - url: servers[0].url, - token: users[0].accessToken, - sort: '-createdAt', - search: 'user3_channel' - }) - expect(res.body.total).to.equal(1) - - const subscriptions = res.body.data - expect(subscriptions).to.have.lengthOf(1) + const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) } { - const res = await listUserSubscriptions({ - url: servers[0].url, - token: users[0].accessToken, - sort: '-createdAt', - search: 'toto' - }) - expect(res.body.total).to.equal(0) - - const subscriptions = res.body.data - expect(subscriptions).to.have.lengthOf(0) + const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' }) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) } }) it('Should list subscription videos', async function () { { - const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + const body = await command.listVideos() + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(3) + const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(3) - const videos: Video[] = res.body.data + const videos = body.data expect(videos).to.be.an('array') expect(videos).to.have.lengthOf(3) @@ -212,17 +193,17 @@ describe('Test users subscriptions', function () { await waitJobs(servers) { - const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + const body = await command.listVideos() + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(4) + const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(4) - const videos: Video[] = res.body.data + const videos = body.data expect(videos).to.be.an('array') expect(videos).to.have.lengthOf(4) @@ -281,17 +262,17 @@ describe('Test users subscriptions', function () { it('Should still list subscription videos', async function () { { - const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + const body = await command.listVideos() + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(4) + const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(4) - const videos: Video[] = res.body.data + const videos = body.data expect(videos).to.be.an('array') expect(videos).to.have.lengthOf(4) @@ -309,44 +290,41 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - const videos: Video[] = res.body.data - expect(videos[2].name).to.equal('video server 3 added after follow updated') + const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.data[2].name).to.equal('video server 3 added after follow updated') }) it('Should remove user of server 3 subscription', async function () { this.timeout(30000) - await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) + await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) await waitJobs(servers) }) it('Should not display its videos anymore', async function () { - { - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(1) + const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(1) - const videos: Video[] = res.body.data - expect(videos).to.be.an('array') - expect(videos).to.have.lengthOf(1) + const videos = body.data + expect(videos).to.be.an('array') + expect(videos).to.have.lengthOf(1) - expect(videos[0].name).to.equal('video server 1 added after follow') - } + expect(videos[0].name).to.equal('video server 1 added after follow') }) it('Should remove the root subscription and not display the videos anymore', async function () { this.timeout(30000) - await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) + await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) await waitJobs(servers) { - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(0) + const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(0) - const videos: Video[] = res.body.data + const videos = body.data expect(videos).to.be.an('array') expect(videos).to.have.lengthOf(0) } @@ -366,15 +344,15 @@ describe('Test users subscriptions', function () { it('Should follow user of server 3 again', async function () { this.timeout(60000) - await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) + await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) await waitJobs(servers) { - const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(3) + const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) + expect(body.total).to.equal(3) - const videos: Video[] = res.body.data + const videos = body.data expect(videos).to.be.an('array') expect(videos).to.have.lengthOf(3) -- cgit v1.2.3 From 41d1d075011174e73dccb74006181a92a618d7b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 11:05:15 +0200 Subject: Introduce login command --- server/tests/api/users/user-subscriptions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index c119622ad..1d0fc35f1 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -13,7 +13,6 @@ import { SubscriptionsCommand, updateVideo, uploadVideo, - userLogin, waitJobs } from '@shared/extra-utils' @@ -42,7 +41,7 @@ describe('Test users subscriptions', function () { const user = { username: 'user' + server.serverNumber, password: 'password' } await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) - const accessToken = await userLogin(server, user) + const accessToken = await server.loginCommand.getAccessToken(user) users.push({ accessToken }) const videoName1 = 'video 1-' + server.serverNumber -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- server/tests/api/users/user-subscriptions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 1d0fc35f1..c09a85a32 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -4,7 +4,6 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - createUser, doubleFollow, flushAndRunMultipleServers, getVideosList, @@ -39,7 +38,7 @@ describe('Test users subscriptions', function () { { for (const server of servers) { const user = { username: 'user' + server.serverNumber, password: 'password' } - await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) + await server.usersCommand.create({ username: user.username, password: user.password }) const accessToken = await server.loginCommand.getAccessToken(user) users.push({ accessToken }) -- cgit v1.2.3 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/api/users/user-subscriptions.ts | 56 +++++++++++++--------------- 1 file changed, 26 insertions(+), 30 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index c09a85a32..622cddb7d 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -6,12 +6,9 @@ import { cleanupTests, doubleFollow, flushAndRunMultipleServers, - getVideosList, ServerInfo, setAccessTokensToServers, SubscriptionsCommand, - updateVideo, - uploadVideo, waitJobs } from '@shared/extra-utils' @@ -44,10 +41,10 @@ describe('Test users subscriptions', function () { users.push({ accessToken }) const videoName1 = 'video 1-' + server.serverNumber - await uploadVideo(server.url, accessToken, { name: videoName1 }) + await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName1 } }) const videoName2 = 'video 2-' + server.serverNumber - await uploadVideo(server.url, accessToken, { name: videoName2 }) + await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName2 } }) } } @@ -57,9 +54,9 @@ describe('Test users subscriptions', function () { }) it('Should display videos of server 2 on server 1', async function () { - const res = await getVideosList(servers[0].url) + const { total } = await servers[0].videosCommand.list() - expect(res.body.total).to.equal(4) + expect(total).to.equal(4) }) it('User of server 1 should follow user of server 3 and root of server 1', async function () { @@ -70,17 +67,17 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - const res = await uploadVideo(servers[2].url, users[2].accessToken, { name: 'video server 3 added after follow' }) - video3UUID = res.body.video.uuid + const { uuid } = await servers[2].videosCommand.upload({ attributes: { name: 'video server 3 added after follow' } }) + video3UUID = uuid await waitJobs(servers) }) it('Should not display videos of server 3 on server 1', async function () { - const res = await getVideosList(servers[0].url) + const { total, data } = await servers[0].videosCommand.list() + expect(total).to.equal(4) - expect(res.body.total).to.equal(4) - for (const video of res.body.data) { + for (const video of data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') expect(video.name).to.not.contain('video server 3 added after follow') @@ -186,7 +183,7 @@ describe('Test users subscriptions', function () { this.timeout(60000) const videoName = 'video server 1 added after follow' - await uploadVideo(servers[0].url, servers[0].accessToken, { name: videoName }) + await servers[0].videosCommand.upload({ attributes: { name: videoName } }) await waitJobs(servers) @@ -212,10 +209,10 @@ describe('Test users subscriptions', function () { } { - const res = await getVideosList(servers[0].url) + const { data, total } = await servers[0].videosCommand.list() + expect(total).to.equal(5) - expect(res.body.total).to.equal(5) - for (const video of res.body.data) { + for (const video of data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') expect(video.name).to.not.contain('video server 3 added after follow') @@ -230,13 +227,12 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - const res = await getVideosList(servers[0].url) - - expect(res.body.total).to.equal(8) + const { data, total } = await servers[0].videosCommand.list() + expect(total).to.equal(8) const names = [ '1-3', '2-3', 'video server 3 added after follow' ] for (const name of names) { - const video = res.body.data.find(v => v.name.indexOf(name) === -1) + const video = data.find(v => v.name.includes(name)) expect(video).to.not.be.undefined } }) @@ -248,10 +244,10 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - const res = await getVideosList(servers[0].url) + const { total, data } = await servers[0].videosCommand.list() + expect(total).to.equal(5) - expect(res.body.total).to.equal(5) - for (const video of res.body.data) { + for (const video of data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') expect(video.name).to.not.contain('video server 3 added after follow') @@ -284,7 +280,7 @@ describe('Test users subscriptions', function () { it('Should update a video of server 3 and see the updated video on server 1', async function () { this.timeout(30000) - await updateVideo(servers[2].url, users[2].accessToken, video3UUID, { name: 'video server 3 added after follow updated' }) + await servers[2].videosCommand.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) await waitJobs(servers) @@ -329,10 +325,10 @@ describe('Test users subscriptions', function () { }) it('Should correctly display public videos on server 1', async function () { - const res = await getVideosList(servers[0].url) + const { total, data } = await servers[0].videosCommand.list() + expect(total).to.equal(5) - expect(res.body.total).to.equal(5) - for (const video of res.body.data) { + for (const video of data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') expect(video.name).to.not.contain('video server 3 added after follow updated') @@ -360,10 +356,10 @@ describe('Test users subscriptions', function () { } { - const res = await getVideosList(servers[0].url) + const { total, data } = await servers[0].videosCommand.list() + expect(total).to.equal(5) - expect(res.body.total).to.equal(5) - for (const video of res.body.data) { + for (const video of data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') expect(video.name).to.not.contain('video server 3 added after follow updated') -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/users/user-subscriptions.ts | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 622cddb7d..1b15a98dc 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -35,26 +35,26 @@ describe('Test users subscriptions', function () { { for (const server of servers) { const user = { username: 'user' + server.serverNumber, password: 'password' } - await server.usersCommand.create({ username: user.username, password: user.password }) + await server.users.create({ username: user.username, password: user.password }) - const accessToken = await server.loginCommand.getAccessToken(user) + const accessToken = await server.login.getAccessToken(user) users.push({ accessToken }) const videoName1 = 'video 1-' + server.serverNumber - await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName1 } }) + await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) const videoName2 = 'video 2-' + server.serverNumber - await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName2 } }) + await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) } } await waitJobs(servers) - command = servers[0].subscriptionsCommand + command = servers[0].subscriptions }) it('Should display videos of server 2 on server 1', async function () { - const { total } = await servers[0].videosCommand.list() + const { total } = await servers[0].videos.list() expect(total).to.equal(4) }) @@ -67,14 +67,14 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - const { uuid } = await servers[2].videosCommand.upload({ attributes: { name: 'video server 3 added after follow' } }) + const { uuid } = await servers[2].videos.upload({ attributes: { name: 'video server 3 added after follow' } }) video3UUID = uuid await waitJobs(servers) }) it('Should not display videos of server 3 on server 1', async function () { - const { total, data } = await servers[0].videosCommand.list() + const { total, data } = await servers[0].videos.list() expect(total).to.equal(4) for (const video of data) { @@ -183,7 +183,7 @@ describe('Test users subscriptions', function () { this.timeout(60000) const videoName = 'video server 1 added after follow' - await servers[0].videosCommand.upload({ attributes: { name: videoName } }) + await servers[0].videos.upload({ attributes: { name: videoName } }) await waitJobs(servers) @@ -209,7 +209,7 @@ describe('Test users subscriptions', function () { } { - const { data, total } = await servers[0].videosCommand.list() + const { data, total } = await servers[0].videos.list() expect(total).to.equal(5) for (const video of data) { @@ -223,11 +223,11 @@ describe('Test users subscriptions', function () { it('Should have server 1 follow server 3 and display server 3 videos', async function () { this.timeout(60000) - await servers[0].followsCommand.follow({ targets: [ servers[2].url ] }) + await servers[0].follows.follow({ targets: [ servers[2].url ] }) await waitJobs(servers) - const { data, total } = await servers[0].videosCommand.list() + const { data, total } = await servers[0].videos.list() expect(total).to.equal(8) const names = [ '1-3', '2-3', 'video server 3 added after follow' ] @@ -240,11 +240,11 @@ describe('Test users subscriptions', function () { it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { this.timeout(60000) - await servers[0].followsCommand.unfollow({ target: servers[2] }) + await servers[0].follows.unfollow({ target: servers[2] }) await waitJobs(servers) - const { total, data } = await servers[0].videosCommand.list() + const { total, data } = await servers[0].videos.list() expect(total).to.equal(5) for (const video of data) { @@ -280,7 +280,7 @@ describe('Test users subscriptions', function () { it('Should update a video of server 3 and see the updated video on server 1', async function () { this.timeout(30000) - await servers[2].videosCommand.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) + await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) await waitJobs(servers) @@ -325,7 +325,7 @@ describe('Test users subscriptions', function () { }) it('Should correctly display public videos on server 1', async function () { - const { total, data } = await servers[0].videosCommand.list() + const { total, data } = await servers[0].videos.list() expect(total).to.equal(5) for (const video of data) { @@ -356,7 +356,7 @@ describe('Test users subscriptions', function () { } { - const { total, data } = await servers[0].videosCommand.list() + const { total, data } = await servers[0].videos.list() expect(total).to.equal(5) for (const video of data) { -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/users/user-subscriptions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 1b15a98dc..d2bb9c387 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, - ServerInfo, + createMultipleServers, + PeerTubeServer, setAccessTokensToServers, SubscriptionsCommand, waitJobs @@ -15,7 +15,7 @@ import { const expect = chai.expect describe('Test users subscriptions', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] const users: { accessToken: string }[] = [] let video3UUID: string @@ -24,7 +24,7 @@ describe('Test users subscriptions', function () { before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(3) + servers = await createMultipleServers(3) // Get the access tokens await setAccessTokensToServers(servers) -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/api/users/user-subscriptions.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index d2bb9c387..565b4bd77 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -4,8 +4,8 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - doubleFollow, createMultipleServers, + doubleFollow, PeerTubeServer, setAccessTokensToServers, SubscriptionsCommand, @@ -67,7 +67,8 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - const { uuid } = await servers[2].videos.upload({ attributes: { name: 'video server 3 added after follow' } }) + const attributes = { name: 'video server 3 added after follow' } + const { uuid } = await servers[2].videos.upload({ token: users[2].accessToken, attributes }) video3UUID = uuid await waitJobs(servers) -- cgit v1.2.3 From 4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Jul 2021 14:15:15 +0200 Subject: Add ability for instances to follow any actor --- server/tests/api/users/user-subscriptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/users/user-subscriptions.ts') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 565b4bd77..77b99886d 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -224,7 +224,7 @@ describe('Test users subscriptions', function () { it('Should have server 1 follow server 3 and display server 3 videos', async function () { this.timeout(60000) - await servers[0].follows.follow({ targets: [ servers[2].url ] }) + await servers[0].follows.follow({ hosts: [ servers[2].url ] }) await waitJobs(servers) -- cgit v1.2.3