Add banner tests

This commit is contained in:
Chocobozzz
2021-04-07 10:36:13 +02:00
committed by Chocobozzz
parent 2cb03dc1f4
commit 213e30ef90
18 changed files with 211 additions and 126 deletions

View File

@@ -234,7 +234,8 @@ describe('Test video channels API validator', function () {
})
})
describe('When updating video channel avatar', function () {
describe('When updating video channel avatar/banner', function () {
const types = [ 'avatar', 'banner' ]
let path: string
before(async function () {
@@ -242,48 +243,57 @@ describe('Test video channels API validator', function () {
})
it('Should fail with an incorrect input file', async function () {
const fields = {}
const attaches = {
avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
for (const type of types) {
const fields = {}
const attaches = {
[type + 'file']: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches })
}
await makeUploadRequest({ url: server.url, path: path + '/avatar/pick', token: server.accessToken, fields, attaches })
})
it('Should fail with a big file', async function () {
const fields = {}
const attaches = {
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
for (const type of types) {
const fields = {}
const attaches = {
[type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches })
}
await makeUploadRequest({ url: server.url, path: path + '/avatar/pick', token: server.accessToken, fields, attaches })
})
it('Should fail with an unauthenticated user', async function () {
const fields = {}
const attaches = {
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
for (const type of types) {
const fields = {}
const attaches = {
[type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
url: server.url,
path: `${path}/${type}/pick`,
fields,
attaches,
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
})
}
await makeUploadRequest({
url: server.url,
path: path + '/avatar/pick',
fields,
attaches,
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
})
})
it('Should succeed with the correct params', async function () {
const fields = {}
const attaches = {
avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
for (const type of types) {
const fields = {}
const attaches = {
[type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
url: server.url,
path: `${path}/${type}/pick`,
token: server.accessToken,
fields,
attaches,
statusCodeExpected: HttpStatusCode.OK_200
})
}
await makeUploadRequest({
url: server.url,
path: path + '/avatar/pick',
token: server.accessToken,
fields,
attaches,
statusCodeExpected: HttpStatusCode.OK_200
})
})
})

View File

@@ -5,13 +5,14 @@ import * as chai from 'chai'
import {
cleanupTests,
createUser,
deleteVideoChannelImage,
doubleFollow,
flushAndRunMultipleServers,
getVideo,
getVideoChannelVideos,
testImage,
updateVideo,
updateVideoChannelAvatar,
updateVideoChannelImage,
uploadVideo,
userLogin,
wait
@@ -21,7 +22,6 @@ import {
deleteVideoChannel,
getAccountVideoChannelsList,
getMyUserInformation,
getVideoChannel,
getVideoChannelsList,
ServerInfo,
setAccessTokensToServers,
@@ -33,6 +33,13 @@ import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/inde
const expect = chai.expect
async function findChannel (server: ServerInfo, channelId: number) {
const res = await getVideoChannelsList(server.url, 0, 5, '-name')
const videoChannel = res.body.data.find(c => c.id === channelId)
return videoChannel as VideoChannel
}
describe('Test video channels', function () {
let servers: ServerInfo[]
let userInfo: User
@@ -262,38 +269,85 @@ describe('Test video channels', function () {
})
it('Should update video channel avatar', async function () {
this.timeout(5000)
this.timeout(15000)
const fixture = 'avatar.png'
await updateVideoChannelAvatar({
await updateVideoChannelImage({
url: servers[0].url,
accessToken: servers[0].accessToken,
videoChannelName: 'second_video_channel',
fixture
fixture,
type: 'avatar'
})
await waitJobs(servers)
})
it('Should have video channel avatar updated', async function () {
for (const server of servers) {
const res = await getVideoChannelsList(server.url, 0, 1, '-name')
const videoChannel = res.body.data.find(c => c.id === secondVideoChannelId)
const videoChannel = await findChannel(server, secondVideoChannelId)
await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png')
}
})
it('Should get video channel', async function () {
const res = await getVideoChannel(servers[0].url, 'second_video_channel')
it('Should update video channel banner', async function () {
this.timeout(15000)
const videoChannel = res.body
expect(videoChannel.name).to.equal('second_video_channel')
expect(videoChannel.displayName).to.equal('video channel updated')
expect(videoChannel.description).to.equal('video channel description updated')
expect(videoChannel.support).to.equal('video channel support text updated')
const fixture = 'banner.jpg'
await updateVideoChannelImage({
url: servers[0].url,
accessToken: servers[0].accessToken,
videoChannelName: 'second_video_channel',
fixture,
type: 'banner'
})
await waitJobs(servers)
for (const server of servers) {
const videoChannel = await findChannel(server, secondVideoChannelId)
await testImage(server.url, 'banner-resized', videoChannel.banner.path)
}
})
it('Should delete the video channel avatar', async function () {
this.timeout(15000)
await deleteVideoChannelImage({
url: servers[0].url,
accessToken: servers[0].accessToken,
videoChannelName: 'second_video_channel',
type: 'avatar'
})
await waitJobs(servers)
for (const server of servers) {
const videoChannel = await findChannel(server, secondVideoChannelId)
expect(videoChannel.avatar).to.be.null
}
})
it('Should delete the video channel banner', async function () {
this.timeout(15000)
await deleteVideoChannelImage({
url: servers[0].url,
accessToken: servers[0].accessToken,
videoChannelName: 'second_video_channel',
type: 'banner'
})
await waitJobs(servers)
for (const server of servers) {
const videoChannel = await findChannel(server, secondVideoChannelId)
expect(videoChannel.banner).to.be.null
}
})
it('Should list the second video channel videos', async function () {