]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
ee286591 C |
2 | |
3 | import * as chai from 'chai' | |
4 | import 'mocha' | |
a1587156 | 5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' |
ee286591 | 6 | import { |
ee286591 | 7 | getPluginTestPath, |
a1587156 C |
8 | getVideo, |
9 | getVideoCategories, | |
10 | getVideoLanguages, | |
11 | getVideoLicences, | |
ee286591 | 12 | installPlugin, |
ee286591 | 13 | setAccessTokensToServers, |
a1587156 C |
14 | uninstallPlugin, |
15 | uploadVideo | |
ee286591 | 16 | } from '../../../shared/extra-utils' |
ee286591 | 17 | import { VideoDetails } from '../../../shared/models/videos' |
ee286591 C |
18 | |
19 | const expect = chai.expect | |
20 | ||
21 | describe('Test plugin altering video constants', function () { | |
22 | let server: ServerInfo | |
23 | ||
24 | before(async function () { | |
25 | this.timeout(30000) | |
26 | ||
27 | server = await flushAndRunServer(1) | |
28 | await setAccessTokensToServers([ server ]) | |
29 | ||
30 | await installPlugin({ | |
31 | url: server.url, | |
32 | accessToken: server.accessToken, | |
33 | path: getPluginTestPath('-three') | |
34 | }) | |
35 | }) | |
36 | ||
37 | it('Should have updated languages', async function () { | |
38 | const res = await getVideoLanguages(server.url) | |
39 | const languages = res.body | |
40 | ||
41 | expect(languages['en']).to.not.exist | |
42 | expect(languages['fr']).to.not.exist | |
43 | ||
44 | expect(languages['al_bhed']).to.equal('Al Bhed') | |
45 | expect(languages['al_bhed2']).to.equal('Al Bhed 2') | |
46 | }) | |
47 | ||
48 | it('Should have updated categories', async function () { | |
49 | const res = await getVideoCategories(server.url) | |
50 | const categories = res.body | |
51 | ||
52 | expect(categories[1]).to.not.exist | |
53 | expect(categories[2]).to.not.exist | |
54 | ||
55 | expect(categories[42]).to.equal('Best category') | |
56 | expect(categories[43]).to.equal('High best category') | |
57 | }) | |
58 | ||
59 | it('Should have updated licences', async function () { | |
60 | const res = await getVideoLicences(server.url) | |
61 | const licences = res.body | |
62 | ||
63 | expect(licences[1]).to.not.exist | |
64 | expect(licences[7]).to.not.exist | |
65 | ||
66 | expect(licences[42]).to.equal('Best licence') | |
67 | expect(licences[43]).to.equal('High best licence') | |
68 | }) | |
69 | ||
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) | |
73 | ||
74 | const res = await getVideo(server.url, resUpload.body.video.uuid) | |
75 | ||
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') | |
80 | }) | |
81 | ||
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' }) | |
84 | ||
85 | { | |
86 | const res = await getVideoLanguages(server.url) | |
87 | const languages = res.body | |
88 | ||
a1587156 C |
89 | expect(languages['en']).to.equal('English') |
90 | expect(languages['fr']).to.equal('French') | |
ee286591 | 91 | |
a1587156 C |
92 | expect(languages['al_bhed']).to.not.exist |
93 | expect(languages['al_bhed2']).to.not.exist | |
ee286591 C |
94 | } |
95 | ||
96 | { | |
97 | const res = await getVideoCategories(server.url) | |
98 | const categories = res.body | |
99 | ||
a1587156 C |
100 | expect(categories[1]).to.equal('Music') |
101 | expect(categories[2]).to.equal('Films') | |
ee286591 | 102 | |
a1587156 C |
103 | expect(categories[42]).to.not.exist |
104 | expect(categories[43]).to.not.exist | |
ee286591 C |
105 | } |
106 | ||
107 | { | |
108 | const res = await getVideoLicences(server.url) | |
109 | const licences = res.body | |
110 | ||
a1587156 C |
111 | expect(licences[1]).to.equal('Attribution') |
112 | expect(licences[7]).to.equal('Public Domain Dedication') | |
ee286591 | 113 | |
a1587156 C |
114 | expect(licences[42]).to.not.exist |
115 | expect(licences[43]).to.not.exist | |
ee286591 C |
116 | } |
117 | }) | |
118 | ||
119 | after(async function () { | |
120 | await cleanupTests([ server ]) | |
121 | }) | |
122 | }) |