aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
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
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')
-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
-rw-r--r--server/tests/api/server/follows.ts1
-rw-r--r--server/tests/api/videos/multiple-servers.ts27
-rw-r--r--server/tests/api/videos/single-server.ts5
6 files changed, 97 insertions, 9 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
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index fc9c5c3b6..e6dfd5f62 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -246,6 +246,7 @@ describe('Test follows', function () {
246 host: 'localhost:9003', 246 host: 'localhost:9003',
247 account: 'root', 247 account: 'root',
248 isLocal, 248 isLocal,
249 commentsEnabled: true,
249 duration: 5, 250 duration: 5,
250 tags: [ 'tag1', 'tag2', 'tag3' ], 251 tags: [ 'tag1', 'tag2', 'tag3' ],
251 privacy: VideoPrivacy.PUBLIC, 252 privacy: VideoPrivacy.PUBLIC,
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index abd051a30..b6dfe0d1b 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -93,6 +93,7 @@ describe('Test multiple servers', function () {
93 duration: 10, 93 duration: 10,
94 tags: [ 'tag1p1', 'tag2p1' ], 94 tags: [ 'tag1p1', 'tag2p1' ],
95 privacy: VideoPrivacy.PUBLIC, 95 privacy: VideoPrivacy.PUBLIC,
96 commentsEnabled: true,
96 channel: { 97 channel: {
97 name: 'my channel', 98 name: 'my channel',
98 description: 'super channel', 99 description: 'super channel',
@@ -155,6 +156,7 @@ describe('Test multiple servers', function () {
155 host: 'localhost:9002', 156 host: 'localhost:9002',
156 account: 'user1', 157 account: 'user1',
157 isLocal, 158 isLocal,
159 commentsEnabled: true,
158 duration: 5, 160 duration: 5,
159 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], 161 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
160 privacy: VideoPrivacy.PUBLIC, 162 privacy: VideoPrivacy.PUBLIC,
@@ -254,6 +256,7 @@ describe('Test multiple servers', function () {
254 account: 'root', 256 account: 'root',
255 isLocal, 257 isLocal,
256 duration: 5, 258 duration: 5,
259 commentsEnabled: true,
257 tags: [ 'tag1p3' ], 260 tags: [ 'tag1p3' ],
258 privacy: VideoPrivacy.PUBLIC, 261 privacy: VideoPrivacy.PUBLIC,
259 channel: { 262 channel: {
@@ -280,6 +283,7 @@ describe('Test multiple servers', function () {
280 description: 'my super description for server 3-2', 283 description: 'my super description for server 3-2',
281 host: 'localhost:9003', 284 host: 'localhost:9003',
282 account: 'root', 285 account: 'root',
286 commentsEnabled: true,
283 isLocal, 287 isLocal,
284 duration: 5, 288 duration: 5,
285 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 289 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
@@ -545,6 +549,7 @@ describe('Test multiple servers', function () {
545 account: 'root', 549 account: 'root',
546 isLocal, 550 isLocal,
547 duration: 5, 551 duration: 5,
552 commentsEnabled: true,
548 tags: [ 'tag_up_1', 'tag_up_2' ], 553 tags: [ 'tag_up_1', 'tag_up_2' ],
549 privacy: VideoPrivacy.PUBLIC, 554 privacy: VideoPrivacy.PUBLIC,
550 channel: { 555 channel: {
@@ -732,6 +737,26 @@ describe('Test multiple servers', function () {
732 expect(secondChild.children).to.have.lengthOf(0) 737 expect(secondChild.children).to.have.lengthOf(0)
733 } 738 }
734 }) 739 })
740
741 it('Should disable comments', async function () {
742 this.timeout(20000)
743
744 const attributes = {
745 commentsEnabled: false
746 }
747
748 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
749
750 await wait(5000)
751
752 for (const server of servers) {
753 const res = await getVideo(server.url, videoUUID)
754 expect(res.body.commentsEnabled).to.be.false
755
756 const text = 'my super forbidden comment'
757 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
758 }
759 })
735 }) 760 })
736 761
737 describe('With minimum parameters', function () { 762 describe('With minimum parameters', function () {
@@ -748,6 +773,7 @@ describe('Test multiple servers', function () {
748 .field('privacy', '1') 773 .field('privacy', '1')
749 .field('nsfw', 'false') 774 .field('nsfw', 'false')
750 .field('channelId', '1') 775 .field('channelId', '1')
776 .field('commentsEnabled', 'true')
751 777
752 const filePath = join(__dirname, '..', '..', 'api', 'fixtures', 'video_short.webm') 778 const filePath = join(__dirname, '..', '..', 'api', 'fixtures', 'video_short.webm')
753 779
@@ -772,6 +798,7 @@ describe('Test multiple servers', function () {
772 account: 'root', 798 account: 'root',
773 isLocal, 799 isLocal,
774 duration: 5, 800 duration: 5,
801 commentsEnabled: true,
775 tags: [ ], 802 tags: [ ],
776 privacy: VideoPrivacy.PUBLIC, 803 privacy: VideoPrivacy.PUBLIC,
777 channel: { 804 channel: {
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 2a3126f32..0a0c95750 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -32,6 +32,7 @@ describe('Test a single server', function () {
32 duration: 5, 32 duration: 5,
33 tags: [ 'tag1', 'tag2', 'tag3' ], 33 tags: [ 'tag1', 'tag2', 'tag3' ],
34 privacy: VideoPrivacy.PUBLIC, 34 privacy: VideoPrivacy.PUBLIC,
35 commentsEnabled: true,
35 channel: { 36 channel: {
36 name: 'Default root channel', 37 name: 'Default root channel',
37 description: '', 38 description: '',
@@ -51,7 +52,7 @@ describe('Test a single server', function () {
51 category: 4, 52 category: 4,
52 licence: 2, 53 licence: 2,
53 language: 5, 54 language: 5,
54 nsfw: true, 55 nsfw: false,
55 description: 'my super description updated', 56 description: 'my super description updated',
56 host: 'localhost:9001', 57 host: 'localhost:9001',
57 account: 'root', 58 account: 'root',
@@ -59,6 +60,7 @@ describe('Test a single server', function () {
59 tags: [ 'tagup1', 'tagup2' ], 60 tags: [ 'tagup1', 'tagup2' ],
60 privacy: VideoPrivacy.PUBLIC, 61 privacy: VideoPrivacy.PUBLIC,
61 duration: 5, 62 duration: 5,
63 commentsEnabled: false,
62 channel: { 64 channel: {
63 name: 'Default root channel', 65 name: 'Default root channel',
64 description: '', 66 description: '',
@@ -475,6 +477,7 @@ describe('Test a single server', function () {
475 language: 5, 477 language: 5,
476 nsfw: false, 478 nsfw: false,
477 description: 'my super description updated', 479 description: 'my super description updated',
480 commentsEnabled: false,
478 tags: [ 'tagup1', 'tagup2' ] 481 tags: [ 'tagup1', 'tagup2' ]
479 } 482 }
480 await updateVideo(server.url, server.accessToken, videoId, attributes) 483 await updateVideo(server.url, server.accessToken, videoId, attributes)