aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/server/follows.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/server/follows.ts')
-rw-r--r--server/tests/api/server/follows.ts186
1 files changed, 93 insertions, 93 deletions
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 6c815ace8..311631aae 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -2,7 +2,9 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { Video, VideoPrivacy } from '../../../../shared/models/videos'
5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 6import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
7import { completeVideoCheck } from '../../utils'
6 8
7import { 9import {
8 flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, 10 flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
@@ -163,111 +165,109 @@ describe('Test follows', function () {
163 expect(res.body.data[0].name).to.equal('server3') 165 expect(res.body.data[0].name).to.equal('server3')
164 }) 166 })
165 167
166 it('Should propagate previous uploaded videos on a new following', async function () { 168 describe('Should propagate data on a new following', async function () {
167 this.timeout(20000) 169 let video4: Video
168
169 const video4Attributes = {
170 name: 'server3-4',
171 category: 2,
172 nsfw: true,
173 licence: 6,
174 tags: [ 'tag1', 'tag2', 'tag3' ]
175 }
176 170
177 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' }) 171 before(async function () {
178 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' }) 172 this.timeout(20000)
179 await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes)
180 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' })
181 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' })
182 173
183 { 174 const video4Attributes = {
184 const user = { username: 'captain', password: 'password' } 175 name: 'server3-4',
185 await createUser(servers[2].url, servers[2].accessToken, user.username, user.password) 176 category: 2,
186 const userAccessToken = await userLogin(servers[2], user) 177 nsfw: true,
178 licence: 6,
179 tags: [ 'tag1', 'tag2', 'tag3' ]
180 }
187 181
188 const resVideos = await getVideosList(servers[ 2 ].url) 182 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-2' })
189 const video4 = resVideos.body.data.find(v => v.name === 'server3-4') 183 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-3' })
184 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4Attributes)
185 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-5' })
186 await uploadVideo(servers[ 2 ].url, servers[ 2 ].accessToken, { name: 'server3-6' })
190 187
191 { 188 {
192 await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like') 189 const user = { username: 'captain', password: 'password' }
193 await rateVideo(servers[ 2 ].url, userAccessToken, video4.id, 'dislike') 190 await createUser(servers[ 2 ].url, servers[ 2 ].accessToken, user.username, user.password)
194 } 191 const userAccessToken = await userLogin(servers[ 2 ], user)
195 192
196 { 193 const resVideos = await getVideosList(servers[ 2 ].url)
197 const text = 'my super first comment' 194 video4 = resVideos.body.data.find(v => v.name === 'server3-4')
198 const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
199 const threadId = res.body.comment.id
200 195
201 const text1 = 'my super answer to thread 1' 196 {
202 const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1) 197 await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like')
203 const childCommentId = childCommentRes.body.comment.id 198 await rateVideo(servers[ 2 ].url, userAccessToken, video4.id, 'dislike')
199 }
204 200
205 const text2 = 'my super answer to answer of thread 1' 201 {
206 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text2) 202 const text = 'my super first comment'
203 const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
204 const threadId = res.body.comment.id
207 205
208 const text3 = 'my second answer to thread 1' 206 const text1 = 'my super answer to thread 1'
209 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text3) 207 const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1)
210 } 208 const childCommentId = childCommentRes.body.comment.id
211 }
212 209
213 await wait(5000) 210 const text2 = 'my super answer to answer of thread 1'
211 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text2)
214 212
215 // Server 1 follows server 3 213 const text3 = 'my second answer to thread 1'
216 await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken) 214 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text3)
215 }
216 }
217 217
218 await wait(7000) 218 await wait(5000)
219
220 // Server 1 follows server 3
221 await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken)
222
223 await wait(7000)
224 })
225
226 it('Should propagate videos', async function () {
227 const res = await getVideosList(servers[ 0 ].url)
228 expect(res.body.total).to.equal(7)
229
230 const video2 = res.body.data.find(v => v.name === 'server3-2')
231 video4 = res.body.data.find(v => v.name === 'server3-4')
232 const video6 = res.body.data.find(v => v.name === 'server3-6')
233
234 expect(video2).to.not.be.undefined
235 expect(video4).to.not.be.undefined
236 expect(video6).to.not.be.undefined
237
238 const isLocal = false
239 const checkAttributes = {
240 name: 'server3-4',
241 category: 2,
242 licence: 6,
243 language: 3,
244 nsfw: true,
245 description: 'my super description',
246 host: 'localhost:9003',
247 account: 'root',
248 isLocal,
249 duration: 5,
250 tags: [ 'tag1', 'tag2', 'tag3' ],
251 privacy: VideoPrivacy.PUBLIC,
252 likes: 1,
253 dislikes: 1,
254 channel: {
255 name: 'Default root channel',
256 description: '',
257 isLocal
258 },
259 fixture: 'video_short.webm',
260 files: [
261 {
262 resolution: 720,
263 size: 218910
264 }
265 ]
266 }
267 await completeVideoCheck(servers[ 0 ].url, video4, checkAttributes)
268 })
219 269
220 let res = await getVideosList(servers[0].url) 270 it('Should propagate comments', async function () {
221 expect(res.body.total).to.equal(7)
222
223 const video2 = res.body.data.find(v => v.name === 'server3-2')
224 const video4 = res.body.data.find(v => v.name === 'server3-4')
225 const video6 = res.body.data.find(v => v.name === 'server3-6')
226
227 expect(video2).to.not.be.undefined
228 expect(video4).to.not.be.undefined
229 expect(video6).to.not.be.undefined
230
231 const res2 = await getVideo(servers[0].url, video4.id)
232 const videoDetails = res2.body
233
234 expect(videoDetails.name).to.equal('server3-4')
235 expect(videoDetails.category).to.equal(2)
236 expect(videoDetails.categoryLabel).to.equal('Films')
237 expect(videoDetails.licence).to.equal(6)
238 expect(videoDetails.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
239 expect(videoDetails.language).to.equal(3)
240 expect(videoDetails.languageLabel).to.equal('Mandarin')
241 expect(videoDetails.nsfw).to.be.ok
242 expect(videoDetails.description).to.equal('my super description')
243 expect(videoDetails.serverHost).to.equal('localhost:9003')
244 expect(videoDetails.accountName).to.equal('root')
245 expect(videoDetails.likes).to.equal(1)
246 expect(videoDetails.dislikes).to.equal(1)
247 expect(videoDetails.isLocal).to.be.false
248 expect(videoDetails.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
249 expect(dateIsValid(videoDetails.createdAt)).to.be.true
250 expect(dateIsValid(videoDetails.updatedAt)).to.be.true
251 expect(videoDetails.files).to.have.lengthOf(1)
252
253 const file = videoDetails.files[0]
254 const magnetUri = file.magnetUri
255 expect(file.magnetUri).to.have.lengthOf.above(2)
256 expect(file.torrentUrl).to.equal(`${servers[2].url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
257 expect(file.fileUrl).to.equal(`${servers[2].url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
258 expect(file.resolution).to.equal(720)
259 expect(file.resolutionLabel).to.equal('720p')
260 expect(file.size).to.equal(218910)
261
262 const test = await testVideoImage(servers[2].url, 'video_short.webm', videoDetails.thumbnailPath)
263 expect(test).to.equal(true)
264
265 const torrent = await webtorrentAdd(magnetUri)
266 expect(torrent.files).to.be.an('array')
267 expect(torrent.files.length).to.equal(1)
268 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
269
270 {
271 const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5) 271 const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5)
272 272
273 expect(res1.body.total).to.equal(1) 273 expect(res1.body.total).to.equal(1)
@@ -304,7 +304,7 @@ describe('Test follows', function () {
304 const secondChild = tree.children[1] 304 const secondChild = tree.children[1]
305 expect(secondChild.comment.text).to.equal('my second answer to thread 1') 305 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
306 expect(secondChild.children).to.have.lengthOf(0) 306 expect(secondChild.children).to.have.lengthOf(0)
307 } 307 })
308 }) 308 })
309 309
310 after(async function () { 310 after(async function () {