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