X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fusers%2Fuser-subscriptions.ts;h=48811e647d172606b4db54aee8fce30270dd8212;hb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;hp=cb7d94b0b9aff80a983cc93f83626c672945802e;hpb=f6eebcb336c067e160a62020a5140d8d992ba384;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index cb7d94b0b..48811e647 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -2,18 +2,28 @@ import * as chai from 'chai' import 'mocha' -import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, updateVideo, userLogin } from '../../utils' -import { killallServers, ServerInfo, uploadVideo } from '../../utils/index' -import { setAccessTokensToServers } from '../../utils/users/login' +import { + cleanupTests, + createUser, + doubleFollow, + flushAndRunMultipleServers, + follow, + getVideosList, + unfollow, + updateVideo, + userLogin +} from '../../../../shared/extra-utils' +import { killallServers, 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 '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { addUserSubscription, listUserSubscriptions, listUserSubscriptionVideos, removeUserSubscription, - getUserSubscription -} from '../../utils/users/user-subscriptions' + getUserSubscription, areSubscriptionsExist +} from '../../../../shared/extra-utils/users/user-subscriptions' const expect = chai.expect @@ -36,7 +46,7 @@ describe('Test users subscriptions', function () { { for (const server of servers) { const user = { username: 'user' + server.serverNumber, password: 'password' } - await createUser(server.url, server.accessToken, user.username, user.password) + await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) const accessToken = await userLogin(server, user) users.push({ accessToken }) @@ -128,6 +138,23 @@ describe('Test users subscriptions', function () { } }) + it('Should return the existing subscriptions', async function () { + const uris = [ + 'user3_channel@localhost:9003', + 'root2_channel@localhost:9001', + 'root_channel@localhost:9001', + 'user3_channel@localhost:9001' + ] + + const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris) + const body = res.body + + expect(body['user3_channel@localhost:9003']).to.be.true + expect(body['root2_channel@localhost:9001']).to.be.false + expect(body['root_channel@localhost:9001']).to.be.true + expect(body['user3_channel@localhost:9001']).to.be.false + }) + it('Should list subscription videos', async function () { { const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) @@ -343,6 +370,6 @@ describe('Test users subscriptions', function () { }) after(async function () { - killallServers(servers) + await cleanupTests(servers) }) })