diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-20 14:15:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 13:35:31 +0200 |
commit | 4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef (patch) | |
tree | 20bcdd660ab4eb731814db3a4a40fffb48ce7482 /server/tests/api | |
parent | 7f28f2ddbaeecf451d501e99ded0408c14a33600 (diff) | |
download | PeerTube-4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef.tar.gz PeerTube-4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef.tar.zst PeerTube-4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef.zip |
Add ability for instances to follow any actor
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/follows.ts | 36 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 4 | ||||
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 4 | ||||
-rw-r--r-- | server/tests/api/redundancy/redundancy-constraints.ts | 4 | ||||
-rw-r--r-- | server/tests/api/server/auto-follows.ts | 2 | ||||
-rw-r--r-- | server/tests/api/server/follows-moderation.ts | 10 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 595 | ||||
-rw-r--r-- | server/tests/api/server/handle-down.ts | 6 | ||||
-rw-r--r-- | server/tests/api/server/stats.ts | 2 | ||||
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 2 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 2 |
11 files changed, 369 insertions, 298 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index dfe3f226d..2bc9f6b96 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -32,19 +32,13 @@ describe('Test server follows API validators', function () { | |||
32 | let userAccessToken = null | 32 | let userAccessToken = null |
33 | 33 | ||
34 | before(async function () { | 34 | before(async function () { |
35 | const user = { | 35 | userAccessToken = await server.users.generateUserAndToken('user1') |
36 | username: 'user1', | ||
37 | password: 'password' | ||
38 | } | ||
39 | |||
40 | await server.users.create({ username: user.username, password: user.password }) | ||
41 | userAccessToken = await server.login.getAccessToken(user) | ||
42 | }) | 36 | }) |
43 | 37 | ||
44 | describe('When adding follows', function () { | 38 | describe('When adding follows', function () { |
45 | const path = '/api/v1/server/following' | 39 | const path = '/api/v1/server/following' |
46 | 40 | ||
47 | it('Should fail without hosts', async function () { | 41 | it('Should fail with nothing', async function () { |
48 | await makePostBodyRequest({ | 42 | await makePostBodyRequest({ |
49 | url: server.url, | 43 | url: server.url, |
50 | path, | 44 | path, |
@@ -53,41 +47,51 @@ describe('Test server follows API validators', function () { | |||
53 | }) | 47 | }) |
54 | }) | 48 | }) |
55 | 49 | ||
56 | it('Should fail if hosts is not an array', async function () { | 50 | it('Should fail if hosts is not composed by hosts', async function () { |
57 | await makePostBodyRequest({ | 51 | await makePostBodyRequest({ |
58 | url: server.url, | 52 | url: server.url, |
59 | path, | 53 | path, |
54 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, | ||
60 | token: server.accessToken, | 55 | token: server.accessToken, |
61 | fields: { hosts: 'localhost:9002' }, | ||
62 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 56 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
63 | }) | 57 | }) |
64 | }) | 58 | }) |
65 | 59 | ||
66 | it('Should fail if the array is not composed by hosts', async function () { | 60 | it('Should fail if hosts is composed with http schemes', async function () { |
67 | await makePostBodyRequest({ | 61 | await makePostBodyRequest({ |
68 | url: server.url, | 62 | url: server.url, |
69 | path, | 63 | path, |
70 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, | 64 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, |
71 | token: server.accessToken, | 65 | token: server.accessToken, |
72 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 66 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
73 | }) | 67 | }) |
74 | }) | 68 | }) |
75 | 69 | ||
76 | it('Should fail if the array is composed with http schemes', async function () { | 70 | it('Should fail if hosts are not unique', async function () { |
77 | await makePostBodyRequest({ | 71 | await makePostBodyRequest({ |
78 | url: server.url, | 72 | url: server.url, |
79 | path, | 73 | path, |
80 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, | 74 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, |
81 | token: server.accessToken, | 75 | token: server.accessToken, |
82 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 76 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
83 | }) | 77 | }) |
84 | }) | 78 | }) |
85 | 79 | ||
86 | it('Should fail if hosts are not unique', async function () { | 80 | it('Should fail if handles is not composed by handles', async function () { |
87 | await makePostBodyRequest({ | 81 | await makePostBodyRequest({ |
88 | url: server.url, | 82 | url: server.url, |
89 | path, | 83 | path, |
90 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, | 84 | fields: { handles: [ 'hello@example.com', 'localhost:9001' ] }, |
85 | token: server.accessToken, | ||
86 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
87 | }) | ||
88 | }) | ||
89 | |||
90 | it('Should fail if handles are not unique', async function () { | ||
91 | await makePostBodyRequest({ | ||
92 | url: server.url, | ||
93 | path, | ||
94 | fields: { urls: [ 'hello@example.com', 'hello@example.com' ] }, | ||
91 | token: server.accessToken, | 95 | token: server.accessToken, |
92 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 96 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
93 | }) | 97 | }) |
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 8ed5ad9e5..089af8b15 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -690,7 +690,7 @@ describe('Test blocklist', function () { | |||
690 | const now = new Date() | 690 | const now = new Date() |
691 | await servers[1].follows.unfollow({ target: servers[0] }) | 691 | await servers[1].follows.unfollow({ target: servers[0] }) |
692 | await waitJobs(servers) | 692 | await waitJobs(servers) |
693 | await servers[1].follows.follow({ targets: [ servers[0].host ] }) | 693 | await servers[1].follows.follow({ hosts: [ servers[0].host ] }) |
694 | 694 | ||
695 | await waitJobs(servers) | 695 | await waitJobs(servers) |
696 | 696 | ||
@@ -751,7 +751,7 @@ describe('Test blocklist', function () { | |||
751 | const now = new Date() | 751 | const now = new Date() |
752 | await servers[1].follows.unfollow({ target: servers[0] }) | 752 | await servers[1].follows.unfollow({ target: servers[0] }) |
753 | await waitJobs(servers) | 753 | await waitJobs(servers) |
754 | await servers[1].follows.follow({ targets: [ servers[0].host ] }) | 754 | await servers[1].follows.follow({ hosts: [ servers[0].host ] }) |
755 | 755 | ||
756 | await waitJobs(servers) | 756 | await waitJobs(servers) |
757 | 757 | ||
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 6e8f8a2b4..6f74709b3 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -368,7 +368,7 @@ describe('Test moderation notifications', function () { | |||
368 | it('Should send a notification only to admin when there is a new instance follower', async function () { | 368 | it('Should send a notification only to admin when there is a new instance follower', async function () { |
369 | this.timeout(20000) | 369 | this.timeout(20000) |
370 | 370 | ||
371 | await servers[2].follows.follow({ targets: [ servers[0].url ] }) | 371 | await servers[2].follows.follow({ hosts: [ servers[0].url ] }) |
372 | 372 | ||
373 | await waitJobs(servers) | 373 | await waitJobs(servers) |
374 | 374 | ||
@@ -393,7 +393,7 @@ describe('Test moderation notifications', function () { | |||
393 | } | 393 | } |
394 | await servers[0].config.updateCustomSubConfig({ newConfig: config }) | 394 | await servers[0].config.updateCustomSubConfig({ newConfig: config }) |
395 | 395 | ||
396 | await servers[2].follows.follow({ targets: [ servers[0].url ] }) | 396 | await servers[2].follows.follow({ hosts: [ servers[0].url ] }) |
397 | 397 | ||
398 | await waitJobs(servers) | 398 | await waitJobs(servers) |
399 | 399 | ||
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 25cd11658..933a2c776 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts | |||
@@ -75,7 +75,7 @@ describe('Test redundancy constraints', function () { | |||
75 | await waitJobs(servers) | 75 | await waitJobs(servers) |
76 | 76 | ||
77 | // Server 1 and server 2 follow each other | 77 | // Server 1 and server 2 follow each other |
78 | await remoteServer.follows.follow({ targets: [ localServer.url ] }) | 78 | await remoteServer.follows.follow({ hosts: [ localServer.url ] }) |
79 | await waitJobs(servers) | 79 | await waitJobs(servers) |
80 | await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) | 80 | await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) |
81 | 81 | ||
@@ -161,7 +161,7 @@ describe('Test redundancy constraints', function () { | |||
161 | it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () { | 161 | it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () { |
162 | this.timeout(120000) | 162 | this.timeout(120000) |
163 | 163 | ||
164 | await localServer.follows.follow({ targets: [ remoteServer.url ] }) | 164 | await localServer.follows.follow({ hosts: [ remoteServer.url ] }) |
165 | await waitJobs(servers) | 165 | await waitJobs(servers) |
166 | 166 | ||
167 | await uploadWrapper('video 4 server 2') | 167 | await uploadWrapper('video 4 server 2') |
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts index 8dca2e5e5..ce7b51925 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/server/tests/api/server/auto-follows.ts | |||
@@ -33,7 +33,7 @@ async function checkFollow (follower: PeerTubeServer, following: PeerTubeServer, | |||
33 | } | 33 | } |
34 | 34 | ||
35 | async function server1Follows2 (servers: PeerTubeServer[]) { | 35 | async function server1Follows2 (servers: PeerTubeServer[]) { |
36 | await servers[0].follows.follow({ targets: [ servers[1].host ] }) | 36 | await servers[0].follows.follow({ hosts: [ servers[1].host ] }) |
37 | 37 | ||
38 | await waitJobs(servers) | 38 | await waitJobs(servers) |
39 | } | 39 | } |
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts index 0aa328c5a..921f51043 100644 --- a/server/tests/api/server/follows-moderation.ts +++ b/server/tests/api/server/follows-moderation.ts | |||
@@ -60,7 +60,7 @@ describe('Test follows moderation', function () { | |||
60 | it('Should have server 1 following server 2', async function () { | 60 | it('Should have server 1 following server 2', async function () { |
61 | this.timeout(30000) | 61 | this.timeout(30000) |
62 | 62 | ||
63 | await commands[0].follow({ targets: [ servers[1].url ] }) | 63 | await commands[0].follow({ hosts: [ servers[1].url ] }) |
64 | 64 | ||
65 | await waitJobs(servers) | 65 | await waitJobs(servers) |
66 | }) | 66 | }) |
@@ -95,7 +95,7 @@ describe('Test follows moderation', function () { | |||
95 | 95 | ||
96 | await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) | 96 | await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) |
97 | 97 | ||
98 | await commands[0].follow({ targets: [ servers[1].url ] }) | 98 | await commands[0].follow({ hosts: [ servers[1].url ] }) |
99 | await waitJobs(servers) | 99 | await waitJobs(servers) |
100 | 100 | ||
101 | await checkNoFollowers(servers) | 101 | await checkNoFollowers(servers) |
@@ -115,7 +115,7 @@ describe('Test follows moderation', function () { | |||
115 | 115 | ||
116 | await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) | 116 | await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) |
117 | 117 | ||
118 | await commands[0].follow({ targets: [ servers[1].url ] }) | 118 | await commands[0].follow({ hosts: [ servers[1].url ] }) |
119 | await waitJobs(servers) | 119 | await waitJobs(servers) |
120 | 120 | ||
121 | await checkServer1And2HasFollowers(servers) | 121 | await checkServer1And2HasFollowers(servers) |
@@ -139,7 +139,7 @@ describe('Test follows moderation', function () { | |||
139 | await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) | 139 | await servers[1].config.updateCustomSubConfig({ newConfig: subConfig }) |
140 | await servers[2].config.updateCustomSubConfig({ newConfig: subConfig }) | 140 | await servers[2].config.updateCustomSubConfig({ newConfig: subConfig }) |
141 | 141 | ||
142 | await commands[0].follow({ targets: [ servers[1].url ] }) | 142 | await commands[0].follow({ hosts: [ servers[1].url ] }) |
143 | await waitJobs(servers) | 143 | await waitJobs(servers) |
144 | 144 | ||
145 | await checkServer1And2HasFollowers(servers, 'pending') | 145 | await checkServer1And2HasFollowers(servers, 'pending') |
@@ -157,7 +157,7 @@ describe('Test follows moderation', function () { | |||
157 | it('Should reject another follower', async function () { | 157 | it('Should reject another follower', async function () { |
158 | this.timeout(20000) | 158 | this.timeout(20000) |
159 | 159 | ||
160 | await commands[0].follow({ targets: [ servers[2].url ] }) | 160 | await commands[0].follow({ hosts: [ servers[2].url ] }) |
161 | await waitJobs(servers) | 161 | await waitJobs(servers) |
162 | 162 | ||
163 | { | 163 | { |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index ff8f880a6..a616edcff 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -8,308 +8,369 @@ import { | |||
8 | createMultipleServers, | 8 | createMultipleServers, |
9 | dateIsValid, | 9 | dateIsValid, |
10 | expectAccountFollows, | 10 | expectAccountFollows, |
11 | FollowsCommand, | 11 | expectChannelsFollows, |
12 | PeerTubeServer, | 12 | PeerTubeServer, |
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | testCaptionFile, | 14 | testCaptionFile, |
15 | waitJobs | 15 | waitJobs |
16 | } from '@shared/extra-utils' | 16 | } from '@shared/extra-utils' |
17 | import { Video, VideoPrivacy } from '@shared/models' | 17 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
21 | describe('Test follows', function () { | 21 | describe('Test follows', function () { |
22 | let servers: PeerTubeServer[] = [] | 22 | let servers: PeerTubeServer[] = [] |
23 | let followsCommands: FollowsCommand[] | ||
24 | 23 | ||
25 | before(async function () { | 24 | before(async function () { |
26 | this.timeout(30000) | 25 | this.timeout(30000) |
27 | 26 | ||
28 | servers = await createMultipleServers(3) | 27 | servers = await createMultipleServers(3) |
29 | followsCommands = servers.map(s => s.follows) | ||
30 | 28 | ||
31 | // Get the access tokens | 29 | // Get the access tokens |
32 | await setAccessTokensToServers(servers) | 30 | await setAccessTokensToServers(servers) |
33 | }) | 31 | }) |
34 | 32 | ||
35 | it('Should not have followers', async function () { | 33 | describe('Data propagation after follow', function () { |
36 | for (const server of servers) { | ||
37 | const body = await server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' }) | ||
38 | expect(body.total).to.equal(0) | ||
39 | |||
40 | const follows = body.data | ||
41 | expect(follows).to.be.an('array') | ||
42 | expect(follows.length).to.equal(0) | ||
43 | } | ||
44 | }) | ||
45 | 34 | ||
46 | it('Should not have following', async function () { | 35 | it('Should not have followers/followings', async function () { |
47 | for (const server of servers) { | 36 | for (const server of servers) { |
48 | const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' }) | 37 | const bodies = await Promise.all([ |
49 | expect(body.total).to.equal(0) | 38 | server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' }), |
39 | server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' }) | ||
40 | ]) | ||
50 | 41 | ||
51 | const follows = body.data | 42 | for (const body of bodies) { |
52 | expect(follows).to.be.an('array') | 43 | expect(body.total).to.equal(0) |
53 | expect(follows.length).to.equal(0) | ||
54 | } | ||
55 | }) | ||
56 | 44 | ||
57 | it('Should have server 1 following server 2 and 3', async function () { | 45 | const follows = body.data |
58 | this.timeout(30000) | 46 | expect(follows).to.be.an('array') |
47 | expect(follows).to.have.lengthOf(0) | ||
48 | } | ||
49 | } | ||
50 | }) | ||
59 | 51 | ||
60 | await followsCommands[0].follow({ targets: [ servers[1].url, servers[2].url ] }) | 52 | it('Should have server 1 following root account of server 2 and server 3', async function () { |
53 | this.timeout(30000) | ||
61 | 54 | ||
62 | await waitJobs(servers) | 55 | await servers[0].follows.follow({ |
63 | }) | 56 | hosts: [ servers[2].url ], |
57 | handles: [ 'root@' + servers[1].host ] | ||
58 | }) | ||
64 | 59 | ||
65 | it('Should have 2 followings on server 1', async function () { | 60 | await waitJobs(servers) |
66 | const body = await followsCommands[0].getFollowings({ start: 0, count: 1, sort: 'createdAt' }) | 61 | }) |
67 | expect(body.total).to.equal(2) | ||
68 | 62 | ||
69 | let follows = body.data | 63 | it('Should have 2 followings on server 1', async function () { |
70 | expect(follows).to.be.an('array') | 64 | const body = await servers[0].follows.getFollowings({ start: 0, count: 1, sort: 'createdAt' }) |
71 | expect(follows.length).to.equal(1) | 65 | expect(body.total).to.equal(2) |
72 | 66 | ||
73 | const body2 = await followsCommands[0].getFollowings({ start: 1, count: 1, sort: 'createdAt' }) | 67 | let follows = body.data |
74 | follows = follows.concat(body2.data) | 68 | expect(follows).to.be.an('array') |
69 | expect(follows).to.have.lengthOf(1) | ||
75 | 70 | ||
76 | const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port) | 71 | const body2 = await servers[0].follows.getFollowings({ start: 1, count: 1, sort: 'createdAt' }) |
77 | const server3Follow = follows.find(f => f.following.host === 'localhost:' + servers[2].port) | 72 | follows = follows.concat(body2.data) |
78 | 73 | ||
79 | expect(server2Follow).to.not.be.undefined | 74 | const server2Follow = follows.find(f => f.following.host === servers[1].host) |
80 | expect(server3Follow).to.not.be.undefined | 75 | const server3Follow = follows.find(f => f.following.host === servers[2].host) |
81 | expect(server2Follow.state).to.equal('accepted') | ||
82 | expect(server3Follow.state).to.equal('accepted') | ||
83 | }) | ||
84 | 76 | ||
85 | it('Should search/filter followings on server 1', async function () { | 77 | expect(server2Follow).to.not.be.undefined |
86 | const sort = 'createdAt' | 78 | expect(server2Follow.following.name).to.equal('root') |
87 | const start = 0 | 79 | expect(server2Follow.state).to.equal('accepted') |
88 | const count = 1 | ||
89 | 80 | ||
90 | { | 81 | expect(server3Follow).to.not.be.undefined |
91 | const search = ':' + servers[1].port | 82 | expect(server3Follow.following.name).to.equal('peertube') |
83 | expect(server3Follow.state).to.equal('accepted') | ||
84 | }) | ||
92 | 85 | ||
93 | { | 86 | it('Should have 0 followings on server 2 and 3', async function () { |
94 | const body = await followsCommands[0].getFollowings({ start, count, sort, search }) | 87 | for (const server of [ servers[1], servers[2] ]) { |
95 | expect(body.total).to.equal(1) | 88 | const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' }) |
89 | expect(body.total).to.equal(0) | ||
96 | 90 | ||
97 | const follows = body.data | 91 | const follows = body.data |
98 | expect(follows.length).to.equal(1) | 92 | expect(follows).to.be.an('array') |
99 | expect(follows[0].following.host).to.equal('localhost:' + servers[1].port) | 93 | expect(follows).to.have.lengthOf(0) |
100 | } | 94 | } |
95 | }) | ||
101 | 96 | ||
102 | { | 97 | it('Should have 1 followers on server 3', async function () { |
103 | const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'accepted' }) | 98 | const body = await servers[2].follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' }) |
104 | expect(body.total).to.equal(1) | 99 | expect(body.total).to.equal(1) |
105 | expect(body.data).to.have.lengthOf(1) | 100 | |
101 | const follows = body.data | ||
102 | expect(follows).to.be.an('array') | ||
103 | expect(follows).to.have.lengthOf(1) | ||
104 | expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port) | ||
105 | }) | ||
106 | |||
107 | it('Should have 0 followers on server 1 and 2', async function () { | ||
108 | for (const server of [ servers[0], servers[1] ]) { | ||
109 | const body = await server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' }) | ||
110 | expect(body.total).to.equal(0) | ||
111 | |||
112 | const follows = body.data | ||
113 | expect(follows).to.be.an('array') | ||
114 | expect(follows).to.have.lengthOf(0) | ||
106 | } | 115 | } |
116 | }) | ||
117 | |||
118 | it('Should search/filter followings on server 1', async function () { | ||
119 | const sort = 'createdAt' | ||
120 | const start = 0 | ||
121 | const count = 1 | ||
107 | 122 | ||
108 | { | 123 | { |
109 | const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'accepted', actorType: 'Person' }) | 124 | const search = ':' + servers[1].port |
110 | expect(body.total).to.equal(0) | 125 | |
111 | expect(body.data).to.have.lengthOf(0) | 126 | { |
127 | const body = await servers[0].follows.getFollowings({ start, count, sort, search }) | ||
128 | expect(body.total).to.equal(1) | ||
129 | |||
130 | const follows = body.data | ||
131 | expect(follows).to.have.lengthOf(1) | ||
132 | expect(follows[0].following.host).to.equal(servers[1].host) | ||
133 | } | ||
134 | |||
135 | { | ||
136 | const body = await servers[0].follows.getFollowings({ start, count, sort, search, state: 'accepted' }) | ||
137 | expect(body.total).to.equal(1) | ||
138 | expect(body.data).to.have.lengthOf(1) | ||
139 | } | ||
140 | |||
141 | { | ||
142 | const body = await servers[0].follows.getFollowings({ start, count, sort, search, state: 'accepted', actorType: 'Person' }) | ||
143 | expect(body.total).to.equal(1) | ||
144 | expect(body.data).to.have.lengthOf(1) | ||
145 | } | ||
146 | |||
147 | { | ||
148 | const body = await servers[0].follows.getFollowings({ | ||
149 | start, | ||
150 | count, | ||
151 | sort, | ||
152 | search, | ||
153 | state: 'accepted', | ||
154 | actorType: 'Application' | ||
155 | }) | ||
156 | expect(body.total).to.equal(0) | ||
157 | expect(body.data).to.have.lengthOf(0) | ||
158 | } | ||
159 | |||
160 | { | ||
161 | const body = await servers[0].follows.getFollowings({ start, count, sort, search, state: 'pending' }) | ||
162 | expect(body.total).to.equal(0) | ||
163 | expect(body.data).to.have.lengthOf(0) | ||
164 | } | ||
112 | } | 165 | } |
113 | 166 | ||
114 | { | 167 | { |
115 | const body = await followsCommands[0].getFollowings({ | 168 | const body = await servers[0].follows.getFollowings({ start, count, sort, search: 'root' }) |
116 | start, | ||
117 | count, | ||
118 | sort, | ||
119 | search, | ||
120 | state: 'accepted', | ||
121 | actorType: 'Application' | ||
122 | }) | ||
123 | expect(body.total).to.equal(1) | 169 | expect(body.total).to.equal(1) |
124 | expect(body.data).to.have.lengthOf(1) | 170 | expect(body.data).to.have.lengthOf(1) |
125 | } | 171 | } |
126 | 172 | ||
127 | { | 173 | { |
128 | const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'pending' }) | 174 | const body = await servers[0].follows.getFollowings({ start, count, sort, search: 'bla' }) |
129 | expect(body.total).to.equal(0) | 175 | expect(body.total).to.equal(0) |
176 | |||
130 | expect(body.data).to.have.lengthOf(0) | 177 | expect(body.data).to.have.lengthOf(0) |
131 | } | 178 | } |
132 | } | 179 | }) |
133 | 180 | ||
134 | { | 181 | it('Should search/filter followers on server 2', async function () { |
135 | const body = await followsCommands[0].getFollowings({ start, count, sort, search: 'bla' }) | 182 | const start = 0 |
136 | expect(body.total).to.equal(0) | 183 | const count = 5 |
184 | const sort = 'createdAt' | ||
137 | 185 | ||
138 | expect(body.data.length).to.equal(0) | 186 | { |
139 | } | 187 | const search = servers[0].port + '' |
140 | }) | ||
141 | 188 | ||
142 | it('Should have 0 followings on server 2 and 3', async function () { | 189 | { |
143 | for (const server of [ servers[1], servers[2] ]) { | 190 | const body = await servers[2].follows.getFollowers({ start, count, sort, search }) |
144 | const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' }) | 191 | expect(body.total).to.equal(1) |
145 | expect(body.total).to.equal(0) | ||
146 | 192 | ||
147 | const follows = body.data | 193 | const follows = body.data |
148 | expect(follows).to.be.an('array') | 194 | expect(follows).to.have.lengthOf(1) |
149 | expect(follows.length).to.equal(0) | 195 | expect(follows[0].following.host).to.equal(servers[2].host) |
150 | } | 196 | } |
151 | }) | ||
152 | 197 | ||
153 | it('Should have 1 followers on server 2 and 3', async function () { | 198 | { |
154 | for (const server of [ servers[1], servers[2] ]) { | 199 | const body = await servers[2].follows.getFollowers({ start, count, sort, search, state: 'accepted' }) |
155 | const body = await server.follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' }) | 200 | expect(body.total).to.equal(1) |
156 | expect(body.total).to.equal(1) | 201 | expect(body.data).to.have.lengthOf(1) |
202 | } | ||
157 | 203 | ||
158 | const follows = body.data | 204 | { |
159 | expect(follows).to.be.an('array') | 205 | const body = await servers[2].follows.getFollowers({ start, count, sort, search, state: 'accepted', actorType: 'Person' }) |
160 | expect(follows.length).to.equal(1) | 206 | expect(body.total).to.equal(0) |
161 | expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port) | 207 | expect(body.data).to.have.lengthOf(0) |
162 | } | 208 | } |
163 | }) | ||
164 | 209 | ||
165 | it('Should search/filter followers on server 2', async function () { | 210 | { |
166 | const start = 0 | 211 | const body = await servers[2].follows.getFollowers({ |
167 | const count = 5 | 212 | start, |
168 | const sort = 'createdAt' | 213 | count, |
214 | sort, | ||
215 | search, | ||
216 | state: 'accepted', | ||
217 | actorType: 'Application' | ||
218 | }) | ||
219 | expect(body.total).to.equal(1) | ||
220 | expect(body.data).to.have.lengthOf(1) | ||
221 | } | ||
169 | 222 | ||
170 | { | 223 | { |
171 | const search = servers[0].port + '' | 224 | const body = await servers[2].follows.getFollowers({ start, count, sort, search, state: 'pending' }) |
225 | expect(body.total).to.equal(0) | ||
226 | expect(body.data).to.have.lengthOf(0) | ||
227 | } | ||
228 | } | ||
172 | 229 | ||
173 | { | 230 | { |
174 | const body = await followsCommands[2].getFollowers({ start, count, sort, search }) | 231 | const body = await servers[2].follows.getFollowers({ start, count, sort, search: 'bla' }) |
175 | expect(body.total).to.equal(1) | 232 | expect(body.total).to.equal(0) |
176 | 233 | ||
177 | const follows = body.data | 234 | const follows = body.data |
178 | expect(follows.length).to.equal(1) | 235 | expect(follows).to.have.lengthOf(0) |
179 | expect(follows[0].following.host).to.equal('localhost:' + servers[2].port) | ||
180 | } | 236 | } |
237 | }) | ||
181 | 238 | ||
182 | { | 239 | it('Should have the correct follows counts', async function () { |
183 | const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'accepted' }) | 240 | await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 }) |
184 | expect(body.total).to.equal(1) | 241 | await expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 }) |
185 | expect(body.data).to.have.lengthOf(1) | 242 | await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }) |
186 | } | ||
187 | 243 | ||
188 | { | 244 | // Server 2 and 3 does not know server 1 follow another server (there was not a refresh) |
189 | const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'accepted', actorType: 'Person' }) | 245 | await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }) |
190 | expect(body.total).to.equal(0) | 246 | await expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 }) |
191 | expect(body.data).to.have.lengthOf(0) | 247 | await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }) |
192 | } | ||
193 | 248 | ||
194 | { | 249 | await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }) |
195 | const body = await followsCommands[2].getFollowers({ | 250 | await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }) |
196 | start, | 251 | }) |
197 | count, | ||
198 | sort, | ||
199 | search, | ||
200 | state: 'accepted', | ||
201 | actorType: 'Application' | ||
202 | }) | ||
203 | expect(body.total).to.equal(1) | ||
204 | expect(body.data).to.have.lengthOf(1) | ||
205 | } | ||
206 | 252 | ||
207 | { | 253 | it('Should unfollow server 3 on server 1', async function () { |
208 | const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'pending' }) | 254 | this.timeout(15000) |
209 | expect(body.total).to.equal(0) | ||
210 | expect(body.data).to.have.lengthOf(0) | ||
211 | } | ||
212 | } | ||
213 | 255 | ||
214 | { | 256 | await servers[0].follows.unfollow({ target: servers[2] }) |
215 | const body = await followsCommands[2].getFollowers({ start, count, sort, search: 'bla' }) | 257 | |
216 | expect(body.total).to.equal(0) | 258 | await waitJobs(servers) |
259 | }) | ||
260 | |||
261 | it('Should not follow server 3 on server 1 anymore', async function () { | ||
262 | const body = await servers[0].follows.getFollowings({ start: 0, count: 2, sort: 'createdAt' }) | ||
263 | expect(body.total).to.equal(1) | ||
217 | 264 | ||
218 | const follows = body.data | 265 | const follows = body.data |
219 | expect(follows.length).to.equal(0) | 266 | expect(follows).to.be.an('array') |
220 | } | 267 | expect(follows).to.have.lengthOf(1) |
221 | }) | ||
222 | 268 | ||
223 | it('Should have 0 followers on server 1', async function () { | 269 | expect(follows[0].following.host).to.equal(servers[1].host) |
224 | const body = await followsCommands[0].getFollowers({ start: 0, count: 5, sort: 'createdAt' }) | 270 | }) |
225 | expect(body.total).to.equal(0) | ||
226 | 271 | ||
227 | const follows = body.data | 272 | it('Should not have server 1 as follower on server 3 anymore', async function () { |
228 | expect(follows).to.be.an('array') | 273 | const body = await servers[2].follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' }) |
229 | expect(follows.length).to.equal(0) | 274 | expect(body.total).to.equal(0) |
230 | }) | ||
231 | 275 | ||
232 | it('Should have the correct follows counts', async function () { | 276 | const follows = body.data |
233 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 2 }) | 277 | expect(follows).to.be.an('array') |
234 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 }) | 278 | expect(follows).to.have.lengthOf(0) |
235 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 }) | 279 | }) |
236 | 280 | ||
237 | // Server 2 and 3 does not know server 1 follow another server (there was not a refresh) | 281 | it('Should have the correct follows counts after the unfollow', async function () { |
238 | await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 }) | 282 | await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }) |
239 | await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 }) | 283 | await expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 }) |
284 | await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 0, following: 0 }) | ||
240 | 285 | ||
241 | await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 }) | 286 | await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }) |
242 | await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 }) | 287 | await expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 }) |
243 | }) | 288 | await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }) |
244 | 289 | ||
245 | it('Should unfollow server 3 on server 1', async function () { | 290 | await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 0 }) |
246 | this.timeout(5000) | 291 | await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 0, following: 0 }) |
292 | }) | ||
247 | 293 | ||
248 | await followsCommands[0].unfollow({ target: servers[2] }) | 294 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { |
295 | this.timeout(60000) | ||
249 | 296 | ||
250 | await waitJobs(servers) | 297 | await servers[1].videos.upload({ attributes: { name: 'server2' } }) |
251 | }) | 298 | await servers[2].videos.upload({ attributes: { name: 'server3' } }) |
252 | 299 | ||
253 | it('Should not follow server 3 on server 1 anymore', async function () { | 300 | await waitJobs(servers) |
254 | const body = await followsCommands[0].getFollowings({ start: 0, count: 2, sort: 'createdAt' }) | ||
255 | expect(body.total).to.equal(1) | ||
256 | 301 | ||
257 | const follows = body.data | 302 | { |
258 | expect(follows).to.be.an('array') | 303 | const { total, data } = await servers[0].videos.list() |
259 | expect(follows.length).to.equal(1) | 304 | expect(total).to.equal(1) |
305 | expect(data[0].name).to.equal('server2') | ||
306 | } | ||
260 | 307 | ||
261 | expect(follows[0].following.host).to.equal('localhost:' + servers[1].port) | 308 | { |
262 | }) | 309 | const { total, data } = await servers[1].videos.list() |
310 | expect(total).to.equal(1) | ||
311 | expect(data[0].name).to.equal('server2') | ||
312 | } | ||
263 | 313 | ||
264 | it('Should not have server 1 as follower on server 3 anymore', async function () { | 314 | { |
265 | const body = await followsCommands[2].getFollowers({ start: 0, count: 1, sort: 'createdAt' }) | 315 | const { total, data } = await servers[2].videos.list() |
266 | expect(body.total).to.equal(0) | 316 | expect(total).to.equal(1) |
317 | expect(data[0].name).to.equal('server3') | ||
318 | } | ||
319 | }) | ||
267 | 320 | ||
268 | const follows = body.data | 321 | it('Should remove account follow', async function () { |
269 | expect(follows).to.be.an('array') | 322 | this.timeout(15000) |
270 | expect(follows.length).to.equal(0) | ||
271 | }) | ||
272 | 323 | ||
273 | it('Should have the correct follows counts 2', async function () { | 324 | await servers[0].follows.unfollow({ target: 'root@' + servers[1].host }) |
274 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 }) | ||
275 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 }) | ||
276 | 325 | ||
277 | await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 }) | 326 | await waitJobs(servers) |
278 | await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 }) | 327 | }) |
279 | 328 | ||
280 | await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 0 }) | 329 | it('Should have removed the account follow', async function () { |
281 | await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 0, following: 0 }) | 330 | await expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 0, following: 0 }) |
282 | }) | 331 | await expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 0, following: 0 }) |
283 | 332 | ||
284 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { | 333 | { |
285 | this.timeout(60000) | 334 | const { total, data } = await servers[0].follows.getFollowings() |
335 | expect(total).to.equal(0) | ||
336 | expect(data).to.have.lengthOf(0) | ||
337 | } | ||
286 | 338 | ||
287 | await servers[1].videos.upload({ attributes: { name: 'server2' } }) | 339 | { |
288 | await servers[2].videos.upload({ attributes: { name: 'server3' } }) | 340 | const { total, data } = await servers[0].videos.list() |
341 | expect(total).to.equal(0) | ||
342 | expect(data).to.have.lengthOf(0) | ||
343 | } | ||
344 | }) | ||
289 | 345 | ||
290 | await waitJobs(servers) | 346 | it('Should follow a channel', async function () { |
347 | this.timeout(15000) | ||
291 | 348 | ||
292 | { | 349 | await servers[0].follows.follow({ |
293 | const { total, data } = await servers[0].videos.list() | 350 | handles: [ 'root_channel@' + servers[1].host ] |
294 | expect(total).to.equal(1) | 351 | }) |
295 | expect(data[0].name).to.equal('server2') | ||
296 | } | ||
297 | 352 | ||
298 | { | 353 | await waitJobs(servers) |
299 | const { total, data } = await servers[1].videos.list() | ||
300 | expect(total).to.equal(1) | ||
301 | expect(data[0].name).to.equal('server2') | ||
302 | } | ||
303 | 354 | ||
304 | { | 355 | await expectChannelsFollows({ server: servers[0], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }) |
305 | const { total, data } = await servers[2].videos.list() | 356 | await expectChannelsFollows({ server: servers[1], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }) |
306 | expect(total).to.equal(1) | 357 | |
307 | expect(data[0].name).to.equal('server3') | 358 | { |
308 | } | 359 | const { total, data } = await servers[0].follows.getFollowings() |
360 | expect(total).to.equal(1) | ||
361 | expect(data).to.have.lengthOf(1) | ||
362 | } | ||
363 | |||
364 | { | ||
365 | const { total, data } = await servers[0].videos.list() | ||
366 | expect(total).to.equal(1) | ||
367 | expect(data).to.have.lengthOf(1) | ||
368 | } | ||
369 | }) | ||
309 | }) | 370 | }) |
310 | 371 | ||
311 | describe('Should propagate data on a new following', function () { | 372 | describe('Should propagate data on a new server follow', function () { |
312 | let video4: Video | 373 | let video4: VideoCreateResult |
313 | 374 | ||
314 | before(async function () { | 375 | before(async function () { |
315 | this.timeout(50000) | 376 | this.timeout(50000) |
@@ -324,83 +385,64 @@ describe('Test follows', function () { | |||
324 | 385 | ||
325 | await servers[2].videos.upload({ attributes: { name: 'server3-2' } }) | 386 | await servers[2].videos.upload({ attributes: { name: 'server3-2' } }) |
326 | await servers[2].videos.upload({ attributes: { name: 'server3-3' } }) | 387 | await servers[2].videos.upload({ attributes: { name: 'server3-3' } }) |
327 | await servers[2].videos.upload({ attributes: video4Attributes }) | 388 | video4 = await servers[2].videos.upload({ attributes: video4Attributes }) |
328 | await servers[2].videos.upload({ attributes: { name: 'server3-5' } }) | 389 | await servers[2].videos.upload({ attributes: { name: 'server3-5' } }) |
329 | await servers[2].videos.upload({ attributes: { name: 'server3-6' } }) | 390 | await servers[2].videos.upload({ attributes: { name: 'server3-6' } }) |
330 | 391 | ||
331 | { | 392 | { |
332 | const userAccessToken = await servers[2].users.generateUserAndToken('captain') | 393 | const userAccessToken = await servers[2].users.generateUserAndToken('captain') |
333 | 394 | ||
334 | const { data } = await servers[2].videos.list() | 395 | await servers[2].videos.rate({ id: video4.id, rating: 'like' }) |
335 | video4 = data.find(v => v.name === 'server3-4') | 396 | await servers[2].videos.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' }) |
336 | 397 | } | |
337 | { | ||
338 | await servers[2].videos.rate({ id: video4.id, rating: 'like' }) | ||
339 | await servers[2].videos.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' }) | ||
340 | } | ||
341 | |||
342 | { | ||
343 | { | ||
344 | const text = 'my super first comment' | ||
345 | const created = await servers[2].comments.createThread({ videoId: video4.id, text }) | ||
346 | const threadId = created.id | ||
347 | |||
348 | const text1 = 'my super answer to thread 1' | ||
349 | const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 }) | ||
350 | |||
351 | const text2 = 'my super answer to answer of thread 1' | ||
352 | await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 }) | ||
353 | |||
354 | const text3 = 'my second answer to thread 1' | ||
355 | await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 }) | ||
356 | } | ||
357 | 398 | ||
358 | { | 399 | { |
359 | const text = 'will be deleted' | 400 | await servers[2].comments.createThread({ videoId: video4.id, text: 'my super first comment' }) |
360 | const created = await servers[2].comments.createThread({ videoId: video4.id, text }) | ||
361 | const threadId = created.id | ||
362 | 401 | ||
363 | const text1 = 'answer to deleted' | 402 | await servers[2].comments.addReplyToLastThread({ text: 'my super answer to thread 1' }) |
364 | await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 }) | 403 | await servers[2].comments.addReplyToLastReply({ text: 'my super answer to answer of thread 1' }) |
404 | await servers[2].comments.addReplyToLastThread({ text: 'my second answer to thread 1' }) | ||
405 | } | ||
365 | 406 | ||
366 | const text2 = 'will also be deleted' | 407 | { |
367 | const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 }) | 408 | const { id: threadId } = await servers[2].comments.createThread({ videoId: video4.id, text: 'will be deleted' }) |
409 | await servers[2].comments.addReplyToLastThread({ text: 'answer to deleted' }) | ||
368 | 410 | ||
369 | const text3 = 'my second answer to deleted' | 411 | const { id: replyId } = await servers[2].comments.addReplyToLastThread({ text: 'will also be deleted' }) |
370 | await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 }) | ||
371 | 412 | ||
372 | await servers[2].comments.delete({ videoId: video4.id, commentId: threadId }) | 413 | await servers[2].comments.addReplyToLastReply({ text: 'my second answer to deleted' }) |
373 | await servers[2].comments.delete({ videoId: video4.id, commentId: childComment.id }) | ||
374 | } | ||
375 | } | ||
376 | 414 | ||
377 | { | 415 | await servers[2].comments.delete({ videoId: video4.id, commentId: threadId }) |
378 | await servers[2].captions.createVideoCaption({ | 416 | await servers[2].comments.delete({ videoId: video4.id, commentId: replyId }) |
379 | language: 'ar', | ||
380 | videoId: video4.id, | ||
381 | fixture: 'subtitle-good2.vtt' | ||
382 | }) | ||
383 | } | ||
384 | } | 417 | } |
385 | 418 | ||
419 | await servers[2].captions.createVideoCaption({ | ||
420 | language: 'ar', | ||
421 | videoId: video4.id, | ||
422 | fixture: 'subtitle-good2.vtt' | ||
423 | }) | ||
424 | |||
386 | await waitJobs(servers) | 425 | await waitJobs(servers) |
387 | 426 | ||
388 | // Server 1 follows server 3 | 427 | // Server 1 follows server 3 |
389 | await followsCommands[0].follow({ targets: [ servers[2].url ] }) | 428 | await servers[0].follows.follow({ hosts: [ servers[2].url ] }) |
390 | 429 | ||
391 | await waitJobs(servers) | 430 | await waitJobs(servers) |
392 | }) | 431 | }) |
393 | 432 | ||
394 | it('Should have the correct follows counts 3', async function () { | 433 | it('Should have the correct follows counts', async function () { |
395 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 2 }) | 434 | await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 }) |
396 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 }) | 435 | await expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 0, following: 0 }) |
397 | await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 }) | 436 | await expectChannelsFollows({ server: servers[0], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }) |
437 | await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }) | ||
398 | 438 | ||
399 | await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 }) | 439 | await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }) |
400 | await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 }) | 440 | await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }) |
441 | await expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 0, following: 0 }) | ||
442 | await expectChannelsFollows({ server: servers[1], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }) | ||
401 | 443 | ||
402 | await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 }) | 444 | await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }) |
403 | await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 }) | 445 | await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }) |
404 | }) | 446 | }) |
405 | 447 | ||
406 | it('Should have propagated videos', async function () { | 448 | it('Should have propagated videos', async function () { |
@@ -426,7 +468,7 @@ describe('Test follows', function () { | |||
426 | support: 'my super support text', | 468 | support: 'my super support text', |
427 | account: { | 469 | account: { |
428 | name: 'root', | 470 | name: 'root', |
429 | host: 'localhost:' + servers[2].port | 471 | host: servers[2].host |
430 | }, | 472 | }, |
431 | isLocal, | 473 | isLocal, |
432 | commentsEnabled: true, | 474 | commentsEnabled: true, |
@@ -467,7 +509,7 @@ describe('Test follows', function () { | |||
467 | expect(comment.videoId).to.equal(video4.id) | 509 | expect(comment.videoId).to.equal(video4.id) |
468 | expect(comment.id).to.equal(comment.threadId) | 510 | expect(comment.id).to.equal(comment.threadId) |
469 | expect(comment.account.name).to.equal('root') | 511 | expect(comment.account.name).to.equal('root') |
470 | expect(comment.account.host).to.equal('localhost:' + servers[2].port) | 512 | expect(comment.account.host).to.equal(servers[2].host) |
471 | expect(comment.totalReplies).to.equal(3) | 513 | expect(comment.totalReplies).to.equal(3) |
472 | expect(dateIsValid(comment.createdAt as string)).to.be.true | 514 | expect(dateIsValid(comment.createdAt as string)).to.be.true |
473 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | 515 | expect(dateIsValid(comment.updatedAt as string)).to.be.true |
@@ -541,14 +583,39 @@ describe('Test follows', function () { | |||
541 | it('Should unfollow server 3 on server 1 and does not list server 3 videos', async function () { | 583 | it('Should unfollow server 3 on server 1 and does not list server 3 videos', async function () { |
542 | this.timeout(5000) | 584 | this.timeout(5000) |
543 | 585 | ||
544 | await followsCommands[0].unfollow({ target: servers[2] }) | 586 | await servers[0].follows.unfollow({ target: servers[2] }) |
545 | 587 | ||
546 | await waitJobs(servers) | 588 | await waitJobs(servers) |
547 | 589 | ||
548 | const { total } = await servers[0].videos.list() | 590 | const { total } = await servers[0].videos.list() |
549 | expect(total).to.equal(1) | 591 | expect(total).to.equal(1) |
550 | }) | 592 | }) |
593 | }) | ||
594 | |||
595 | describe('Should propagate data on a new channel follow', function () { | ||
596 | |||
597 | before(async function () { | ||
598 | this.timeout(60000) | ||
551 | 599 | ||
600 | await servers[2].videos.upload({ attributes: { name: 'server3-7' } }) | ||
601 | |||
602 | await waitJobs(servers) | ||
603 | |||
604 | const video = await servers[0].videos.find({ name: 'server3-7' }) | ||
605 | expect(video).to.not.exist | ||
606 | }) | ||
607 | |||
608 | it('Should have propagated channel video', async function () { | ||
609 | this.timeout(60000) | ||
610 | |||
611 | await servers[0].follows.follow({ handles: [ 'root_channel@' + servers[2].host ] }) | ||
612 | |||
613 | await waitJobs(servers) | ||
614 | |||
615 | const video = await servers[0].videos.find({ name: 'server3-7' }) | ||
616 | |||
617 | expect(video).to.exist | ||
618 | }) | ||
552 | }) | 619 | }) |
553 | 620 | ||
554 | after(async function () { | 621 | after(async function () { |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 1f751c957..2f3950354 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -97,8 +97,8 @@ describe('Test handle downs', function () { | |||
97 | this.timeout(240000) | 97 | this.timeout(240000) |
98 | 98 | ||
99 | // Server 2 and 3 follow server 1 | 99 | // Server 2 and 3 follow server 1 |
100 | await servers[1].follows.follow({ targets: [ servers[0].url ] }) | 100 | await servers[1].follows.follow({ hosts: [ servers[0].url ] }) |
101 | await servers[2].follows.follow({ targets: [ servers[0].url ] }) | 101 | await servers[2].follows.follow({ hosts: [ servers[0].url ] }) |
102 | 102 | ||
103 | await waitJobs(servers) | 103 | await waitJobs(servers) |
104 | 104 | ||
@@ -180,7 +180,7 @@ describe('Test handle downs', function () { | |||
180 | await servers[1].follows.unfollow({ target: servers[0] }) | 180 | await servers[1].follows.unfollow({ target: servers[0] }) |
181 | await waitJobs(servers) | 181 | await waitJobs(servers) |
182 | 182 | ||
183 | await servers[1].follows.follow({ targets: [ servers[0].url ] }) | 183 | await servers[1].follows.follow({ hosts: [ servers[0].url ] }) |
184 | 184 | ||
185 | await waitJobs(servers) | 185 | await waitJobs(servers) |
186 | 186 | ||
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index 942602b70..5ec771429 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts | |||
@@ -43,7 +43,7 @@ describe('Test stats (excluding redundancy)', function () { | |||
43 | // Wait the video views repeatable job | 43 | // Wait the video views repeatable job |
44 | await wait(8000) | 44 | await wait(8000) |
45 | 45 | ||
46 | await servers[2].follows.follow({ targets: [ servers[0].url ] }) | 46 | await servers[2].follows.follow({ hosts: [ servers[0].url ] }) |
47 | await waitJobs(servers) | 47 | await waitJobs(servers) |
48 | }) | 48 | }) |
49 | 49 | ||
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 () { | |||
224 | it('Should have server 1 follow server 3 and display server 3 videos', async function () { | 224 | it('Should have server 1 follow server 3 and display server 3 videos', async function () { |
225 | this.timeout(60000) | 225 | this.timeout(60000) |
226 | 226 | ||
227 | await servers[0].follows.follow({ targets: [ servers[2].url ] }) | 227 | await servers[0].follows.follow({ hosts: [ servers[2].url ] }) |
228 | 228 | ||
229 | await waitJobs(servers) | 229 | await waitJobs(servers) |
230 | 230 | ||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 066da88ee..1419ae820 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -103,7 +103,7 @@ describe('Test users', function () { | |||
103 | token = 'my_super_token' | 103 | token = 'my_super_token' |
104 | 104 | ||
105 | await server.follows.follow({ | 105 | await server.follows.follow({ |
106 | targets: [ 'http://example.com' ], | 106 | hosts: [ 'http://example.com' ], |
107 | token, | 107 | token, |
108 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 | 108 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
109 | }) | 109 | }) |