aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-17 09:09:06 +0100
committerChocobozzz <me@florianbigard.com>2022-03-17 09:09:06 +0100
commit2769876fb26742f5cc8aa4b761be7bafca97d18d (patch)
tree250988e78313840b15f925a40d20c7109adb4ab5 /server/tests/api
parent52fe4b671a20c37ae46cf88d175dd16cddfc4de7 (diff)
downloadPeerTube-2769876fb26742f5cc8aa4b761be7bafca97d18d.tar.gz
PeerTube-2769876fb26742f5cc8aa4b761be7bafca97d18d.tar.zst
PeerTube-2769876fb26742f5cc8aa4b761be7bafca97d18d.zip
Fix client html cache on theme update
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/video-editor.ts3
-rw-r--r--server/tests/api/server/plugins.ts104
2 files changed, 64 insertions, 43 deletions
diff --git a/server/tests/api/check-params/video-editor.ts b/server/tests/api/check-params/video-editor.ts
index 1fd22c497..5f5faf8fb 100644
--- a/server/tests/api/check-params/video-editor.ts
+++ b/server/tests/api/check-params/video-editor.ts
@@ -122,7 +122,10 @@ describe('Test video editor API validator', function () {
122 }) 122 })
123 123
124 it('Should fail with an already in transcoding state video', async function () { 124 it('Should fail with an already in transcoding state video', async function () {
125 this.timeout(30000)
126
125 const { uuid } = await server.videos.quickUpload({ name: 'transcoded video' }) 127 const { uuid } = await server.videos.quickUpload({ name: 'transcoded video' })
128 await waitJobs([ server ])
126 129
127 await server.jobs.pauseJobQueue() 130 await server.jobs.pauseJobQueue()
128 await server.videos.runTranscoding({ videoId: uuid, transcodingType: 'hls' }) 131 await server.videos.runTranscoding({ videoId: uuid, transcodingType: 'hls' })
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index 76d3e2481..8aa34fb15 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -95,15 +95,15 @@ describe('Test plugins', function () {
95 }) 95 })
96 96
97 it('Should have the plugin loaded in the configuration', async function () { 97 it('Should have the plugin loaded in the configuration', async function () {
98 const config = await server.config.getConfig() 98 for (const config of [ await server.config.getConfig(), await server.config.getIndexHTMLConfig() ]) {
99 99 const theme = config.theme.registered.find(r => r.name === 'background-red')
100 const theme = config.theme.registered.find(r => r.name === 'background-red') 100 expect(theme).to.not.be.undefined
101 expect(theme).to.not.be.undefined 101 expect(theme.npmName).to.equal('peertube-theme-background-red')
102 expect(theme.npmName).to.equal('peertube-theme-background-red') 102
103 103 const plugin = config.plugin.registered.find(r => r.name === 'hello-world')
104 const plugin = config.plugin.registered.find(r => r.name === 'hello-world') 104 expect(plugin).to.not.be.undefined
105 expect(plugin).to.not.be.undefined 105 expect(plugin.npmName).to.equal('peertube-plugin-hello-world')
106 expect(plugin.npmName).to.equal('peertube-plugin-hello-world') 106 }
107 }) 107 })
108 108
109 it('Should update the default theme in the configuration', async function () { 109 it('Should update the default theme in the configuration', async function () {
@@ -113,8 +113,9 @@ describe('Test plugins', function () {
113 } 113 }
114 }) 114 })
115 115
116 const config = await server.config.getConfig() 116 for (const config of [ await server.config.getConfig(), await server.config.getIndexHTMLConfig() ]) {
117 expect(config.theme.default).to.equal('background-red') 117 expect(config.theme.default).to.equal('background-red')
118 }
118 }) 119 })
119 120
120 it('Should update my default theme', async function () { 121 it('Should update my default theme', async function () {
@@ -228,45 +229,62 @@ describe('Test plugins', function () {
228 }) 229 })
229 230
230 it('Should update the plugin and the theme', async function () { 231 it('Should update the plugin and the theme', async function () {
231 this.timeout(90000) 232 this.timeout(180000)
232 233
233 // Wait the scheduler that get the latest plugins versions 234 // Wait the scheduler that get the latest plugins versions
234 await wait(6000) 235 await wait(6000)
235 236
236 // Fake update our plugin version 237 async function testUpdate (type: 'plugin' | 'theme', name: string) {
237 await server.sql.setPluginVersion('hello-world', '0.0.1') 238 // Fake update our plugin version
239 await server.sql.setPluginVersion(name, '0.0.1')
238 240
239 // Fake update package.json 241 // Fake update package.json
240 const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world') 242 const packageJSON = await command.getPackageJSON(`peertube-${type}-${name}`)
241 const oldVersion = packageJSON.version 243 const oldVersion = packageJSON.version
242 244
243 packageJSON.version = '0.0.1' 245 packageJSON.version = '0.0.1'
244 await command.updatePackageJSON('peertube-plugin-hello-world', packageJSON) 246 await command.updatePackageJSON(`peertube-${type}-${name}`, packageJSON)
245 247
246 // Restart the server to take into account this change 248 // Restart the server to take into account this change
247 await killallServers([ server ]) 249 await killallServers([ server ])
248 await server.run() 250 await server.run()
249 251
250 { 252 const checkConfig = async (version: string) => {
251 const body = await command.list({ pluginType: PluginType.PLUGIN }) 253 for (const config of [ await server.config.getConfig(), await server.config.getIndexHTMLConfig() ]) {
254 expect(config[type].registered.find(r => r.name === name).version).to.equal(version)
255 }
256 }
252 257
253 const plugin = body.data[0] 258 const getPluginFromAPI = async () => {
254 expect(plugin.version).to.equal('0.0.1') 259 const body = await command.list({ pluginType: type === 'plugin' ? PluginType.PLUGIN : PluginType.THEME })
255 expect(plugin.latestVersion).to.exist
256 expect(plugin.latestVersion).to.not.equal('0.0.1')
257 }
258 260
259 { 261 return body.data.find(p => p.name === name)
260 await command.update({ npmName: 'peertube-plugin-hello-world' }) 262 }
261 263
262 const body = await command.list({ pluginType: PluginType.PLUGIN }) 264 {
265 const plugin = await getPluginFromAPI()
266 expect(plugin.version).to.equal('0.0.1')
267 expect(plugin.latestVersion).to.exist
268 expect(plugin.latestVersion).to.not.equal('0.0.1')
269
270 await checkConfig('0.0.1')
271 }
272
273 {
274 await command.update({ npmName: `peertube-${type}-${name}` })
263 275
264 const plugin = body.data[0] 276 const plugin = await getPluginFromAPI()
265 expect(plugin.version).to.equal(oldVersion) 277 expect(plugin.version).to.equal(oldVersion)
266 278
267 const updatedPackageJSON = await command.getPackageJSON('peertube-plugin-hello-world') 279 const updatedPackageJSON = await command.getPackageJSON(`peertube-${type}-${name}`)
268 expect(updatedPackageJSON.version).to.equal(oldVersion) 280 expect(updatedPackageJSON.version).to.equal(oldVersion)
281
282 await checkConfig(oldVersion)
283 }
269 } 284 }
285
286 await testUpdate('theme', 'background-red')
287 await testUpdate('plugin', 'hello-world')
270 }) 288 })
271 289
272 it('Should uninstall the plugin', async function () { 290 it('Should uninstall the plugin', async function () {
@@ -293,15 +311,15 @@ describe('Test plugins', function () {
293 }) 311 })
294 312
295 it('Should have updated the configuration', async function () { 313 it('Should have updated the configuration', async function () {
296 const config = await server.config.getConfig() 314 for (const config of [ await server.config.getConfig(), await server.config.getIndexHTMLConfig() ]) {
315 expect(config.theme.default).to.equal('default')
297 316
298 expect(config.theme.default).to.equal('default') 317 const theme = config.theme.registered.find(r => r.name === 'background-red')
318 expect(theme).to.be.undefined
299 319
300 const theme = config.theme.registered.find(r => r.name === 'background-red') 320 const plugin = config.plugin.registered.find(r => r.name === 'hello-world')
301 expect(theme).to.be.undefined 321 expect(plugin).to.be.undefined
302 322 }
303 const plugin = config.plugin.registered.find(r => r.name === 'hello-world')
304 expect(plugin).to.be.undefined
305 }) 323 })
306 324
307 it('Should have updated the user theme', async function () { 325 it('Should have updated the user theme', async function () {