]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/video-constants.ts
Merge branch 'next' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / video-constants.ts
index f527a2b3019e78c09b7b9175cfd231be9b5ff80b..19cba6c2c85d34651c7823cc8a5cb42b64bd617a 100644 (file)
@@ -2,7 +2,14 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils'
+import {
+  cleanupTests,
+  createSingleServer,
+  makeGetRequest,
+  PeerTubeServer,
+  PluginsCommand,
+  setAccessTokensToServers
+} from '@shared/extra-utils'
 import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
 
 const expect = chai.expect
@@ -139,6 +146,37 @@ describe('Test plugin altering video constants', function () {
     }
   })
 
+  it('Should be able to reset categories', async function () {
+    await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
+
+    {
+      const categories = await server.videos.getCategories()
+
+      expect(categories[1]).to.not.exist
+      expect(categories[2]).to.not.exist
+
+      expect(categories[42]).to.exist
+      expect(categories[43]).to.exist
+    }
+
+    await makeGetRequest({
+      url: server.url,
+      token: server.accessToken,
+      path: '/plugins/test-video-constants/router/reset-categories',
+      expectedStatus: HttpStatusCode.NO_CONTENT_204
+    })
+
+    {
+      const categories = await server.videos.getCategories()
+
+      expect(categories[1]).to.exist
+      expect(categories[2]).to.exist
+
+      expect(categories[42]).to.not.exist
+      expect(categories[43]).to.not.exist
+    }
+  })
+
   after(async function () {
     await cleanupTests([ server ])
   })