1
0
Fork 0

Refractor check video tests

This commit is contained in:
Chocobozzz 2017-12-29 11:51:55 +01:00
parent a20399c972
commit b1f5b93e4f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 315 additions and 340 deletions

View File

@ -2,7 +2,9 @@
import * as chai from 'chai' import * as chai from 'chai'
import 'mocha' import 'mocha'
import { Video, VideoPrivacy } from '../../../../shared/models/videos'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { completeVideoCheck } from '../../utils'
import { import {
flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
@ -163,7 +165,10 @@ describe('Test follows', function () {
expect(res.body.data[0].name).to.equal('server3') expect(res.body.data[0].name).to.equal('server3')
}) })
it('Should propagate previous uploaded videos on a new following', async function () { describe('Should propagate data on a new following', async function () {
let video4: Video
before(async function () {
this.timeout(20000) this.timeout(20000)
const video4Attributes = { const video4Attributes = {
@ -186,7 +191,7 @@ describe('Test follows', function () {
const userAccessToken = await userLogin(servers[ 2 ], user) const userAccessToken = await userLogin(servers[ 2 ], user)
const resVideos = await getVideosList(servers[ 2 ].url) const resVideos = await getVideosList(servers[ 2 ].url)
const video4 = resVideos.body.data.find(v => v.name === 'server3-4') video4 = resVideos.body.data.find(v => v.name === 'server3-4')
{ {
await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like') await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like')
@ -216,58 +221,53 @@ describe('Test follows', function () {
await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken) await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken)
await wait(7000) await wait(7000)
})
let res = await getVideosList(servers[0].url) it('Should propagate videos', async function () {
const res = await getVideosList(servers[ 0 ].url)
expect(res.body.total).to.equal(7) expect(res.body.total).to.equal(7)
const video2 = res.body.data.find(v => v.name === 'server3-2') const video2 = res.body.data.find(v => v.name === 'server3-2')
const video4 = res.body.data.find(v => v.name === 'server3-4') video4 = res.body.data.find(v => v.name === 'server3-4')
const video6 = res.body.data.find(v => v.name === 'server3-6') const video6 = res.body.data.find(v => v.name === 'server3-6')
expect(video2).to.not.be.undefined expect(video2).to.not.be.undefined
expect(video4).to.not.be.undefined expect(video4).to.not.be.undefined
expect(video6).to.not.be.undefined expect(video6).to.not.be.undefined
const res2 = await getVideo(servers[0].url, video4.id) const isLocal = false
const videoDetails = res2.body const checkAttributes = {
name: 'server3-4',
expect(videoDetails.name).to.equal('server3-4') category: 2,
expect(videoDetails.category).to.equal(2) licence: 6,
expect(videoDetails.categoryLabel).to.equal('Films') language: 3,
expect(videoDetails.licence).to.equal(6) nsfw: true,
expect(videoDetails.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') description: 'my super description',
expect(videoDetails.language).to.equal(3) host: 'localhost:9003',
expect(videoDetails.languageLabel).to.equal('Mandarin') account: 'root',
expect(videoDetails.nsfw).to.be.ok isLocal,
expect(videoDetails.description).to.equal('my super description') duration: 5,
expect(videoDetails.serverHost).to.equal('localhost:9003') tags: [ 'tag1', 'tag2', 'tag3' ],
expect(videoDetails.accountName).to.equal('root') privacy: VideoPrivacy.PUBLIC,
expect(videoDetails.likes).to.equal(1) likes: 1,
expect(videoDetails.dislikes).to.equal(1) dislikes: 1,
expect(videoDetails.isLocal).to.be.false channel: {
expect(videoDetails.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) name: 'Default root channel',
expect(dateIsValid(videoDetails.createdAt)).to.be.true description: '',
expect(dateIsValid(videoDetails.updatedAt)).to.be.true isLocal
expect(videoDetails.files).to.have.lengthOf(1) },
fixture: 'video_short.webm',
const file = videoDetails.files[0] files: [
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('')
{ {
resolution: 720,
size: 218910
}
]
}
await completeVideoCheck(servers[ 0 ].url, video4, checkAttributes)
})
it('Should propagate comments', async function () {
const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5) const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5)
expect(res1.body.total).to.equal(1) expect(res1.body.total).to.equal(1)
@ -304,7 +304,7 @@ describe('Test follows', function () {
const secondChild = tree.children[1] const secondChild = tree.children[1]
expect(secondChild.comment.text).to.equal('my second answer to thread 1') expect(secondChild.comment.text).to.equal('my second answer to thread 1')
expect(secondChild.children).to.have.lengthOf(0) expect(secondChild.children).to.have.lengthOf(0)
} })
}) })
after(async function () { after(async function () {

View File

@ -4,19 +4,18 @@ import * as chai from 'chai'
import 'mocha' import 'mocha'
import { join } from 'path' import { join } from 'path'
import * as request from 'supertest' import * as request from 'supertest'
import { VideoPrivacy } from '../../../../shared/models/videos'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { import {
addVideoChannel, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, userLogin, getVideo, addVideoChannel, completeVideoCheck, createUser, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, getVideo,
getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage, getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage,
updateVideo, uploadVideo, wait, webtorrentAdd updateVideo, uploadVideo, userLogin, viewVideo, wait, webtorrentAdd
} from '../../utils/index' } from '../../utils'
import { createUser } from '../../utils/users/users'
import { import {
addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
getVideoThreadComments getVideoThreadComments
} from '../../utils/videos/video-comments' } from '../../utils/videos/video-comments'
import { viewVideo } from '../../utils/videos/videos'
const expect = chai.expect const expect = chai.expect
@ -80,67 +79,41 @@ describe('Test multiple servers', function () {
// All servers should have this video // All servers should have this video
for (const server of servers) { for (const server of servers) {
let baseMagnet = null const isLocal = server.url === 'http://localhost:9001'
const checkAttributes = {
name: 'my super name for server 1',
category: 5,
licence: 4,
language: 9,
nsfw: true,
description: 'my super description for server 1',
host: 'localhost:9001',
account: 'root',
isLocal,
duration: 10,
tags: [ 'tag1p1', 'tag2p1' ],
privacy: VideoPrivacy.PUBLIC,
channel: {
name: 'my channel',
description: 'super channel',
isLocal
},
fixture: 'video_short.webm',
files: [
{
resolution: 720,
size: 572456
}
]
}
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
const videos = res.body.data const videos = res.body.data
expect(videos).to.be.an('array') expect(videos).to.be.an('array')
expect(videos.length).to.equal(1) expect(videos.length).to.equal(1)
const video = videos[0] const video = videos[0]
expect(video.name).to.equal('my super name for server 1')
expect(video.category).to.equal(5)
expect(video.categoryLabel).to.equal('Sports')
expect(video.licence).to.equal(4)
expect(video.licenceLabel).to.equal('Attribution - Non Commercial')
expect(video.language).to.equal(9)
expect(video.languageLabel).to.equal('Japanese')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description for server 1')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.duration).to.equal(10)
expect(dateIsValid(video.createdAt)).to.be.true
expect(dateIsValid(video.updatedAt)).to.be.true
expect(video.accountName).to.equal('root')
const res2 = await getVideo(server.url, video.uuid) await completeVideoCheck(server.url, video, checkAttributes)
const videoDetails = res2.body
expect(videoDetails.channel.name).to.equal('my channel')
expect(videoDetails.channel.description).to.equal('super channel')
expect(videoDetails.account.name).to.equal('root')
expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true
expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
expect(videoDetails.files).to.have.lengthOf(1)
expect(videoDetails.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
const file = videoDetails.files[0]
const magnetUri = file.magnetUri
expect(file.magnetUri).to.have.lengthOf.above(2)
expect(file.torrentUrl).to
.equal(`http://${videoDetails.serverHost}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
expect(file.fileUrl).to.equal(`http://${videoDetails.serverHost}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
expect(file.resolution).to.equal(720)
expect(file.resolutionLabel).to.equal('720p')
expect(file.size).to.equal(572456)
if (server.url !== 'http://localhost:9001') {
expect(video.isLocal).to.be.false
expect(videoDetails.channel.isLocal).to.be.false
} else {
expect(video.isLocal).to.be.true
expect(videoDetails.channel.isLocal).to.be.true
}
// All servers should have the same magnet Uri
if (baseMagnet === null) {
baseMagnet = magnetUri
} else {
expect(baseMagnet).to.equal(magnetUri)
}
const test = await testVideoImage(server.url, 'video_short1.webm', video.thumbnailPath)
expect(test).to.equal(true)
} }
}) })
@ -171,79 +144,53 @@ describe('Test multiple servers', function () {
// All servers should have this video // All servers should have this video
for (const server of servers) { for (const server of servers) {
let baseMagnet = {} const isLocal = server.url === 'http://localhost:9002'
const checkAttributes = {
name: 'my super name for server 2',
category: 4,
licence: 3,
language: 11,
nsfw: true,
description: 'my super description for server 2',
host: 'localhost:9002',
account: 'user1',
isLocal,
duration: 5,
tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
privacy: VideoPrivacy.PUBLIC,
channel: {
name: 'Default user1 channel',
description: 'super channel',
isLocal
},
fixture: 'video_short2.webm',
files: [
{
resolution: 240,
size: 190000
},
{
resolution: 360,
size: 280000
},
{
resolution: 480,
size: 390000
},
{
resolution: 720,
size: 710000
}
]
}
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
const videos = res.body.data const videos = res.body.data
expect(videos).to.be.an('array') expect(videos).to.be.an('array')
expect(videos.length).to.equal(2) expect(videos.length).to.equal(2)
const video = videos[1] const video = videos[1]
expect(video.name).to.equal('my super name for server 2')
expect(video.category).to.equal(4)
expect(video.categoryLabel).to.equal('Art')
expect(video.licence).to.equal(3)
expect(video.licenceLabel).to.equal('Attribution - No Derivatives')
expect(video.language).to.equal(11)
expect(video.languageLabel).to.equal('German')
expect(video.nsfw).to.be.true
expect(video.description).to.equal('my super description for server 2')
expect(video.serverHost).to.equal('localhost:9002')
expect(video.duration).to.equal(5)
expect(dateIsValid(video.createdAt)).to.be.true
expect(dateIsValid(video.updatedAt)).to.be.true
expect(video.accountName).to.equal('user1')
if (server.url !== 'http://localhost:9002') { await completeVideoCheck(server.url, video, checkAttributes)
expect(video.isLocal).to.be.false
} else {
expect(video.isLocal).to.be.true
}
const res2 = await getVideo(server.url, video.uuid)
const videoDetails = res2.body
expect(videoDetails.channel.name).to.equal('Default user1 channel')
expect(dateIsValid(videoDetails.channel.createdAt)).to.be.true
expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
expect(videoDetails.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
expect(videoDetails.files).to.have.lengthOf(4)
// Check common attributes
for (const file of videoDetails.files) {
expect(file.magnetUri).to.have.lengthOf.above(2)
// All servers should have the same magnet Uri
if (baseMagnet[file.resolution] === undefined) {
baseMagnet[file.resolution] = file.magnet
} else {
expect(baseMagnet[file.resolution]).to.equal(file.magnet)
}
}
const file240p = videoDetails.files.find(f => f.resolution === 240)
expect(file240p).not.to.be.undefined
expect(file240p.resolutionLabel).to.equal('240p')
expect(file240p.size).to.be.above(180000).and.below(200000)
const file360p = videoDetails.files.find(f => f.resolution === 360)
expect(file360p).not.to.be.undefined
expect(file360p.resolutionLabel).to.equal('360p')
expect(file360p.size).to.be.above(270000).and.below(290000)
const file480p = videoDetails.files.find(f => f.resolution === 480)
expect(file480p).not.to.be.undefined
expect(file480p.resolutionLabel).to.equal('480p')
expect(file480p.size).to.be.above(380000).and.below(400000)
const file720p = videoDetails.files.find(f => f.resolution === 720)
expect(file720p).not.to.be.undefined
expect(file720p.resolutionLabel).to.equal('720p')
expect(file720p.size).to.be.above(700000).and.below(7200000)
const test = await testVideoImage(server.url, 'video_short2.webm', videoDetails.thumbnailPath)
expect(test).to.equal(true)
} }
}) })
@ -276,9 +223,9 @@ describe('Test multiple servers', function () {
await wait(10000) await wait(10000)
let baseMagnet = null
// All servers should have this video // All servers should have this video
for (const server of servers) { for (const server of servers) {
const isLocal = server.url === 'http://localhost:9003'
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
const videos = res.body.data const videos = res.body.data
@ -296,80 +243,61 @@ describe('Test multiple servers', function () {
video2 = videos[2] video2 = videos[2]
} }
expect(video1.name).to.equal('my super name for server 3') const checkAttributesVideo1 = {
expect(video1.category).to.equal(6) name: 'my super name for server 3',
expect(video1.categoryLabel).to.equal('Travels') category: 6,
expect(video1.licence).to.equal(5) licence: 5,
expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike') language: 11,
expect(video1.language).to.equal(11) nsfw: true,
expect(video1.languageLabel).to.equal('German') description: 'my super description for server 3',
expect(video1.nsfw).to.be.ok host: 'localhost:9003',
expect(video1.description).to.equal('my super description for server 3') account: 'root',
expect(video1.serverHost).to.equal('localhost:9003') isLocal,
expect(video1.duration).to.equal(5) duration: 5,
expect(video1.accountName).to.equal('root') tags: [ 'tag1p3' ],
expect(dateIsValid(video1.createdAt)).to.be.true privacy: VideoPrivacy.PUBLIC,
expect(dateIsValid(video1.updatedAt)).to.be.true channel: {
name: 'Default root channel',
const res2 = await getVideo(server.url, video1.id) description: '',
const video1Details = res2.body isLocal
expect(video1Details.files).to.have.lengthOf(1) },
expect(video1Details.tags).to.deep.equal([ 'tag1p3' ]) fixture: 'video_short3.webm',
files: [
const file1 = video1Details.files[0] {
expect(file1.magnetUri).to.have.lengthOf.above(2) resolution: 720,
expect(file1.resolution).to.equal(720) size: 292677
expect(file1.resolutionLabel).to.equal('720p')
expect(file1.size).to.equal(292677)
expect(video2.name).to.equal('my super name for server 3-2')
expect(video2.category).to.equal(7)
expect(video2.categoryLabel).to.equal('Gaming')
expect(video2.licence).to.equal(6)
expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
expect(video2.language).to.equal(12)
expect(video2.languageLabel).to.equal('Korean')
expect(video2.nsfw).to.be.false
expect(video2.description).to.equal('my super description for server 3-2')
expect(video2.serverHost).to.equal('localhost:9003')
expect(video2.duration).to.equal(5)
expect(video2.accountName).to.equal('root')
expect(dateIsValid(video2.createdAt)).to.be.true
expect(dateIsValid(video2.updatedAt)).to.be.true
const res3 = await getVideo(server.url, video2.id)
const video2Details = res3.body
expect(video2Details.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
expect(video2Details.files).to.have.lengthOf(1)
const file2 = video2Details.files[0]
const magnetUri2 = file2.magnetUri
expect(file2.magnetUri).to.have.lengthOf.above(2)
expect(file2.resolution).to.equal(720)
expect(file2.resolutionLabel).to.equal('720p')
expect(file2.size).to.equal(218910)
if (server.url !== 'http://localhost:9003') {
expect(video1.isLocal).to.be.false
expect(video2.isLocal).to.be.false
} else {
expect(video1.isLocal).to.be.true
expect(video2.isLocal).to.be.true
} }
]
// All servers should have the same magnet Uri
if (baseMagnet === null) {
baseMagnet = magnetUri2
} else {
expect(baseMagnet).to.equal(magnetUri2)
} }
await completeVideoCheck(server.url, video1, checkAttributesVideo1)
const test1 = await testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath) const checkAttributesVideo2 = {
expect(test1).to.equal(true) name: 'my super name for server 3-2',
category: 7,
const test2 = await testVideoImage(server.url, 'video_short.webm', video2.thumbnailPath) licence: 6,
expect(test2).to.equal(true) language: 12,
nsfw: false,
description: 'my super description for server 3-2',
host: 'localhost:9003',
account: 'root',
isLocal,
duration: 5,
tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
privacy: VideoPrivacy.PUBLIC,
channel: {
name: 'Default root channel',
description: '',
isLocal
},
fixture: 'video_short3.webm',
files: [
{
resolution: 720,
size: 218910
}
]
}
await completeVideoCheck(server.url, video2, checkAttributesVideo2)
} }
}) })
}) })
@ -387,7 +315,7 @@ describe('Test multiple servers', function () {
const res2 = await getVideo(servers[2].url, video.id) const res2 = await getVideo(servers[2].url, video.id)
const videoDetails = res2.body const videoDetails = res2.body
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
expect(torrent.files).to.be.an('array') expect(torrent.files).to.be.an('array')
expect(torrent.files.length).to.equal(1) expect(torrent.files.length).to.equal(1)
expect(torrent.files[0].path).to.exist.and.to.not.equal('') expect(torrent.files[0].path).to.exist.and.to.not.equal('')
@ -402,7 +330,7 @@ describe('Test multiple servers', function () {
const res2 = await getVideo(servers[0].url, video.id) const res2 = await getVideo(servers[0].url, video.id)
const videoDetails = res2.body const videoDetails = res2.body
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
expect(torrent.files).to.be.an('array') expect(torrent.files).to.be.an('array')
expect(torrent.files.length).to.equal(1) expect(torrent.files.length).to.equal(1)
expect(torrent.files[0].path).to.exist.and.to.not.equal('') expect(torrent.files[0].path).to.exist.and.to.not.equal('')
@ -417,7 +345,7 @@ describe('Test multiple servers', function () {
const res2 = await getVideo(servers[1].url, video.id) const res2 = await getVideo(servers[1].url, video.id)
const videoDetails = res2.body const videoDetails = res2.body
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
expect(torrent.files).to.be.an('array') expect(torrent.files).to.be.an('array')
expect(torrent.files.length).to.equal(1) expect(torrent.files.length).to.equal(1)
expect(torrent.files[0].path).to.exist.and.to.not.equal('') expect(torrent.files[0].path).to.exist.and.to.not.equal('')
@ -603,37 +531,36 @@ describe('Test multiple servers', function () {
const videos = res.body.data const videos = res.body.data
const videoUpdated = videos.find(video => video.name === 'my super video updated') const videoUpdated = videos.find(video => video.name === 'my super video updated')
expect(!!videoUpdated).to.be.true expect(!!videoUpdated).to.be.true
expect(videoUpdated.category).to.equal(10)
expect(videoUpdated.categoryLabel).to.equal('Entertainment')
expect(videoUpdated.licence).to.equal(7)
expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication')
expect(videoUpdated.language).to.equal(13)
expect(videoUpdated.languageLabel).to.equal('French')
expect(videoUpdated.nsfw).to.be.ok
expect(videoUpdated.description).to.equal('my super description updated')
expect(dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
const res2 = await getVideo(server.url, videoUpdated.uuid) const isLocal = server.url === 'http://localhost:9003'
const videoUpdatedDetails = res2.body const checkAttributes = {
expect(videoUpdatedDetails.tags).to.deep.equal([ 'tag_up_1', 'tag_up_2' ]) name: 'my super video updated',
category: 10,
const file = videoUpdatedDetails.files[0] licence: 7,
expect(file.magnetUri).to.have.lengthOf.above(2) language: 13,
expect(file.resolution).to.equal(720) nsfw: true,
expect(file.resolutionLabel).to.equal('720p') description: 'my super description updated',
expect(file.size).to.equal(292677) host: 'localhost:9003',
account: 'root',
const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath) isLocal,
expect(test).to.equal(true) duration: 5,
tags: [ 'tag_up_1', 'tag_up_2' ],
// Avoid "duplicate torrent" errors privacy: VideoPrivacy.PUBLIC,
const refreshWebTorrent = true channel: {
const torrent = await webtorrentAdd(videoUpdatedDetails .files[0].magnetUri, refreshWebTorrent) name: 'Default root channel',
expect(torrent.files).to.be.an('array') description: '',
expect(torrent.files.length).to.equal(1) isLocal
expect(torrent.files[0].path).to.exist.and.to.not.equal('') },
fixture: 'video_short3.webm',
files: [
{
resolution: 720,
size: 292677
}
]
}
await completeVideoCheck(server.url, videoUpdated, checkAttributes)
} }
}) })
@ -833,19 +760,46 @@ describe('Test multiple servers', function () {
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
const video = res.body.data.find(v => v.name === 'minimum parameters') const video = res.body.data.find(v => v.name === 'minimum parameters')
expect(video.name).to.equal('minimum parameters') const isLocal = server.url === 'http://localhost:9002'
expect(video.category).to.equal(null) const checkAttributes = {
expect(video.categoryLabel).to.equal('Misc') name: 'minimum parameters',
expect(video.licence).to.equal(null) category: null,
expect(video.licenceLabel).to.equal('Unknown') licence: null,
expect(video.language).to.equal(null) language: null,
expect(video.languageLabel).to.equal('Unknown') nsfw: false,
expect(video.nsfw).to.not.be.ok description: null,
expect(video.description).to.equal(null) host: 'localhost:9002',
expect(video.serverHost).to.equal('localhost:9002') account: 'root',
expect(video.accountName).to.equal('root') isLocal,
expect(dateIsValid(video.createdAt)).to.be.true duration: 5,
expect(dateIsValid(video.updatedAt)).to.be.true tags: [ ],
privacy: VideoPrivacy.PUBLIC,
channel: {
name: 'Default root channel',
description: '',
isLocal
},
fixture: 'video_short.webm',
files: [
{
resolution: 720,
size: 40315
},
{
resolution: 480,
size: 22808
},
{
resolution: 360,
size: 18617
},
{
resolution: 240,
size: 15217
}
]
}
await completeVideoCheck(server.url, video, checkAttributes)
} }
}) })
}) })

View File

@ -52,10 +52,12 @@ describe('Test a single server', function () {
host: 'localhost:9001', host: 'localhost:9001',
account: 'root', account: 'root',
isLocal: true, isLocal: true,
duration: 5,
tags: [ 'tag1', 'tag2', 'tag3' ], tags: [ 'tag1', 'tag2', 'tag3' ],
privacy: VideoPrivacy.PUBLIC, privacy: VideoPrivacy.PUBLIC,
channel: { channel: {
name: 'Default root channel', name: 'Default root channel',
description: '',
isLocal: true isLocal: true
}, },
fixture: 'video_short.webm', fixture: 'video_short.webm',
@ -79,8 +81,10 @@ describe('Test a single server', function () {
isLocal: true, isLocal: true,
tags: [ 'tagup1', 'tagup2' ], tags: [ 'tagup1', 'tagup2' ],
privacy: VideoPrivacy.PUBLIC, privacy: VideoPrivacy.PUBLIC,
duration: 5,
channel: { channel: {
name: 'Default root channel', name: 'Default root channel',
description: '',
isLocal: true isLocal: true
}, },
fixture: 'video_short3.webm', fixture: 'video_short3.webm',

View File

@ -27,8 +27,8 @@ function readdirPromise (path: string) {
}) })
} }
// Default interval -> 2 minutes // Default interval -> 5 minutes
function dateIsValid (dateString: string, interval = 120000) { function dateIsValid (dateString: string, interval = 300000) {
const dateToCheck = new Date(dateString) const dateToCheck = new Date(dateString)
const now = new Date() const now = new Date()

View File

@ -3,7 +3,7 @@
import { expect } from 'chai' import { expect } from 'chai'
import { readFile } from 'fs' import { readFile } from 'fs'
import * as parseTorrent from 'parse-torrent' import * as parseTorrent from 'parse-torrent'
import { isAbsolute, join } from 'path' import { extname, isAbsolute, join } from 'path'
import * as request from 'supertest' import * as request from 'supertest'
import { getMyUserInformation, makeGetRequest, readFilePromise, ServerInfo } from '../' import { getMyUserInformation, makeGetRequest, readFilePromise, ServerInfo } from '../'
import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoPrivacy } from '../../../../shared/models/videos'
@ -332,8 +332,12 @@ async function completeVideoCheck (
isLocal: boolean, isLocal: boolean,
tags: string[], tags: string[],
privacy: number, privacy: number,
likes?: number,
dislikes?: number,
duration: number,
channel: { channel: {
name: string, name: string,
description
isLocal: boolean isLocal: boolean
} }
fixture: string, fixture: string,
@ -343,18 +347,24 @@ async function completeVideoCheck (
}[] }[]
} }
) { ) {
if (!attributes.likes) attributes.likes = 0
if (!attributes.dislikes) attributes.dislikes = 0
expect(video.name).to.equal(attributes.name) expect(video.name).to.equal(attributes.name)
expect(video.category).to.equal(attributes.category) expect(video.category).to.equal(attributes.category)
expect(video.categoryLabel).to.equal(VIDEO_CATEGORIES[attributes.category]) expect(video.categoryLabel).to.equal(VIDEO_CATEGORIES[attributes.category] || 'Misc')
expect(video.licence).to.equal(attributes.licence) expect(video.licence).to.equal(attributes.licence)
expect(video.licenceLabel).to.equal(VIDEO_LICENCES[attributes.licence]) expect(video.licenceLabel).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown')
expect(video.language).to.equal(attributes.language) expect(video.language).to.equal(attributes.language)
expect(video.languageLabel).to.equal(VIDEO_LANGUAGES[attributes.language]) expect(video.languageLabel).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown')
expect(video.nsfw).to.equal(attributes.nsfw) expect(video.nsfw).to.equal(attributes.nsfw)
expect(video.description).to.equal(attributes.description) expect(video.description).to.equal(attributes.description)
expect(video.serverHost).to.equal(attributes.host) expect(video.serverHost).to.equal(attributes.host)
expect(video.accountName).to.equal(attributes.account) expect(video.accountName).to.equal(attributes.account)
expect(video.likes).to.equal(attributes.likes)
expect(video.dislikes).to.equal(attributes.dislikes)
expect(video.isLocal).to.equal(attributes.isLocal) expect(video.isLocal).to.equal(attributes.isLocal)
expect(video.duration).to.equal(attributes.duration)
expect(dateIsValid(video.createdAt)).to.be.true expect(dateIsValid(video.createdAt)).to.be.true
expect(dateIsValid(video.updatedAt)).to.be.true expect(dateIsValid(video.updatedAt)).to.be.true
@ -376,13 +386,20 @@ async function completeVideoCheck (
const file = videoDetails.files.find(f => f.resolution === attributeFile.resolution) const file = videoDetails.files.find(f => f.resolution === attributeFile.resolution)
expect(file).not.to.be.undefined expect(file).not.to.be.undefined
let extension = extname(attributes.fixture)
// Transcoding enabled on server 2, extension will always be .mp4
if (attributes.host === 'localhost:9002') extension = '.mp4'
const magnetUri = file.magnetUri const magnetUri = file.magnetUri
expect(file.magnetUri).to.have.lengthOf.above(2) expect(file.magnetUri).to.have.lengthOf.above(2)
expect(file.torrentUrl).to.equal(`${url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) expect(file.torrentUrl).to.equal(`http://${attributes.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
expect(file.fileUrl).to.equal(`${url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`) expect(file.fileUrl).to.equal(`http://${attributes.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`)
expect(file.resolution).to.equal(attributeFile.resolution) expect(file.resolution).to.equal(attributeFile.resolution)
expect(file.resolutionLabel).to.equal(attributeFile.resolution + 'p') expect(file.resolutionLabel).to.equal(attributeFile.resolution + 'p')
expect(file.size).to.equal(attributeFile.size)
const minSize = attributeFile.size - ((10 * attributeFile.size) / 100)
const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100)
expect(file.size).to.be.above(minSize).and.below(maxSize)
const test = await testVideoImage(url, attributes.fixture, videoDetails.thumbnailPath) const test = await testVideoImage(url, attributes.fixture, videoDetails.thumbnailPath)
expect(test).to.equal(true) expect(test).to.equal(true)