1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
4 import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands'
6 describe('Test plugin translations', function () {
7 let server: PeerTubeServer
8 let command: PluginsCommand
10 before(async function () {
13 server = await createSingleServer(1)
14 await setAccessTokensToServers([ server ])
16 command = server.plugins
18 await command.install({ path: PluginsCommand.getPluginTestPath() })
19 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
22 it('Should not have translations for locale pt', async function () {
23 const body = await command.getTranslations({ locale: 'pt' })
25 expect(body).to.deep.equal({})
28 it('Should have translations for locale fr', async function () {
29 const body = await command.getTranslations({ locale: 'fr-FR' })
31 expect(body).to.deep.equal({
32 'peertube-plugin-test': {
35 'peertube-plugin-test-filter-translations': {
36 'Hello world': 'Bonjour le monde'
41 it('Should have translations of locale it', async function () {
42 const body = await command.getTranslations({ locale: 'it-IT' })
44 expect(body).to.deep.equal({
45 'peertube-plugin-test-filter-translations': {
46 'Hello world': 'Ciao, mondo!'
51 it('Should remove the plugin and remove the locales', async function () {
52 await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' })
55 const body = await command.getTranslations({ locale: 'fr-FR' })
57 expect(body).to.deep.equal({
58 'peertube-plugin-test': {
65 const body = await command.getTranslations({ locale: 'it-IT' })
67 expect(body).to.deep.equal({})
71 after(async function () {
72 await cleanupTests([ server ])