From ae2abfd3aed3e75d39a316b49b914d187faa7475 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 10:33:49 +0200 Subject: Introduce plugins command --- server/tests/plugins/action-hooks.ts | 9 ++---- server/tests/plugins/external-auth.ts | 47 +++++++++++------------------- server/tests/plugins/filter-hooks.ts | 16 ++-------- server/tests/plugins/html-injection.ts | 33 +++++++++------------ server/tests/plugins/id-and-pass-auth.ts | 36 ++++++++++------------- server/tests/plugins/plugin-helpers.ts | 24 +++++++-------- server/tests/plugins/plugin-router.ts | 27 +++++++---------- server/tests/plugins/plugin-storage.ts | 29 ++++++------------ server/tests/plugins/plugin-transcoding.ts | 26 ++++++----------- server/tests/plugins/plugin-unloading.ts | 32 ++++---------------- server/tests/plugins/translations.ts | 46 +++++++++++------------------ server/tests/plugins/video-constants.ts | 28 +++++++++--------- 12 files changed, 125 insertions(+), 228 deletions(-) (limited to 'server/tests/plugins') diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts index 0f57ef7fe..0de5b523b 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/server/tests/plugins/action-hooks.ts @@ -11,8 +11,7 @@ import { createUser, createVideoPlaylist, deleteVideoComment, - getPluginTestPath, - installPlugin, + PluginsCommand, registerUser, removeUser, setAccessTokensToServers, @@ -49,11 +48,7 @@ describe('Test plugin action hooks', function () { await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) - await installPlugin({ - url: servers[0].url, - accessToken: servers[0].accessToken, - path: getPluginTestPath() - }) + await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() }) killallServers([ servers[0] ]) diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index 5addb45c7..424302786 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts @@ -2,27 +2,26 @@ import 'mocha' import { expect } from 'chai' -import { ServerConfig, User, UserRole } from '@shared/models' +import { HttpStatusCode } from '@shared/core-utils' import { + cleanupTests, + createUser, decodeQueryString, + flushAndRunServer, getConfig, - getExternalAuth, getMyUserInformation, - getPluginTestPath, - installPlugin, loginUsingExternalToken, logout, + PluginsCommand, refreshToken, + ServerInfo, setAccessTokensToServers, - uninstallPlugin, updateMyUser, - wait, userLogin, - updatePluginSettings, - createUser -} from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' + wait, + waitUntilLog +} from '@shared/extra-utils' +import { ServerConfig, User, UserRole } from '@shared/models' async function loginExternal (options: { server: ServerInfo @@ -33,13 +32,12 @@ async function loginExternal (options: { statusCodeExpected?: HttpStatusCode statusCodeExpectedStep2?: HttpStatusCode }) { - const res = await getExternalAuth({ - url: options.server.url, + const res = await options.server.pluginsCommand.getExternalAuth({ npmName: options.npmName, npmVersion: '0.0.1', authName: options.authName, query: options.query, - statusCodeExpected: options.statusCodeExpected || HttpStatusCode.FOUND_302 + expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302 }) if (res.status !== HttpStatusCode.FOUND_302) return @@ -75,11 +73,7 @@ describe('Test external auth plugins', function () { await setAccessTokensToServers([ server ]) for (const suffix of [ 'one', 'two', 'three' ]) { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-external-auth-' + suffix) - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) }) } }) @@ -98,15 +92,14 @@ describe('Test external auth plugins', function () { }) it('Should redirect for a Cyan login', async function () { - const res = await getExternalAuth({ - url: server.url, + const res = await server.pluginsCommand.getExternalAuth({ npmName: 'test-external-auth-one', npmVersion: '0.0.1', authName: 'external-auth-1', query: { username: 'cyan' }, - statusCodeExpected: HttpStatusCode.FOUND_302 + expectedStatus: HttpStatusCode.FOUND_302 }) const location = res.header.location @@ -275,9 +268,7 @@ describe('Test external auth plugins', function () { }) it('Should unregister external-auth-2 and do not login existing Kefka', async function () { - await updatePluginSettings({ - url: server.url, - accessToken: server.accessToken, + await server.pluginsCommand.updateSettings({ npmName: 'peertube-plugin-test-external-auth-one', settings: { disableKefka: true } }) @@ -309,11 +300,7 @@ describe('Test external auth plugins', function () { }) it('Should uninstall the plugin one and do not login Cyan', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-test-external-auth-one' - }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' }) await loginExternal({ server, diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index e2ec5457b..c51e96ab7 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -14,7 +14,6 @@ import { getAccountVideos, getConfig, getMyVideos, - getPluginTestPath, getVideo, getVideoChannelVideos, getVideoCommentThreads, @@ -23,8 +22,8 @@ import { getVideosListPagination, getVideoThreadComments, getVideoWithToken, - installPlugin, makeRawRequest, + PluginsCommand, registerUser, ServerInfo, setAccessTokensToServers, @@ -63,17 +62,8 @@ describe('Test plugin filter hooks', function () { await setDefaultVideoChannel(servers) await doubleFollow(servers[0], servers[1]) - await installPlugin({ - url: servers[0].url, - accessToken: servers[0].accessToken, - path: getPluginTestPath() - }) - - await installPlugin({ - url: servers[0].url, - accessToken: servers[0].accessToken, - path: getPluginTestPath('-filter-translations') - }) + await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() }) + await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) for (let i = 0; i < 10; i++) { await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'default video ' + i }) diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 4fa8caa3a..80d67ae0e 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts @@ -5,30 +5,31 @@ import * as chai from 'chai' import { cleanupTests, flushAndRunServer, - getPluginsCSS, - installPlugin, makeHTMLRequest, + PluginsCommand, ServerInfo, - setAccessTokensToServers, - uninstallPlugin + setAccessTokensToServers } from '../../../shared/extra-utils' const expect = chai.expect describe('Test plugins HTML injection', function () { let server: ServerInfo = null + let command: PluginsCommand before(async function () { this.timeout(30000) server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) + + command = server.pluginsCommand }) it('Should not inject global css file in HTML', async function () { { - const res = await getPluginsCSS(server.url) - expect(res.text).to.be.empty + const text = await command.getCSS() + expect(text).to.be.empty } for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { @@ -40,17 +41,13 @@ describe('Test plugins HTML injection', function () { it('Should install a plugin and a theme', async function () { this.timeout(30000) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-hello-world' - }) + await command.install({ npmName: 'peertube-plugin-hello-world' }) }) it('Should have the correct global css', async function () { { - const res = await getPluginsCSS(server.url) - expect(res.text).to.contain('background-color: red') + const text = await command.getCSS() + expect(text).to.contain('background-color: red') } for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { @@ -60,15 +57,11 @@ describe('Test plugins HTML injection', function () { }) it('Should have an empty global css on uninstall', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-hello-world' - }) + await command.uninstall({ npmName: 'peertube-plugin-hello-world' }) { - const res = await getPluginsCSS(server.url) - expect(res.text).to.be.empty + const text = await command.getCSS() + expect(text).to.be.empty } for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index cbba638c2..545968040 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts @@ -1,21 +1,25 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' +import { expect } from 'chai' import { + cleanupTests, + flushAndRunServer, + getConfig, getMyUserInformation, - getPluginTestPath, - installPlugin, + getUsersList, + login, logout, + PluginsCommand, + refreshToken, + ServerInfo, setAccessTokensToServers, - uninstallPlugin, updateMyUser, userLogin, wait, - login, refreshToken, getConfig, updatePluginSettings, getUsersList -} from '../../../shared/extra-utils' -import { User, UserRole, ServerConfig } from '@shared/models' -import { expect } from 'chai' + waitUntilLog +} from '@shared/extra-utils' +import { ServerConfig, User, UserRole } from '@shared/models' describe('Test id and pass auth plugins', function () { let server: ServerInfo @@ -33,11 +37,7 @@ describe('Test id and pass auth plugins', function () { await setAccessTokensToServers([ server ]) for (const suffix of [ 'one', 'two', 'three' ]) { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-id-pass-auth-' + suffix) - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) }) } }) @@ -180,9 +180,7 @@ describe('Test id and pass auth plugins', function () { }) it('Should unregister spyro-auth and do not login existing Spyro', async function () { - await updatePluginSettings({ - url: server.url, - accessToken: server.accessToken, + await server.pluginsCommand.updateSettings({ npmName: 'peertube-plugin-test-id-pass-auth-one', settings: { disableSpyro: true } }) @@ -204,11 +202,7 @@ describe('Test id and pass auth plugins', function () { }) it('Should uninstall the plugin one and do not login existing Crash', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-test-id-pass-auth-one' - }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' }) await userLogin(server, { username: 'crash', password: 'crash password' }, 400) }) diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 0296d6eb7..0e0f61638 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -1,23 +1,25 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { expect } from 'chai' +import { HttpStatusCode } from '@shared/core-utils' import { checkVideoFilesWereRemoved, + cleanupTests, doubleFollow, - getPluginTestPath, + flushAndRunMultipleServers, getVideo, - installPlugin, + getVideosList, + makeGetRequest, makePostBodyRequest, + PluginsCommand, + ServerInfo, setAccessTokensToServers, uploadVideoAndGetId, viewVideo, - getVideosList, waitJobs, - makeGetRequest -} from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' -import { expect } from 'chai' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' + waitUntilLog +} from '@shared/extra-utils' function postCommand (server: ServerInfo, command: string, bodyArg?: object) { const body = { command } @@ -42,11 +44,7 @@ describe('Test plugin helpers', function () { await doubleFollow(servers[0], servers[1]) - await installPlugin({ - url: servers[0].url, - accessToken: servers[0].accessToken, - path: getPluginTestPath('-four') - }) + await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-four') }) }) describe('Logger', function () { diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index 24e6a1e83..81e18dabd 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts @@ -1,16 +1,17 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' +import { expect } from 'chai' +import { HttpStatusCode } from '@shared/core-utils' import { - getPluginTestPath, - installPlugin, + cleanupTests, + flushAndRunServer, makeGetRequest, makePostBodyRequest, - setAccessTokensToServers, uninstallPlugin -} from '../../../shared/extra-utils' -import { expect } from 'chai' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' + PluginsCommand, + ServerInfo, + setAccessTokensToServers +} from '@shared/extra-utils' describe('Test plugin helpers', function () { let server: ServerInfo @@ -25,11 +26,7 @@ describe('Test plugin helpers', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-five') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-five') }) }) it('Should answer "pong"', async function () { @@ -85,11 +82,7 @@ describe('Test plugin helpers', function () { }) it('Should remove the plugin and remove the routes', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-test-five' - }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-five' }) for (const path of basePaths) { await makeGetRequest({ diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts index 3c46b2585..4c65463f2 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/server/tests/plugins/plugin-storage.ts @@ -7,13 +7,14 @@ import { join } from 'path' import { HttpStatusCode } from '@shared/core-utils' import { buildServerDirectory, - getPluginTestPath, - installPlugin, + cleanupTests, + flushAndRunServer, makeGetRequest, + PluginsCommand, + ServerInfo, setAccessTokensToServers, - uninstallPlugin -} from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' + waitUntilLog +} from '@shared/extra-utils' describe('Test plugin storage', function () { let server: ServerInfo @@ -24,11 +25,7 @@ describe('Test plugin storage', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-six') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') }) }) describe('DB storage', function () { @@ -76,22 +73,14 @@ describe('Test plugin storage', function () { }) it('Should still have the file after an uninstallation', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-test-six' - }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-six' }) const content = await getFileContent() expect(content).to.equal('Prince Ali') }) it('Should still have the file after the reinstallation', async function () { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-six') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') }) const content = await getFileContent() expect(content).to.equal('Prince Ali') diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index eefb2294d..f1ff91077 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts @@ -4,25 +4,25 @@ import 'mocha' import { expect } from 'chai' import { join } from 'path' import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' -import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models' import { buildServerDirectory, + cleanupTests, createLive, + flushAndRunServer, getConfig, - getPluginTestPath, getVideo, - installPlugin, + PluginsCommand, sendRTMPStreamInVideo, + ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, testFfmpegStreamError, - uninstallPlugin, updateCustomSubConfig, uploadVideoAndGetId, waitJobs, waitUntilLivePublished -} from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' +} from '@shared/extra-utils' +import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models' async function createLiveWrapper (server: ServerInfo) { const liveAttributes = { @@ -109,11 +109,7 @@ describe('Test transcoding plugins', function () { } before(async function () { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-transcoding-one') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') }) }) it('Should have the appropriate available profiles', async function () { @@ -225,7 +221,7 @@ describe('Test transcoding plugins', function () { it('Should default to the default profile if the specified profile does not exist', async function () { this.timeout(240000) - await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-transcoding-one' }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }) const res = await getConfig(server.url) const config = res.body as ServerConfig @@ -244,11 +240,7 @@ describe('Test transcoding plugins', function () { describe('When using a plugin adding new encoders', function () { before(async function () { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-transcoding-two') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') }) await updateConf(server, 'test-vod-profile', 'test-live-profile') }) diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 74ca82e2f..f430f82b8 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -1,18 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { - cleanupTests, - flushAndRunServer, - getPluginTestPath, - makeGetRequest, - installPlugin, - uninstallPlugin, - ServerInfo, - setAccessTokensToServers -} from '../../../shared/extra-utils' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { expect } from 'chai' +import { HttpStatusCode } from '@shared/core-utils' +import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' describe('Test plugins module unloading', function () { let server: ServerInfo = null @@ -25,11 +16,7 @@ describe('Test plugins module unloading', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-unloading') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) }) it('Should return a numeric value', async function () { @@ -54,11 +41,7 @@ describe('Test plugins module unloading', function () { }) it('Should uninstall the plugin and free the route', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-test-unloading' - }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' }) await makeGetRequest({ url: server.url, @@ -68,11 +51,8 @@ describe('Test plugins module unloading', function () { }) it('Should return a different numeric value', async function () { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-unloading') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) + const res = await makeGetRequest({ url: server.url, path: requestPath, diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts index 9fd2ba1c5..0e11a0b53 100644 --- a/server/tests/plugins/translations.ts +++ b/server/tests/plugins/translations.ts @@ -1,20 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils' import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' -import { - getPluginTestPath, - getPluginTranslations, - installPlugin, - setAccessTokensToServers, - uninstallPlugin -} from '../../../shared/extra-utils' const expect = chai.expect describe('Test plugin translations', function () { let server: ServerInfo + let command: PluginsCommand before(async function () { this.timeout(30000) @@ -22,29 +17,22 @@ describe('Test plugin translations', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath() - }) + command = server.pluginsCommand - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-filter-translations') - }) + await command.install({ path: PluginsCommand.getPluginTestPath() }) + await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) }) it('Should not have translations for locale pt', async function () { - const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) + const body = await command.getTranslations({ locale: 'pt' }) - expect(res.body).to.deep.equal({}) + expect(body).to.deep.equal({}) }) it('Should have translations for locale fr', async function () { - const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) + const body = await command.getTranslations({ locale: 'fr-FR' }) - expect(res.body).to.deep.equal({ + expect(body).to.deep.equal({ 'peertube-plugin-test': { Hi: 'Coucou' }, @@ -55,9 +43,9 @@ describe('Test plugin translations', function () { }) it('Should have translations of locale it', async function () { - const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) + const body = await command.getTranslations({ locale: 'it-IT' }) - expect(res.body).to.deep.equal({ + expect(body).to.deep.equal({ 'peertube-plugin-test-filter-translations': { 'Hello world': 'Ciao, mondo!' } @@ -65,12 +53,12 @@ describe('Test plugin translations', function () { }) it('Should remove the plugin and remove the locales', async function () { - await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-filter-translations' }) + await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' }) { - const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) + const body = await command.getTranslations({ locale: 'fr-FR' }) - expect(res.body).to.deep.equal({ + expect(body).to.deep.equal({ 'peertube-plugin-test': { Hi: 'Coucou' } @@ -78,9 +66,9 @@ describe('Test plugin translations', function () { } { - const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) + const body = await command.getTranslations({ locale: 'it-IT' }) - expect(res.body).to.deep.equal({}) + expect(body).to.deep.equal({}) } }) diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index eb014c596..4124e8a52 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts @@ -1,22 +1,24 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' -import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' +import * as chai from 'chai' +import { HttpStatusCode } from '@shared/core-utils' import { + cleanupTests, createVideoPlaylist, - getPluginTestPath, + flushAndRunServer, getVideo, getVideoCategories, getVideoLanguages, - getVideoLicences, getVideoPlaylistPrivacies, getVideoPrivacies, - installPlugin, + getVideoLicences, + getVideoPlaylistPrivacies, + getVideoPrivacies, + PluginsCommand, + ServerInfo, setAccessTokensToServers, - uninstallPlugin, uploadVideo -} from '../../../shared/extra-utils' -import { VideoDetails, VideoPlaylistPrivacy } from '../../../shared/models/videos' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +} from '@shared/extra-utils' +import { VideoDetails, VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect @@ -29,11 +31,7 @@ describe('Test plugin altering video constants', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-video-constants') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-video-constants') }) }) it('Should have updated languages', async function () { @@ -117,7 +115,7 @@ describe('Test plugin altering video constants', function () { }) it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { - await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-video-constants' }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' }) { const res = await getVideoLanguages(server.url) -- cgit v1.2.3