aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/single-server.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-12-07 17:03:56 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-12-07 17:05:23 +0100
commit8e7f08b5a5e65195ad6dd3d7850fda57021421f3 (patch)
tree1ee2bff1a5a51643e6b86c6f21e4766013a9213d /server/tests/api/single-server.ts
parent27e1a06c331278e5d37bc5172ee7e4fc968e4b5e (diff)
downloadPeerTube-8e7f08b5a5e65195ad6dd3d7850fda57021421f3.tar.gz
PeerTube-8e7f08b5a5e65195ad6dd3d7850fda57021421f3.tar.zst
PeerTube-8e7f08b5a5e65195ad6dd3d7850fda57021421f3.zip
Make some fields optional when uploading a video
Diffstat (limited to 'server/tests/api/single-server.ts')
-rw-r--r--server/tests/api/single-server.ts82
1 files changed, 60 insertions, 22 deletions
diff --git a/server/tests/api/single-server.ts b/server/tests/api/single-server.ts
index d7e9ad41f..fbb2dd1fb 100644
--- a/server/tests/api/single-server.ts
+++ b/server/tests/api/single-server.ts
@@ -1,40 +1,41 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import * as chai from 'chai'
3import { keyBy } from 'lodash' 4import { keyBy } from 'lodash'
4import { join } from 'path'
5import 'mocha' 5import 'mocha'
6import * as chai from 'chai' 6import { join } from 'path'
7const expect = chai.expect 7import * as request from 'supertest'
8
9import { 8import {
10 ServerInfo,
11 flushTests,
12 runServer,
13 uploadVideo,
14 getVideosList,
15 rateVideo,
16 removeVideo,
17 wait,
18 setAccessTokensToServers,
19 searchVideo,
20 killallServers,
21 dateIsValid, 9 dateIsValid,
10 flushTests,
11 getVideo,
22 getVideoCategories, 12 getVideoCategories,
23 getVideoLicences,
24 getVideoLanguages, 13 getVideoLanguages,
14 getVideoLicences,
25 getVideoPrivacies, 15 getVideoPrivacies,
26 testVideoImage, 16 getVideosList,
27 webtorrentAdd,
28 getVideo,
29 readdirPromise,
30 getVideosListPagination, 17 getVideosListPagination,
31 searchVideoWithPagination,
32 getVideosListSort, 18 getVideosListSort,
19 killallServers,
20 rateVideo,
21 readdirPromise,
22 removeVideo,
23 runServer,
24 searchVideo,
25 searchVideoWithPagination,
33 searchVideoWithSort, 26 searchVideoWithSort,
34 updateVideo 27 ServerInfo,
28 setAccessTokensToServers,
29 testVideoImage,
30 updateVideo,
31 uploadVideo,
32 wait,
33 webtorrentAdd
35} from '../utils' 34} from '../utils'
36import { viewVideo } from '../utils/videos' 35import { viewVideo } from '../utils/videos'
37 36
37const expect = chai.expect
38
38describe('Test a single server', function () { 39describe('Test a single server', function () {
39 let server: ServerInfo = null 40 let server: ServerInfo = null
40 let videoId = -1 41 let videoId = -1
@@ -693,6 +694,43 @@ describe('Test a single server', function () {
693 expect(video.dislikes).to.equal(1) 694 expect(video.dislikes).to.equal(1)
694 }) 695 })
695 696
697 it('Should upload a video with minimum parameters', async function () {
698 const path = '/api/v1/videos/upload'
699
700 const req = request(server.url)
701 .post(path)
702 .set('Accept', 'application/json')
703 .set('Authorization', 'Bearer ' + server.accessToken)
704 .field('name', 'minimum parameters')
705 .field('privacy', '1')
706 .field('nsfw', 'false')
707 .field('channelId', '1')
708
709 const filePath = join(__dirname, '..', 'api', 'fixtures', 'video_short.webm')
710
711 await req.attach('videofile', filePath)
712 .expect(204)
713
714 const res = await getVideosList(server.url)
715 const video = res.body.data.find(v => v.name === 'minimum parameters')
716
717 expect(video.name).to.equal('minimum parameters')
718 expect(video.category).to.equal(null)
719 expect(video.categoryLabel).to.equal('Misc')
720 expect(video.licence).to.equal(null)
721 expect(video.licenceLabel).to.equal('Unknown')
722 expect(video.language).to.equal(null)
723 expect(video.languageLabel).to.equal('Unknown')
724 expect(video.nsfw).to.not.be.ok
725 expect(video.description).to.equal(null)
726 expect(video.serverHost).to.equal('localhost:9001')
727 expect(video.accountName).to.equal('root')
728 expect(video.isLocal).to.be.true
729 expect(video.tags).to.deep.equal([ ])
730 expect(dateIsValid(video.createdAt)).to.be.true
731 expect(dateIsValid(video.updatedAt)).to.be.true
732 })
733
696 after(async function () { 734 after(async function () {
697 killallServers([ server ]) 735 killallServers([ server ])
698 736