1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
7 flushAndRunMultipleServers,
8 flushAndRunServer, killallServers, reRunServer,
11 } from '../../../shared/extra-utils/server/servers'
14 addVideoCommentThread, deleteVideoComment,
16 installPlugin, removeVideo,
17 setAccessTokensToServers,
21 } from '../../../shared/extra-utils'
23 const expect = chai.expect
25 describe('Test plugin action hooks', function () {
26 let servers: ServerInfo[]
30 function checkHook (hook: string) {
31 return waitUntilLog(servers[0], 'Run hook ' + hook)
34 before(async function () {
37 servers = await flushAndRunMultipleServers(2)
38 await setAccessTokensToServers(servers)
42 accessToken: servers[0].accessToken,
43 path: getPluginTestPath()
46 await killallServers([ servers[0] ])
48 await reRunServer(servers[0])
51 it('Should run action:application.listening', async function () {
52 await checkHook('action:application.listening')
55 it('Should run action:api.video.uploaded', async function () {
56 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
57 videoUUID = res.body.video.uuid
59 await checkHook('action:api.video.uploaded')
62 it('Should run action:api.video.updated', async function () {
63 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video updated' })
65 await checkHook('action:api.video.updated')
68 it('Should run action:api.video.viewed', async function () {
69 await viewVideo(servers[0].url, videoUUID)
71 await checkHook('action:api.video.viewed')
74 it('Should run action:api.video-thread.created', async function () {
75 const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread')
76 threadId = res.body.comment.id
78 await checkHook('action:api.video-thread.created')
81 it('Should run action:api.video-comment-reply.created', async function () {
82 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID, threadId, 'reply')
84 await checkHook('action:api.video-comment-reply.created')
87 it('Should run action:api.video-comment.deleted', async function () {
88 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
90 await checkHook('action:api.video-comment.deleted')
93 it('Should run action:api.video.deleted', async function () {
94 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
96 await checkHook('action:api.video.deleted')
99 after(async function () {
100 await cleanupTests(servers)