diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-11 13:30:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-11 13:30:51 +0200 |
commit | cea2fd90ddb3bf57c2fed77128938d12d4c2be6b (patch) | |
tree | 667da2c84456849cd4dacf990bc4b02ed14d5861 /server/tests/api/users | |
parent | 9d4c60dccc8e7e777ad139a82e9f61feda9d21fc (diff) | |
parent | a6b26afc561703cc343f8962906734324b8c2d0c (diff) | |
download | PeerTube-cea2fd90ddb3bf57c2fed77128938d12d4c2be6b.tar.gz PeerTube-cea2fd90ddb3bf57c2fed77128938d12d4c2be6b.tar.zst PeerTube-cea2fd90ddb3bf57c2fed77128938d12d4c2be6b.zip |
Merge branch 'release/4.3.0' into develop
Diffstat (limited to 'server/tests/api/users')
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 857 |
1 files changed, 440 insertions, 417 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 894a49f98..fbeca7d67 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -53,310 +53,292 @@ describe('Test users subscriptions', function () { | |||
53 | command = servers[0].subscriptions | 53 | command = servers[0].subscriptions |
54 | }) | 54 | }) |
55 | 55 | ||
56 | it('Should display videos of server 2 on server 1', async function () { | 56 | describe('Destinction between server videos and user videos', function () { |
57 | const { total } = await servers[0].videos.list() | 57 | it('Should display videos of server 2 on server 1', async function () { |
58 | const { total } = await servers[0].videos.list() | ||
58 | 59 | ||
59 | expect(total).to.equal(4) | 60 | expect(total).to.equal(4) |
60 | }) | 61 | }) |
61 | 62 | ||
62 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { | 63 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { |
63 | this.timeout(60000) | 64 | this.timeout(60000) |
64 | 65 | ||
65 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) | 66 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) |
66 | await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) | 67 | await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) |
67 | 68 | ||
68 | await waitJobs(servers) | 69 | await waitJobs(servers) |
69 | 70 | ||
70 | const attributes = { name: 'video server 3 added after follow' } | 71 | const attributes = { name: 'video server 3 added after follow' } |
71 | const { uuid } = await servers[2].videos.upload({ token: users[2].accessToken, attributes }) | 72 | const { uuid } = await servers[2].videos.upload({ token: users[2].accessToken, attributes }) |
72 | video3UUID = uuid | 73 | video3UUID = uuid |
73 | 74 | ||
74 | await waitJobs(servers) | 75 | await waitJobs(servers) |
75 | }) | 76 | }) |
76 | 77 | ||
77 | it('Should not display videos of server 3 on server 1', async function () { | 78 | it('Should not display videos of server 3 on server 1', async function () { |
78 | const { total, data } = await servers[0].videos.list() | 79 | const { total, data } = await servers[0].videos.list() |
79 | expect(total).to.equal(4) | 80 | expect(total).to.equal(4) |
80 | 81 | ||
81 | for (const video of data) { | 82 | for (const video of data) { |
82 | expect(video.name).to.not.contain('1-3') | 83 | expect(video.name).to.not.contain('1-3') |
83 | expect(video.name).to.not.contain('2-3') | 84 | expect(video.name).to.not.contain('2-3') |
84 | expect(video.name).to.not.contain('video server 3 added after follow') | 85 | expect(video.name).to.not.contain('video server 3 added after follow') |
85 | } | 86 | } |
87 | }) | ||
86 | }) | 88 | }) |
87 | 89 | ||
88 | it('Should list subscriptions', async function () { | 90 | describe('Subscription endpoints', function () { |
89 | { | ||
90 | const body = await command.list() | ||
91 | expect(body.total).to.equal(0) | ||
92 | expect(body.data).to.be.an('array') | ||
93 | expect(body.data).to.have.lengthOf(0) | ||
94 | } | ||
95 | 91 | ||
96 | { | 92 | it('Should list subscriptions', async function () { |
97 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) | 93 | { |
98 | expect(body.total).to.equal(2) | 94 | const body = await command.list() |
95 | expect(body.total).to.equal(0) | ||
96 | expect(body.data).to.be.an('array') | ||
97 | expect(body.data).to.have.lengthOf(0) | ||
98 | } | ||
99 | 99 | ||
100 | const subscriptions = body.data | 100 | { |
101 | expect(subscriptions).to.be.an('array') | 101 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) |
102 | expect(subscriptions).to.have.lengthOf(2) | 102 | expect(body.total).to.equal(2) |
103 | 103 | ||
104 | expect(subscriptions[0].name).to.equal('user3_channel') | 104 | const subscriptions = body.data |
105 | expect(subscriptions[1].name).to.equal('root_channel') | 105 | expect(subscriptions).to.be.an('array') |
106 | } | 106 | expect(subscriptions).to.have.lengthOf(2) |
107 | }) | ||
108 | |||
109 | it('Should get subscription', async function () { | ||
110 | { | ||
111 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) | ||
112 | 107 | ||
113 | expect(videoChannel.name).to.equal('user3_channel') | 108 | expect(subscriptions[0].name).to.equal('user3_channel') |
114 | expect(videoChannel.host).to.equal('localhost:' + servers[2].port) | 109 | expect(subscriptions[1].name).to.equal('root_channel') |
115 | expect(videoChannel.displayName).to.equal('Main user3 channel') | 110 | } |
116 | expect(videoChannel.followingCount).to.equal(0) | 111 | }) |
117 | expect(videoChannel.followersCount).to.equal(1) | ||
118 | } | ||
119 | 112 | ||
120 | { | 113 | it('Should get subscription', async function () { |
121 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) | 114 | { |
115 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) | ||
122 | 116 | ||
123 | expect(videoChannel.name).to.equal('root_channel') | 117 | expect(videoChannel.name).to.equal('user3_channel') |
124 | expect(videoChannel.host).to.equal('localhost:' + servers[0].port) | 118 | expect(videoChannel.host).to.equal('localhost:' + servers[2].port) |
125 | expect(videoChannel.displayName).to.equal('Main root channel') | 119 | expect(videoChannel.displayName).to.equal('Main user3 channel') |
126 | expect(videoChannel.followingCount).to.equal(0) | 120 | expect(videoChannel.followingCount).to.equal(0) |
127 | expect(videoChannel.followersCount).to.equal(1) | 121 | expect(videoChannel.followersCount).to.equal(1) |
128 | } | 122 | } |
129 | }) | ||
130 | 123 | ||
131 | it('Should return the existing subscriptions', async function () { | 124 | { |
132 | const uris = [ | 125 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) |
133 | 'user3_channel@localhost:' + servers[2].port, | ||
134 | 'root2_channel@localhost:' + servers[0].port, | ||
135 | 'root_channel@localhost:' + servers[0].port, | ||
136 | 'user3_channel@localhost:' + servers[0].port | ||
137 | ] | ||
138 | 126 | ||
139 | const body = await command.exist({ token: users[0].accessToken, uris }) | 127 | expect(videoChannel.name).to.equal('root_channel') |
128 | expect(videoChannel.host).to.equal('localhost:' + servers[0].port) | ||
129 | expect(videoChannel.displayName).to.equal('Main root channel') | ||
130 | expect(videoChannel.followingCount).to.equal(0) | ||
131 | expect(videoChannel.followersCount).to.equal(1) | ||
132 | } | ||
133 | }) | ||
134 | |||
135 | it('Should return the existing subscriptions', async function () { | ||
136 | const uris = [ | ||
137 | 'user3_channel@localhost:' + servers[2].port, | ||
138 | 'root2_channel@localhost:' + servers[0].port, | ||
139 | 'root_channel@localhost:' + servers[0].port, | ||
140 | 'user3_channel@localhost:' + servers[0].port | ||
141 | ] | ||
142 | |||
143 | const body = await command.exist({ token: users[0].accessToken, uris }) | ||
144 | |||
145 | expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true | ||
146 | expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false | ||
147 | expect(body['root_channel@localhost:' + servers[0].port]).to.be.true | ||
148 | expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false | ||
149 | }) | ||
150 | |||
151 | it('Should search among subscriptions', async function () { | ||
152 | { | ||
153 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' }) | ||
154 | expect(body.total).to.equal(1) | ||
155 | expect(body.data).to.have.lengthOf(1) | ||
156 | } | ||
140 | 157 | ||
141 | expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true | 158 | { |
142 | expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false | 159 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' }) |
143 | expect(body['root_channel@localhost:' + servers[0].port]).to.be.true | 160 | expect(body.total).to.equal(0) |
144 | expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false | 161 | expect(body.data).to.have.lengthOf(0) |
162 | } | ||
163 | }) | ||
145 | }) | 164 | }) |
146 | 165 | ||
147 | it('Should search among subscriptions', async function () { | 166 | describe('Subscription videos', function () { |
148 | { | ||
149 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' }) | ||
150 | expect(body.total).to.equal(1) | ||
151 | expect(body.data).to.have.lengthOf(1) | ||
152 | } | ||
153 | 167 | ||
154 | { | 168 | it('Should list subscription videos', async function () { |
155 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' }) | 169 | { |
156 | expect(body.total).to.equal(0) | 170 | const body = await command.listVideos() |
157 | expect(body.data).to.have.lengthOf(0) | 171 | expect(body.total).to.equal(0) |
158 | } | 172 | expect(body.data).to.be.an('array') |
159 | }) | 173 | expect(body.data).to.have.lengthOf(0) |
160 | 174 | } | |
161 | it('Should list subscription videos', async function () { | ||
162 | { | ||
163 | const body = await command.listVideos() | ||
164 | expect(body.total).to.equal(0) | ||
165 | expect(body.data).to.be.an('array') | ||
166 | expect(body.data).to.have.lengthOf(0) | ||
167 | } | ||
168 | 175 | ||
169 | { | 176 | { |
170 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | 177 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
171 | expect(body.total).to.equal(3) | 178 | expect(body.total).to.equal(3) |
172 | 179 | ||
173 | const videos = body.data | 180 | const videos = body.data |
174 | expect(videos).to.be.an('array') | 181 | expect(videos).to.be.an('array') |
175 | expect(videos).to.have.lengthOf(3) | 182 | expect(videos).to.have.lengthOf(3) |
176 | 183 | ||
177 | expect(videos[0].name).to.equal('video 1-3') | 184 | expect(videos[0].name).to.equal('video 1-3') |
178 | expect(videos[1].name).to.equal('video 2-3') | 185 | expect(videos[1].name).to.equal('video 2-3') |
179 | expect(videos[2].name).to.equal('video server 3 added after follow') | 186 | expect(videos[2].name).to.equal('video server 3 added after follow') |
180 | } | 187 | } |
181 | }) | 188 | }) |
182 | 189 | ||
183 | it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { | 190 | it('Should upload a video by root on server 1 and see it in the subscription videos', async function () { |
184 | this.timeout(60000) | 191 | this.timeout(60000) |
185 | 192 | ||
186 | const videoName = 'video server 1 added after follow' | 193 | const videoName = 'video server 1 added after follow' |
187 | await servers[0].videos.upload({ attributes: { name: videoName } }) | 194 | await servers[0].videos.upload({ attributes: { name: videoName } }) |
188 | 195 | ||
189 | await waitJobs(servers) | 196 | await waitJobs(servers) |
190 | 197 | ||
191 | { | 198 | { |
192 | const body = await command.listVideos() | 199 | const body = await command.listVideos() |
193 | expect(body.total).to.equal(0) | 200 | expect(body.total).to.equal(0) |
194 | expect(body.data).to.be.an('array') | 201 | expect(body.data).to.be.an('array') |
195 | expect(body.data).to.have.lengthOf(0) | 202 | expect(body.data).to.have.lengthOf(0) |
196 | } | 203 | } |
197 | 204 | ||
198 | { | 205 | { |
199 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | 206 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
200 | expect(body.total).to.equal(4) | 207 | expect(body.total).to.equal(4) |
201 | 208 | ||
202 | const videos = body.data | 209 | const videos = body.data |
203 | expect(videos).to.be.an('array') | 210 | expect(videos).to.be.an('array') |
204 | expect(videos).to.have.lengthOf(4) | 211 | expect(videos).to.have.lengthOf(4) |
205 | 212 | ||
206 | expect(videos[0].name).to.equal('video 1-3') | 213 | expect(videos[0].name).to.equal('video 1-3') |
207 | expect(videos[1].name).to.equal('video 2-3') | 214 | expect(videos[1].name).to.equal('video 2-3') |
208 | expect(videos[2].name).to.equal('video server 3 added after follow') | 215 | expect(videos[2].name).to.equal('video server 3 added after follow') |
209 | expect(videos[3].name).to.equal('video server 1 added after follow') | 216 | expect(videos[3].name).to.equal('video server 1 added after follow') |
210 | } | 217 | } |
211 | 218 | ||
212 | { | 219 | { |
213 | const { data, total } = await servers[0].videos.list() | 220 | const { data, total } = await servers[0].videos.list() |
214 | expect(total).to.equal(5) | 221 | expect(total).to.equal(5) |
215 | 222 | ||
216 | for (const video of data) { | 223 | for (const video of data) { |
217 | expect(video.name).to.not.contain('1-3') | 224 | expect(video.name).to.not.contain('1-3') |
218 | expect(video.name).to.not.contain('2-3') | 225 | expect(video.name).to.not.contain('2-3') |
219 | expect(video.name).to.not.contain('video server 3 added after follow') | 226 | expect(video.name).to.not.contain('video server 3 added after follow') |
227 | } | ||
220 | } | 228 | } |
221 | } | 229 | }) |
222 | }) | ||
223 | 230 | ||
224 | it('Should have server 1 follow server 3 and display server 3 videos', async function () { | 231 | it('Should have server 1 following server 3 and display server 3 videos', async function () { |
225 | this.timeout(60000) | 232 | this.timeout(60000) |
226 | 233 | ||
227 | await servers[0].follows.follow({ hosts: [ servers[2].url ] }) | 234 | await servers[0].follows.follow({ hosts: [ servers[2].url ] }) |
228 | 235 | ||
229 | await waitJobs(servers) | 236 | await waitJobs(servers) |
230 | |||
231 | const { data, total } = await servers[0].videos.list() | ||
232 | expect(total).to.equal(8) | ||
233 | 237 | ||
234 | const names = [ '1-3', '2-3', 'video server 3 added after follow' ] | 238 | const { data, total } = await servers[0].videos.list() |
235 | for (const name of names) { | 239 | expect(total).to.equal(8) |
236 | const video = data.find(v => v.name.includes(name)) | ||
237 | expect(video).to.not.be.undefined | ||
238 | } | ||
239 | }) | ||
240 | 240 | ||
241 | it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { | 241 | const names = [ '1-3', '2-3', 'video server 3 added after follow' ] |
242 | this.timeout(60000) | 242 | for (const name of names) { |
243 | const video = data.find(v => v.name.includes(name)) | ||
244 | expect(video).to.not.be.undefined | ||
245 | } | ||
246 | }) | ||
243 | 247 | ||
244 | await servers[0].follows.unfollow({ target: servers[2] }) | 248 | it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { |
249 | this.timeout(60000) | ||
245 | 250 | ||
246 | await waitJobs(servers) | 251 | await servers[0].follows.unfollow({ target: servers[2] }) |
247 | 252 | ||
248 | const { total, data } = await servers[0].videos.list() | 253 | await waitJobs(servers) |
249 | expect(total).to.equal(5) | ||
250 | 254 | ||
251 | for (const video of data) { | 255 | const { total, data } = await servers[0].videos.list() |
252 | expect(video.name).to.not.contain('1-3') | 256 | expect(total).to.equal(5) |
253 | expect(video.name).to.not.contain('2-3') | ||
254 | expect(video.name).to.not.contain('video server 3 added after follow') | ||
255 | } | ||
256 | }) | ||
257 | 257 | ||
258 | it('Should still list subscription videos', async function () { | 258 | for (const video of data) { |
259 | { | 259 | expect(video.name).to.not.contain('1-3') |
260 | const body = await command.listVideos() | 260 | expect(video.name).to.not.contain('2-3') |
261 | expect(body.total).to.equal(0) | 261 | expect(video.name).to.not.contain('video server 3 added after follow') |
262 | expect(body.data).to.be.an('array') | 262 | } |
263 | expect(body.data).to.have.lengthOf(0) | 263 | }) |
264 | } | 264 | |
265 | it('Should still list subscription videos', async function () { | ||
266 | { | ||
267 | const body = await command.listVideos() | ||
268 | expect(body.total).to.equal(0) | ||
269 | expect(body.data).to.be.an('array') | ||
270 | expect(body.data).to.have.lengthOf(0) | ||
271 | } | ||
265 | 272 | ||
266 | { | 273 | { |
267 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | 274 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
268 | expect(body.total).to.equal(4) | 275 | expect(body.total).to.equal(4) |
269 | 276 | ||
270 | const videos = body.data | 277 | const videos = body.data |
271 | expect(videos).to.be.an('array') | 278 | expect(videos).to.be.an('array') |
272 | expect(videos).to.have.lengthOf(4) | 279 | expect(videos).to.have.lengthOf(4) |
273 | 280 | ||
274 | expect(videos[0].name).to.equal('video 1-3') | 281 | expect(videos[0].name).to.equal('video 1-3') |
275 | expect(videos[1].name).to.equal('video 2-3') | 282 | expect(videos[1].name).to.equal('video 2-3') |
276 | expect(videos[2].name).to.equal('video server 3 added after follow') | 283 | expect(videos[2].name).to.equal('video server 3 added after follow') |
277 | expect(videos[3].name).to.equal('video server 1 added after follow') | 284 | expect(videos[3].name).to.equal('video server 1 added after follow') |
278 | } | 285 | } |
286 | }) | ||
279 | }) | 287 | }) |
280 | 288 | ||
281 | it('Should update a video of server 3 and see the updated video on server 1', async function () { | 289 | describe('Existing subscription video update', function () { |
282 | this.timeout(30000) | ||
283 | |||
284 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) | ||
285 | |||
286 | await waitJobs(servers) | ||
287 | 290 | ||
288 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | 291 | it('Should update a video of server 3 and see the updated video on server 1', async function () { |
289 | expect(body.data[2].name).to.equal('video server 3 added after follow updated') | 292 | this.timeout(30000) |
290 | }) | ||
291 | 293 | ||
292 | it('Should remove user of server 3 subscription', async function () { | 294 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) |
293 | this.timeout(30000) | ||
294 | 295 | ||
295 | await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) | 296 | await waitJobs(servers) |
296 | 297 | ||
297 | await waitJobs(servers) | 298 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
299 | expect(body.data[2].name).to.equal('video server 3 added after follow updated') | ||
300 | }) | ||
298 | }) | 301 | }) |
299 | 302 | ||
300 | it('Should not display its videos anymore', async function () { | 303 | describe('Subscription removal', function () { |
301 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | ||
302 | expect(body.total).to.equal(1) | ||
303 | 304 | ||
304 | const videos = body.data | 305 | it('Should remove user of server 3 subscription', async function () { |
305 | expect(videos).to.be.an('array') | 306 | this.timeout(30000) |
306 | expect(videos).to.have.lengthOf(1) | ||
307 | |||
308 | expect(videos[0].name).to.equal('video server 1 added after follow') | ||
309 | }) | ||
310 | 307 | ||
311 | it('Should remove the root subscription and not display the videos anymore', async function () { | 308 | await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) |
312 | this.timeout(30000) | ||
313 | 309 | ||
314 | await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) | 310 | await waitJobs(servers) |
311 | }) | ||
315 | 312 | ||
316 | await waitJobs(servers) | 313 | it('Should not display its videos anymore', async function () { |
317 | 314 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | |
318 | { | 315 | expect(body.total).to.equal(1) |
319 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) | ||
320 | expect(body.total).to.equal(0) | ||
321 | 316 | ||
322 | const videos = body.data | 317 | const videos = body.data |
323 | expect(videos).to.be.an('array') | 318 | expect(videos).to.be.an('array') |
324 | expect(videos).to.have.lengthOf(0) | 319 | expect(videos).to.have.lengthOf(1) |
325 | } | ||
326 | }) | ||
327 | 320 | ||
328 | it('Should correctly display public videos on server 1', async function () { | 321 | expect(videos[0].name).to.equal('video server 1 added after follow') |
329 | const { total, data } = await servers[0].videos.list() | 322 | }) |
330 | expect(total).to.equal(5) | ||
331 | 323 | ||
332 | for (const video of data) { | 324 | it('Should remove the root subscription and not display the videos anymore', async function () { |
333 | expect(video.name).to.not.contain('1-3') | 325 | this.timeout(30000) |
334 | expect(video.name).to.not.contain('2-3') | ||
335 | expect(video.name).to.not.contain('video server 3 added after follow updated') | ||
336 | } | ||
337 | }) | ||
338 | 326 | ||
339 | it('Should follow user of server 3 again', async function () { | 327 | await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) |
340 | this.timeout(60000) | ||
341 | 328 | ||
342 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) | 329 | await waitJobs(servers) |
343 | 330 | ||
344 | await waitJobs(servers) | 331 | { |
332 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) | ||
333 | expect(body.total).to.equal(0) | ||
345 | 334 | ||
346 | { | 335 | const videos = body.data |
347 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) | 336 | expect(videos).to.be.an('array') |
348 | expect(body.total).to.equal(3) | 337 | expect(videos).to.have.lengthOf(0) |
349 | 338 | } | |
350 | const videos = body.data | 339 | }) |
351 | expect(videos).to.be.an('array') | ||
352 | expect(videos).to.have.lengthOf(3) | ||
353 | |||
354 | expect(videos[0].name).to.equal('video 1-3') | ||
355 | expect(videos[1].name).to.equal('video 2-3') | ||
356 | expect(videos[2].name).to.equal('video server 3 added after follow updated') | ||
357 | } | ||
358 | 340 | ||
359 | { | 341 | it('Should correctly display public videos on server 1', async function () { |
360 | const { total, data } = await servers[0].videos.list() | 342 | const { total, data } = await servers[0].videos.list() |
361 | expect(total).to.equal(5) | 343 | expect(total).to.equal(5) |
362 | 344 | ||
@@ -365,213 +347,254 @@ describe('Test users subscriptions', function () { | |||
365 | expect(video.name).to.not.contain('2-3') | 347 | expect(video.name).to.not.contain('2-3') |
366 | expect(video.name).to.not.contain('video server 3 added after follow updated') | 348 | expect(video.name).to.not.contain('video server 3 added after follow updated') |
367 | } | 349 | } |
368 | } | 350 | }) |
369 | }) | 351 | }) |
370 | 352 | ||
371 | it('Should follow user channels of server 3 by root of server 3', async function () { | 353 | describe('Re-follow', function () { |
372 | this.timeout(60000) | ||
373 | 354 | ||
374 | await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } }) | 355 | it('Should follow user of server 3 again', async function () { |
356 | this.timeout(60000) | ||
375 | 357 | ||
376 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) | 358 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) |
377 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@localhost:' + servers[2].port }) | ||
378 | 359 | ||
379 | await waitJobs(servers) | 360 | await waitJobs(servers) |
380 | }) | ||
381 | 361 | ||
382 | it('Should list user 3 followers', async function () { | 362 | { |
383 | { | 363 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
384 | const { total, data } = await servers[2].accounts.listFollowers({ | 364 | expect(body.total).to.equal(3) |
385 | token: users[2].accessToken, | ||
386 | accountName: 'user3', | ||
387 | start: 0, | ||
388 | count: 5, | ||
389 | sort: 'createdAt' | ||
390 | }) | ||
391 | |||
392 | expect(total).to.equal(3) | ||
393 | expect(data).to.have.lengthOf(3) | ||
394 | |||
395 | expect(data[0].following.host).to.equal(servers[2].host) | ||
396 | expect(data[0].following.name).to.equal('user3_channel') | ||
397 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
398 | expect(data[0].follower.name).to.equal('user1') | ||
399 | |||
400 | expect(data[1].following.host).to.equal(servers[2].host) | ||
401 | expect(data[1].following.name).to.equal('user3_channel') | ||
402 | expect(data[1].follower.host).to.equal(servers[2].host) | ||
403 | expect(data[1].follower.name).to.equal('root') | ||
404 | |||
405 | expect(data[2].following.host).to.equal(servers[2].host) | ||
406 | expect(data[2].following.name).to.equal('user3_channel2') | ||
407 | expect(data[2].follower.host).to.equal(servers[2].host) | ||
408 | expect(data[2].follower.name).to.equal('root') | ||
409 | } | ||
410 | 365 | ||
411 | { | 366 | const videos = body.data |
412 | const { total, data } = await servers[2].accounts.listFollowers({ | 367 | expect(videos).to.be.an('array') |
413 | token: users[2].accessToken, | 368 | expect(videos).to.have.lengthOf(3) |
414 | accountName: 'user3', | ||
415 | start: 0, | ||
416 | count: 1, | ||
417 | sort: '-createdAt' | ||
418 | }) | ||
419 | |||
420 | expect(total).to.equal(3) | ||
421 | expect(data).to.have.lengthOf(1) | ||
422 | |||
423 | expect(data[0].following.host).to.equal(servers[2].host) | ||
424 | expect(data[0].following.name).to.equal('user3_channel2') | ||
425 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
426 | expect(data[0].follower.name).to.equal('root') | ||
427 | } | ||
428 | 369 | ||
429 | { | 370 | expect(videos[0].name).to.equal('video 1-3') |
430 | const { total, data } = await servers[2].accounts.listFollowers({ | 371 | expect(videos[1].name).to.equal('video 2-3') |
431 | token: users[2].accessToken, | 372 | expect(videos[2].name).to.equal('video server 3 added after follow updated') |
432 | accountName: 'user3', | 373 | } |
433 | start: 1, | ||
434 | count: 1, | ||
435 | sort: '-createdAt' | ||
436 | }) | ||
437 | |||
438 | expect(total).to.equal(3) | ||
439 | expect(data).to.have.lengthOf(1) | ||
440 | |||
441 | expect(data[0].following.host).to.equal(servers[2].host) | ||
442 | expect(data[0].following.name).to.equal('user3_channel') | ||
443 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
444 | expect(data[0].follower.name).to.equal('root') | ||
445 | } | ||
446 | 374 | ||
447 | { | 375 | { |
448 | const { total, data } = await servers[2].accounts.listFollowers({ | 376 | const { total, data } = await servers[0].videos.list() |
449 | token: users[2].accessToken, | 377 | expect(total).to.equal(5) |
450 | accountName: 'user3', | ||
451 | search: 'user1', | ||
452 | sort: '-createdAt' | ||
453 | }) | ||
454 | |||
455 | expect(total).to.equal(1) | ||
456 | expect(data).to.have.lengthOf(1) | ||
457 | |||
458 | expect(data[0].following.host).to.equal(servers[2].host) | ||
459 | expect(data[0].following.name).to.equal('user3_channel') | ||
460 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
461 | expect(data[0].follower.name).to.equal('user1') | ||
462 | } | ||
463 | }) | ||
464 | 378 | ||
465 | it('Should list user3_channel followers', async function () { | 379 | for (const video of data) { |
466 | { | 380 | expect(video.name).to.not.contain('1-3') |
467 | const { total, data } = await servers[2].channels.listFollowers({ | 381 | expect(video.name).to.not.contain('2-3') |
468 | token: users[2].accessToken, | 382 | expect(video.name).to.not.contain('video server 3 added after follow updated') |
469 | channelName: 'user3_channel', | 383 | } |
470 | start: 0, | 384 | } |
471 | count: 5, | 385 | }) |
472 | sort: 'createdAt' | ||
473 | }) | ||
474 | |||
475 | expect(total).to.equal(2) | ||
476 | expect(data).to.have.lengthOf(2) | ||
477 | |||
478 | expect(data[0].following.host).to.equal(servers[2].host) | ||
479 | expect(data[0].following.name).to.equal('user3_channel') | ||
480 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
481 | expect(data[0].follower.name).to.equal('user1') | ||
482 | |||
483 | expect(data[1].following.host).to.equal(servers[2].host) | ||
484 | expect(data[1].following.name).to.equal('user3_channel') | ||
485 | expect(data[1].follower.host).to.equal(servers[2].host) | ||
486 | expect(data[1].follower.name).to.equal('root') | ||
487 | } | ||
488 | 386 | ||
489 | { | 387 | it('Should follow user channels of server 3 by root of server 3', async function () { |
490 | const { total, data } = await servers[2].channels.listFollowers({ | 388 | this.timeout(60000) |
491 | token: users[2].accessToken, | ||
492 | channelName: 'user3_channel', | ||
493 | start: 0, | ||
494 | count: 1, | ||
495 | sort: '-createdAt' | ||
496 | }) | ||
497 | |||
498 | expect(total).to.equal(2) | ||
499 | expect(data).to.have.lengthOf(1) | ||
500 | |||
501 | expect(data[0].following.host).to.equal(servers[2].host) | ||
502 | expect(data[0].following.name).to.equal('user3_channel') | ||
503 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
504 | expect(data[0].follower.name).to.equal('root') | ||
505 | } | ||
506 | 389 | ||
507 | { | 390 | await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } }) |
508 | const { total, data } = await servers[2].channels.listFollowers({ | ||
509 | token: users[2].accessToken, | ||
510 | channelName: 'user3_channel', | ||
511 | start: 1, | ||
512 | count: 1, | ||
513 | sort: '-createdAt' | ||
514 | }) | ||
515 | |||
516 | expect(total).to.equal(2) | ||
517 | expect(data).to.have.lengthOf(1) | ||
518 | |||
519 | expect(data[0].following.host).to.equal(servers[2].host) | ||
520 | expect(data[0].following.name).to.equal('user3_channel') | ||
521 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
522 | expect(data[0].follower.name).to.equal('user1') | ||
523 | } | ||
524 | 391 | ||
525 | { | 392 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) |
526 | const { total, data } = await servers[2].channels.listFollowers({ | 393 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@localhost:' + servers[2].port }) |
527 | token: users[2].accessToken, | 394 | |
528 | channelName: 'user3_channel', | 395 | await waitJobs(servers) |
529 | search: 'user1', | 396 | }) |
530 | sort: '-createdAt' | ||
531 | }) | ||
532 | |||
533 | expect(total).to.equal(1) | ||
534 | expect(data).to.have.lengthOf(1) | ||
535 | |||
536 | expect(data[0].following.host).to.equal(servers[2].host) | ||
537 | expect(data[0].following.name).to.equal('user3_channel') | ||
538 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
539 | expect(data[0].follower.name).to.equal('user1') | ||
540 | } | ||
541 | }) | 397 | }) |
542 | 398 | ||
543 | it('Should update video as internal and not see from remote server', async function () { | 399 | describe('Followers listing', function () { |
544 | this.timeout(30000) | 400 | |
401 | it('Should list user 3 followers', async function () { | ||
402 | { | ||
403 | const { total, data } = await servers[2].accounts.listFollowers({ | ||
404 | token: users[2].accessToken, | ||
405 | accountName: 'user3', | ||
406 | start: 0, | ||
407 | count: 5, | ||
408 | sort: 'createdAt' | ||
409 | }) | ||
410 | |||
411 | expect(total).to.equal(3) | ||
412 | expect(data).to.have.lengthOf(3) | ||
413 | |||
414 | expect(data[0].following.host).to.equal(servers[2].host) | ||
415 | expect(data[0].following.name).to.equal('user3_channel') | ||
416 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
417 | expect(data[0].follower.name).to.equal('user1') | ||
418 | |||
419 | expect(data[1].following.host).to.equal(servers[2].host) | ||
420 | expect(data[1].following.name).to.equal('user3_channel') | ||
421 | expect(data[1].follower.host).to.equal(servers[2].host) | ||
422 | expect(data[1].follower.name).to.equal('root') | ||
423 | |||
424 | expect(data[2].following.host).to.equal(servers[2].host) | ||
425 | expect(data[2].following.name).to.equal('user3_channel2') | ||
426 | expect(data[2].follower.host).to.equal(servers[2].host) | ||
427 | expect(data[2].follower.name).to.equal('root') | ||
428 | } | ||
545 | 429 | ||
546 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) | 430 | { |
547 | await waitJobs(servers) | 431 | const { total, data } = await servers[2].accounts.listFollowers({ |
432 | token: users[2].accessToken, | ||
433 | accountName: 'user3', | ||
434 | start: 0, | ||
435 | count: 1, | ||
436 | sort: '-createdAt' | ||
437 | }) | ||
438 | |||
439 | expect(total).to.equal(3) | ||
440 | expect(data).to.have.lengthOf(1) | ||
441 | |||
442 | expect(data[0].following.host).to.equal(servers[2].host) | ||
443 | expect(data[0].following.name).to.equal('user3_channel2') | ||
444 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
445 | expect(data[0].follower.name).to.equal('root') | ||
446 | } | ||
548 | 447 | ||
549 | { | 448 | { |
550 | const { data } = await command.listVideos({ token: users[0].accessToken }) | 449 | const { total, data } = await servers[2].accounts.listFollowers({ |
551 | expect(data.find(v => v.name === 'internal')).to.not.exist | 450 | token: users[2].accessToken, |
552 | } | 451 | accountName: 'user3', |
553 | }) | 452 | start: 1, |
453 | count: 1, | ||
454 | sort: '-createdAt' | ||
455 | }) | ||
456 | |||
457 | expect(total).to.equal(3) | ||
458 | expect(data).to.have.lengthOf(1) | ||
459 | |||
460 | expect(data[0].following.host).to.equal(servers[2].host) | ||
461 | expect(data[0].following.name).to.equal('user3_channel') | ||
462 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
463 | expect(data[0].follower.name).to.equal('root') | ||
464 | } | ||
554 | 465 | ||
555 | it('Should see internal from local user', async function () { | 466 | { |
556 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | 467 | const { total, data } = await servers[2].accounts.listFollowers({ |
557 | expect(data.find(v => v.name === 'internal')).to.exist | 468 | token: users[2].accessToken, |
469 | accountName: 'user3', | ||
470 | search: 'user1', | ||
471 | sort: '-createdAt' | ||
472 | }) | ||
473 | |||
474 | expect(total).to.equal(1) | ||
475 | expect(data).to.have.lengthOf(1) | ||
476 | |||
477 | expect(data[0].following.host).to.equal(servers[2].host) | ||
478 | expect(data[0].following.name).to.equal('user3_channel') | ||
479 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
480 | expect(data[0].follower.name).to.equal('user1') | ||
481 | } | ||
482 | }) | ||
483 | |||
484 | it('Should list user3_channel followers', async function () { | ||
485 | { | ||
486 | const { total, data } = await servers[2].channels.listFollowers({ | ||
487 | token: users[2].accessToken, | ||
488 | channelName: 'user3_channel', | ||
489 | start: 0, | ||
490 | count: 5, | ||
491 | sort: 'createdAt' | ||
492 | }) | ||
493 | |||
494 | expect(total).to.equal(2) | ||
495 | expect(data).to.have.lengthOf(2) | ||
496 | |||
497 | expect(data[0].following.host).to.equal(servers[2].host) | ||
498 | expect(data[0].following.name).to.equal('user3_channel') | ||
499 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
500 | expect(data[0].follower.name).to.equal('user1') | ||
501 | |||
502 | expect(data[1].following.host).to.equal(servers[2].host) | ||
503 | expect(data[1].following.name).to.equal('user3_channel') | ||
504 | expect(data[1].follower.host).to.equal(servers[2].host) | ||
505 | expect(data[1].follower.name).to.equal('root') | ||
506 | } | ||
507 | |||
508 | { | ||
509 | const { total, data } = await servers[2].channels.listFollowers({ | ||
510 | token: users[2].accessToken, | ||
511 | channelName: 'user3_channel', | ||
512 | start: 0, | ||
513 | count: 1, | ||
514 | sort: '-createdAt' | ||
515 | }) | ||
516 | |||
517 | expect(total).to.equal(2) | ||
518 | expect(data).to.have.lengthOf(1) | ||
519 | |||
520 | expect(data[0].following.host).to.equal(servers[2].host) | ||
521 | expect(data[0].following.name).to.equal('user3_channel') | ||
522 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
523 | expect(data[0].follower.name).to.equal('root') | ||
524 | } | ||
525 | |||
526 | { | ||
527 | const { total, data } = await servers[2].channels.listFollowers({ | ||
528 | token: users[2].accessToken, | ||
529 | channelName: 'user3_channel', | ||
530 | start: 1, | ||
531 | count: 1, | ||
532 | sort: '-createdAt' | ||
533 | }) | ||
534 | |||
535 | expect(total).to.equal(2) | ||
536 | expect(data).to.have.lengthOf(1) | ||
537 | |||
538 | expect(data[0].following.host).to.equal(servers[2].host) | ||
539 | expect(data[0].following.name).to.equal('user3_channel') | ||
540 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
541 | expect(data[0].follower.name).to.equal('user1') | ||
542 | } | ||
543 | |||
544 | { | ||
545 | const { total, data } = await servers[2].channels.listFollowers({ | ||
546 | token: users[2].accessToken, | ||
547 | channelName: 'user3_channel', | ||
548 | search: 'user1', | ||
549 | sort: '-createdAt' | ||
550 | }) | ||
551 | |||
552 | expect(total).to.equal(1) | ||
553 | expect(data).to.have.lengthOf(1) | ||
554 | |||
555 | expect(data[0].following.host).to.equal(servers[2].host) | ||
556 | expect(data[0].following.name).to.equal('user3_channel') | ||
557 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
558 | expect(data[0].follower.name).to.equal('user1') | ||
559 | } | ||
560 | }) | ||
558 | }) | 561 | }) |
559 | 562 | ||
560 | it('Should update video as private and not see from anyone server', async function () { | 563 | describe('Subscription videos privacy', function () { |
561 | this.timeout(30000) | ||
562 | 564 | ||
563 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) | 565 | it('Should update video as internal and not see from remote server', async function () { |
564 | await waitJobs(servers) | 566 | this.timeout(30000) |
565 | 567 | ||
566 | { | 568 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) |
567 | const { data } = await command.listVideos({ token: users[0].accessToken }) | 569 | await waitJobs(servers) |
568 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
569 | } | ||
570 | 570 | ||
571 | { | 571 | { |
572 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
573 | expect(data.find(v => v.name === 'internal')).to.not.exist | ||
574 | } | ||
575 | }) | ||
576 | |||
577 | it('Should see internal from local user', async function () { | ||
572 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | 578 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) |
573 | expect(data.find(v => v.name === 'private')).to.not.exist | 579 | expect(data.find(v => v.name === 'internal')).to.exist |
574 | } | 580 | }) |
581 | |||
582 | it('Should update video as private and not see from anyone server', async function () { | ||
583 | this.timeout(30000) | ||
584 | |||
585 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) | ||
586 | await waitJobs(servers) | ||
587 | |||
588 | { | ||
589 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
590 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
591 | } | ||
592 | |||
593 | { | ||
594 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
595 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
596 | } | ||
597 | }) | ||
575 | }) | 598 | }) |
576 | 599 | ||
577 | after(async function () { | 600 | after(async function () { |