diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-07 11:51:09 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | 65e6e2602c0d5521f3a6740f7469bb92830ecb53 (patch) | |
tree | f89024ffff1dafb0281ee2fe028e89b95101bd44 /server/tests/client.ts | |
parent | bc8090411ddaa8d742ce4de3c83f9dba7bc18e2a (diff) | |
download | PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.tar.gz PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.tar.zst PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.zip |
Introduce config command
Diffstat (limited to 'server/tests/client.ts')
-rw-r--r-- | server/tests/client.ts | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts index 7c4fb4e46..be7ce18b4 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
7 | import { Account, CustomConfig, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' | 7 | import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' |
8 | import { | 8 | import { |
9 | addVideoInPlaylist, | 9 | addVideoInPlaylist, |
10 | cleanupTests, | 10 | cleanupTests, |
@@ -12,16 +12,12 @@ import { | |||
12 | doubleFollow, | 12 | doubleFollow, |
13 | flushAndRunMultipleServers, | 13 | flushAndRunMultipleServers, |
14 | getAccount, | 14 | getAccount, |
15 | getConfig, | ||
16 | getCustomConfig, | ||
17 | getVideosList, | 15 | getVideosList, |
18 | makeGetRequest, | 16 | makeGetRequest, |
19 | makeHTMLRequest, | 17 | makeHTMLRequest, |
20 | ServerInfo, | 18 | ServerInfo, |
21 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
22 | setDefaultVideoChannel, | 20 | setDefaultVideoChannel, |
23 | updateCustomConfig, | ||
24 | updateCustomSubConfig, | ||
25 | updateMyUser, | 21 | updateMyUser, |
26 | updateVideoChannel, | 22 | updateVideoChannel, |
27 | uploadVideo, | 23 | uploadVideo, |
@@ -307,14 +303,13 @@ describe('Test a client controllers', function () { | |||
307 | describe('Whitelisted', function () { | 303 | describe('Whitelisted', function () { |
308 | 304 | ||
309 | before(async function () { | 305 | before(async function () { |
310 | const res = await getCustomConfig(servers[0].url, servers[0].accessToken) | 306 | const config = await servers[0].configCommand.getCustomConfig() |
311 | const config = res.body as CustomConfig | ||
312 | config.services.twitter = { | 307 | config.services.twitter = { |
313 | username: '@Kuja', | 308 | username: '@Kuja', |
314 | whitelisted: true | 309 | whitelisted: true |
315 | } | 310 | } |
316 | 311 | ||
317 | await updateCustomConfig(servers[0].url, servers[0].accessToken, config) | 312 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: config }) |
318 | }) | 313 | }) |
319 | 314 | ||
320 | async function accountPageTest (path: string) { | 315 | async function accountPageTest (path: string) { |
@@ -382,40 +377,42 @@ describe('Test a client controllers', function () { | |||
382 | describe('Index HTML', function () { | 377 | describe('Index HTML', function () { |
383 | 378 | ||
384 | it('Should have valid index html tags (title, description...)', async function () { | 379 | it('Should have valid index html tags (title, description...)', async function () { |
385 | const resConfig = await getConfig(servers[0].url) | 380 | const config = await servers[0].configCommand.getConfig() |
386 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') | 381 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') |
387 | 382 | ||
388 | const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' | 383 | const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' |
389 | checkIndexTags(res.text, 'PeerTube', description, '', resConfig.body) | 384 | checkIndexTags(res.text, 'PeerTube', description, '', config) |
390 | }) | 385 | }) |
391 | 386 | ||
392 | it('Should update the customized configuration and have the correct index html tags', async function () { | 387 | it('Should update the customized configuration and have the correct index html tags', async function () { |
393 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | 388 | await servers[0].configCommand.updateCustomSubConfig({ |
394 | instance: { | 389 | newConfig: { |
395 | name: 'PeerTube updated', | 390 | instance: { |
396 | shortDescription: 'my short description', | 391 | name: 'PeerTube updated', |
397 | description: 'my super description', | 392 | shortDescription: 'my short description', |
398 | terms: 'my super terms', | 393 | description: 'my super description', |
399 | defaultNSFWPolicy: 'blur', | 394 | terms: 'my super terms', |
400 | defaultClientRoute: '/videos/recently-added', | 395 | defaultNSFWPolicy: 'blur', |
401 | customizations: { | 396 | defaultClientRoute: '/videos/recently-added', |
402 | javascript: 'alert("coucou")', | 397 | customizations: { |
403 | css: 'body { background-color: red; }' | 398 | javascript: 'alert("coucou")', |
399 | css: 'body { background-color: red; }' | ||
400 | } | ||
404 | } | 401 | } |
405 | } | 402 | } |
406 | }) | 403 | }) |
407 | 404 | ||
408 | const resConfig = await getConfig(servers[0].url) | 405 | const config = await servers[0].configCommand.getConfig() |
409 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') | 406 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') |
410 | 407 | ||
411 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body) | 408 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) |
412 | }) | 409 | }) |
413 | 410 | ||
414 | it('Should have valid index html updated tags (title, description...)', async function () { | 411 | it('Should have valid index html updated tags (title, description...)', async function () { |
415 | const resConfig = await getConfig(servers[0].url) | 412 | const config = await servers[0].configCommand.getConfig() |
416 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') | 413 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') |
417 | 414 | ||
418 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body) | 415 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) |
419 | }) | 416 | }) |
420 | 417 | ||
421 | it('Should use the original video URL for the canonical tag', async function () { | 418 | it('Should use the original video URL for the canonical tag', async function () { |
@@ -428,7 +425,7 @@ describe('Test a client controllers', function () { | |||
428 | }) | 425 | }) |
429 | 426 | ||
430 | it('Should use the original account URL for the canonical tag', async function () { | 427 | it('Should use the original account URL for the canonical tag', async function () { |
431 | const accountURLtest = (res) => { | 428 | const accountURLtest = res => { |
432 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) | 429 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) |
433 | } | 430 | } |
434 | 431 | ||
@@ -438,7 +435,7 @@ describe('Test a client controllers', function () { | |||
438 | }) | 435 | }) |
439 | 436 | ||
440 | it('Should use the original channel URL for the canonical tag', async function () { | 437 | it('Should use the original channel URL for the canonical tag', async function () { |
441 | const channelURLtests = (res) => { | 438 | const channelURLtests = res => { |
442 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) | 439 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) |
443 | } | 440 | } |
444 | 441 | ||
@@ -460,10 +457,10 @@ describe('Test a client controllers', function () { | |||
460 | describe('Embed HTML', function () { | 457 | describe('Embed HTML', function () { |
461 | 458 | ||
462 | it('Should have the correct embed html tags', async function () { | 459 | it('Should have the correct embed html tags', async function () { |
463 | const resConfig = await getConfig(servers[0].url) | 460 | const config = await servers[0].configCommand.getConfig() |
464 | const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath) | 461 | const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath) |
465 | 462 | ||
466 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body) | 463 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) |
467 | }) | 464 | }) |
468 | }) | 465 | }) |
469 | 466 | ||