aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/users.ts13
-rw-r--r--server/tests/api/server/index.ts1
-rw-r--r--server/tests/api/server/plugins.ts130
-rw-r--r--server/tests/api/users/users.ts19
4 files changed, 161 insertions, 2 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 5d62fe2b3..5b788e328 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -387,13 +387,24 @@ describe('Test users API validators', function () {
387 } 387 }
388 }) 388 })
389 389
390 it('Should fail with an invalid theme', async function () {
391 const fields = { theme: 'invalid' }
392 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
393 })
394
395 it('Should fail with an unknown theme', async function () {
396 const fields = { theme: 'peertube-theme-unknown' }
397 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
398 })
399
390 it('Should succeed to change password with the correct params', async function () { 400 it('Should succeed to change password with the correct params', async function () {
391 const fields = { 401 const fields = {
392 currentPassword: 'my super password', 402 currentPassword: 'my super password',
393 password: 'my super password', 403 password: 'my super password',
394 nsfwPolicy: 'blur', 404 nsfwPolicy: 'blur',
395 autoPlayVideo: false, 405 autoPlayVideo: false,
396 email: 'super_email@example.com' 406 email: 'super_email@example.com',
407 theme: 'default'
397 } 408 }
398 409
399 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) 410 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts
index 94c15e0d0..3daeeb49a 100644
--- a/server/tests/api/server/index.ts
+++ b/server/tests/api/server/index.ts
@@ -11,3 +11,4 @@ import './reverse-proxy'
11import './stats' 11import './stats'
12import './tracker' 12import './tracker'
13import './no-client' 13import './no-client'
14import './plugins'
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
new file mode 100644
index 000000000..9a623c553
--- /dev/null
+++ b/server/tests/api/server/plugins.ts
@@ -0,0 +1,130 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5import { About } from '../../../../shared/models/server/about.model'
6import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
7import {
8 cleanupTests,
9 deleteCustomConfig,
10 flushAndRunServer,
11 getAbout,
12 getConfig,
13 getCustomConfig, installPlugin,
14 killallServers, parallelTests,
15 registerUser,
16 reRunServer, ServerInfo,
17 setAccessTokensToServers,
18 updateCustomConfig, uploadVideo
19} from '../../../../shared/extra-utils'
20import { ServerConfig } from '../../../../shared/models'
21import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model'
22
23const expect = chai.expect
24
25describe('Test plugins', function () {
26 let server = null
27
28 before(async function () {
29 this.timeout(30000)
30
31 server = await flushAndRunServer(1)
32 await setAccessTokensToServers([ server ])
33
34 {
35 await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-hello-world' })
36 }
37
38 {
39 await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-background-color' })
40 }
41 })
42
43 it('Should list available plugins and themes', async function () {
44 // List without filter
45 // List with filter (plugin and theme)
46 })
47
48 it('Should search available plugins', async function () {
49 // Search with filter (plugin and theme)
50 // Add pagination
51 // Add sort
52 // Add peertube engine
53 })
54
55 it('Should have an empty global css', async function () {
56 // get /global.css
57 })
58
59 it('Should install a plugin and a theme', async function () {
60
61 })
62
63 it('Should have the correct global css', async function () {
64 // get /global.css
65 })
66
67 it('Should have the plugin loaded in the configuration', async function () {
68 // Check registered themes/plugins
69 })
70
71 it('Should update the default theme in the configuration', async function () {
72 // Update config
73 })
74
75 it('Should list plugins and themes', async function () {
76 // List without filter
77 // List with filter (theme/plugin)
78 // List with pagination
79 // List with sort
80 })
81
82 it('Should get a plugin and a theme', async function () {
83 // Get plugin
84 // Get theme
85 })
86
87 it('Should get registered settings', async function () {
88 // Get plugin
89 })
90
91 it('Should update the settings', async function () {
92 // Update /settings
93
94 // get /plugin
95 })
96
97 it('Should update the plugin and the theme', async function () {
98 // update BDD -> 0.0.1
99 // update package.json (theme + plugin)
100 // list to check versions
101 // update plugin + theme
102 // list to check they have been updated
103 // check package.json are upgraded too
104 })
105
106 it('Should uninstall the plugin', async function () {
107 // uninstall
108 // list
109 })
110
111 it('Should have an empty global css', async function () {
112 // get /global.css
113 })
114
115 it('Should list uninstalled plugins', async function () {
116 // { uninstalled: true }
117 })
118
119 it('Should uninstall the theme', async function () {
120 // Uninstall
121 })
122
123 it('Should have updated the configuration', async function () {
124 // get /config (default theme + registered themes + registered plugins)
125 })
126
127 after(async function () {
128 await cleanupTests([ server ])
129 })
130})
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6fc2a070f..3a3fabb4c 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -18,7 +18,7 @@ import {
18 getUsersList, 18 getUsersList,
19 getUsersListPaginationAndSort, 19 getUsersListPaginationAndSort,
20 getVideoChannel, 20 getVideoChannel,
21 getVideosList, 21 getVideosList, installPlugin,
22 login, 22 login,
23 makePutBodyRequest, 23 makePutBodyRequest,
24 rateVideo, 24 rateVideo,
@@ -57,6 +57,8 @@ describe('Test users', function () {
57 server = await flushAndRunServer(1) 57 server = await flushAndRunServer(1)
58 58
59 await setAccessTokensToServers([ server ]) 59 await setAccessTokensToServers([ server ])
60
61 await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-theme-background-red' })
60 }) 62 })
61 63
62 describe('OAuth client', function () { 64 describe('OAuth client', function () {
@@ -551,6 +553,21 @@ describe('Test users', function () {
551 expect(user.account.displayName).to.equal('new display name') 553 expect(user.account.displayName).to.equal('new display name')
552 expect(user.account.description).to.equal('my super description updated') 554 expect(user.account.description).to.equal('my super description updated')
553 }) 555 })
556
557 it('Should be able to update my theme', async function () {
558 for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
559 await updateMyUser({
560 url: server.url,
561 accessToken: accessTokenUser,
562 theme
563 })
564
565 const res = await getMyUserInformation(server.url, accessTokenUser)
566 const body: User = res.body
567
568 expect(body.theme).to.equal(theme)
569 }
570 })
554 }) 571 })
555 572
556 describe('Updating another user', function () { 573 describe('Updating another user', function () {