]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/plugins/video-constants.ts
Increase tests timeout
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / video-constants.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
ee286591
C
2
3import * as chai from 'chai'
4import 'mocha'
a1587156 5import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
ee286591 6import {
b3af2601 7 createVideoPlaylist,
ee286591 8 getPluginTestPath,
a1587156
C
9 getVideo,
10 getVideoCategories,
11 getVideoLanguages,
b3af2601 12 getVideoLicences, getVideoPlaylistPrivacies, getVideoPrivacies,
ee286591 13 installPlugin,
ee286591 14 setAccessTokensToServers,
a1587156
C
15 uninstallPlugin,
16 uploadVideo
ee286591 17} from '../../../shared/extra-utils'
b3af2601 18import { VideoDetails, VideoPlaylistPrivacy } from '../../../shared/models/videos'
f2eb23cd 19import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
ee286591
C
20
21const expect = chai.expect
22
23describe('Test plugin altering video constants', function () {
24 let server: ServerInfo
25
26 before(async function () {
27 this.timeout(30000)
28
29 server = await flushAndRunServer(1)
30 await setAccessTokensToServers([ server ])
31
32 await installPlugin({
33 url: server.url,
34 accessToken: server.accessToken,
35 path: getPluginTestPath('-three')
36 })
37 })
38
39 it('Should have updated languages', async function () {
40 const res = await getVideoLanguages(server.url)
41 const languages = res.body
42
43 expect(languages['en']).to.not.exist
44 expect(languages['fr']).to.not.exist
45
46 expect(languages['al_bhed']).to.equal('Al Bhed')
47 expect(languages['al_bhed2']).to.equal('Al Bhed 2')
48 })
49
50 it('Should have updated categories', async function () {
51 const res = await getVideoCategories(server.url)
52 const categories = res.body
53
54 expect(categories[1]).to.not.exist
55 expect(categories[2]).to.not.exist
56
57 expect(categories[42]).to.equal('Best category')
58 expect(categories[43]).to.equal('High best category')
59 })
60
61 it('Should have updated licences', async function () {
62 const res = await getVideoLicences(server.url)
63 const licences = res.body
64
65 expect(licences[1]).to.not.exist
66 expect(licences[7]).to.not.exist
67
68 expect(licences[42]).to.equal('Best licence')
69 expect(licences[43]).to.equal('High best licence')
70 })
71
b3af2601
C
72 it('Should have updated video privacies', async function () {
73 const res = await getVideoPrivacies(server.url)
74 const privacies = res.body
75
76 expect(privacies[1]).to.exist
77 expect(privacies[2]).to.not.exist
78 expect(privacies[3]).to.exist
79 expect(privacies[4]).to.exist
80 })
81
82 it('Should have updated playlist privacies', async function () {
83 const res = await getVideoPlaylistPrivacies(server.url)
84 const playlistPrivacies = res.body
85
86 expect(playlistPrivacies[1]).to.exist
87 expect(playlistPrivacies[2]).to.exist
88 expect(playlistPrivacies[3]).to.not.exist
89 })
90
91 it('Should not be able to create a video with this privacy', async function () {
92 const attrs = { name: 'video', privacy: 2 }
f2eb23cd 93 await uploadVideo(server.url, server.accessToken, attrs, HttpStatusCode.BAD_REQUEST_400)
b3af2601
C
94 })
95
96 it('Should not be able to create a video with this privacy', async function () {
97 const attrs = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE }
f2eb23cd
RK
98 await createVideoPlaylist({
99 url: server.url,
100 token: server.accessToken,
101 playlistAttrs: attrs,
102 expectedStatus: HttpStatusCode.BAD_REQUEST_400
103 })
b3af2601
C
104 })
105
ee286591
C
106 it('Should be able to upload a video with these values', async function () {
107 const attrs = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
108 const resUpload = await uploadVideo(server.url, server.accessToken, attrs)
109
110 const res = await getVideo(server.url, resUpload.body.video.uuid)
111
112 const video: VideoDetails = res.body
113 expect(video.language.label).to.equal('Al Bhed 2')
114 expect(video.licence.label).to.equal('Best licence')
115 expect(video.category.label).to.equal('Best category')
116 })
117
b3af2601 118 it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () {
ee286591
C
119 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' })
120
121 {
122 const res = await getVideoLanguages(server.url)
123 const languages = res.body
124
a1587156
C
125 expect(languages['en']).to.equal('English')
126 expect(languages['fr']).to.equal('French')
ee286591 127
a1587156
C
128 expect(languages['al_bhed']).to.not.exist
129 expect(languages['al_bhed2']).to.not.exist
ee286591
C
130 }
131
132 {
133 const res = await getVideoCategories(server.url)
134 const categories = res.body
135
a1587156
C
136 expect(categories[1]).to.equal('Music')
137 expect(categories[2]).to.equal('Films')
ee286591 138
a1587156
C
139 expect(categories[42]).to.not.exist
140 expect(categories[43]).to.not.exist
ee286591
C
141 }
142
143 {
144 const res = await getVideoLicences(server.url)
145 const licences = res.body
146
a1587156
C
147 expect(licences[1]).to.equal('Attribution')
148 expect(licences[7]).to.equal('Public Domain Dedication')
ee286591 149
a1587156
C
150 expect(licences[42]).to.not.exist
151 expect(licences[43]).to.not.exist
ee286591 152 }
b3af2601
C
153
154 {
155 const res = await getVideoPrivacies(server.url)
156 const privacies = res.body
157
158 expect(privacies[1]).to.exist
159 expect(privacies[2]).to.exist
160 expect(privacies[3]).to.exist
161 expect(privacies[4]).to.exist
162 }
163
164 {
165 const res = await getVideoPlaylistPrivacies(server.url)
166 const playlistPrivacies = res.body
167
168 expect(playlistPrivacies[1]).to.exist
169 expect(playlistPrivacies[2]).to.exist
170 expect(playlistPrivacies[3]).to.exist
171 }
ee286591
C
172 })
173
174 after(async function () {
175 await cleanupTests([ server ])
176 })
177})