Fix tests

This commit is contained in:
Chocobozzz 2018-02-14 18:21:14 +01:00
parent 3bcfff7f44
commit 7b0956ec4f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
10 changed files with 13 additions and 19 deletions

View File

@ -7,7 +7,7 @@ import 'videojs-dock/dist/videojs-dock.es.js'
import { VideoDetails } from '../../../../shared'
function getVideoUrl (id: string) {
return window.location.origin + '/api/v1/videos/' + videoId
return window.location.origin + '/api/v1/videos/' + id
}
async function loadVideoInfo (videoId: string): Promise<VideoDetails> {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -65,8 +65,7 @@ describe('Test users with multiple servers', function () {
const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
user = res.body
const test = await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png')
expect(test).to.equal(true)
await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png')
await wait(5000)
})
@ -83,8 +82,7 @@ describe('Test users with multiple servers', function () {
expect(rootServer1Get.name).to.equal('root')
expect(rootServer1Get.host).to.equal('localhost:9001')
const test = await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png')
expect(test).to.equal(true)
await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png')
}
})

View File

@ -359,8 +359,7 @@ describe('Test users', function () {
const res = await getMyUserInformation(server.url, accessTokenUser)
const user = res.body
const test = await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png')
expect(test).to.equal(true)
await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png')
})
it('Should be able to update another user', async function () {

View File

@ -641,8 +641,7 @@ describe('Test multiple servers', function () {
const res = await getVideo(server.url, videoUUID)
const video = res.body
const test = await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
expect(test).to.equal(true)
await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
}
})
})

View File

@ -341,9 +341,7 @@ describe('Test a single server', function () {
for (const video of videos) {
const videoName = video.name.replace(' name', '')
const test = await testImage(server.url, videoName, video.thumbnailPath)
expect(test).to.equal(true)
await testImage(server.url, videoName, video.thumbnailPath)
}
})

View File

@ -83,8 +83,7 @@ describe('Test video comments', function () {
expect(comment.account.name).to.equal('root')
expect(comment.account.host).to.equal('localhost:9001')
const test = await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
expect(test).to.equal(true)
await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
expect(comment.totalReplies).to.equal(0)
expect(dateIsValid(comment.createdAt as string)).to.be.true

View File

@ -1,10 +1,12 @@
/* tslint:disable:no-unused-expression */
import * as chai from 'chai'
import { isAbsolute, join } from 'path'
import * as request from 'supertest'
import * as WebTorrent from 'webtorrent'
import { readFileBufferPromise } from '../../../helpers/core-utils'
const expect = chai.expect
let webtorrent = new WebTorrent()
function immutableAssign <T, U> (target: T, source: U) {
@ -48,7 +50,8 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
const minLength = body.length - ((20 * body.length) / 100)
const maxLength = body.length + ((20 * body.length) / 100)
return data.length > minLength && data.length < maxLength
expect(data.length).to.be.above(minLength)
expect(data.length).to.be.below(maxLength)
} else {
console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.')
return true

View File

@ -445,13 +445,11 @@ async function completeVideoCheck (
expect(file.size).to.be.above(minSize).and.below(maxSize)
{
const test = await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath)
expect(test).to.equal(true)
await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath)
}
if (attributes.previewfile) {
const test = await testImage(url, attributes.previewfile, videoDetails.previewPath)
expect(test).to.equal(true)
await testImage(url, attributes.previewfile, videoDetails.previewPath)
}
const torrent = await webtorrentAdd(magnetUri, true)