]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/server/follows.ts
Introduce accounts command
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / follows.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
0f91ae62 2
0f91ae62 3import 'mocha'
2b02c520 4import * as chai from 'chai'
0f91ae62 5import {
2b02c520
C
6 addVideoCommentReply,
7 addVideoCommentThread,
8 cleanupTests,
9 completeVideoCheck,
10 createUser,
11 createVideoCaption,
12 dateIsValid,
13 deleteVideoComment,
14 expectAccountFollows,
3cd0734f 15 flushAndRunMultipleServers,
c3d29f69 16 FollowsCommand,
3cd0734f 17 getVideoCommentThreads,
2b02c520
C
18 getVideosList,
19 getVideoThreadComments,
20 listVideoCaptions,
21 rateVideo,
22 ServerInfo,
23 setAccessTokensToServers,
24 testCaptionFile,
2b02c520
C
25 uploadVideo,
26 userLogin,
27 waitJobs
28} from '@shared/extra-utils'
29import { Video, VideoCaption, VideoComment, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
0f91ae62
C
30
31const expect = chai.expect
32
33describe('Test follows', function () {
34 let servers: ServerInfo[] = []
c3d29f69 35 let followsCommands: FollowsCommand[]
0f91ae62
C
36
37 before(async function () {
e212f887 38 this.timeout(30000)
0f91ae62
C
39
40 servers = await flushAndRunMultipleServers(3)
c3d29f69 41 followsCommands = servers.map(s => s.followsCommand)
0f91ae62
C
42
43 // Get the access tokens
44 await setAccessTokensToServers(servers)
45 })
46
47 it('Should not have followers', async function () {
48 for (const server of servers) {
c3d29f69
C
49 const body = await server.followsCommand.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
50 expect(body.total).to.equal(0)
0f91ae62 51
c3d29f69 52 const follows = body.data
0f91ae62
C
53 expect(follows).to.be.an('array')
54 expect(follows.length).to.equal(0)
55 }
56 })
57
58 it('Should not have following', async function () {
59 for (const server of servers) {
c3d29f69
C
60 const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
61 expect(body.total).to.equal(0)
0f91ae62 62
c3d29f69 63 const follows = body.data
0f91ae62
C
64 expect(follows).to.be.an('array')
65 expect(follows.length).to.equal(0)
66 }
67 })
68
69 it('Should have server 1 following server 2 and 3', async function () {
288178bf 70 this.timeout(30000)
0f91ae62 71
c3d29f69 72 await followsCommands[0].follow({ targets: [ servers[1].url, servers[2].url ] })
0f91ae62 73
3cd0734f 74 await waitJobs(servers)
0f91ae62
C
75 })
76
77 it('Should have 2 followings on server 1', async function () {
c3d29f69
C
78 const body = await followsCommands[0].getFollowings({ start: 0, count: 1, sort: 'createdAt' })
79 expect(body.total).to.equal(2)
0f91ae62 80
c3d29f69 81 let follows = body.data
0f91ae62
C
82 expect(follows).to.be.an('array')
83 expect(follows.length).to.equal(1)
84
c3d29f69
C
85 const body2 = await followsCommands[0].getFollowings({ start: 1, count: 1, sort: 'createdAt' })
86 follows = follows.concat(body2.data)
0f91ae62 87
7243f84d
C
88 const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port)
89 const server3Follow = follows.find(f => f.following.host === 'localhost:' + servers[2].port)
0f91ae62
C
90
91 expect(server2Follow).to.not.be.undefined
92 expect(server3Follow).to.not.be.undefined
93 expect(server2Follow.state).to.equal('accepted')
94 expect(server3Follow.state).to.equal('accepted')
0f91ae62
C
95 })
96
b8f4167f 97 it('Should search/filter followings on server 1', async function () {
97ecddae
C
98 const sort = 'createdAt'
99 const start = 0
100 const count = 1
97ecddae 101
b014b6b9 102 {
b8f4167f 103 const search = ':' + servers[1].port
b8f4167f 104
97ecddae 105 {
c3d29f69
C
106 const body = await followsCommands[0].getFollowings({ start, count, sort, search })
107 expect(body.total).to.equal(1)
97ecddae 108
c3d29f69 109 const follows = body.data
97ecddae 110 expect(follows.length).to.equal(1)
a1587156 111 expect(follows[0].following.host).to.equal('localhost:' + servers[1].port)
97ecddae
C
112 }
113
114 {
c3d29f69
C
115 const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'accepted' })
116 expect(body.total).to.equal(1)
117 expect(body.data).to.have.lengthOf(1)
97ecddae
C
118 }
119
120 {
c3d29f69
C
121 const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'accepted', actorType: 'Person' })
122 expect(body.total).to.equal(0)
123 expect(body.data).to.have.lengthOf(0)
97ecddae
C
124 }
125
126 {
c3d29f69 127 const body = await followsCommands[0].getFollowings({
97ecddae
C
128 start,
129 count,
130 sort,
131 search,
132 state: 'accepted',
133 actorType: 'Application'
134 })
c3d29f69
C
135 expect(body.total).to.equal(1)
136 expect(body.data).to.have.lengthOf(1)
97ecddae
C
137 }
138
139 {
c3d29f69
C
140 const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'pending' })
141 expect(body.total).to.equal(0)
142 expect(body.data).to.have.lengthOf(0)
97ecddae 143 }
b014b6b9
C
144 }
145
146 {
c3d29f69
C
147 const body = await followsCommands[0].getFollowings({ start, count, sort, search: 'bla' })
148 expect(body.total).to.equal(0)
b014b6b9 149
c3d29f69 150 expect(body.data.length).to.equal(0)
b014b6b9
C
151 }
152 })
153
154 it('Should have 0 followings on server 2 and 3', async function () {
0f91ae62 155 for (const server of [ servers[1], servers[2] ]) {
c3d29f69
C
156 const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
157 expect(body.total).to.equal(0)
0f91ae62 158
c3d29f69 159 const follows = body.data
0f91ae62
C
160 expect(follows).to.be.an('array')
161 expect(follows.length).to.equal(0)
162 }
163 })
164
165 it('Should have 1 followers on server 2 and 3', async function () {
166 for (const server of [ servers[1], servers[2] ]) {
c3d29f69
C
167 const body = await server.followsCommand.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
168 expect(body.total).to.equal(1)
0f91ae62 169
c3d29f69 170 const follows = body.data
0f91ae62
C
171 expect(follows).to.be.an('array')
172 expect(follows.length).to.equal(1)
7243f84d 173 expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port)
0f91ae62
C
174 }
175 })
176
b8f4167f 177 it('Should search/filter followers on server 2', async function () {
97ecddae
C
178 const start = 0
179 const count = 5
180 const sort = 'createdAt'
181
b014b6b9 182 {
b8f4167f 183 const search = servers[0].port + ''
b8f4167f 184
97ecddae 185 {
c3d29f69
C
186 const body = await followsCommands[2].getFollowers({ start, count, sort, search })
187 expect(body.total).to.equal(1)
97ecddae 188
c3d29f69 189 const follows = body.data
97ecddae 190 expect(follows.length).to.equal(1)
a1587156 191 expect(follows[0].following.host).to.equal('localhost:' + servers[2].port)
97ecddae
C
192 }
193
194 {
c3d29f69
C
195 const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'accepted' })
196 expect(body.total).to.equal(1)
197 expect(body.data).to.have.lengthOf(1)
97ecddae
C
198 }
199
200 {
c3d29f69
C
201 const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'accepted', actorType: 'Person' })
202 expect(body.total).to.equal(0)
203 expect(body.data).to.have.lengthOf(0)
97ecddae
C
204 }
205
206 {
c3d29f69 207 const body = await followsCommands[2].getFollowers({
97ecddae
C
208 start,
209 count,
210 sort,
211 search,
212 state: 'accepted',
213 actorType: 'Application'
214 })
c3d29f69
C
215 expect(body.total).to.equal(1)
216 expect(body.data).to.have.lengthOf(1)
97ecddae
C
217 }
218
219 {
c3d29f69
C
220 const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'pending' })
221 expect(body.total).to.equal(0)
222 expect(body.data).to.have.lengthOf(0)
97ecddae 223 }
b014b6b9
C
224 }
225
226 {
c3d29f69
C
227 const body = await followsCommands[2].getFollowers({ start, count, sort, search: 'bla' })
228 expect(body.total).to.equal(0)
b014b6b9 229
c3d29f69 230 const follows = body.data
b014b6b9
C
231 expect(follows.length).to.equal(0)
232 }
233 })
234
0f91ae62 235 it('Should have 0 followers on server 1', async function () {
c3d29f69
C
236 const body = await followsCommands[0].getFollowers({ start: 0, count: 5, sort: 'createdAt' })
237 expect(body.total).to.equal(0)
0f91ae62 238
c3d29f69 239 const follows = body.data
0f91ae62
C
240 expect(follows).to.be.an('array')
241 expect(follows.length).to.equal(0)
242 })
243
38768a36 244 it('Should have the correct follows counts', async function () {
9fff08cf
C
245 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 2 })
246 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
247 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
32b2b43c
C
248
249 // Server 2 and 3 does not know server 1 follow another server (there was not a refresh)
9fff08cf
C
250 await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
251 await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
32b2b43c 252
9fff08cf
C
253 await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
254 await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
32b2b43c
C
255 })
256
0f91ae62
C
257 it('Should unfollow server 3 on server 1', async function () {
258 this.timeout(5000)
259
c3d29f69 260 await followsCommands[0].unfollow({ target: servers[2] })
0f91ae62 261
3cd0734f 262 await waitJobs(servers)
0f91ae62
C
263 })
264
265 it('Should not follow server 3 on server 1 anymore', async function () {
c3d29f69
C
266 const body = await followsCommands[0].getFollowings({ start: 0, count: 2, sort: 'createdAt' })
267 expect(body.total).to.equal(1)
0f91ae62 268
c3d29f69 269 const follows = body.data
0f91ae62
C
270 expect(follows).to.be.an('array')
271 expect(follows.length).to.equal(1)
272
7243f84d 273 expect(follows[0].following.host).to.equal('localhost:' + servers[1].port)
0f91ae62
C
274 })
275
276 it('Should not have server 1 as follower on server 3 anymore', async function () {
c3d29f69
C
277 const body = await followsCommands[2].getFollowers({ start: 0, count: 1, sort: 'createdAt' })
278 expect(body.total).to.equal(0)
0f91ae62 279
c3d29f69 280 const follows = body.data
0f91ae62
C
281 expect(follows).to.be.an('array')
282 expect(follows.length).to.equal(0)
283 })
284
38768a36 285 it('Should have the correct follows counts 2', async function () {
9fff08cf
C
286 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
287 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
32b2b43c 288
9fff08cf
C
289 await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
290 await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
32b2b43c 291
9fff08cf
C
292 await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 0 })
293 await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 0, following: 0 })
32b2b43c
C
294 })
295
2bb0f9d5 296 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
e0783718 297 this.timeout(60000)
0f91ae62
C
298
299 await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' })
300 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' })
301
3cd0734f 302 await waitJobs(servers)
0f91ae62
C
303
304 let res = await getVideosList(servers[0].url)
305 expect(res.body.total).to.equal(1)
306 expect(res.body.data[0].name).to.equal('server2')
307
308 res = await getVideosList(servers[1].url)
309 expect(res.body.total).to.equal(1)
310 expect(res.body.data[0].name).to.equal('server2')
311
312 res = await getVideosList(servers[2].url)
313 expect(res.body.total).to.equal(1)
314 expect(res.body.data[0].name).to.equal('server3')
315 })
316
9b39106d 317 describe('Should propagate data on a new following', function () {
b1f5b93e 318 let video4: Video
d8553faa 319
b1f5b93e 320 before(async function () {
8b381422 321 this.timeout(50000)
c46edbc2 322
b1f5b93e
C
323 const video4Attributes = {
324 name: 'server3-4',
325 category: 2,
326 nsfw: true,
327 licence: 6,
328 tags: [ 'tag1', 'tag2', 'tag3' ]
329 }
d8553faa 330
a1587156
C
331 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' })
332 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' })
333 await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes)
334 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' })
335 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' })
d8553faa 336
db799da3 337 {
b1f5b93e 338 const user = { username: 'captain', password: 'password' }
a1587156
C
339 await createUser({ url: servers[2].url, accessToken: servers[2].accessToken, username: user.username, password: user.password })
340 const userAccessToken = await userLogin(servers[2], user)
db799da3 341
a1587156 342 const resVideos = await getVideosList(servers[2].url)
b1f5b93e 343 video4 = resVideos.body.data.find(v => v.name === 'server3-4')
db799da3 344
b1f5b93e 345 {
a1587156
C
346 await rateVideo(servers[2].url, servers[2].accessToken, video4.id, 'like')
347 await rateVideo(servers[2].url, userAccessToken, video4.id, 'dislike')
b1f5b93e 348 }
db799da3 349
b1f5b93e 350 {
c883db6d
C
351 {
352 const text = 'my super first comment'
a1587156 353 const res = await addVideoCommentThread(servers[2].url, servers[2].accessToken, video4.id, text)
c883db6d
C
354 const threadId = res.body.comment.id
355
356 const text1 = 'my super answer to thread 1'
a1587156 357 const childCommentRes = await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text1)
c883db6d
C
358 const childCommentId = childCommentRes.body.comment.id
359
360 const text2 = 'my super answer to answer of thread 1'
a1587156 361 await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, childCommentId, text2)
c883db6d
C
362
363 const text3 = 'my second answer to thread 1'
a1587156 364 await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text3)
c883db6d
C
365 }
366
367 {
368 const text = 'will be deleted'
a1587156 369 const res = await addVideoCommentThread(servers[2].url, servers[2].accessToken, video4.id, text)
c883db6d
C
370 const threadId = res.body.comment.id
371
372 const text1 = 'answer to deleted'
a1587156 373 await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text1)
db799da3 374
c883db6d 375 const text2 = 'will also be deleted'
a1587156 376 const childCommentRes = await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, threadId, text2)
c883db6d 377 const childCommentId = childCommentRes.body.comment.id
d8553faa 378
c883db6d 379 const text3 = 'my second answer to deleted'
a1587156 380 await addVideoCommentReply(servers[2].url, servers[2].accessToken, video4.id, childCommentId, text3)
c46edbc2 381
a1587156
C
382 await deleteVideoComment(servers[2].url, servers[2].accessToken, video4.id, threadId)
383 await deleteVideoComment(servers[2].url, servers[2].accessToken, video4.id, childCommentId)
c883db6d 384 }
b1f5b93e 385 }
40e87e9e
C
386
387 {
388 await createVideoCaption({
389 url: servers[2].url,
390 accessToken: servers[2].accessToken,
391 language: 'ar',
392 videoId: video4.id,
393 fixture: 'subtitle-good2.vtt'
394 })
395 }
b1f5b93e 396 }
c46edbc2 397
3cd0734f 398 await waitJobs(servers)
b1f5b93e
C
399
400 // Server 1 follows server 3
c3d29f69 401 await followsCommands[0].follow({ targets: [ servers[2].url ] })
b1f5b93e 402
3cd0734f 403 await waitJobs(servers)
b1f5b93e
C
404 })
405
38768a36 406 it('Should have the correct follows counts 3', async function () {
9fff08cf
C
407 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 2 })
408 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
409 await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
32b2b43c 410
9fff08cf
C
411 await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
412 await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
32b2b43c 413
9fff08cf
C
414 await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
415 await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
32b2b43c
C
416 })
417
40e87e9e 418 it('Should have propagated videos', async function () {
a1587156 419 const res = await getVideosList(servers[0].url)
b1f5b93e
C
420 expect(res.body.total).to.equal(7)
421
422 const video2 = res.body.data.find(v => v.name === 'server3-2')
423 video4 = res.body.data.find(v => v.name === 'server3-4')
424 const video6 = res.body.data.find(v => v.name === 'server3-6')
425
426 expect(video2).to.not.be.undefined
427 expect(video4).to.not.be.undefined
428 expect(video6).to.not.be.undefined
429
430 const isLocal = false
431 const checkAttributes = {
432 name: 'server3-4',
433 category: 2,
434 licence: 6,
9d3ef9fe 435 language: 'zh',
b1f5b93e
C
436 nsfw: true,
437 description: 'my super description',
2422c46b 438 support: 'my super support text',
b64c950a
C
439 account: {
440 name: 'root',
7243f84d 441 host: 'localhost:' + servers[2].port
b64c950a 442 },
b1f5b93e 443 isLocal,
47564bbe 444 commentsEnabled: true,
7f2cfe3a 445 downloadEnabled: true,
b1f5b93e
C
446 duration: 5,
447 tags: [ 'tag1', 'tag2', 'tag3' ],
448 privacy: VideoPrivacy.PUBLIC,
449 likes: 1,
450 dislikes: 1,
451 channel: {
f6eebcb3
C
452 displayName: 'Main root channel',
453 name: 'root_channel',
b1f5b93e
C
454 description: '',
455 isLocal
456 },
457 fixture: 'video_short.webm',
458 files: [
459 {
460 resolution: 720,
461 size: 218910
462 }
463 ]
464 }
a1587156 465 await completeVideoCheck(servers[0].url, video4, checkAttributes)
b1f5b93e 466 })
c46edbc2 467
40e87e9e 468 it('Should have propagated comments', async function () {
c883db6d 469 const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5, 'createdAt')
db799da3 470
c883db6d 471 expect(res1.body.total).to.equal(2)
db799da3 472 expect(res1.body.data).to.be.an('array')
c883db6d
C
473 expect(res1.body.data).to.have.lengthOf(2)
474
475 {
a1587156 476 const comment: VideoComment = res1.body.data[0]
c883db6d
C
477 expect(comment.inReplyToCommentId).to.be.null
478 expect(comment.text).equal('my super first comment')
479 expect(comment.videoId).to.equal(video4.id)
480 expect(comment.id).to.equal(comment.threadId)
481 expect(comment.account.name).to.equal('root')
a1587156 482 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
c883db6d
C
483 expect(comment.totalReplies).to.equal(3)
484 expect(dateIsValid(comment.createdAt as string)).to.be.true
485 expect(dateIsValid(comment.updatedAt as string)).to.be.true
486
487 const threadId = comment.threadId
488
a1587156 489 const res2 = await getVideoThreadComments(servers[0].url, video4.id, threadId)
c883db6d
C
490
491 const tree: VideoCommentThreadTree = res2.body
492 expect(tree.comment.text).equal('my super first comment')
493 expect(tree.children).to.have.lengthOf(2)
494
a1587156 495 const firstChild = tree.children[0]
c883db6d
C
496 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
497 expect(firstChild.children).to.have.lengthOf(1)
498
a1587156 499 const childOfFirstChild = firstChild.children[0]
c883db6d
C
500 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
501 expect(childOfFirstChild.children).to.have.lengthOf(0)
502
a1587156 503 const secondChild = tree.children[1]
c883db6d
C
504 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
505 expect(secondChild.children).to.have.lengthOf(0)
506 }
507
508 {
509 const deletedComment: VideoComment = res1.body.data[1]
510 expect(deletedComment).to.not.be.undefined
511 expect(deletedComment.isDeleted).to.be.true
512 expect(deletedComment.deletedAt).to.not.be.null
513 expect(deletedComment.text).to.equal('')
514 expect(deletedComment.inReplyToCommentId).to.be.null
515 expect(deletedComment.account).to.be.null
9de33c6b 516 expect(deletedComment.totalReplies).to.equal(2)
c883db6d
C
517 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
518
519 const res2 = await getVideoThreadComments(servers[0].url, video4.id, deletedComment.threadId)
520
521 const tree: VideoCommentThreadTree = res2.body
522 const [ commentRoot, deletedChildRoot ] = tree.children
523
524 expect(deletedChildRoot).to.not.be.undefined
525 expect(deletedChildRoot.comment.isDeleted).to.be.true
526 expect(deletedChildRoot.comment.deletedAt).to.not.be.null
527 expect(deletedChildRoot.comment.text).to.equal('')
528 expect(deletedChildRoot.comment.inReplyToCommentId).to.equal(deletedComment.id)
529 expect(deletedChildRoot.comment.account).to.be.null
530 expect(deletedChildRoot.children).to.have.lengthOf(1)
531
532 const answerToDeletedChild = deletedChildRoot.children[0]
533 expect(answerToDeletedChild.comment).to.not.be.undefined
534 expect(answerToDeletedChild.comment.inReplyToCommentId).to.equal(deletedChildRoot.comment.id)
535 expect(answerToDeletedChild.comment.text).to.equal('my second answer to deleted')
536 expect(answerToDeletedChild.comment.account.name).to.equal('root')
537
538 expect(commentRoot.comment).to.not.be.undefined
539 expect(commentRoot.comment.inReplyToCommentId).to.equal(deletedComment.id)
540 expect(commentRoot.comment.text).to.equal('answer to deleted')
541 expect(commentRoot.comment.account.name).to.equal('root')
542 }
b1f5b93e 543 })
f05a1c30 544
40e87e9e
C
545 it('Should have propagated captions', async function () {
546 const res = await listVideoCaptions(servers[0].url, video4.id)
547 expect(res.body.total).to.equal(1)
548 expect(res.body.data).to.have.lengthOf(1)
549
550 const caption1: VideoCaption = res.body.data[0]
551 expect(caption1.language.id).to.equal('ar')
552 expect(caption1.language.label).to.equal('Arabic')
a35a2279 553 expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/.+-ar.vtt$'))
40e87e9e
C
554 await testCaptionFile(servers[0].url, caption1.captionPath, 'Subtitle good 2.')
555 })
556
f05a1c30
C
557 it('Should unfollow server 3 on server 1 and does not list server 3 videos', async function () {
558 this.timeout(5000)
559
c3d29f69 560 await followsCommands[0].unfollow({ target: servers[2] })
f05a1c30 561
3cd0734f 562 await waitJobs(servers)
f05a1c30 563
a1587156 564 const res = await getVideosList(servers[0].url)
f05a1c30 565 expect(res.body.total).to.equal(1)
f05a1c30
C
566 })
567
c46edbc2
C
568 })
569
7c3b7976
C
570 after(async function () {
571 await cleanupTests(servers)
0f91ae62
C
572 })
573})