]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | |
2 | ||
3 | import * as chai from 'chai' | |
4 | import 'mocha' | |
5 | 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 | ||
14 | const expect = chai.expect | |
15 | ||
16 | describe('Test plugin translations', function () { | |
17 | let server: ServerInfo | |
18 | ||
19 | before(async function () { | |
20 | this.timeout(30000) | |
21 | ||
22 | server = await flushAndRunServer(1) | |
23 | await setAccessTokensToServers([ server ]) | |
24 | ||
25 | await installPlugin({ | |
26 | url: server.url, | |
27 | accessToken: server.accessToken, | |
28 | path: getPluginTestPath() | |
29 | }) | |
30 | ||
31 | await installPlugin({ | |
32 | url: server.url, | |
33 | accessToken: server.accessToken, | |
34 | path: getPluginTestPath('-two') | |
35 | }) | |
36 | }) | |
37 | ||
38 | it('Should not have translations for locale pt', async function () { | |
39 | const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) | |
40 | ||
41 | expect(res.body).to.deep.equal({}) | |
42 | }) | |
43 | ||
44 | it('Should have translations for locale fr', async function () { | |
45 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | |
46 | ||
47 | expect(res.body).to.deep.equal({ | |
48 | 'peertube-plugin-test': { | |
49 | Hi: 'Coucou' | |
50 | }, | |
51 | 'peertube-plugin-test-two': { | |
52 | 'Hello world': 'Bonjour le monde' | |
53 | } | |
54 | }) | |
55 | }) | |
56 | ||
57 | it('Should have translations of locale it', async function () { | |
58 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | |
59 | ||
60 | expect(res.body).to.deep.equal({ | |
61 | 'peertube-plugin-test-two': { | |
62 | 'Hello world': 'Ciao, mondo!' | |
63 | } | |
64 | }) | |
65 | }) | |
66 | ||
67 | it('Should remove the plugin and remove the locales', async function () { | |
68 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-two' }) | |
69 | ||
70 | { | |
71 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | |
72 | ||
73 | expect(res.body).to.deep.equal({ | |
74 | 'peertube-plugin-test': { | |
75 | Hi: 'Coucou' | |
76 | } | |
77 | }) | |
78 | } | |
79 | ||
80 | { | |
81 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | |
82 | ||
83 | expect(res.body).to.deep.equal({}) | |
84 | } | |
85 | }) | |
86 | ||
87 | after(async function () { | |
88 | await cleanupTests([ server ]) | |
89 | }) | |
90 | }) |