From d8553faa4939889fa7b7ef7329aa474a81cbbdb9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 23 Nov 2017 14:37:00 +0100 Subject: Better follows tests --- server/tests/api/follows.ts | 65 +++++++++++++++++++++++++++++++++++- server/tests/api/multiple-servers.ts | 2 +- 2 files changed, 65 insertions(+), 2 deletions(-) (limited to 'server/tests/api') 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 { wait } from '../utils' import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows' +import { getUserAccessToken } from '../utils/login' +import { dateIsValid, webtorrentAdd } from '../utils/miscs' +import { createUser } from '../utils/users' +import { getVideo, rateVideo, testVideoImage } from '../utils/videos' const expect = chai.expect @@ -166,12 +170,32 @@ describe('Test follows', function () { it('Should propagate previous uploaded videos on a new following', async function () { this.timeout(20000) + const video4Attributes = { + name: 'server3-4', + category: 2, + nsfw: true, + licence: 6, + tags: [ 'tag1', 'tag2', 'tag3' ] + } + await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' }) await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' }) - await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-4' }) + await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes) await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' }) await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' }) + { + const user = { username: 'captain', password: 'password' } + await createUser(servers[2].url, servers[2].accessToken, user.username, user.password) + const userAccessToken = await getUserAccessToken(servers[2], user) + + const res = await getVideosList(servers[2].url) + const video4 = res.body.data.find(v => v.name === 'server3-4') + + await rateVideo(servers[2].url, servers[2].accessToken, video4.id, 'like') + await rateVideo(servers[2].url, userAccessToken, video4.id, 'dislike') + } + await wait(5000) // Server 1 follows server 3 @@ -189,6 +213,45 @@ describe('Test follows', function () { expect(video2).to.not.be.undefined expect(video4).to.not.be.undefined expect(video6).to.not.be.undefined + + const res2 = await getVideo(servers[0].url, video4.id) + const videoDetails = res2.body + + expect(videoDetails.name).to.equal('server3-4') + expect(videoDetails.category).to.equal(2) + expect(videoDetails.categoryLabel).to.equal('Films') + expect(videoDetails.licence).to.equal(6) + expect(videoDetails.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') + expect(videoDetails.language).to.equal(3) + expect(videoDetails.languageLabel).to.equal('Mandarin') + expect(videoDetails.nsfw).to.be.ok + expect(videoDetails.description).to.equal('my super description') + expect(videoDetails.serverHost).to.equal('localhost:9003') + expect(videoDetails.account).to.equal('root') + expect(videoDetails.likes).to.equal(1) + expect(videoDetails.dislikes).to.equal(1) + expect(videoDetails.isLocal).to.be.false + expect(videoDetails.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) + expect(dateIsValid(videoDetails.createdAt)).to.be.true + expect(dateIsValid(videoDetails.updatedAt)).to.be.true + expect(videoDetails.files).to.have.lengthOf(1) + + const file = videoDetails.files[0] + const magnetUri = file.magnetUri + expect(file.magnetUri).to.have.lengthOf.above(2) + expect(file.torrentUrl).to.equal(`${servers[2].url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) + expect(file.fileUrl).to.equal(`${servers[2].url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`) + expect(file.resolution).to.equal(720) + expect(file.resolutionLabel).to.equal('720p') + expect(file.size).to.equal(218910) + + const test = await testVideoImage(servers[2].url, 'video_short.webm', videoDetails.thumbnailPath) + expect(test).to.equal(true) + + const torrent = await webtorrentAdd(magnetUri) + expect(torrent.files).to.be.an('array') + expect(torrent.files.length).to.equal(1) + expect(torrent.files[0].path).to.exist.and.to.not.equal('') }) 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 () { await uploadVideo(servers[1].url, userAccessToken, videoAttributes) // Transcoding - await wait(15000) + await wait(25000) // All servers should have this video for (const server of servers) { -- cgit v1.2.3