diff options
Diffstat (limited to 'server/tests/api/users')
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 37 | ||||
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 9 |
2 files changed, 19 insertions, 27 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 2ba6cdfaf..ba59a9a60 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, userLogin } from '../../utils' | 5 | import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, userLogin } from '../../utils' |
6 | import { getMyUserInformation, killallServers, ServerInfo, uploadVideo } from '../../utils/index' | 6 | import { killallServers, ServerInfo, uploadVideo } from '../../utils/index' |
7 | import { setAccessTokensToServers } from '../../utils/users/login' | 7 | import { setAccessTokensToServers } from '../../utils/users/login' |
8 | import { Video, VideoChannel } from '../../../../shared/models/videos' | 8 | import { Video, VideoChannel } from '../../../../shared/models/videos' |
9 | import { waitJobs } from '../../utils/server/jobs' | 9 | import { waitJobs } from '../../utils/server/jobs' |
@@ -18,8 +18,7 @@ const expect = chai.expect | |||
18 | 18 | ||
19 | describe('Test users subscriptions', function () { | 19 | describe('Test users subscriptions', function () { |
20 | let servers: ServerInfo[] = [] | 20 | let servers: ServerInfo[] = [] |
21 | const users: { accessToken: string, videoChannelName: string }[] = [] | 21 | const users: { accessToken: string }[] = [] |
22 | let rootChannelNameServer1: string | ||
23 | 22 | ||
24 | before(async function () { | 23 | before(async function () { |
25 | this.timeout(120000) | 24 | this.timeout(120000) |
@@ -32,19 +31,13 @@ describe('Test users subscriptions', function () { | |||
32 | // Server 1 and server 2 follow each other | 31 | // Server 1 and server 2 follow each other |
33 | await doubleFollow(servers[0], servers[1]) | 32 | await doubleFollow(servers[0], servers[1]) |
34 | 33 | ||
35 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | ||
36 | rootChannelNameServer1 = res.body.videoChannels[0].name | ||
37 | |||
38 | { | 34 | { |
39 | for (const server of servers) { | 35 | for (const server of servers) { |
40 | const user = { username: 'user' + server.serverNumber, password: 'password' } | 36 | const user = { username: 'user' + server.serverNumber, password: 'password' } |
41 | await createUser(server.url, server.accessToken, user.username, user.password) | 37 | await createUser(server.url, server.accessToken, user.username, user.password) |
42 | 38 | ||
43 | const accessToken = await userLogin(server, user) | 39 | const accessToken = await userLogin(server, user) |
44 | const res = await getMyUserInformation(server.url, accessToken) | 40 | users.push({ accessToken }) |
45 | const videoChannels: VideoChannel[] = res.body.videoChannels | ||
46 | |||
47 | users.push({ accessToken, videoChannelName: videoChannels[0].name }) | ||
48 | 41 | ||
49 | const videoName1 = 'video 1-' + server.serverNumber | 42 | const videoName1 = 'video 1-' + server.serverNumber |
50 | await uploadVideo(server.url, accessToken, { name: videoName1 }) | 43 | await uploadVideo(server.url, accessToken, { name: videoName1 }) |
@@ -64,10 +57,10 @@ describe('Test users subscriptions', function () { | |||
64 | }) | 57 | }) |
65 | 58 | ||
66 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { | 59 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { |
67 | this.timeout(30000) | 60 | this.timeout(60000) |
68 | 61 | ||
69 | await addUserSubscription(servers[0].url, users[0].accessToken, users[2].videoChannelName + '@localhost:9003') | 62 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') |
70 | await addUserSubscription(servers[0].url, users[0].accessToken, rootChannelNameServer1 + '@localhost:9001') | 63 | await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') |
71 | 64 | ||
72 | await waitJobs(servers) | 65 | await waitJobs(servers) |
73 | 66 | ||
@@ -103,8 +96,8 @@ describe('Test users subscriptions', function () { | |||
103 | expect(subscriptions).to.be.an('array') | 96 | expect(subscriptions).to.be.an('array') |
104 | expect(subscriptions).to.have.lengthOf(2) | 97 | expect(subscriptions).to.have.lengthOf(2) |
105 | 98 | ||
106 | expect(subscriptions[0].name).to.equal(users[2].videoChannelName) | 99 | expect(subscriptions[0].name).to.equal('user3_channel') |
107 | expect(subscriptions[1].name).to.equal(rootChannelNameServer1) | 100 | expect(subscriptions[1].name).to.equal('root_channel') |
108 | } | 101 | } |
109 | }) | 102 | }) |
110 | 103 | ||
@@ -131,7 +124,7 @@ describe('Test users subscriptions', function () { | |||
131 | }) | 124 | }) |
132 | 125 | ||
133 | it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { | 126 | it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { |
134 | this.timeout(30000) | 127 | this.timeout(60000) |
135 | 128 | ||
136 | const videoName = 'video server 1 added after follow' | 129 | const videoName = 'video server 1 added after follow' |
137 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: videoName }) | 130 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: videoName }) |
@@ -172,7 +165,7 @@ describe('Test users subscriptions', function () { | |||
172 | }) | 165 | }) |
173 | 166 | ||
174 | it('Should have server 1 follow server 3 and display server 3 videos', async function () { | 167 | it('Should have server 1 follow server 3 and display server 3 videos', async function () { |
175 | this.timeout(30000) | 168 | this.timeout(60000) |
176 | 169 | ||
177 | await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken) | 170 | await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken) |
178 | 171 | ||
@@ -190,7 +183,7 @@ describe('Test users subscriptions', function () { | |||
190 | }) | 183 | }) |
191 | 184 | ||
192 | it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { | 185 | it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { |
193 | this.timeout(30000) | 186 | this.timeout(60000) |
194 | 187 | ||
195 | await unfollow(servers[0].url, servers[0].accessToken, servers[2]) | 188 | await unfollow(servers[0].url, servers[0].accessToken, servers[2]) |
196 | 189 | ||
@@ -230,7 +223,7 @@ describe('Test users subscriptions', function () { | |||
230 | }) | 223 | }) |
231 | 224 | ||
232 | it('Should remove user of server 3 subscription', async function () { | 225 | it('Should remove user of server 3 subscription', async function () { |
233 | await removeUserSubscription(servers[0].url, users[0].accessToken, users[2].videoChannelName + '@localhost:9003') | 226 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') |
234 | 227 | ||
235 | await waitJobs(servers) | 228 | await waitJobs(servers) |
236 | }) | 229 | }) |
@@ -249,7 +242,7 @@ describe('Test users subscriptions', function () { | |||
249 | }) | 242 | }) |
250 | 243 | ||
251 | it('Should remove the root subscription and not display the videos anymore', async function () { | 244 | it('Should remove the root subscription and not display the videos anymore', async function () { |
252 | await removeUserSubscription(servers[0].url, users[0].accessToken, rootChannelNameServer1 + '@localhost:9001') | 245 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') |
253 | 246 | ||
254 | await waitJobs(servers) | 247 | await waitJobs(servers) |
255 | 248 | ||
@@ -275,9 +268,9 @@ describe('Test users subscriptions', function () { | |||
275 | }) | 268 | }) |
276 | 269 | ||
277 | it('Should follow user of server 3 again', async function () { | 270 | it('Should follow user of server 3 again', async function () { |
278 | this.timeout(30000) | 271 | this.timeout(60000) |
279 | 272 | ||
280 | await addUserSubscription(servers[0].url, users[0].accessToken, users[2].videoChannelName + '@localhost:9003') | 273 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') |
281 | 274 | ||
282 | await waitJobs(servers) | 275 | await waitJobs(servers) |
283 | 276 | ||
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 81489021b..575e04546 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -12,10 +12,9 @@ import { | |||
12 | getVideoChannelsList, | 12 | getVideoChannelsList, |
13 | removeUser, | 13 | removeUser, |
14 | updateMyUser, | 14 | updateMyUser, |
15 | userLogin, | 15 | userLogin |
16 | wait | ||
17 | } from '../../utils' | 16 | } from '../../utils' |
18 | import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' | 17 | import { getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' |
19 | import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' | 18 | import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' |
20 | import { setAccessTokensToServers } from '../../utils/users/login' | 19 | import { setAccessTokensToServers } from '../../utils/users/login' |
21 | import { User } from '../../../../shared/models/users' | 20 | import { User } from '../../../../shared/models/users' |
@@ -172,7 +171,7 @@ describe('Test users with multiple servers', function () { | |||
172 | 171 | ||
173 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) | 172 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) |
174 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { | 173 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { |
175 | return a.displayName === 'Default user1 channel' && a.host === 'localhost:9001' | 174 | return a.displayName === 'Main user1 channel' && a.host === 'localhost:9001' |
176 | }) as VideoChannel | 175 | }) as VideoChannel |
177 | expect(videoChannelDeleted).not.to.be.undefined | 176 | expect(videoChannelDeleted).not.to.be.undefined |
178 | } | 177 | } |
@@ -189,7 +188,7 @@ describe('Test users with multiple servers', function () { | |||
189 | 188 | ||
190 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) | 189 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) |
191 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { | 190 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { |
192 | return a.name === 'Default user1 channel' && a.host === 'localhost:9001' | 191 | return a.name === 'Main user1 channel' && a.host === 'localhost:9001' |
193 | }) as VideoChannel | 192 | }) as VideoChannel |
194 | expect(videoChannelDeleted).to.be.undefined | 193 | expect(videoChannelDeleted).to.be.undefined |
195 | } | 194 | } |