aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-03 10:12:36 +0100
committerChocobozzz <me@florianbigard.com>2018-01-03 10:38:19 +0100
commit47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04 (patch)
tree25e2836baf3dfce6f422192d98332db1bfe65890 /server/tests/api/check-params
parentc5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (diff)
downloadPeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.tar.gz
PeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.tar.zst
PeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.zip
Add ability to disable video comments
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/users.ts16
-rw-r--r--server/tests/api/check-params/video-comments.ts35
-rw-r--r--server/tests/api/check-params/videos.ts22
3 files changed, 65 insertions, 8 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 44412ad82..33d92ac24 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -2,14 +2,13 @@
2 2
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import 'mocha' 4import 'mocha'
5import { join } from "path" 5import { join } from 'path'
6import { UserRole } from '../../../../shared' 6import { UserRole } from '../../../../shared'
7 7
8import { 8import {
9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, 9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
10 makePostBodyRequest, makePostUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers, 10 makePostBodyRequest, makePostUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,
11 updateUser, 11 updateUser, uploadVideo, userLogin
12 uploadVideo, userLogin
13} from '../../utils' 12} from '../../utils'
14import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 13import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
15 14
@@ -25,7 +24,7 @@ describe('Test users API validators', function () {
25 // --------------------------------------------------------------- 24 // ---------------------------------------------------------------
26 25
27 before(async function () { 26 before(async function () {
28 this.timeout(120000) 27 this.timeout(20000)
29 28
30 await flushTests() 29 await flushTests()
31 30
@@ -282,7 +281,14 @@ describe('Test users API validators', function () {
282 const attaches = { 281 const attaches = {
283 'avatarfile': join(__dirname, '..', 'fixtures', 'avatar.png') 282 'avatarfile': join(__dirname, '..', 'fixtures', 'avatar.png')
284 } 283 }
285 await makePostUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) 284 await makePostUploadRequest({
285 url: server.url,
286 path: path + '/me/avatar/pick',
287 token: server.accessToken,
288 fields,
289 attaches,
290 statusCodeExpected: 200
291 })
286 }) 292 })
287 }) 293 })
288 294
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index cdb48a276..c11660d07 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -1,5 +1,6 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import * as chai from 'chai'
3import 'mocha' 4import 'mocha'
4import { 5import {
5 flushTests, killallServers, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, 6 flushTests, killallServers, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers,
@@ -8,6 +9,8 @@ import {
8import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 9import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
9import { addVideoCommentThread } from '../../utils/videos/video-comments' 10import { addVideoCommentThread } from '../../utils/videos/video-comments'
10 11
12const expect = chai.expect
13
11describe('Test video comments API validator', function () { 14describe('Test video comments API validator', function () {
12 let pathThread: string 15 let pathThread: string
13 let pathComment: string 16 let pathComment: string
@@ -42,17 +45,14 @@ describe('Test video comments API validator', function () {
42 describe('When listing video comment threads', function () { 45 describe('When listing video comment threads', function () {
43 it('Should fail with a bad start pagination', async function () { 46 it('Should fail with a bad start pagination', async function () {
44 await checkBadStartPagination(server.url, pathThread, server.accessToken) 47 await checkBadStartPagination(server.url, pathThread, server.accessToken)
45
46 }) 48 })
47 49
48 it('Should fail with a bad count pagination', async function () { 50 it('Should fail with a bad count pagination', async function () {
49 await checkBadCountPagination(server.url, pathThread, server.accessToken) 51 await checkBadCountPagination(server.url, pathThread, server.accessToken)
50
51 }) 52 })
52 53
53 it('Should fail with an incorrect sort', async function () { 54 it('Should fail with an incorrect sort', async function () {
54 await checkBadSortPagination(server.url, pathThread, server.accessToken) 55 await checkBadSortPagination(server.url, pathThread, server.accessToken)
55
56 }) 56 })
57 57
58 it('Should fail with an incorrect video', async function () { 58 it('Should fail with an incorrect video', async function () {
@@ -185,6 +185,35 @@ describe('Test video comments API validator', function () {
185 }) 185 })
186 }) 186 })
187 187
188 describe('When a video has comments disabled', function () {
189 before(async function () {
190 const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false })
191 videoUUID = res.body.video.uuid
192 pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads'
193 })
194
195 it('Should return an empty thread list', async function () {
196 const res = await makeGetRequest({
197 url: server.url,
198 path: pathThread,
199 statusCodeExpected: 200
200 })
201 expect(res.body.total).to.equal(0)
202 expect(res.body.data).to.have.lengthOf(0)
203 })
204
205 it('Should return an thread comments list')
206
207 it('Should return conflict on thread add', async function () {
208 const fields = {
209 text: 'super comment'
210 }
211 await makePostBodyRequest({ url: server.url, path: pathThread, token: server.accessToken, fields, statusCodeExpected: 409 })
212 })
213
214 it('Should return conflict on comment thread add')
215 })
216
188 after(async function () { 217 after(async function () {
189 killallServers([ server ]) 218 killallServers([ server ])
190 219
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index b9484afc4..5c067dc96 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -100,6 +100,7 @@ describe('Test videos API validator', function () {
100 licence: 1, 100 licence: 1,
101 language: 6, 101 language: 6,
102 nsfw: false, 102 nsfw: false,
103 commentsEnabled: true,
103 description: 'my super description', 104 description: 'my super description',
104 tags: [ 'tag1', 'tag2' ], 105 tags: [ 'tag1', 'tag2' ],
105 privacy: VideoPrivacy.PUBLIC, 106 privacy: VideoPrivacy.PUBLIC,
@@ -162,6 +163,20 @@ describe('Test videos API validator', function () {
162 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 163 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
163 }) 164 })
164 165
166 it('Should fail without commentsEnabled attribute', async function () {
167 const fields = omit(baseCorrectParams, 'commentsEnabled')
168 const attaches = baseCorrectAttaches
169
170 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
171 })
172
173 it('Should fail with a bad commentsEnabled attribute', async function () {
174 const fields = immutableAssign(baseCorrectParams, { commentsEnabled: 2 })
175 const attaches = baseCorrectAttaches
176
177 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
178 })
179
165 it('Should fail with a long description', async function () { 180 it('Should fail with a long description', async function () {
166 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) 181 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) })
167 const attaches = baseCorrectAttaches 182 const attaches = baseCorrectAttaches
@@ -291,6 +306,7 @@ describe('Test videos API validator', function () {
291 licence: 2, 306 licence: 2,
292 language: 6, 307 language: 6,
293 nsfw: false, 308 nsfw: false,
309 commentsEnabled: false,
294 description: 'my super description', 310 description: 'my super description',
295 privacy: VideoPrivacy.PUBLIC, 311 privacy: VideoPrivacy.PUBLIC,
296 tags: [ 'tag1', 'tag2' ] 312 tags: [ 'tag1', 'tag2' ]
@@ -354,6 +370,12 @@ describe('Test videos API validator', function () {
354 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 370 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
355 }) 371 })
356 372
373 it('Should fail with a bad commentsEnabled attribute', async function () {
374 const fields = immutableAssign(baseCorrectParams, { commentsEnabled: 2 })
375
376 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
377 })
378
357 it('Should fail with a long description', async function () { 379 it('Should fail with a long description', async function () {
358 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) 380 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) })
359 381