aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-12 11:47:45 +0100
committerChocobozzz <me@florianbigard.com>2018-01-12 11:47:45 +0100
commit32b2b43c06621e384c0bd1610ef0bb9f23399be7 (patch)
treec195943354838bcbe3b1993d77aaf0d3200fd19d /server/tests
parent6502c3d43e512e968ad49f5a3bc9abc302471e18 (diff)
downloadPeerTube-32b2b43c06621e384c0bd1610ef0bb9f23399be7.tar.gz
PeerTube-32b2b43c06621e384c0bd1610ef0bb9f23399be7.tar.zst
PeerTube-32b2b43c06621e384c0bd1610ef0bb9f23399be7.zip
Update follower/following counts
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/follows.ts37
-rw-r--r--server/tests/utils/users/accounts.ts12
2 files changed, 49 insertions, 0 deletions
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index e6dfd5f62..27cf94985 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -12,6 +12,7 @@ import {
12} from '../../utils/index' 12} from '../../utils/index'
13import { dateIsValid } from '../../utils/miscs/miscs' 13import { dateIsValid } from '../../utils/miscs/miscs'
14import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows' 14import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows'
15import { expectAccountFollows } from '../../utils/users/accounts'
15import { userLogin } from '../../utils/users/login' 16import { userLogin } from '../../utils/users/login'
16import { createUser } from '../../utils/users/users' 17import { createUser } from '../../utils/users/users'
17import { 18import {
@@ -116,6 +117,19 @@ describe('Test follows', function () {
116 expect(follows.length).to.equal(0) 117 expect(follows.length).to.equal(0)
117 }) 118 })
118 119
120 it('Should have the correct following counts', async function () {
121 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2)
122 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
123 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0)
124
125 // Server 2 and 3 does not know server 1 follow another server (there was not a refresh)
126 await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1)
127 await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0)
128
129 await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 1)
130 await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0)
131 })
132
119 it('Should unfollow server 3 on server 1', async function () { 133 it('Should unfollow server 3 on server 1', async function () {
120 this.timeout(5000) 134 this.timeout(5000)
121 135
@@ -144,6 +158,17 @@ describe('Test follows', function () {
144 expect(follows.length).to.equal(0) 158 expect(follows.length).to.equal(0)
145 }) 159 })
146 160
161 it('Should have the correct following counts 2', async function () {
162 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1)
163 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
164
165 await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1)
166 await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0)
167
168 await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 0)
169 await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 0, 0)
170 })
171
147 it('Should upload a video on server 2 ans 3 and propagate only the video of server 2', async function () { 172 it('Should upload a video on server 2 ans 3 and propagate only the video of server 2', async function () {
148 this.timeout(10000) 173 this.timeout(10000)
149 174
@@ -223,6 +248,18 @@ describe('Test follows', function () {
223 await wait(7000) 248 await wait(7000)
224 }) 249 })
225 250
251 it('Should have the correct following counts 2', async function () {
252 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2)
253 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
254 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0)
255
256 await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1)
257 await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0)
258
259 await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 1)
260 await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0)
261 })
262
226 it('Should propagate videos', async function () { 263 it('Should propagate videos', async function () {
227 const res = await getVideosList(servers[ 0 ].url) 264 const res = await getVideosList(servers[ 0 ].url)
228 expect(res.body.total).to.equal(7) 265 expect(res.body.total).to.equal(7)
diff --git a/server/tests/utils/users/accounts.ts b/server/tests/utils/users/accounts.ts
index 71712100e..0ec7992b3 100644
--- a/server/tests/utils/users/accounts.ts
+++ b/server/tests/utils/users/accounts.ts
@@ -1,3 +1,5 @@
1import { expect } from 'chai'
2import { Account } from '../../../../shared/models/actors'
1import { makeGetRequest } from '../requests/requests' 3import { makeGetRequest } from '../requests/requests'
2 4
3function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) { 5function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) {
@@ -21,9 +23,19 @@ function getAccount (url: string, accountId: number | string, statusCodeExpected
21 }) 23 })
22} 24}
23 25
26async function expectAccountFollows (url: string, nameWithDomain: string, followersCount: number, followingCount: number) {
27 const res = await getAccountsList(url)
28 const account = res.body.data.find((a: Account) => a.name + '@' + a.host === nameWithDomain)
29
30 const message = `${nameWithDomain} on ${url}`
31 expect(account.followersCount).to.equal(followersCount, message)
32 expect(account.followingCount).to.equal(followingCount, message)
33}
34
24// --------------------------------------------------------------------------- 35// ---------------------------------------------------------------------------
25 36
26export { 37export {
27 getAccount, 38 getAccount,
39 expectAccountFollows,
28 getAccountsList 40 getAccountsList
29} 41}