import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
-import { cleanupTests, flushAndRunServer, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
-import { VideoPlaylistPrivacy } from '@shared/models'
+import {
+ cleanupTests,
+ createSingleServer,
+ makeGetRequest,
+ PeerTubeServer,
+ PluginsCommand,
+ setAccessTokensToServers
+} from '@shared/extra-utils'
+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
const expect = chai.expect
describe('Test plugin altering video constants', function () {
- let server: ServerInfo
+ let server: PeerTubeServer
before(async function () {
this.timeout(30000)
- server = await flushAndRunServer(1)
+ server = await createSingleServer(1)
await setAccessTokensToServers([ server ])
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
}
})
+ 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 ])
})