diff options
Diffstat (limited to 'server/tests/plugins/translations.ts')
-rw-r--r-- | server/tests/plugins/translations.ts | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts index 9fd2ba1c5..8b25c6b75 100644 --- a/server/tests/plugins/translations.ts +++ b/server/tests/plugins/translations.ts | |||
@@ -1,50 +1,37 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | 4 | import * as chai from 'chai' |
6 | import { | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils' |
7 | getPluginTestPath, | ||
8 | getPluginTranslations, | ||
9 | installPlugin, | ||
10 | setAccessTokensToServers, | ||
11 | uninstallPlugin | ||
12 | } from '../../../shared/extra-utils' | ||
13 | 6 | ||
14 | const expect = chai.expect | 7 | const expect = chai.expect |
15 | 8 | ||
16 | describe('Test plugin translations', function () { | 9 | describe('Test plugin translations', function () { |
17 | let server: ServerInfo | 10 | let server: PeerTubeServer |
11 | let command: PluginsCommand | ||
18 | 12 | ||
19 | before(async function () { | 13 | before(async function () { |
20 | this.timeout(30000) | 14 | this.timeout(30000) |
21 | 15 | ||
22 | server = await flushAndRunServer(1) | 16 | server = await createSingleServer(1) |
23 | await setAccessTokensToServers([ server ]) | 17 | await setAccessTokensToServers([ server ]) |
24 | 18 | ||
25 | await installPlugin({ | 19 | command = server.plugins |
26 | url: server.url, | ||
27 | accessToken: server.accessToken, | ||
28 | path: getPluginTestPath() | ||
29 | }) | ||
30 | 20 | ||
31 | await installPlugin({ | 21 | await command.install({ path: PluginsCommand.getPluginTestPath() }) |
32 | url: server.url, | 22 | await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) |
33 | accessToken: server.accessToken, | ||
34 | path: getPluginTestPath('-filter-translations') | ||
35 | }) | ||
36 | }) | 23 | }) |
37 | 24 | ||
38 | it('Should not have translations for locale pt', async function () { | 25 | it('Should not have translations for locale pt', async function () { |
39 | const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) | 26 | const body = await command.getTranslations({ locale: 'pt' }) |
40 | 27 | ||
41 | expect(res.body).to.deep.equal({}) | 28 | expect(body).to.deep.equal({}) |
42 | }) | 29 | }) |
43 | 30 | ||
44 | it('Should have translations for locale fr', async function () { | 31 | it('Should have translations for locale fr', async function () { |
45 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | 32 | const body = await command.getTranslations({ locale: 'fr-FR' }) |
46 | 33 | ||
47 | expect(res.body).to.deep.equal({ | 34 | expect(body).to.deep.equal({ |
48 | 'peertube-plugin-test': { | 35 | 'peertube-plugin-test': { |
49 | Hi: 'Coucou' | 36 | Hi: 'Coucou' |
50 | }, | 37 | }, |
@@ -55,9 +42,9 @@ describe('Test plugin translations', function () { | |||
55 | }) | 42 | }) |
56 | 43 | ||
57 | it('Should have translations of locale it', async function () { | 44 | it('Should have translations of locale it', async function () { |
58 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | 45 | const body = await command.getTranslations({ locale: 'it-IT' }) |
59 | 46 | ||
60 | expect(res.body).to.deep.equal({ | 47 | expect(body).to.deep.equal({ |
61 | 'peertube-plugin-test-filter-translations': { | 48 | 'peertube-plugin-test-filter-translations': { |
62 | 'Hello world': 'Ciao, mondo!' | 49 | 'Hello world': 'Ciao, mondo!' |
63 | } | 50 | } |
@@ -65,12 +52,12 @@ describe('Test plugin translations', function () { | |||
65 | }) | 52 | }) |
66 | 53 | ||
67 | it('Should remove the plugin and remove the locales', async function () { | 54 | it('Should remove the plugin and remove the locales', async function () { |
68 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-filter-translations' }) | 55 | await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' }) |
69 | 56 | ||
70 | { | 57 | { |
71 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | 58 | const body = await command.getTranslations({ locale: 'fr-FR' }) |
72 | 59 | ||
73 | expect(res.body).to.deep.equal({ | 60 | expect(body).to.deep.equal({ |
74 | 'peertube-plugin-test': { | 61 | 'peertube-plugin-test': { |
75 | Hi: 'Coucou' | 62 | Hi: 'Coucou' |
76 | } | 63 | } |
@@ -78,9 +65,9 @@ describe('Test plugin translations', function () { | |||
78 | } | 65 | } |
79 | 66 | ||
80 | { | 67 | { |
81 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | 68 | const body = await command.getTranslations({ locale: 'it-IT' }) |
82 | 69 | ||
83 | expect(res.body).to.deep.equal({}) | 70 | expect(body).to.deep.equal({}) |
84 | } | 71 | } |
85 | }) | 72 | }) |
86 | 73 | ||