diff options
Diffstat (limited to 'server/tests/client.ts')
-rw-r--r-- | server/tests/client.ts | 196 |
1 files changed, 93 insertions, 103 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts index 7c4fb4e46..9c27a7aae 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -3,28 +3,16 @@ | |||
3 | import 'mocha' | 3 | 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 { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' |
7 | import { Account, CustomConfig, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' | ||
8 | import { | 7 | import { |
9 | addVideoInPlaylist, | ||
10 | cleanupTests, | 8 | cleanupTests, |
11 | createVideoPlaylist, | 9 | createMultipleServers, |
12 | doubleFollow, | 10 | doubleFollow, |
13 | flushAndRunMultipleServers, | ||
14 | getAccount, | ||
15 | getConfig, | ||
16 | getCustomConfig, | ||
17 | getVideosList, | ||
18 | makeGetRequest, | 11 | makeGetRequest, |
19 | makeHTMLRequest, | 12 | makeHTMLRequest, |
20 | ServerInfo, | 13 | PeerTubeServer, |
21 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
22 | setDefaultVideoChannel, | 15 | setDefaultVideoChannel, |
23 | updateCustomConfig, | ||
24 | updateCustomSubConfig, | ||
25 | updateMyUser, | ||
26 | updateVideoChannel, | ||
27 | uploadVideo, | ||
28 | waitJobs | 16 | waitJobs |
29 | } from '../../shared/extra-utils' | 17 | } from '../../shared/extra-utils' |
30 | 18 | ||
@@ -40,7 +28,7 @@ function checkIndexTags (html: string, title: string, description: string, css: | |||
40 | } | 28 | } |
41 | 29 | ||
42 | describe('Test a client controllers', function () { | 30 | describe('Test a client controllers', function () { |
43 | let servers: ServerInfo[] = [] | 31 | let servers: PeerTubeServer[] = [] |
44 | let account: Account | 32 | let account: Account |
45 | 33 | ||
46 | const videoName = 'my super name for server 1' | 34 | const videoName = 'my super name for server 1' |
@@ -62,7 +50,7 @@ describe('Test a client controllers', function () { | |||
62 | before(async function () { | 50 | before(async function () { |
63 | this.timeout(120000) | 51 | this.timeout(120000) |
64 | 52 | ||
65 | servers = await flushAndRunMultipleServers(2) | 53 | servers = await createMultipleServers(2) |
66 | 54 | ||
67 | await setAccessTokensToServers(servers) | 55 | await setAccessTokensToServers(servers) |
68 | 56 | ||
@@ -70,47 +58,48 @@ describe('Test a client controllers', function () { | |||
70 | 58 | ||
71 | await setDefaultVideoChannel(servers) | 59 | await setDefaultVideoChannel(servers) |
72 | 60 | ||
73 | await updateVideoChannel(servers[0].url, servers[0].accessToken, servers[0].videoChannel.name, { description: channelDescription }) | 61 | await servers[0].channels.update({ |
62 | channelName: servers[0].store.channel.name, | ||
63 | attributes: { description: channelDescription } | ||
64 | }) | ||
74 | 65 | ||
75 | // Video | 66 | // Video |
76 | 67 | ||
77 | const videoAttributes = { name: videoName, description: videoDescription } | 68 | { |
78 | await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) | 69 | const attributes = { name: videoName, description: videoDescription } |
70 | await servers[0].videos.upload({ attributes }) | ||
79 | 71 | ||
80 | const resVideosRequest = await getVideosList(servers[0].url) | 72 | const { data } = await servers[0].videos.list() |
81 | const videos = resVideosRequest.body.data | 73 | expect(data.length).to.equal(1) |
82 | expect(videos.length).to.equal(1) | ||
83 | 74 | ||
84 | const video = videos[0] | 75 | const video = data[0] |
85 | servers[0].video = video | 76 | servers[0].store.video = video |
86 | videoIds = [ video.id, video.uuid, video.shortUUID ] | 77 | videoIds = [ video.id, video.uuid, video.shortUUID ] |
78 | } | ||
87 | 79 | ||
88 | // Playlist | 80 | // Playlist |
89 | 81 | ||
90 | const playlistAttrs = { | 82 | { |
91 | displayName: playlistName, | 83 | const attributes = { |
92 | description: playlistDescription, | 84 | displayName: playlistName, |
93 | privacy: VideoPlaylistPrivacy.PUBLIC, | 85 | description: playlistDescription, |
94 | videoChannelId: servers[0].videoChannel.id | 86 | privacy: VideoPlaylistPrivacy.PUBLIC, |
95 | } | 87 | videoChannelId: servers[0].store.channel.id |
88 | } | ||
96 | 89 | ||
97 | const resVideoPlaylistRequest = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs }) | 90 | playlist = await servers[0].playlists.create({ attributes }) |
98 | playlist = resVideoPlaylistRequest.body.videoPlaylist | 91 | playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ] |
99 | playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ] | ||
100 | 92 | ||
101 | await addVideoInPlaylist({ | 93 | await servers[0].playlists.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].store.video.id } }) |
102 | url: servers[0].url, | 94 | } |
103 | token: servers[0].accessToken, | ||
104 | playlistId: playlist.shortUUID, | ||
105 | elementAttrs: { videoId: video.id } | ||
106 | }) | ||
107 | 95 | ||
108 | // Account | 96 | // Account |
109 | 97 | ||
110 | await updateMyUser({ url: servers[0].url, accessToken: servers[0].accessToken, description: 'my account description' }) | 98 | { |
99 | await servers[0].users.updateMe({ description: 'my account description' }) | ||
111 | 100 | ||
112 | const resAccountRequest = await getAccount(servers[0].url, `${servers[0].user.username}@${servers[0].host}`) | 101 | account = await servers[0].accounts.get({ accountName: `${servers[0].store.user.username}@${servers[0].host}` }) |
113 | account = resAccountRequest.body | 102 | } |
114 | 103 | ||
115 | await waitJobs(servers) | 104 | await waitJobs(servers) |
116 | }) | 105 | }) |
@@ -124,14 +113,14 @@ describe('Test a client controllers', function () { | |||
124 | url: servers[0].url, | 113 | url: servers[0].url, |
125 | path: basePath + id, | 114 | path: basePath + id, |
126 | accept: 'text/html', | 115 | accept: 'text/html', |
127 | statusCodeExpected: HttpStatusCode.OK_200 | 116 | expectedStatus: HttpStatusCode.OK_200 |
128 | }) | 117 | }) |
129 | 118 | ||
130 | const port = servers[0].port | 119 | const port = servers[0].port |
131 | 120 | ||
132 | const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + | 121 | const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + |
133 | `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].video.uuid}" ` + | 122 | `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].store.video.uuid}" ` + |
134 | `title="${servers[0].video.name}" />` | 123 | `title="${servers[0].store.video.name}" />` |
135 | 124 | ||
136 | expect(res.text).to.contain(expectedLink) | 125 | expect(res.text).to.contain(expectedLink) |
137 | } | 126 | } |
@@ -145,7 +134,7 @@ describe('Test a client controllers', function () { | |||
145 | url: servers[0].url, | 134 | url: servers[0].url, |
146 | path: basePath + id, | 135 | path: basePath + id, |
147 | accept: 'text/html', | 136 | accept: 'text/html', |
148 | statusCodeExpected: HttpStatusCode.OK_200 | 137 | expectedStatus: HttpStatusCode.OK_200 |
149 | }) | 138 | }) |
150 | 139 | ||
151 | const port = servers[0].port | 140 | const port = servers[0].port |
@@ -163,37 +152,37 @@ describe('Test a client controllers', function () { | |||
163 | describe('Open Graph', function () { | 152 | describe('Open Graph', function () { |
164 | 153 | ||
165 | async function accountPageTest (path: string) { | 154 | async function accountPageTest (path: string) { |
166 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 155 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
167 | const text = res.text | 156 | const text = res.text |
168 | 157 | ||
169 | expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) | 158 | expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) |
170 | expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`) | 159 | expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`) |
171 | expect(text).to.contain('<meta property="og:type" content="website" />') | 160 | expect(text).to.contain('<meta property="og:type" content="website" />') |
172 | expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`) | 161 | expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].store.user.username}" />`) |
173 | } | 162 | } |
174 | 163 | ||
175 | async function channelPageTest (path: string) { | 164 | async function channelPageTest (path: string) { |
176 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 165 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
177 | const text = res.text | 166 | const text = res.text |
178 | 167 | ||
179 | expect(text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`) | 168 | expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`) |
180 | expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) | 169 | expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) |
181 | expect(text).to.contain('<meta property="og:type" content="website" />') | 170 | expect(text).to.contain('<meta property="og:type" content="website" />') |
182 | expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`) | 171 | expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].store.channel.name}" />`) |
183 | } | 172 | } |
184 | 173 | ||
185 | async function watchVideoPageTest (path: string) { | 174 | async function watchVideoPageTest (path: string) { |
186 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 175 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
187 | const text = res.text | 176 | const text = res.text |
188 | 177 | ||
189 | expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`) | 178 | expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`) |
190 | expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`) | 179 | expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`) |
191 | expect(text).to.contain('<meta property="og:type" content="video" />') | 180 | expect(text).to.contain('<meta property="og:type" content="video" />') |
192 | expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].video.uuid}" />`) | 181 | expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].store.video.uuid}" />`) |
193 | } | 182 | } |
194 | 183 | ||
195 | async function watchPlaylistPageTest (path: string) { | 184 | async function watchPlaylistPageTest (path: string) { |
196 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 185 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
197 | const text = res.text | 186 | const text = res.text |
198 | 187 | ||
199 | expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`) | 188 | expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`) |
@@ -203,15 +192,15 @@ describe('Test a client controllers', function () { | |||
203 | } | 192 | } |
204 | 193 | ||
205 | it('Should have valid Open Graph tags on the account page', async function () { | 194 | it('Should have valid Open Graph tags on the account page', async function () { |
206 | await accountPageTest('/accounts/' + servers[0].user.username) | 195 | await accountPageTest('/accounts/' + servers[0].store.user.username) |
207 | await accountPageTest('/a/' + servers[0].user.username) | 196 | await accountPageTest('/a/' + servers[0].store.user.username) |
208 | await accountPageTest('/@' + servers[0].user.username) | 197 | await accountPageTest('/@' + servers[0].store.user.username) |
209 | }) | 198 | }) |
210 | 199 | ||
211 | it('Should have valid Open Graph tags on the channel page', async function () { | 200 | it('Should have valid Open Graph tags on the channel page', async function () { |
212 | await channelPageTest('/video-channels/' + servers[0].videoChannel.name) | 201 | await channelPageTest('/video-channels/' + servers[0].store.channel.name) |
213 | await channelPageTest('/c/' + servers[0].videoChannel.name) | 202 | await channelPageTest('/c/' + servers[0].store.channel.name) |
214 | await channelPageTest('/@' + servers[0].videoChannel.name) | 203 | await channelPageTest('/@' + servers[0].store.channel.name) |
215 | }) | 204 | }) |
216 | 205 | ||
217 | it('Should have valid Open Graph tags on the watch page', async function () { | 206 | it('Should have valid Open Graph tags on the watch page', async function () { |
@@ -236,7 +225,7 @@ describe('Test a client controllers', function () { | |||
236 | describe('Not whitelisted', function () { | 225 | describe('Not whitelisted', function () { |
237 | 226 | ||
238 | async function accountPageTest (path: string) { | 227 | async function accountPageTest (path: string) { |
239 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 228 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
240 | const text = res.text | 229 | const text = res.text |
241 | 230 | ||
242 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 231 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -246,17 +235,17 @@ describe('Test a client controllers', function () { | |||
246 | } | 235 | } |
247 | 236 | ||
248 | async function channelPageTest (path: string) { | 237 | async function channelPageTest (path: string) { |
249 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 238 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
250 | const text = res.text | 239 | const text = res.text |
251 | 240 | ||
252 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 241 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
253 | expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') | 242 | expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') |
254 | expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`) | 243 | expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].store.channel.displayName}" />`) |
255 | expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) | 244 | expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) |
256 | } | 245 | } |
257 | 246 | ||
258 | async function watchVideoPageTest (path: string) { | 247 | async function watchVideoPageTest (path: string) { |
259 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 248 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
260 | const text = res.text | 249 | const text = res.text |
261 | 250 | ||
262 | expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />') | 251 | expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />') |
@@ -266,7 +255,7 @@ describe('Test a client controllers', function () { | |||
266 | } | 255 | } |
267 | 256 | ||
268 | async function watchPlaylistPageTest (path: string) { | 257 | async function watchPlaylistPageTest (path: string) { |
269 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 258 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
270 | const text = res.text | 259 | const text = res.text |
271 | 260 | ||
272 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 261 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -298,27 +287,26 @@ describe('Test a client controllers', function () { | |||
298 | }) | 287 | }) |
299 | 288 | ||
300 | it('Should have valid twitter card on the channel page', async function () { | 289 | it('Should have valid twitter card on the channel page', async function () { |
301 | await channelPageTest('/video-channels/' + servers[0].videoChannel.name) | 290 | await channelPageTest('/video-channels/' + servers[0].store.channel.name) |
302 | await channelPageTest('/c/' + servers[0].videoChannel.name) | 291 | await channelPageTest('/c/' + servers[0].store.channel.name) |
303 | await channelPageTest('/@' + servers[0].videoChannel.name) | 292 | await channelPageTest('/@' + servers[0].store.channel.name) |
304 | }) | 293 | }) |
305 | }) | 294 | }) |
306 | 295 | ||
307 | describe('Whitelisted', function () { | 296 | describe('Whitelisted', function () { |
308 | 297 | ||
309 | before(async function () { | 298 | before(async function () { |
310 | const res = await getCustomConfig(servers[0].url, servers[0].accessToken) | 299 | const config = await servers[0].config.getCustomConfig() |
311 | const config = res.body as CustomConfig | ||
312 | config.services.twitter = { | 300 | config.services.twitter = { |
313 | username: '@Kuja', | 301 | username: '@Kuja', |
314 | whitelisted: true | 302 | whitelisted: true |
315 | } | 303 | } |
316 | 304 | ||
317 | await updateCustomConfig(servers[0].url, servers[0].accessToken, config) | 305 | await servers[0].config.updateCustomConfig({ newCustomConfig: config }) |
318 | }) | 306 | }) |
319 | 307 | ||
320 | async function accountPageTest (path: string) { | 308 | async function accountPageTest (path: string) { |
321 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 309 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
322 | const text = res.text | 310 | const text = res.text |
323 | 311 | ||
324 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 312 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -326,7 +314,7 @@ describe('Test a client controllers', function () { | |||
326 | } | 314 | } |
327 | 315 | ||
328 | async function channelPageTest (path: string) { | 316 | async function channelPageTest (path: string) { |
329 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 317 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
330 | const text = res.text | 318 | const text = res.text |
331 | 319 | ||
332 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 320 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -334,7 +322,7 @@ describe('Test a client controllers', function () { | |||
334 | } | 322 | } |
335 | 323 | ||
336 | async function watchVideoPageTest (path: string) { | 324 | async function watchVideoPageTest (path: string) { |
337 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 325 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
338 | const text = res.text | 326 | const text = res.text |
339 | 327 | ||
340 | expect(text).to.contain('<meta property="twitter:card" content="player" />') | 328 | expect(text).to.contain('<meta property="twitter:card" content="player" />') |
@@ -342,7 +330,7 @@ describe('Test a client controllers', function () { | |||
342 | } | 330 | } |
343 | 331 | ||
344 | async function watchPlaylistPageTest (path: string) { | 332 | async function watchPlaylistPageTest (path: string) { |
345 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 333 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
346 | const text = res.text | 334 | const text = res.text |
347 | 335 | ||
348 | expect(text).to.contain('<meta property="twitter:card" content="player" />') | 336 | expect(text).to.contain('<meta property="twitter:card" content="player" />') |
@@ -372,9 +360,9 @@ describe('Test a client controllers', function () { | |||
372 | }) | 360 | }) |
373 | 361 | ||
374 | it('Should have valid twitter card on the channel page', async function () { | 362 | it('Should have valid twitter card on the channel page', async function () { |
375 | await channelPageTest('/video-channels/' + servers[0].videoChannel.name) | 363 | await channelPageTest('/video-channels/' + servers[0].store.channel.name) |
376 | await channelPageTest('/c/' + servers[0].videoChannel.name) | 364 | await channelPageTest('/c/' + servers[0].store.channel.name) |
377 | await channelPageTest('/@' + servers[0].videoChannel.name) | 365 | await channelPageTest('/@' + servers[0].store.channel.name) |
378 | }) | 366 | }) |
379 | }) | 367 | }) |
380 | }) | 368 | }) |
@@ -382,53 +370,55 @@ describe('Test a client controllers', function () { | |||
382 | describe('Index HTML', function () { | 370 | describe('Index HTML', function () { |
383 | 371 | ||
384 | it('Should have valid index html tags (title, description...)', async function () { | 372 | it('Should have valid index html tags (title, description...)', async function () { |
385 | const resConfig = await getConfig(servers[0].url) | 373 | const config = await servers[0].config.getConfig() |
386 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') | 374 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') |
387 | 375 | ||
388 | const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' | 376 | const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' |
389 | checkIndexTags(res.text, 'PeerTube', description, '', resConfig.body) | 377 | checkIndexTags(res.text, 'PeerTube', description, '', config) |
390 | }) | 378 | }) |
391 | 379 | ||
392 | it('Should update the customized configuration and have the correct index html tags', async function () { | 380 | it('Should update the customized configuration and have the correct index html tags', async function () { |
393 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | 381 | await servers[0].config.updateCustomSubConfig({ |
394 | instance: { | 382 | newConfig: { |
395 | name: 'PeerTube updated', | 383 | instance: { |
396 | shortDescription: 'my short description', | 384 | name: 'PeerTube updated', |
397 | description: 'my super description', | 385 | shortDescription: 'my short description', |
398 | terms: 'my super terms', | 386 | description: 'my super description', |
399 | defaultNSFWPolicy: 'blur', | 387 | terms: 'my super terms', |
400 | defaultClientRoute: '/videos/recently-added', | 388 | defaultNSFWPolicy: 'blur', |
401 | customizations: { | 389 | defaultClientRoute: '/videos/recently-added', |
402 | javascript: 'alert("coucou")', | 390 | customizations: { |
403 | css: 'body { background-color: red; }' | 391 | javascript: 'alert("coucou")', |
392 | css: 'body { background-color: red; }' | ||
393 | } | ||
404 | } | 394 | } |
405 | } | 395 | } |
406 | }) | 396 | }) |
407 | 397 | ||
408 | const resConfig = await getConfig(servers[0].url) | 398 | const config = await servers[0].config.getConfig() |
409 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') | 399 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') |
410 | 400 | ||
411 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body) | 401 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) |
412 | }) | 402 | }) |
413 | 403 | ||
414 | it('Should have valid index html updated tags (title, description...)', async function () { | 404 | it('Should have valid index html updated tags (title, description...)', async function () { |
415 | const resConfig = await getConfig(servers[0].url) | 405 | const config = await servers[0].config.getConfig() |
416 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') | 406 | const res = await makeHTMLRequest(servers[0].url, '/videos/trending') |
417 | 407 | ||
418 | 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) |
419 | }) | 409 | }) |
420 | 410 | ||
421 | it('Should use the original video URL for the canonical tag', async function () { | 411 | it('Should use the original video URL for the canonical tag', async function () { |
422 | for (const basePath of watchVideoBasePaths) { | 412 | for (const basePath of watchVideoBasePaths) { |
423 | for (const id of videoIds) { | 413 | for (const id of videoIds) { |
424 | const res = await makeHTMLRequest(servers[1].url, basePath + id) | 414 | const res = await makeHTMLRequest(servers[1].url, basePath + id) |
425 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`) | 415 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].store.video.uuid}" />`) |
426 | } | 416 | } |
427 | } | 417 | } |
428 | }) | 418 | }) |
429 | 419 | ||
430 | it('Should use the original account URL for the canonical tag', async function () { | 420 | it('Should use the original account URL for the canonical tag', async function () { |
431 | const accountURLtest = (res) => { | 421 | const accountURLtest = res => { |
432 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) | 422 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) |
433 | } | 423 | } |
434 | 424 | ||
@@ -438,7 +428,7 @@ describe('Test a client controllers', function () { | |||
438 | }) | 428 | }) |
439 | 429 | ||
440 | it('Should use the original channel URL for the canonical tag', async function () { | 430 | it('Should use the original channel URL for the canonical tag', async function () { |
441 | const channelURLtests = (res) => { | 431 | const channelURLtests = res => { |
442 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) | 432 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) |
443 | } | 433 | } |
444 | 434 | ||
@@ -460,10 +450,10 @@ describe('Test a client controllers', function () { | |||
460 | describe('Embed HTML', function () { | 450 | describe('Embed HTML', function () { |
461 | 451 | ||
462 | it('Should have the correct embed html tags', async function () { | 452 | it('Should have the correct embed html tags', async function () { |
463 | const resConfig = await getConfig(servers[0].url) | 453 | const config = await servers[0].config.getConfig() |
464 | const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath) | 454 | const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath) |
465 | 455 | ||
466 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body) | 456 | checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) |
467 | }) | 457 | }) |
468 | }) | 458 | }) |
469 | 459 | ||