Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

featured-links.js 3.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  1. const { getDOM, getJSON } = require('../helpers/supertest')
  2. const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
  3. const japaneseCharacters = require('japanese-characters')
  4. describe('featuredLinks', () => {
  5. jest.setTimeout(3 * 60 * 1000)
  6. describe('rendering', () => {
  7. test('non-TOC pages do not have intro links', async () => {
  8. const $ = await getDOM('/en/github/getting-started-with-github/set-up-git')
  9. expect($('.featured-links')).toHaveLength(0)
  10. })
  11. test('landing page intro links have expected properties', async () => {
  12. const $ = await getDOM('/en')
  13. const $featuredLinks = $('.featured-links a')
  14. expect($featuredLinks).toHaveLength(9)
  15. expect($featuredLinks.eq(0).attr('href')).toBe('/en/github/getting-started-with-github/set-up-git')
  16. expect($featuredLinks.eq(0).children('h4').text().startsWith('Set up Git')).toBe(true)
  17. expect($featuredLinks.eq(0).children('p').text().startsWith('At the heart of GitHub')).toBe(true)
  18. expect($featuredLinks.eq(8).attr('href')).toBe('/en/github/working-with-github-pages')
  19. expect($featuredLinks.eq(8).children('h4').text().startsWith('GitHub Pages')).toBe(true)
  20. expect($featuredLinks.eq(8).children('p').text().startsWith('You can create a website')).toBe(true)
  21. })
  22. test('localized intro links link to localized pages', async () => {
  23. const $ = await getDOM('/ja')
  24. const $featuredLinks = $('.featured-links a')
  25. expect($featuredLinks).toHaveLength(9)
  26. expect($featuredLinks.eq(0).attr('href').startsWith('/ja')).toBe(true)
  27. expect(japaneseCharacters.presentIn($featuredLinks.eq(0).children('h4').text())).toBe(true)
  28. expect(japaneseCharacters.presentIn($featuredLinks.eq(0).children('p').text())).toBe(true)
  29. })
  30. test('Enterprise user intro links have expected values', async () => {
  31. const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/insights`)
  32. const $featuredLinks = $('.featured-links a')
  33. expect($featuredLinks).toHaveLength(6)
  34. expect($featuredLinks.eq(0).attr('href')).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/about-github-insights`)
  35. expect($featuredLinks.eq(0).children('h4').text().startsWith('About GitHub Insights')).toBe(true)
  36. expect($featuredLinks.eq(0).children('p').text().startsWith('GitHub Insights provides metrics')).toBe(true)
  37. })
  38. test('featured links respect versioning', async () => {
  39. const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/packages`)
  40. const $featuredLinks = $('.all-articles-list a')
  41. expect($featuredLinks.length).toBeGreaterThan(2)
  42. expect($featuredLinks.text().includes('Package client guides for GitHub Packages')).toBe(true)
  43. // does not include dotcom-only links
  44. expect($featuredLinks.text().includes('About GitHub Container Registry')).toBe(false)
  45. expect($featuredLinks.text().includes('Getting started with GitHub Container Registry')).toBe(false)
  46. })
  47. })
  48. describe('context.page object', () => {
  49. test('returns modified array of links', async () => {
  50. const gettingStartedLinks = await getJSON('/en?json=featuredLinks.gettingStarted')
  51. const expectedFirstLink = {
  52. href: '/en/github/getting-started-with-github/set-up-git',
  53. title: 'Set up Git'
  54. }
  55. expect(gettingStartedLinks[0].href).toEqual(expectedFirstLink.href)
  56. expect(gettingStartedLinks[0].title).toEqual(expectedFirstLink.title)
  57. expect(gettingStartedLinks[0].intro.startsWith('At the heart of GitHub')).toBe(true)
  58. })
  59. test('returns raw array of links on the page object', async () => {
  60. const rawGettingStartedLinks = await getJSON('/en?json=page.featuredLinks.gettingStarted')
  61. expect(rawGettingStartedLinks[0]).toEqual('/github/getting-started-with-github/set-up-git')
  62. })
  63. })
  64. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...