diff options
Diffstat (limited to 'server/tests/api/single-server.ts')
-rw-r--r-- | server/tests/api/single-server.ts | 82 |
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 | ||
3 | import * as chai from 'chai' | ||
3 | import { keyBy } from 'lodash' | 4 | import { keyBy } from 'lodash' |
4 | import { join } from 'path' | ||
5 | import 'mocha' | 5 | import 'mocha' |
6 | import * as chai from 'chai' | 6 | import { join } from 'path' |
7 | const expect = chai.expect | 7 | import * as request from 'supertest' |
8 | |||
9 | import { | 8 | import { |
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' |
36 | import { viewVideo } from '../utils/videos' | 35 | import { viewVideo } from '../utils/videos' |
37 | 36 | ||
37 | const expect = chai.expect | ||
38 | |||
38 | describe('Test a single server', function () { | 39 | describe('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 | ||