1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils'
6 import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
8 const expect = chai.expect
10 describe('Test plugin translations', function () {
11 let server: ServerInfo
12 let command: PluginsCommand
14 before(async function () {
17 server = await flushAndRunServer(1)
18 await setAccessTokensToServers([ server ])
20 command = server.pluginsCommand
22 await command.install({ path: PluginsCommand.getPluginTestPath() })
23 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
26 it('Should not have translations for locale pt', async function () {
27 const body = await command.getTranslations({ locale: 'pt' })
29 expect(body).to.deep.equal({})
32 it('Should have translations for locale fr', async function () {
33 const body = await command.getTranslations({ locale: 'fr-FR' })
35 expect(body).to.deep.equal({
36 'peertube-plugin-test': {
39 'peertube-plugin-test-filter-translations': {
40 'Hello world': 'Bonjour le monde'
45 it('Should have translations of locale it', async function () {
46 const body = await command.getTranslations({ locale: 'it-IT' })
48 expect(body).to.deep.equal({
49 'peertube-plugin-test-filter-translations': {
50 'Hello world': 'Ciao, mondo!'
55 it('Should remove the plugin and remove the locales', async function () {
56 await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' })
59 const body = await command.getTranslations({ locale: 'fr-FR' })
61 expect(body).to.deep.equal({
62 'peertube-plugin-test': {
69 const body = await command.getTranslations({ locale: 'it-IT' })
71 expect(body).to.deep.equal({})
75 after(async function () {
76 await cleanupTests([ server ])