aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/follows.ts65
-rw-r--r--server/tests/api/multiple-servers.ts2
2 files changed, 65 insertions, 2 deletions
diff --git a/server/tests/api/follows.ts b/server/tests/api/follows.ts
index 875d814a7..aadae3cce 100644
--- a/server/tests/api/follows.ts
+++ b/server/tests/api/follows.ts
@@ -14,6 +14,10 @@ import {
14 wait 14 wait
15} from '../utils' 15} from '../utils'
16import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows' 16import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows'
17import { getUserAccessToken } from '../utils/login'
18import { dateIsValid, webtorrentAdd } from '../utils/miscs'
19import { createUser } from '../utils/users'
20import { getVideo, rateVideo, testVideoImage } from '../utils/videos'
17 21
18const expect = chai.expect 22const expect = chai.expect
19 23
@@ -166,12 +170,32 @@ describe('Test follows', function () {
166 it('Should propagate previous uploaded videos on a new following', async function () { 170 it('Should propagate previous uploaded videos on a new following', async function () {
167 this.timeout(20000) 171 this.timeout(20000)
168 172
173 const video4Attributes = {
174 name: 'server3-4',
175 category: 2,
176 nsfw: true,
177 licence: 6,
178 tags: [ 'tag1', 'tag2', 'tag3' ]
179 }
180
169 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' }) 181 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' })
170 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' }) 182 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' })
171 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-4' }) 183 await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes)
172 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' }) 184 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' })
173 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' }) 185 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' })
174 186
187 {
188 const user = { username: 'captain', password: 'password' }
189 await createUser(servers[2].url, servers[2].accessToken, user.username, user.password)
190 const userAccessToken = await getUserAccessToken(servers[2], user)
191
192 const res = await getVideosList(servers[2].url)
193 const video4 = res.body.data.find(v => v.name === 'server3-4')
194
195 await rateVideo(servers[2].url, servers[2].accessToken, video4.id, 'like')
196 await rateVideo(servers[2].url, userAccessToken, video4.id, 'dislike')
197 }
198
175 await wait(5000) 199 await wait(5000)
176 200
177 // Server 1 follows server 3 201 // Server 1 follows server 3
@@ -189,6 +213,45 @@ describe('Test follows', function () {
189 expect(video2).to.not.be.undefined 213 expect(video2).to.not.be.undefined
190 expect(video4).to.not.be.undefined 214 expect(video4).to.not.be.undefined
191 expect(video6).to.not.be.undefined 215 expect(video6).to.not.be.undefined
216
217 const res2 = await getVideo(servers[0].url, video4.id)
218 const videoDetails = res2.body
219
220 expect(videoDetails.name).to.equal('server3-4')
221 expect(videoDetails.category).to.equal(2)
222 expect(videoDetails.categoryLabel).to.equal('Films')
223 expect(videoDetails.licence).to.equal(6)
224 expect(videoDetails.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
225 expect(videoDetails.language).to.equal(3)
226 expect(videoDetails.languageLabel).to.equal('Mandarin')
227 expect(videoDetails.nsfw).to.be.ok
228 expect(videoDetails.description).to.equal('my super description')
229 expect(videoDetails.serverHost).to.equal('localhost:9003')
230 expect(videoDetails.account).to.equal('root')
231 expect(videoDetails.likes).to.equal(1)
232 expect(videoDetails.dislikes).to.equal(1)
233 expect(videoDetails.isLocal).to.be.false
234 expect(videoDetails.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
235 expect(dateIsValid(videoDetails.createdAt)).to.be.true
236 expect(dateIsValid(videoDetails.updatedAt)).to.be.true
237 expect(videoDetails.files).to.have.lengthOf(1)
238
239 const file = videoDetails.files[0]
240 const magnetUri = file.magnetUri
241 expect(file.magnetUri).to.have.lengthOf.above(2)
242 expect(file.torrentUrl).to.equal(`${servers[2].url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
243 expect(file.fileUrl).to.equal(`${servers[2].url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
244 expect(file.resolution).to.equal(720)
245 expect(file.resolutionLabel).to.equal('720p')
246 expect(file.size).to.equal(218910)
247
248 const test = await testVideoImage(servers[2].url, 'video_short.webm', videoDetails.thumbnailPath)
249 expect(test).to.equal(true)
250
251 const torrent = await webtorrentAdd(magnetUri)
252 expect(torrent.files).to.be.an('array')
253 expect(torrent.files.length).to.equal(1)
254 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
192 }) 255 })
193 256
194 after(async function () { 257 after(async function () {
diff --git a/server/tests/api/multiple-servers.ts b/server/tests/api/multiple-servers.ts
index 405dcf625..601e5f39a 100644
--- a/server/tests/api/multiple-servers.ts
+++ b/server/tests/api/multiple-servers.ts
@@ -175,7 +175,7 @@ describe('Test multiple servers', function () {
175 await uploadVideo(servers[1].url, userAccessToken, videoAttributes) 175 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
176 176
177 // Transcoding 177 // Transcoding
178 await wait(15000) 178 await wait(25000)
179 179
180 // All servers should have this video 180 // All servers should have this video
181 for (const server of servers) { 181 for (const server of servers) {