aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/video-constants.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-26 13:13:39 +0200
committerChocobozzz <me@florianbigard.com>2019-07-26 15:18:30 +0200
commitee286591a5b740702bad66c55cc900740f749e9a (patch)
tree16503d1299a107c5972ba16f95228b1ebce20f79 /server/tests/plugins/video-constants.ts
parent16d54696294d15f8ab6ba3a6bcfac21528fec2f2 (diff)
downloadPeerTube-ee286591a5b740702bad66c55cc900740f749e9a.tar.gz
PeerTube-ee286591a5b740702bad66c55cc900740f749e9a.tar.zst
PeerTube-ee286591a5b740702bad66c55cc900740f749e9a.zip
Plugins can update video constants
Categories, licences and languages
Diffstat (limited to 'server/tests/plugins/video-constants.ts')
-rw-r--r--server/tests/plugins/video-constants.ts140
1 files changed, 140 insertions, 0 deletions
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
new file mode 100644
index 000000000..6562e2b45
--- /dev/null
+++ b/server/tests/plugins/video-constants.ts
@@ -0,0 +1,140 @@
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
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 altering video constants', 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('-three')
52 })
53 })
54
55 it('Should have updated languages', async function () {
56 const res = await getVideoLanguages(server.url)
57 const languages = res.body
58
59 expect(languages['en']).to.not.exist
60 expect(languages['fr']).to.not.exist
61
62 expect(languages['al_bhed']).to.equal('Al Bhed')
63 expect(languages['al_bhed2']).to.equal('Al Bhed 2')
64 })
65
66 it('Should have updated categories', async function () {
67 const res = await getVideoCategories(server.url)
68 const categories = res.body
69
70 expect(categories[1]).to.not.exist
71 expect(categories[2]).to.not.exist
72
73 expect(categories[42]).to.equal('Best category')
74 expect(categories[43]).to.equal('High best category')
75 })
76
77 it('Should have updated licences', async function () {
78 const res = await getVideoLicences(server.url)
79 const licences = res.body
80
81 expect(licences[1]).to.not.exist
82 expect(licences[7]).to.not.exist
83
84 expect(licences[42]).to.equal('Best licence')
85 expect(licences[43]).to.equal('High best licence')
86 })
87
88 it('Should be able to upload a video with these values', async function () {
89 const attrs = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
90 const resUpload = await uploadVideo(server.url, server.accessToken, attrs)
91
92 const res = await getVideo(server.url, resUpload.body.video.uuid)
93
94 const video: VideoDetails = res.body
95 expect(video.language.label).to.equal('Al Bhed 2')
96 expect(video.licence.label).to.equal('Best licence')
97 expect(video.category.label).to.equal('Best category')
98 })
99
100 it('Should uninstall the plugin and reset languages, categories and licences', async function () {
101 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' })
102
103 {
104 const res = await getVideoLanguages(server.url)
105 const languages = res.body
106
107 expect(languages[ 'en' ]).to.equal('English')
108 expect(languages[ 'fr' ]).to.equal('French')
109
110 expect(languages[ 'al_bhed' ]).to.not.exist
111 expect(languages[ 'al_bhed2' ]).to.not.exist
112 }
113
114 {
115 const res = await getVideoCategories(server.url)
116 const categories = res.body
117
118 expect(categories[ 1 ]).to.equal('Music')
119 expect(categories[ 2 ]).to.equal('Films')
120
121 expect(categories[ 42 ]).to.not.exist
122 expect(categories[ 43 ]).to.not.exist
123 }
124
125 {
126 const res = await getVideoLicences(server.url)
127 const licences = res.body
128
129 expect(licences[ 1 ]).to.equal('Attribution')
130 expect(licences[ 7 ]).to.equal('Public Domain Dedication')
131
132 expect(licences[ 42 ]).to.not.exist
133 expect(licences[ 43 ]).to.not.exist
134 }
135 })
136
137 after(async function () {
138 await cleanupTests([ server ])
139 })
140})