aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/follows-moderation.ts78
-rw-r--r--server/tests/api/server/index.ts1
2 files changed, 79 insertions, 0 deletions
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts
new file mode 100644
index 000000000..b1cbfb62c
--- /dev/null
+++ b/server/tests/api/server/follows-moderation.ts
@@ -0,0 +1,78 @@
1/* tslint:disable:no-unused-expression */
2
3import * as chai from 'chai'
4import 'mocha'
5import { flushAndRunMultipleServers, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/utils/index'
6import {
7 follow,
8 getFollowersListPaginationAndSort,
9 getFollowingListPaginationAndSort,
10 removeFollower
11} from '../../../../shared/utils/server/follows'
12import { waitJobs } from '../../../../shared/utils/server/jobs'
13import { ActorFollow } from '../../../../shared/models/actors'
14
15const expect = chai.expect
16
17describe('Test follows moderation', function () {
18 let servers: ServerInfo[] = []
19
20 before(async function () {
21 this.timeout(30000)
22
23 servers = await flushAndRunMultipleServers(2)
24
25 // Get the access tokens
26 await setAccessTokensToServers(servers)
27 })
28
29 it('Should have server 1 following server 2', async function () {
30 this.timeout(30000)
31
32 await follow(servers[0].url, [ servers[1].url ], servers[0].accessToken)
33
34 await waitJobs(servers)
35 })
36
37 it('Should have correct follows', async function () {
38 {
39 const res = await getFollowingListPaginationAndSort(servers[0].url, 0, 5, 'createdAt')
40 expect(res.body.total).to.equal(1)
41
42 const follow = res.body.data[0] as ActorFollow
43 expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube')
44 expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube')
45 }
46
47 {
48 const res = await getFollowersListPaginationAndSort(servers[1].url, 0, 5, 'createdAt')
49 expect(res.body.total).to.equal(1)
50
51 const follow = res.body.data[0] as ActorFollow
52 expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube')
53 expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube')
54 }
55 })
56
57 it('Should remove follower on server 2', async function () {
58 await removeFollower(servers[1].url, servers[1].accessToken, servers[0])
59
60 await waitJobs(servers)
61 })
62
63 it('Should not not have follows anymore', async function () {
64 {
65 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt')
66 expect(res.body.total).to.equal(0)
67 }
68
69 {
70 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt')
71 expect(res.body.total).to.equal(0)
72 }
73 })
74
75 after(async function () {
76 killallServers(servers)
77 })
78})
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts
index 1f80cc6cf..4e53074ab 100644
--- a/server/tests/api/server/index.ts
+++ b/server/tests/api/server/index.ts
@@ -3,6 +3,7 @@ import './contact-form'
3import './email' 3import './email'
4import './follow-constraints' 4import './follow-constraints'
5import './follows' 5import './follows'
6import './follows-moderation'
6import './handle-down' 7import './handle-down'
7import './jobs' 8import './jobs'
8import './reverse-proxy' 9import './reverse-proxy'