]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
ee286591 | 2 | |
ee286591 | 3 | import 'mocha' |
ae2abfd3 | 4 | import * as chai from 'chai' |
4c7e60bc C |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils' |
6 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | |
ee286591 C |
7 | |
8 | const expect = chai.expect | |
9 | ||
10 | describe('Test plugin altering video constants', function () { | |
254d3579 | 11 | let server: PeerTubeServer |
ee286591 C |
12 | |
13 | before(async function () { | |
14 | this.timeout(30000) | |
15 | ||
254d3579 | 16 | server = await createSingleServer(1) |
ee286591 C |
17 | await setAccessTokensToServers([ server ]) |
18 | ||
89d241a7 | 19 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') }) |
ee286591 C |
20 | }) |
21 | ||
22 | it('Should have updated languages', async function () { | |
89d241a7 | 23 | const languages = await server.videos.getLanguages() |
ee286591 C |
24 | |
25 | expect(languages['en']).to.not.exist | |
26 | expect(languages['fr']).to.not.exist | |
27 | ||
28 | expect(languages['al_bhed']).to.equal('Al Bhed') | |
29 | expect(languages['al_bhed2']).to.equal('Al Bhed 2') | |
799ece6a | 30 | expect(languages['al_bhed3']).to.not.exist |
ee286591 C |
31 | }) |
32 | ||
33 | it('Should have updated categories', async function () { | |
89d241a7 | 34 | const categories = await server.videos.getCategories() |
ee286591 C |
35 | |
36 | expect(categories[1]).to.not.exist | |
37 | expect(categories[2]).to.not.exist | |
38 | ||
39 | expect(categories[42]).to.equal('Best category') | |
40 | expect(categories[43]).to.equal('High best category') | |
41 | }) | |
42 | ||
43 | it('Should have updated licences', async function () { | |
89d241a7 | 44 | const licences = await server.videos.getLicences() |
ee286591 C |
45 | |
46 | expect(licences[1]).to.not.exist | |
47 | expect(licences[7]).to.not.exist | |
48 | ||
49 | expect(licences[42]).to.equal('Best licence') | |
50 | expect(licences[43]).to.equal('High best licence') | |
51 | }) | |
52 | ||
b3af2601 | 53 | it('Should have updated video privacies', async function () { |
89d241a7 | 54 | const privacies = await server.videos.getPrivacies() |
b3af2601 C |
55 | |
56 | expect(privacies[1]).to.exist | |
57 | expect(privacies[2]).to.not.exist | |
58 | expect(privacies[3]).to.exist | |
59 | expect(privacies[4]).to.exist | |
60 | }) | |
61 | ||
62 | it('Should have updated playlist privacies', async function () { | |
89d241a7 | 63 | const playlistPrivacies = await server.playlists.getPrivacies() |
b3af2601 C |
64 | |
65 | expect(playlistPrivacies[1]).to.exist | |
66 | expect(playlistPrivacies[2]).to.exist | |
67 | expect(playlistPrivacies[3]).to.not.exist | |
68 | }) | |
69 | ||
70 | it('Should not be able to create a video with this privacy', async function () { | |
d23dd9fb | 71 | const attributes = { name: 'video', privacy: 2 } |
89d241a7 | 72 | await server.videos.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
b3af2601 C |
73 | }) |
74 | ||
75 | it('Should not be able to create a video with this privacy', async function () { | |
e6346d59 | 76 | const attributes = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE } |
89d241a7 | 77 | await server.playlists.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
b3af2601 C |
78 | }) |
79 | ||
ee286591 | 80 | it('Should be able to upload a video with these values', async function () { |
d23dd9fb | 81 | const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' } |
89d241a7 | 82 | const { uuid } = await server.videos.upload({ attributes }) |
ee286591 | 83 | |
89d241a7 | 84 | const video = await server.videos.get({ id: uuid }) |
ee286591 C |
85 | expect(video.language.label).to.equal('Al Bhed 2') |
86 | expect(video.licence.label).to.equal('Best licence') | |
87 | expect(video.category.label).to.equal('Best category') | |
88 | }) | |
89 | ||
b3af2601 | 90 | it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { |
89d241a7 | 91 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-video-constants' }) |
ee286591 C |
92 | |
93 | { | |
89d241a7 | 94 | const languages = await server.videos.getLanguages() |
ee286591 | 95 | |
a1587156 C |
96 | expect(languages['en']).to.equal('English') |
97 | expect(languages['fr']).to.equal('French') | |
ee286591 | 98 | |
a1587156 C |
99 | expect(languages['al_bhed']).to.not.exist |
100 | expect(languages['al_bhed2']).to.not.exist | |
799ece6a | 101 | expect(languages['al_bhed3']).to.not.exist |
ee286591 C |
102 | } |
103 | ||
104 | { | |
89d241a7 | 105 | const categories = await server.videos.getCategories() |
ee286591 | 106 | |
a1587156 C |
107 | expect(categories[1]).to.equal('Music') |
108 | expect(categories[2]).to.equal('Films') | |
ee286591 | 109 | |
a1587156 C |
110 | expect(categories[42]).to.not.exist |
111 | expect(categories[43]).to.not.exist | |
ee286591 C |
112 | } |
113 | ||
114 | { | |
89d241a7 | 115 | const licences = await server.videos.getLicences() |
ee286591 | 116 | |
a1587156 C |
117 | expect(licences[1]).to.equal('Attribution') |
118 | expect(licences[7]).to.equal('Public Domain Dedication') | |
ee286591 | 119 | |
a1587156 C |
120 | expect(licences[42]).to.not.exist |
121 | expect(licences[43]).to.not.exist | |
ee286591 | 122 | } |
b3af2601 C |
123 | |
124 | { | |
89d241a7 | 125 | const privacies = await server.videos.getPrivacies() |
b3af2601 C |
126 | |
127 | expect(privacies[1]).to.exist | |
128 | expect(privacies[2]).to.exist | |
129 | expect(privacies[3]).to.exist | |
130 | expect(privacies[4]).to.exist | |
131 | } | |
132 | ||
133 | { | |
89d241a7 | 134 | const playlistPrivacies = await server.playlists.getPrivacies() |
b3af2601 C |
135 | |
136 | expect(playlistPrivacies[1]).to.exist | |
137 | expect(playlistPrivacies[2]).to.exist | |
138 | expect(playlistPrivacies[3]).to.exist | |
139 | } | |
ee286591 C |
140 | }) |
141 | ||
142 | after(async function () { | |
143 | await cleanupTests([ server ]) | |
144 | }) | |
145 | }) |