]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/video-constants.ts
Add runner server tests
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / video-constants.ts
index 953916e8ec8c6ca451a61876ffdc3f49b6893f34..c388f02d1de4befb7231194750e63bbe14dd7e81 100644 (file)
@@ -1,12 +1,15 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
-import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
-import { VideoPlaylistPrivacy } from '@shared/models'
-
-const expect = chai.expect
+import { expect } from 'chai'
+import {
+  cleanupTests,
+  createSingleServer,
+  makeGetRequest,
+  PeerTubeServer,
+  PluginsCommand,
+  setAccessTokensToServers
+} from '@shared/server-commands'
+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
 
 describe('Test plugin altering video constants', function () {
   let server: PeerTubeServer
@@ -140,6 +143,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 ])
   })