diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-26 14:44:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-26 15:18:30 +0200 |
commit | d75db01f14138ea660c4c519e37ab05228b39d13 (patch) | |
tree | 85a3da315ea6e1501fec5b70790482504dd64793 /server/tests/plugins | |
parent | ee286591a5b740702bad66c55cc900740f749e9a (diff) | |
download | PeerTube-d75db01f14138ea660c4c519e37ab05228b39d13.tar.gz PeerTube-d75db01f14138ea660c4c519e37ab05228b39d13.tar.zst PeerTube-d75db01f14138ea660c4c519e37ab05228b39d13.zip |
Add plugin translation system
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/index.ts | 1 | ||||
-rw-r--r-- | server/tests/plugins/translations.ts | 113 |
2 files changed, 114 insertions, 0 deletions
diff --git a/server/tests/plugins/index.ts b/server/tests/plugins/index.ts index 95e358732..f41708055 100644 --- a/server/tests/plugins/index.ts +++ b/server/tests/plugins/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import './action-hooks' | 1 | import './action-hooks' |
2 | import './filter-hooks' | 2 | import './filter-hooks' |
3 | import './translations' | ||
3 | import './video-constants' | 4 | import './video-constants' |
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts new file mode 100644 index 000000000..88d91a033 --- /dev/null +++ b/server/tests/plugins/translations.ts | |||
@@ -0,0 +1,113 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | flushAndRunMultipleServers, | ||
8 | flushAndRunServer, killallServers, reRunServer, | ||
9 | ServerInfo, | ||
10 | waitUntilLog | ||
11 | } from '../../../shared/extra-utils/server/servers' | ||
12 | import { | ||
13 | addVideoCommentReply, | ||
14 | addVideoCommentThread, | ||
15 | deleteVideoComment, | ||
16 | getPluginTestPath, | ||
17 | getVideosList, | ||
18 | installPlugin, | ||
19 | removeVideo, | ||
20 | setAccessTokensToServers, | ||
21 | updateVideo, | ||
22 | uploadVideo, | ||
23 | viewVideo, | ||
24 | getVideosListPagination, | ||
25 | getVideo, | ||
26 | getVideoCommentThreads, | ||
27 | getVideoThreadComments, | ||
28 | getVideoWithToken, | ||
29 | setDefaultVideoChannel, | ||
30 | waitJobs, | ||
31 | doubleFollow, getVideoLanguages, getVideoLicences, getVideoCategories, uninstallPlugin, getPluginTranslations | ||
32 | } from '../../../shared/extra-utils' | ||
33 | import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' | ||
34 | import { VideoDetails } from '../../../shared/models/videos' | ||
35 | import { getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports' | ||
36 | |||
37 | const expect = chai.expect | ||
38 | |||
39 | describe('Test plugin translations', function () { | ||
40 | let server: ServerInfo | ||
41 | |||
42 | before(async function () { | ||
43 | this.timeout(30000) | ||
44 | |||
45 | server = await flushAndRunServer(1) | ||
46 | await setAccessTokensToServers([ server ]) | ||
47 | |||
48 | await installPlugin({ | ||
49 | url: server.url, | ||
50 | accessToken: server.accessToken, | ||
51 | path: getPluginTestPath() | ||
52 | }) | ||
53 | |||
54 | await installPlugin({ | ||
55 | url: server.url, | ||
56 | accessToken: server.accessToken, | ||
57 | path: getPluginTestPath('-two') | ||
58 | }) | ||
59 | }) | ||
60 | |||
61 | it('Should not have translations for locale pt', async function () { | ||
62 | const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) | ||
63 | |||
64 | expect(res.body).to.deep.equal({}) | ||
65 | }) | ||
66 | |||
67 | it('Should have translations for locale fr', async function () { | ||
68 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | ||
69 | |||
70 | expect(res.body).to.deep.equal({ | ||
71 | 'peertube-plugin-test': { | ||
72 | 'Hi': 'Coucou' | ||
73 | }, | ||
74 | 'peertube-plugin-test-two': { | ||
75 | 'Hello world': 'Bonjour le monde' | ||
76 | } | ||
77 | }) | ||
78 | }) | ||
79 | |||
80 | it('Should have translations of locale it', async function () { | ||
81 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | ||
82 | |||
83 | expect(res.body).to.deep.equal({ | ||
84 | 'peertube-plugin-test-two': { | ||
85 | 'Hello world': 'Ciao, mondo!' | ||
86 | } | ||
87 | }) | ||
88 | }) | ||
89 | |||
90 | it('Should remove the plugin and remove the locales', async function () { | ||
91 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-two' }) | ||
92 | |||
93 | { | ||
94 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | ||
95 | |||
96 | expect(res.body).to.deep.equal({ | ||
97 | 'peertube-plugin-test': { | ||
98 | 'Hi': 'Coucou' | ||
99 | } | ||
100 | }) | ||
101 | } | ||
102 | |||
103 | { | ||
104 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | ||
105 | |||
106 | expect(res.body).to.deep.equal({}) | ||
107 | } | ||
108 | }) | ||
109 | |||
110 | after(async function () { | ||
111 | await cleanupTests([ server ]) | ||
112 | }) | ||
113 | }) | ||