diff options
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/server/config.ts | 66 | ||||
-rw-r--r-- | server/tests/utils/videos/video-imports.ts | 37 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 4 |
3 files changed, 105 insertions, 2 deletions
diff --git a/server/tests/utils/server/config.ts b/server/tests/utils/server/config.ts index 57f95a603..e21614282 100644 --- a/server/tests/utils/server/config.ts +++ b/server/tests/utils/server/config.ts | |||
@@ -44,6 +44,69 @@ function updateCustomConfig (url: string, token: string, newCustomConfig: Custom | |||
44 | }) | 44 | }) |
45 | } | 45 | } |
46 | 46 | ||
47 | function updateCustomSubConfig (url: string, token: string, newConfig: any) { | ||
48 | const updateParams: CustomConfig = { | ||
49 | instance: { | ||
50 | name: 'PeerTube updated', | ||
51 | shortDescription: 'my short description', | ||
52 | description: 'my super description', | ||
53 | terms: 'my super terms', | ||
54 | defaultClientRoute: '/videos/recently-added', | ||
55 | defaultNSFWPolicy: 'blur', | ||
56 | customizations: { | ||
57 | javascript: 'alert("coucou")', | ||
58 | css: 'body { background-color: red; }' | ||
59 | } | ||
60 | }, | ||
61 | services: { | ||
62 | twitter: { | ||
63 | username: '@MySuperUsername', | ||
64 | whitelisted: true | ||
65 | } | ||
66 | }, | ||
67 | cache: { | ||
68 | previews: { | ||
69 | size: 2 | ||
70 | }, | ||
71 | captions: { | ||
72 | size: 3 | ||
73 | } | ||
74 | }, | ||
75 | signup: { | ||
76 | enabled: false, | ||
77 | limit: 5 | ||
78 | }, | ||
79 | admin: { | ||
80 | email: 'superadmin1@example.com' | ||
81 | }, | ||
82 | user: { | ||
83 | videoQuota: 5242881 | ||
84 | }, | ||
85 | transcoding: { | ||
86 | enabled: true, | ||
87 | threads: 1, | ||
88 | resolutions: { | ||
89 | '240p': false, | ||
90 | '360p': true, | ||
91 | '480p': true, | ||
92 | '720p': false, | ||
93 | '1080p': false | ||
94 | } | ||
95 | }, | ||
96 | import: { | ||
97 | videos: { | ||
98 | http: { | ||
99 | enabled: false | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | Object.assign(updateParams, newConfig) | ||
106 | |||
107 | return updateCustomConfig(url, token, updateParams) | ||
108 | } | ||
109 | |||
47 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { | 110 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { |
48 | const path = '/api/v1/config/custom' | 111 | const path = '/api/v1/config/custom' |
49 | 112 | ||
@@ -62,5 +125,6 @@ export { | |||
62 | getCustomConfig, | 125 | getCustomConfig, |
63 | updateCustomConfig, | 126 | updateCustomConfig, |
64 | getAbout, | 127 | getAbout, |
65 | deleteCustomConfig | 128 | deleteCustomConfig, |
129 | updateCustomSubConfig | ||
66 | } | 130 | } |
diff --git a/server/tests/utils/videos/video-imports.ts b/server/tests/utils/videos/video-imports.ts new file mode 100644 index 000000000..e0f916990 --- /dev/null +++ b/server/tests/utils/videos/video-imports.ts | |||
@@ -0,0 +1,37 @@ | |||
1 | import { VideoImportCreate } from '../../../../shared/models/videos' | ||
2 | import { makeGetRequest, makePostBodyRequest } from '..' | ||
3 | |||
4 | function getYoutubeVideoUrl () { | ||
5 | return 'https://youtu.be/msX3jv1XdvM' | ||
6 | } | ||
7 | |||
8 | function importVideo (url: string, token: string, attributes: VideoImportCreate) { | ||
9 | const path = '/api/v1/videos/imports' | ||
10 | |||
11 | return makePostBodyRequest({ | ||
12 | url, | ||
13 | path, | ||
14 | token, | ||
15 | fields: attributes, | ||
16 | statusCodeExpected: 200 | ||
17 | }) | ||
18 | } | ||
19 | |||
20 | function getMyVideoImports (url: string, token: string) { | ||
21 | const path = '/api/v1/users/me/videos/imports' | ||
22 | |||
23 | return makeGetRequest({ | ||
24 | url, | ||
25 | path, | ||
26 | token, | ||
27 | statusCodeExpected: 200 | ||
28 | }) | ||
29 | } | ||
30 | |||
31 | // --------------------------------------------------------------------------- | ||
32 | |||
33 | export { | ||
34 | getYoutubeVideoUrl, | ||
35 | importVideo, | ||
36 | getMyVideoImports | ||
37 | } | ||
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 8c49eb02b..b280cccda 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -522,7 +522,9 @@ async function completeVideoCheck ( | |||
522 | 522 | ||
523 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) | 523 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) |
524 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | 524 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) |
525 | expect(file.size).to.be.above(minSize).and.below(maxSize) | 525 | expect(file.size, |
526 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')') | ||
527 | .to.be.above(minSize).and.below(maxSize) | ||
526 | 528 | ||
527 | { | 529 | { |
528 | await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) | 530 | await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) |