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