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