]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/plugins/translations.ts
Optimize videos list SQL queries workflow
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / translations.ts
CommitLineData
d75db01f
C
1/* tslint:disable:no-unused-expression */
2
3import * as chai from 'chai'
4import 'mocha'
5import {
6 cleanupTests,
7 flushAndRunMultipleServers,
8 flushAndRunServer, killallServers, reRunServer,
9 ServerInfo,
10 waitUntilLog
11} from '../../../shared/extra-utils/server/servers'
12import {
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'
33import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
34import { VideoDetails } from '../../../shared/models/videos'
35import { getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports'
36
37const expect = chai.expect
38
39describe('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})