aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-09 14:15:11 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit12edc1495a36b2199f1bf1ba37f50c7b694be382 (patch)
tree3abfe2e5b54076de73fbfa25386d0313fc3b7242 /server/tests/plugins
parenta54618880c394ad7571f3f3222dc96ec2dd10d9a (diff)
downloadPeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.tar.gz
PeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.tar.zst
PeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.zip
Introduce comments command
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/action-hooks.ts11
-rw-r--r--server/tests/plugins/filter-hooks.ts50
2 files changed, 30 insertions, 31 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index fd83bf2ac..6975ca4bb 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -3,11 +3,8 @@
3import 'mocha' 3import 'mocha'
4import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' 4import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
5import { 5import {
6 addVideoCommentReply,
7 addVideoCommentThread,
8 blockUser, 6 blockUser,
9 createUser, 7 createUser,
10 deleteVideoComment,
11 PluginsCommand, 8 PluginsCommand,
12 registerUser, 9 registerUser,
13 removeUser, 10 removeUser,
@@ -101,20 +98,20 @@ describe('Test plugin action hooks', function () {
101 98
102 describe('Comments hooks', function () { 99 describe('Comments hooks', function () {
103 it('Should run action:api.video-thread.created', async function () { 100 it('Should run action:api.video-thread.created', async function () {
104 const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread') 101 const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' })
105 threadId = res.body.comment.id 102 threadId = created.id
106 103
107 await checkHook('action:api.video-thread.created') 104 await checkHook('action:api.video-thread.created')
108 }) 105 })
109 106
110 it('Should run action:api.video-comment-reply.created', async function () { 107 it('Should run action:api.video-comment-reply.created', async function () {
111 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID, threadId, 'reply') 108 await servers[0].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' })
112 109
113 await checkHook('action:api.video-comment-reply.created') 110 await checkHook('action:api.video-comment-reply.created')
114 }) 111 })
115 112
116 it('Should run action:api.video-comment.deleted', async function () { 113 it('Should run action:api.video-comment.deleted', async function () {
117 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) 114 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId: threadId })
118 115
119 await checkHook('action:api.video-comment.deleted') 116 await checkHook('action:api.video-comment.deleted')
120 }) 117 })
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index a3c3c0551..c235508e8 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -4,8 +4,6 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 addVideoCommentReply,
8 addVideoCommentThread,
9 cleanupTests, 7 cleanupTests,
10 doubleFollow, 8 doubleFollow,
11 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -13,10 +11,8 @@ import {
13 getMyVideos, 11 getMyVideos,
14 getVideo, 12 getVideo,
15 getVideoChannelVideos, 13 getVideoChannelVideos,
16 getVideoCommentThreads,
17 getVideosList, 14 getVideosList,
18 getVideosListPagination, 15 getVideosListPagination,
19 getVideoThreadComments,
20 getVideoWithToken, 16 getVideoWithToken,
21 ImportsCommand, 17 ImportsCommand,
22 makeRawRequest, 18 makeRawRequest,
@@ -31,7 +27,7 @@ import {
31 waitJobs, 27 waitJobs,
32 waitUntilLog 28 waitUntilLog
33} from '@shared/extra-utils' 29} from '@shared/extra-utils'
34import { VideoCommentThreadTree, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' 30import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
35 31
36const expect = chai.expect 32const expect = chai.expect
37 33
@@ -226,44 +222,50 @@ describe('Test plugin filter hooks', function () {
226 }) 222 })
227 223
228 it('Should run filter:api.video-thread.create.accept.result', async function () { 224 it('Should run filter:api.video-thread.create.accept.result', async function () {
229 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment with bad word', HttpStatusCode.FORBIDDEN_403) 225 await servers[0].commentsCommand.createThread({
226 videoId: videoUUID,
227 text: 'comment with bad word',
228 expectedStatus: HttpStatusCode.FORBIDDEN_403
229 })
230 }) 230 })
231 231
232 it('Should run filter:api.video-comment-reply.create.accept.result', async function () { 232 it('Should run filter:api.video-comment-reply.create.accept.result', async function () {
233 const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread') 233 const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' })
234 threadId = res.body.comment.id 234 threadId = created.id
235 235
236 await addVideoCommentReply( 236 await servers[0].commentsCommand.addReply({
237 servers[0].url, 237 videoId: videoUUID,
238 servers[0].accessToken, 238 toCommentId: threadId,
239 videoUUID, 239 text: 'comment with bad word',
240 threadId, 240 expectedStatus: HttpStatusCode.FORBIDDEN_403
241 'comment with bad word', 241 })
242 HttpStatusCode.FORBIDDEN_403 242 await servers[0].commentsCommand.addReply({
243 ) 243 videoId: videoUUID,
244 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID, threadId, 'comment with good word', HttpStatusCode.OK_200) 244 toCommentId: threadId,
245 text: 'comment with good word',
246 expectedStatus: HttpStatusCode.OK_200
247 })
245 }) 248 })
246 249
247 it('Should run filter:api.video-threads.list.params', async function () { 250 it('Should run filter:api.video-threads.list.params', async function () {
248 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 0) 251 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 })
249 252
250 // our plugin do +1 to the count parameter 253 // our plugin do +1 to the count parameter
251 expect(res.body.data).to.have.lengthOf(1) 254 expect(data).to.have.lengthOf(1)
252 }) 255 })
253 256
254 it('Should run filter:api.video-threads.list.result', async function () { 257 it('Should run filter:api.video-threads.list.result', async function () {
255 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 0) 258 const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 })
256 259
257 // Plugin do +1 to the total result 260 // Plugin do +1 to the total result
258 expect(res.body.total).to.equal(2) 261 expect(total).to.equal(2)
259 }) 262 })
260 263
261 it('Should run filter:api.video-thread-comments.list.params') 264 it('Should run filter:api.video-thread-comments.list.params')
262 265
263 it('Should run filter:api.video-thread-comments.list.result', async function () { 266 it('Should run filter:api.video-thread-comments.list.result', async function () {
264 const res = await getVideoThreadComments(servers[0].url, videoUUID, threadId) 267 const thread = await servers[0].commentsCommand.getThread({ videoId: videoUUID, threadId })
265 268
266 const thread = res.body as VideoCommentThreadTree
267 expect(thread.comment.text.endsWith(' <3')).to.be.true 269 expect(thread.comment.text.endsWith(' <3')).to.be.true
268 }) 270 })
269 271