diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-07 10:33:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | ae2abfd3aed3e75d39a316b49b914d187faa7475 (patch) | |
tree | 4d5060dc310f3d8cdcd5829779522f49b3d10e71 /server/tests/plugins/translations.ts | |
parent | 9c6327f803aaf4200672f1fc40b2f43786daca47 (diff) | |
download | PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.gz PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.zst PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.zip |
Introduce plugins command
Diffstat (limited to 'server/tests/plugins/translations.ts')
-rw-r--r-- | server/tests/plugins/translations.ts | 46 |
1 files changed, 17 insertions, 29 deletions
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 @@ | |||
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' |
4 | import * as chai from 'chai' | ||
5 | import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils' | ||
5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | 6 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' |
6 | import { | ||
7 | getPluginTestPath, | ||
8 | getPluginTranslations, | ||
9 | installPlugin, | ||
10 | setAccessTokensToServers, | ||
11 | uninstallPlugin | ||
12 | } from '../../../shared/extra-utils' | ||
13 | 7 | ||
14 | const expect = chai.expect | 8 | const expect = chai.expect |
15 | 9 | ||
16 | describe('Test plugin translations', function () { | 10 | describe('Test plugin translations', function () { |
17 | let server: ServerInfo | 11 | let server: ServerInfo |
12 | let command: PluginsCommand | ||
18 | 13 | ||
19 | before(async function () { | 14 | before(async function () { |
20 | this.timeout(30000) | 15 | this.timeout(30000) |
@@ -22,29 +17,22 @@ describe('Test plugin translations', function () { | |||
22 | server = await flushAndRunServer(1) | 17 | server = await flushAndRunServer(1) |
23 | await setAccessTokensToServers([ server ]) | 18 | await setAccessTokensToServers([ server ]) |
24 | 19 | ||
25 | await installPlugin({ | 20 | command = server.pluginsCommand |
26 | url: server.url, | ||
27 | accessToken: server.accessToken, | ||
28 | path: getPluginTestPath() | ||
29 | }) | ||
30 | 21 | ||
31 | await installPlugin({ | 22 | await command.install({ path: PluginsCommand.getPluginTestPath() }) |
32 | url: server.url, | 23 | await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) |
33 | accessToken: server.accessToken, | ||
34 | path: getPluginTestPath('-filter-translations') | ||
35 | }) | ||
36 | }) | 24 | }) |
37 | 25 | ||
38 | it('Should not have translations for locale pt', async function () { | 26 | it('Should not have translations for locale pt', async function () { |
39 | const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) | 27 | const body = await command.getTranslations({ locale: 'pt' }) |
40 | 28 | ||
41 | expect(res.body).to.deep.equal({}) | 29 | expect(body).to.deep.equal({}) |
42 | }) | 30 | }) |
43 | 31 | ||
44 | it('Should have translations for locale fr', async function () { | 32 | it('Should have translations for locale fr', async function () { |
45 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | 33 | const body = await command.getTranslations({ locale: 'fr-FR' }) |
46 | 34 | ||
47 | expect(res.body).to.deep.equal({ | 35 | expect(body).to.deep.equal({ |
48 | 'peertube-plugin-test': { | 36 | 'peertube-plugin-test': { |
49 | Hi: 'Coucou' | 37 | Hi: 'Coucou' |
50 | }, | 38 | }, |
@@ -55,9 +43,9 @@ describe('Test plugin translations', function () { | |||
55 | }) | 43 | }) |
56 | 44 | ||
57 | it('Should have translations of locale it', async function () { | 45 | it('Should have translations of locale it', async function () { |
58 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | 46 | const body = await command.getTranslations({ locale: 'it-IT' }) |
59 | 47 | ||
60 | expect(res.body).to.deep.equal({ | 48 | expect(body).to.deep.equal({ |
61 | 'peertube-plugin-test-filter-translations': { | 49 | 'peertube-plugin-test-filter-translations': { |
62 | 'Hello world': 'Ciao, mondo!' | 50 | 'Hello world': 'Ciao, mondo!' |
63 | } | 51 | } |
@@ -65,12 +53,12 @@ describe('Test plugin translations', function () { | |||
65 | }) | 53 | }) |
66 | 54 | ||
67 | it('Should remove the plugin and remove the locales', async function () { | 55 | 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' }) | 56 | await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' }) |
69 | 57 | ||
70 | { | 58 | { |
71 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | 59 | const body = await command.getTranslations({ locale: 'fr-FR' }) |
72 | 60 | ||
73 | expect(res.body).to.deep.equal({ | 61 | expect(body).to.deep.equal({ |
74 | 'peertube-plugin-test': { | 62 | 'peertube-plugin-test': { |
75 | Hi: 'Coucou' | 63 | Hi: 'Coucou' |
76 | } | 64 | } |
@@ -78,9 +66,9 @@ describe('Test plugin translations', function () { | |||
78 | } | 66 | } |
79 | 67 | ||
80 | { | 68 | { |
81 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | 69 | const body = await command.getTranslations({ locale: 'it-IT' }) |
82 | 70 | ||
83 | expect(res.body).to.deep.equal({}) | 71 | expect(body).to.deep.equal({}) |
84 | } | 72 | } |
85 | }) | 73 | }) |
86 | 74 | ||