aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/video-constants.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/plugins/video-constants.ts')
-rw-r--r--server/tests/plugins/video-constants.ts111
1 files changed, 71 insertions, 40 deletions
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index 6562e2b45..fec9196e2 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -1,38 +1,21 @@
1/* tslint:disable:no-unused-expression */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
5import { 6import {
6 cleanupTests, 7 createVideoPlaylist,
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, 8 getPluginTestPath,
17 getVideosList, 9 getVideo,
10 getVideoCategories,
11 getVideoLanguages,
12 getVideoLicences, getVideoPlaylistPrivacies, getVideoPrivacies,
18 installPlugin, 13 installPlugin,
19 removeVideo,
20 setAccessTokensToServers, 14 setAccessTokensToServers,
21 updateVideo, 15 uninstallPlugin,
22 uploadVideo, 16 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' 17} from '../../../shared/extra-utils'
33import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' 18import { VideoDetails, VideoPlaylistPrivacy } from '../../../shared/models/videos'
34import { VideoDetails } from '../../../shared/models/videos'
35import { getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports'
36 19
37const expect = chai.expect 20const expect = chai.expect
38 21
@@ -85,6 +68,35 @@ describe('Test plugin altering video constants', function () {
85 expect(licences[43]).to.equal('High best licence') 68 expect(licences[43]).to.equal('High best licence')
86 }) 69 })
87 70
71 it('Should have updated video privacies', async function () {
72 const res = await getVideoPrivacies(server.url)
73 const privacies = res.body
74
75 expect(privacies[1]).to.exist
76 expect(privacies[2]).to.not.exist
77 expect(privacies[3]).to.exist
78 expect(privacies[4]).to.exist
79 })
80
81 it('Should have updated playlist privacies', async function () {
82 const res = await getVideoPlaylistPrivacies(server.url)
83 const playlistPrivacies = res.body
84
85 expect(playlistPrivacies[1]).to.exist
86 expect(playlistPrivacies[2]).to.exist
87 expect(playlistPrivacies[3]).to.not.exist
88 })
89
90 it('Should not be able to create a video with this privacy', async function () {
91 const attrs = { name: 'video', privacy: 2 }
92 await uploadVideo(server.url, server.accessToken, attrs, 400)
93 })
94
95 it('Should not be able to create a video with this privacy', async function () {
96 const attrs = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE }
97 await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attrs, expectedStatus: 400 })
98 })
99
88 it('Should be able to upload a video with these values', async function () { 100 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' } 101 const attrs = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
90 const resUpload = await uploadVideo(server.url, server.accessToken, attrs) 102 const resUpload = await uploadVideo(server.url, server.accessToken, attrs)
@@ -97,40 +109,59 @@ describe('Test plugin altering video constants', function () {
97 expect(video.category.label).to.equal('Best category') 109 expect(video.category.label).to.equal('Best category')
98 }) 110 })
99 111
100 it('Should uninstall the plugin and reset languages, categories and licences', async function () { 112 it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () {
101 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' }) 113 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' })
102 114
103 { 115 {
104 const res = await getVideoLanguages(server.url) 116 const res = await getVideoLanguages(server.url)
105 const languages = res.body 117 const languages = res.body
106 118
107 expect(languages[ 'en' ]).to.equal('English') 119 expect(languages['en']).to.equal('English')
108 expect(languages[ 'fr' ]).to.equal('French') 120 expect(languages['fr']).to.equal('French')
109 121
110 expect(languages[ 'al_bhed' ]).to.not.exist 122 expect(languages['al_bhed']).to.not.exist
111 expect(languages[ 'al_bhed2' ]).to.not.exist 123 expect(languages['al_bhed2']).to.not.exist
112 } 124 }
113 125
114 { 126 {
115 const res = await getVideoCategories(server.url) 127 const res = await getVideoCategories(server.url)
116 const categories = res.body 128 const categories = res.body
117 129
118 expect(categories[ 1 ]).to.equal('Music') 130 expect(categories[1]).to.equal('Music')
119 expect(categories[ 2 ]).to.equal('Films') 131 expect(categories[2]).to.equal('Films')
120 132
121 expect(categories[ 42 ]).to.not.exist 133 expect(categories[42]).to.not.exist
122 expect(categories[ 43 ]).to.not.exist 134 expect(categories[43]).to.not.exist
123 } 135 }
124 136
125 { 137 {
126 const res = await getVideoLicences(server.url) 138 const res = await getVideoLicences(server.url)
127 const licences = res.body 139 const licences = res.body
128 140
129 expect(licences[ 1 ]).to.equal('Attribution') 141 expect(licences[1]).to.equal('Attribution')
130 expect(licences[ 7 ]).to.equal('Public Domain Dedication') 142 expect(licences[7]).to.equal('Public Domain Dedication')
143
144 expect(licences[42]).to.not.exist
145 expect(licences[43]).to.not.exist
146 }
147
148 {
149 const res = await getVideoPrivacies(server.url)
150 const privacies = res.body
151
152 expect(privacies[1]).to.exist
153 expect(privacies[2]).to.exist
154 expect(privacies[3]).to.exist
155 expect(privacies[4]).to.exist
156 }
157
158 {
159 const res = await getVideoPlaylistPrivacies(server.url)
160 const playlistPrivacies = res.body
131 161
132 expect(licences[ 42 ]).to.not.exist 162 expect(playlistPrivacies[1]).to.exist
133 expect(licences[ 43 ]).to.not.exist 163 expect(playlistPrivacies[2]).to.exist
164 expect(playlistPrivacies[3]).to.exist
134 } 165 }
135 }) 166 })
136 167