diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-15 10:02:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch) | |
tree | da82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/plugins/video-constants.ts | |
parent | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff) | |
download | PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip |
Introduce videos command
Diffstat (limited to 'server/tests/plugins/video-constants.ts')
-rw-r--r-- | server/tests/plugins/video-constants.ts | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index 4a05af042..641e37fbb 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts | |||
@@ -3,20 +3,8 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/core-utils' |
6 | import { | 6 | import { cleanupTests, flushAndRunServer, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' |
7 | cleanupTests, | 7 | import { VideoPlaylistPrivacy } from '@shared/models' |
8 | flushAndRunServer, | ||
9 | getVideo, | ||
10 | getVideoCategories, | ||
11 | getVideoLanguages, | ||
12 | getVideoLicences, | ||
13 | getVideoPrivacies, | ||
14 | PluginsCommand, | ||
15 | ServerInfo, | ||
16 | setAccessTokensToServers, | ||
17 | uploadVideo | ||
18 | } from '@shared/extra-utils' | ||
19 | import { VideoDetails, VideoPlaylistPrivacy } from '@shared/models' | ||
20 | 8 | ||
21 | const expect = chai.expect | 9 | const expect = chai.expect |
22 | 10 | ||
@@ -33,8 +21,7 @@ describe('Test plugin altering video constants', function () { | |||
33 | }) | 21 | }) |
34 | 22 | ||
35 | it('Should have updated languages', async function () { | 23 | it('Should have updated languages', async function () { |
36 | const res = await getVideoLanguages(server.url) | 24 | const languages = await server.videosCommand.getLanguages() |
37 | const languages = res.body | ||
38 | 25 | ||
39 | expect(languages['en']).to.not.exist | 26 | expect(languages['en']).to.not.exist |
40 | expect(languages['fr']).to.not.exist | 27 | expect(languages['fr']).to.not.exist |
@@ -45,8 +32,7 @@ describe('Test plugin altering video constants', function () { | |||
45 | }) | 32 | }) |
46 | 33 | ||
47 | it('Should have updated categories', async function () { | 34 | it('Should have updated categories', async function () { |
48 | const res = await getVideoCategories(server.url) | 35 | const categories = await server.videosCommand.getCategories() |
49 | const categories = res.body | ||
50 | 36 | ||
51 | expect(categories[1]).to.not.exist | 37 | expect(categories[1]).to.not.exist |
52 | expect(categories[2]).to.not.exist | 38 | expect(categories[2]).to.not.exist |
@@ -56,8 +42,7 @@ describe('Test plugin altering video constants', function () { | |||
56 | }) | 42 | }) |
57 | 43 | ||
58 | it('Should have updated licences', async function () { | 44 | it('Should have updated licences', async function () { |
59 | const res = await getVideoLicences(server.url) | 45 | const licences = await server.videosCommand.getLicences() |
60 | const licences = res.body | ||
61 | 46 | ||
62 | expect(licences[1]).to.not.exist | 47 | expect(licences[1]).to.not.exist |
63 | expect(licences[7]).to.not.exist | 48 | expect(licences[7]).to.not.exist |
@@ -67,8 +52,7 @@ describe('Test plugin altering video constants', function () { | |||
67 | }) | 52 | }) |
68 | 53 | ||
69 | it('Should have updated video privacies', async function () { | 54 | it('Should have updated video privacies', async function () { |
70 | const res = await getVideoPrivacies(server.url) | 55 | const privacies = await server.videosCommand.getPrivacies() |
71 | const privacies = res.body | ||
72 | 56 | ||
73 | expect(privacies[1]).to.exist | 57 | expect(privacies[1]).to.exist |
74 | expect(privacies[2]).to.not.exist | 58 | expect(privacies[2]).to.not.exist |
@@ -85,8 +69,8 @@ describe('Test plugin altering video constants', function () { | |||
85 | }) | 69 | }) |
86 | 70 | ||
87 | it('Should not be able to create a video with this privacy', async function () { | 71 | it('Should not be able to create a video with this privacy', async function () { |
88 | const attrs = { name: 'video', privacy: 2 } | 72 | const attributes = { name: 'video', privacy: 2 } |
89 | await uploadVideo(server.url, server.accessToken, attrs, HttpStatusCode.BAD_REQUEST_400) | 73 | await server.videosCommand.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
90 | }) | 74 | }) |
91 | 75 | ||
92 | it('Should not be able to create a video with this privacy', async function () { | 76 | it('Should not be able to create a video with this privacy', async function () { |
@@ -95,12 +79,10 @@ describe('Test plugin altering video constants', function () { | |||
95 | }) | 79 | }) |
96 | 80 | ||
97 | it('Should be able to upload a video with these values', async function () { | 81 | 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' } | 82 | const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' } |
99 | const resUpload = await uploadVideo(server.url, server.accessToken, attrs) | 83 | const { uuid } = await server.videosCommand.upload({ attributes }) |
100 | 84 | ||
101 | const res = await getVideo(server.url, resUpload.body.video.uuid) | 85 | const video = await server.videosCommand.get({ id: uuid }) |
102 | |||
103 | const video: VideoDetails = res.body | ||
104 | expect(video.language.label).to.equal('Al Bhed 2') | 86 | expect(video.language.label).to.equal('Al Bhed 2') |
105 | expect(video.licence.label).to.equal('Best licence') | 87 | expect(video.licence.label).to.equal('Best licence') |
106 | expect(video.category.label).to.equal('Best category') | 88 | expect(video.category.label).to.equal('Best category') |
@@ -110,8 +92,7 @@ describe('Test plugin altering video constants', function () { | |||
110 | await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' }) | 92 | await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' }) |
111 | 93 | ||
112 | { | 94 | { |
113 | const res = await getVideoLanguages(server.url) | 95 | const languages = await server.videosCommand.getLanguages() |
114 | const languages = res.body | ||
115 | 96 | ||
116 | expect(languages['en']).to.equal('English') | 97 | expect(languages['en']).to.equal('English') |
117 | expect(languages['fr']).to.equal('French') | 98 | expect(languages['fr']).to.equal('French') |
@@ -122,8 +103,7 @@ describe('Test plugin altering video constants', function () { | |||
122 | } | 103 | } |
123 | 104 | ||
124 | { | 105 | { |
125 | const res = await getVideoCategories(server.url) | 106 | const categories = await server.videosCommand.getCategories() |
126 | const categories = res.body | ||
127 | 107 | ||
128 | expect(categories[1]).to.equal('Music') | 108 | expect(categories[1]).to.equal('Music') |
129 | expect(categories[2]).to.equal('Films') | 109 | expect(categories[2]).to.equal('Films') |
@@ -133,8 +113,7 @@ describe('Test plugin altering video constants', function () { | |||
133 | } | 113 | } |
134 | 114 | ||
135 | { | 115 | { |
136 | const res = await getVideoLicences(server.url) | 116 | const licences = await server.videosCommand.getLicences() |
137 | const licences = res.body | ||
138 | 117 | ||
139 | expect(licences[1]).to.equal('Attribution') | 118 | expect(licences[1]).to.equal('Attribution') |
140 | expect(licences[7]).to.equal('Public Domain Dedication') | 119 | expect(licences[7]).to.equal('Public Domain Dedication') |
@@ -144,8 +123,7 @@ describe('Test plugin altering video constants', function () { | |||
144 | } | 123 | } |
145 | 124 | ||
146 | { | 125 | { |
147 | const res = await getVideoPrivacies(server.url) | 126 | const privacies = await server.videosCommand.getPrivacies() |
148 | const privacies = res.body | ||
149 | 127 | ||
150 | expect(privacies[1]).to.exist | 128 | expect(privacies[1]).to.exist |
151 | expect(privacies[2]).to.exist | 129 | expect(privacies[2]).to.exist |