1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import * as chai from 'chai'
5 import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
13 setAccessTokensToServers,
16 } from '../../../shared/extra-utils'
17 import { VideoDetails } from '../../../shared/models/videos'
19 const expect = chai.expect
21 describe('Test plugin altering video constants', function () {
22 let server: ServerInfo
24 before(async function () {
27 server = await flushAndRunServer(1)
28 await setAccessTokensToServers([ server ])
32 accessToken: server.accessToken,
33 path: getPluginTestPath('-three')
37 it('Should have updated languages', async function () {
38 const res = await getVideoLanguages(server.url)
39 const languages = res.body
41 expect(languages['en']).to.not.exist
42 expect(languages['fr']).to.not.exist
44 expect(languages['al_bhed']).to.equal('Al Bhed')
45 expect(languages['al_bhed2']).to.equal('Al Bhed 2')
48 it('Should have updated categories', async function () {
49 const res = await getVideoCategories(server.url)
50 const categories = res.body
52 expect(categories[1]).to.not.exist
53 expect(categories[2]).to.not.exist
55 expect(categories[42]).to.equal('Best category')
56 expect(categories[43]).to.equal('High best category')
59 it('Should have updated licences', async function () {
60 const res = await getVideoLicences(server.url)
61 const licences = res.body
63 expect(licences[1]).to.not.exist
64 expect(licences[7]).to.not.exist
66 expect(licences[42]).to.equal('Best licence')
67 expect(licences[43]).to.equal('High best licence')
70 it('Should be able to upload a video with these values', async function () {
71 const attrs = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
72 const resUpload = await uploadVideo(server.url, server.accessToken, attrs)
74 const res = await getVideo(server.url, resUpload.body.video.uuid)
76 const video: VideoDetails = res.body
77 expect(video.language.label).to.equal('Al Bhed 2')
78 expect(video.licence.label).to.equal('Best licence')
79 expect(video.category.label).to.equal('Best category')
82 it('Should uninstall the plugin and reset languages, categories and licences', async function () {
83 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' })
86 const res = await getVideoLanguages(server.url)
87 const languages = res.body
89 expect(languages['en']).to.equal('English')
90 expect(languages['fr']).to.equal('French')
92 expect(languages['al_bhed']).to.not.exist
93 expect(languages['al_bhed2']).to.not.exist
97 const res = await getVideoCategories(server.url)
98 const categories = res.body
100 expect(categories[1]).to.equal('Music')
101 expect(categories[2]).to.equal('Films')
103 expect(categories[42]).to.not.exist
104 expect(categories[43]).to.not.exist
108 const res = await getVideoLicences(server.url)
109 const licences = res.body
111 expect(licences[1]).to.equal('Attribution')
112 expect(licences[7]).to.equal('Public Domain Dedication')
114 expect(licences[42]).to.not.exist
115 expect(licences[43]).to.not.exist
119 after(async function () {
120 await cleanupTests([ server ])