1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils'
7 const expect = chai.expect
9 describe('Test plugin translations', function () {
10 let server: PeerTubeServer
11 let command: PluginsCommand
13 before(async function () {
16 server = await createSingleServer(1)
17 await setAccessTokensToServers([ server ])
19 command = server.plugins
21 await command.install({ path: PluginsCommand.getPluginTestPath() })
22 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
25 it('Should not have translations for locale pt', async function () {
26 const body = await command.getTranslations({ locale: 'pt' })
28 expect(body).to.deep.equal({})
31 it('Should have translations for locale fr', async function () {
32 const body = await command.getTranslations({ locale: 'fr-FR' })
34 expect(body).to.deep.equal({
35 'peertube-plugin-test': {
38 'peertube-plugin-test-filter-translations': {
39 'Hello world': 'Bonjour le monde'
44 it('Should have translations of locale it', async function () {
45 const body = await command.getTranslations({ locale: 'it-IT' })
47 expect(body).to.deep.equal({
48 'peertube-plugin-test-filter-translations': {
49 'Hello world': 'Ciao, mondo!'
54 it('Should remove the plugin and remove the locales', async function () {
55 await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' })
58 const body = await command.getTranslations({ locale: 'fr-FR' })
60 expect(body).to.deep.equal({
61 'peertube-plugin-test': {
68 const body = await command.getTranslations({ locale: 'it-IT' })
70 expect(body).to.deep.equal({})
74 after(async function () {
75 await cleanupTests([ server ])