mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Add check param tests regarding video imports
This commit is contained in:
parent
a84b8fa5cf
commit
187501f8b8
4 changed files with 102 additions and 7 deletions
|
@ -3,7 +3,7 @@
|
|||
import { omit } from 'lodash'
|
||||
import 'mocha'
|
||||
import { join } from 'path'
|
||||
import { UserRole } from '../../../../shared'
|
||||
import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
|
||||
|
||||
import {
|
||||
createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
|
||||
|
@ -11,6 +11,10 @@ import {
|
|||
updateUser, uploadVideo, userLogin
|
||||
} from '../../utils'
|
||||
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
|
||||
import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports'
|
||||
import { VideoPrivacy } from '../../../../shared/models/videos'
|
||||
import { waitJobs } from '../../utils/server/jobs'
|
||||
import { expect } from 'chai'
|
||||
|
||||
describe('Test users API validators', function () {
|
||||
const path = '/api/v1/users/'
|
||||
|
@ -20,6 +24,7 @@ describe('Test users API validators', function () {
|
|||
let server: ServerInfo
|
||||
let serverWithRegistrationDisabled: ServerInfo
|
||||
let userAccessToken = ''
|
||||
let channelId: number
|
||||
const user = {
|
||||
username: 'user1',
|
||||
password: 'my super password'
|
||||
|
@ -41,8 +46,15 @@ describe('Test users API validators', function () {
|
|||
await createUser(server.url, server.accessToken, user.username, user.password, videoQuota)
|
||||
userAccessToken = await userLogin(server, user)
|
||||
|
||||
const res = await uploadVideo(server.url, server.accessToken, {})
|
||||
videoId = res.body.video.id
|
||||
{
|
||||
const res = await getMyUserInformation(server.url, server.accessToken)
|
||||
channelId = res.body.videoChannels[ 0 ].id
|
||||
}
|
||||
|
||||
{
|
||||
const res = await uploadVideo(server.url, server.accessToken, {})
|
||||
videoId = res.body.video.id
|
||||
}
|
||||
})
|
||||
|
||||
describe('When listing users', function () {
|
||||
|
@ -605,6 +617,32 @@ describe('Test users API validators', function () {
|
|||
await uploadVideo(server.url, userAccessToken, videoAttributes)
|
||||
await uploadVideo(server.url, userAccessToken, videoAttributes, 403)
|
||||
})
|
||||
|
||||
it('Should fail to import with HTTP/Torrent/magnet', async function () {
|
||||
this.timeout(30000)
|
||||
|
||||
const baseAttributes = {
|
||||
channelId: 1,
|
||||
privacy: VideoPrivacy.PUBLIC
|
||||
}
|
||||
await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }))
|
||||
await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
|
||||
await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: '60fps_small-240p.torrent' }))
|
||||
|
||||
await waitJobs([ server ])
|
||||
|
||||
const res = await getMyVideoImports(server.url, server.accessToken)
|
||||
|
||||
expect(res.body.total).to.equal(3)
|
||||
const videoImports: VideoImport[] = res.body.data
|
||||
expect(videoImports).to.have.lengthOf(3)
|
||||
|
||||
for (const videoImport of videoImports) {
|
||||
expect(videoImport.state.id).to.equal(VideoImportState.FAILED)
|
||||
expect(videoImport.error).not.to.be.undefined
|
||||
expect(videoImport.error).to.contain('user video quota is exceeded')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('When asking a password reset', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue