]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/action-hooks.ts
Add live server hooks
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / action-hooks.ts
index 510ec315197c9ad28b855d1c8f5b47eb181a95d7..ac9f2cea5b97075826550e01b4338b9ec04ab832 100644 (file)
@@ -1,40 +1,42 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import * as chai from 'chai'
 import 'mocha'
-import {
-  cleanupTests,
-  flushAndRunMultipleServers,
-  killallServers,
-  reRunServer,
-  ServerInfo,
-  waitUntilLog
-} from '../../../shared/extra-utils/server/servers'
+import { ServerHookName, VideoPrivacy } from '@shared/models'
 import {
   addVideoCommentReply,
   addVideoCommentThread,
   blockUser,
+  createLive,
   createUser,
   deleteVideoComment,
   getPluginTestPath,
-  installPlugin, login,
-  registerUser, removeUser,
+  installPlugin,
+  registerUser,
+  removeUser,
   setAccessTokensToServers,
-  unblockUser, updateUser,
+  setDefaultVideoChannel,
+  unblockUser,
+  updateUser,
   updateVideo,
   uploadVideo,
-  viewVideo,
-  userLogin
+  userLogin,
+  viewVideo
 } from '../../../shared/extra-utils'
-
-const expect = chai.expect
+import {
+  cleanupTests,
+  flushAndRunMultipleServers,
+  killallServers,
+  reRunServer,
+  ServerInfo,
+  waitUntilLog
+} from '../../../shared/extra-utils/server/servers'
 
 describe('Test plugin action hooks', function () {
   let servers: ServerInfo[]
   let videoUUID: string
   let threadId: number
 
-  function checkHook (hook: string) {
+  function checkHook (hook: ServerHookName) {
     return waitUntilLog(servers[0], 'Run hook ' + hook)
   }
 
@@ -43,6 +45,7 @@ describe('Test plugin action hooks', function () {
 
     servers = await flushAndRunMultipleServers(2)
     await setAccessTokensToServers(servers)
+    await setDefaultVideoChannel(servers)
 
     await installPlugin({
       url: servers[0].url,
@@ -52,7 +55,11 @@ describe('Test plugin action hooks', function () {
 
     killallServers([ servers[0] ])
 
-    await reRunServer(servers[0])
+    await reRunServer(servers[0], {
+      live: {
+        enabled: true
+      }
+    })
   })
 
   describe('Application hooks', function () {
@@ -82,6 +89,21 @@ describe('Test plugin action hooks', function () {
     })
   })
 
+  describe('Live hooks', function () {
+
+    it('Should run action:api.live-video.created', async function () {
+      const attributes = {
+        name: 'live',
+        privacy: VideoPrivacy.PUBLIC,
+        channelId: servers[0].videoChannel.id
+      }
+
+      await createLive(servers[0].url, servers[0].accessToken, attributes)
+
+      await checkHook('action:api.live-video.created')
+    })
+  })
+
   describe('Comments hooks', function () {
     it('Should run action:api.video-thread.created', async function () {
       const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread')