1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
7 flushAndRunMultipleServers,
8 flushAndRunServer, killallServers, reRunServer,
11 } from '../../../shared/extra-utils/server/servers'
14 addVideoCommentThread,
20 setAccessTokensToServers,
24 getVideosListPagination,
26 getVideoCommentThreads,
27 getVideoThreadComments,
29 setDefaultVideoChannel,
31 doubleFollow, getVideoLanguages, getVideoLicences, getVideoCategories, uninstallPlugin
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'
37 const expect = chai.expect
39 describe('Test plugin altering video constants', function () {
40 let server: ServerInfo
42 before(async function () {
45 server = await flushAndRunServer(1)
46 await setAccessTokensToServers([ server ])
50 accessToken: server.accessToken,
51 path: getPluginTestPath('-three')
55 it('Should have updated languages', async function () {
56 const res = await getVideoLanguages(server.url)
57 const languages = res.body
59 expect(languages['en']).to.not.exist
60 expect(languages['fr']).to.not.exist
62 expect(languages['al_bhed']).to.equal('Al Bhed')
63 expect(languages['al_bhed2']).to.equal('Al Bhed 2')
66 it('Should have updated categories', async function () {
67 const res = await getVideoCategories(server.url)
68 const categories = res.body
70 expect(categories[1]).to.not.exist
71 expect(categories[2]).to.not.exist
73 expect(categories[42]).to.equal('Best category')
74 expect(categories[43]).to.equal('High best category')
77 it('Should have updated licences', async function () {
78 const res = await getVideoLicences(server.url)
79 const licences = res.body
81 expect(licences[1]).to.not.exist
82 expect(licences[7]).to.not.exist
84 expect(licences[42]).to.equal('Best licence')
85 expect(licences[43]).to.equal('High best licence')
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)
92 const res = await getVideo(server.url, resUpload.body.video.uuid)
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')
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' })
104 const res = await getVideoLanguages(server.url)
105 const languages = res.body
107 expect(languages[ 'en' ]).to.equal('English')
108 expect(languages[ 'fr' ]).to.equal('French')
110 expect(languages[ 'al_bhed' ]).to.not.exist
111 expect(languages[ 'al_bhed2' ]).to.not.exist
115 const res = await getVideoCategories(server.url)
116 const categories = res.body
118 expect(categories[ 1 ]).to.equal('Music')
119 expect(categories[ 2 ]).to.equal('Films')
121 expect(categories[ 42 ]).to.not.exist
122 expect(categories[ 43 ]).to.not.exist
126 const res = await getVideoLicences(server.url)
127 const licences = res.body
129 expect(licences[ 1 ]).to.equal('Attribution')
130 expect(licences[ 7 ]).to.equal('Public Domain Dedication')
132 expect(licences[ 42 ]).to.not.exist
133 expect(licences[ 43 ]).to.not.exist
137 after(async function () {
138 await cleanupTests([ server ])