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