diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/client.ts | 154 |
1 files changed, 118 insertions, 36 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts index 3c99bcd1f..e76220631 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -140,27 +140,51 @@ describe('Test a client controllers', function () { | |||
140 | describe('Open Graph', function () { | 140 | describe('Open Graph', function () { |
141 | 141 | ||
142 | it('Should have valid Open Graph tags on the account page', async function () { | 142 | it('Should have valid Open Graph tags on the account page', async function () { |
143 | const res = await request(servers[0].url) | 143 | const accountPageTests = (res) => { |
144 | expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) | ||
145 | expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`) | ||
146 | expect(res.text).to.contain('<meta property="og:type" content="website" />') | ||
147 | expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`) | ||
148 | } | ||
149 | |||
150 | accountPageTests(await request(servers[0].url) | ||
144 | .get('/accounts/' + servers[0].user.username) | 151 | .get('/accounts/' + servers[0].user.username) |
145 | .set('Accept', 'text/html') | 152 | .set('Accept', 'text/html') |
146 | .expect(HttpStatusCode.OK_200) | 153 | .expect(HttpStatusCode.OK_200)) |
154 | |||
155 | accountPageTests(await request(servers[0].url) | ||
156 | .get('/a/' + servers[0].user.username) | ||
157 | .set('Accept', 'text/html') | ||
158 | .expect(HttpStatusCode.OK_200)) | ||
147 | 159 | ||
148 | expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) | 160 | accountPageTests(await request(servers[0].url) |
149 | expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`) | 161 | .get('/@' + servers[0].user.username) |
150 | expect(res.text).to.contain('<meta property="og:type" content="website" />') | 162 | .set('Accept', 'text/html') |
151 | expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`) | 163 | .expect(HttpStatusCode.OK_200)) |
152 | }) | 164 | }) |
153 | 165 | ||
154 | it('Should have valid Open Graph tags on the channel page', async function () { | 166 | it('Should have valid Open Graph tags on the channel page', async function () { |
155 | const res = await request(servers[0].url) | 167 | const channelPageOGtests = (res) => { |
168 | expect(res.text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`) | ||
169 | expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) | ||
170 | expect(res.text).to.contain('<meta property="og:type" content="website" />') | ||
171 | expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`) | ||
172 | } | ||
173 | |||
174 | channelPageOGtests(await request(servers[0].url) | ||
156 | .get('/video-channels/' + servers[0].videoChannel.name) | 175 | .get('/video-channels/' + servers[0].videoChannel.name) |
157 | .set('Accept', 'text/html') | 176 | .set('Accept', 'text/html') |
158 | .expect(HttpStatusCode.OK_200) | 177 | .expect(HttpStatusCode.OK_200)) |
178 | |||
179 | channelPageOGtests(await request(servers[0].url) | ||
180 | .get('/c/' + servers[0].videoChannel.name) | ||
181 | .set('Accept', 'text/html') | ||
182 | .expect(HttpStatusCode.OK_200)) | ||
159 | 183 | ||
160 | expect(res.text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`) | 184 | channelPageOGtests(await request(servers[0].url) |
161 | expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) | 185 | .get('/@' + servers[0].videoChannel.name) |
162 | expect(res.text).to.contain('<meta property="og:type" content="website" />') | 186 | .set('Accept', 'text/html') |
163 | expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`) | 187 | .expect(HttpStatusCode.OK_200)) |
164 | }) | 188 | }) |
165 | 189 | ||
166 | it('Should have valid Open Graph tags on the watch page with video id', async function () { | 190 | it('Should have valid Open Graph tags on the watch page with video id', async function () { |
@@ -227,27 +251,51 @@ describe('Test a client controllers', function () { | |||
227 | }) | 251 | }) |
228 | 252 | ||
229 | it('Should have valid twitter card on the account page', async function () { | 253 | it('Should have valid twitter card on the account page', async function () { |
230 | const res = await request(servers[0].url) | 254 | const accountPageTests = (res) => { |
255 | expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') | ||
256 | expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') | ||
257 | expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`) | ||
258 | expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`) | ||
259 | } | ||
260 | |||
261 | accountPageTests(await request(servers[0].url) | ||
231 | .get('/accounts/' + account.name) | 262 | .get('/accounts/' + account.name) |
232 | .set('Accept', 'text/html') | 263 | .set('Accept', 'text/html') |
233 | .expect(HttpStatusCode.OK_200) | 264 | .expect(HttpStatusCode.OK_200)) |
234 | 265 | ||
235 | expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') | 266 | accountPageTests(await request(servers[0].url) |
236 | expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') | 267 | .get('/a/' + account.name) |
237 | expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`) | 268 | .set('Accept', 'text/html') |
238 | expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`) | 269 | .expect(HttpStatusCode.OK_200)) |
270 | |||
271 | accountPageTests(await request(servers[0].url) | ||
272 | .get('/@' + account.name) | ||
273 | .set('Accept', 'text/html') | ||
274 | .expect(HttpStatusCode.OK_200)) | ||
239 | }) | 275 | }) |
240 | 276 | ||
241 | it('Should have valid twitter card on the channel page', async function () { | 277 | it('Should have valid twitter card on the channel page', async function () { |
242 | const res = await request(servers[0].url) | 278 | const channelPageTests = (res) => { |
279 | expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') | ||
280 | expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') | ||
281 | expect(res.text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`) | ||
282 | expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) | ||
283 | } | ||
284 | |||
285 | channelPageTests(await request(servers[0].url) | ||
243 | .get('/video-channels/' + servers[0].videoChannel.name) | 286 | .get('/video-channels/' + servers[0].videoChannel.name) |
244 | .set('Accept', 'text/html') | 287 | .set('Accept', 'text/html') |
245 | .expect(HttpStatusCode.OK_200) | 288 | .expect(HttpStatusCode.OK_200)) |
246 | 289 | ||
247 | expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') | 290 | channelPageTests(await request(servers[0].url) |
248 | expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') | 291 | .get('/c/' + servers[0].videoChannel.name) |
249 | expect(res.text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`) | 292 | .set('Accept', 'text/html') |
250 | expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) | 293 | .expect(HttpStatusCode.OK_200)) |
294 | |||
295 | channelPageTests(await request(servers[0].url) | ||
296 | .get('/@' + servers[0].videoChannel.name) | ||
297 | .set('Accept', 'text/html') | ||
298 | .expect(HttpStatusCode.OK_200)) | ||
251 | }) | 299 | }) |
252 | 300 | ||
253 | it('Should have valid twitter card if Twitter is whitelisted', async function () { | 301 | it('Should have valid twitter card if Twitter is whitelisted', async function () { |
@@ -275,21 +323,45 @@ describe('Test a client controllers', function () { | |||
275 | expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />') | 323 | expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />') |
276 | expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') | 324 | expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') |
277 | 325 | ||
278 | const resAccountRequest = await request(servers[0].url) | 326 | const accountTests = (res) => { |
327 | expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') | ||
328 | expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />') | ||
329 | } | ||
330 | |||
331 | accountTests(await request(servers[0].url) | ||
279 | .get('/accounts/' + account.name) | 332 | .get('/accounts/' + account.name) |
280 | .set('Accept', 'text/html') | 333 | .set('Accept', 'text/html') |
281 | .expect(HttpStatusCode.OK_200) | 334 | .expect(HttpStatusCode.OK_200)) |
335 | |||
336 | accountTests(await request(servers[0].url) | ||
337 | .get('/a/' + account.name) | ||
338 | .set('Accept', 'text/html') | ||
339 | .expect(HttpStatusCode.OK_200)) | ||
340 | |||
341 | accountTests(await request(servers[0].url) | ||
342 | .get('/@' + account.name) | ||
343 | .set('Accept', 'text/html') | ||
344 | .expect(HttpStatusCode.OK_200)) | ||
282 | 345 | ||
283 | expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />') | 346 | const channelTests = (res) => { |
284 | expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') | 347 | expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') |
348 | expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />') | ||
349 | } | ||
285 | 350 | ||
286 | const resChannelRequest = await request(servers[0].url) | 351 | channelTests(await request(servers[0].url) |
287 | .get('/video-channels/' + servers[0].videoChannel.name) | 352 | .get('/video-channels/' + servers[0].videoChannel.name) |
288 | .set('Accept', 'text/html') | 353 | .set('Accept', 'text/html') |
289 | .expect(HttpStatusCode.OK_200) | 354 | .expect(HttpStatusCode.OK_200)) |
355 | |||
356 | channelTests(await request(servers[0].url) | ||
357 | .get('/c/' + servers[0].videoChannel.name) | ||
358 | .set('Accept', 'text/html') | ||
359 | .expect(HttpStatusCode.OK_200)) | ||
290 | 360 | ||
291 | expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />') | 361 | channelTests(await request(servers[0].url) |
292 | expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') | 362 | .get('/@' + servers[0].videoChannel.name) |
363 | .set('Accept', 'text/html') | ||
364 | .expect(HttpStatusCode.OK_200)) | ||
293 | }) | 365 | }) |
294 | }) | 366 | }) |
295 | 367 | ||
@@ -335,13 +407,23 @@ describe('Test a client controllers', function () { | |||
335 | }) | 407 | }) |
336 | 408 | ||
337 | it('Should use the original account URL for the canonical tag', async function () { | 409 | it('Should use the original account URL for the canonical tag', async function () { |
338 | const res = await makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host) | 410 | const accountURLtest = (res) => { |
339 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) | 411 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) |
412 | } | ||
413 | |||
414 | accountURLtest(await makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host)) | ||
415 | accountURLtest(await makeHTMLRequest(servers[1].url, '/a/root@' + servers[0].host)) | ||
416 | accountURLtest(await makeHTMLRequest(servers[1].url, '/@root@' + servers[0].host)) | ||
340 | }) | 417 | }) |
341 | 418 | ||
342 | it('Should use the original channel URL for the canonical tag', async function () { | 419 | it('Should use the original channel URL for the canonical tag', async function () { |
343 | const res = await makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host) | 420 | const channelURLtests = (res) => { |
344 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) | 421 | expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) |
422 | } | ||
423 | |||
424 | channelURLtests(await makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host)) | ||
425 | channelURLtests(await makeHTMLRequest(servers[1].url, '/c/root_channel@' + servers[0].host)) | ||
426 | channelURLtests(await makeHTMLRequest(servers[1].url, '/@root_channel@' + servers[0].host)) | ||
345 | }) | 427 | }) |
346 | 428 | ||
347 | it('Should use the original playlist URL for the canonical tag', async function () { | 429 | it('Should use the original playlist URL for the canonical tag', async function () { |