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

header.js 4.3 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  1. const { getDOM } = require('../helpers/supertest')
  2. const { oldestSupported, latest } = require('../../lib/enterprise-server-releases')
  3. describe('header', () => {
  4. jest.setTimeout(5 * 60 * 1000)
  5. test('includes localized meta tags', async () => {
  6. const $ = await getDOM('/en')
  7. expect($('meta[name="site.data.ui.search.placeholder"]').length).toBe(1)
  8. })
  9. test('includes a link to the homepage (in the current page\'s language)', async () => {
  10. let $ = await getDOM('/en')
  11. expect($('#github-logo a[href="/en"]').length).toBe(2)
  12. $ = await getDOM('/ja')
  13. expect($('#github-logo a[href="/ja"]').length).toBe(2)
  14. expect($('#github-logo a[href="/en"]').length).toBe(0)
  15. })
  16. describe('language links', () => {
  17. test('lead to the same page in a different language', async () => {
  18. const $ = await getDOM('/github/administering-a-repository/managing-a-branch-protection-rule')
  19. expect($('#languages-selector a[href="/ja/github/administering-a-repository/managing-a-branch-protection-rule"]').length).toBe(1)
  20. })
  21. test('display the native name and the English name for each translated language', async () => {
  22. const $ = await getDOM('/en')
  23. expect($('#languages-selector a[href="/en"]').text().trim()).toBe('English')
  24. expect($('#languages-selector a[href="/cn"]').text().trim()).toBe('简体中文 (Simplified Chinese)')
  25. expect($('#languages-selector a[href="/ja"]').text().trim()).toBe('日本語 (Japanese)')
  26. })
  27. test('emphasize the current language', async () => {
  28. const $ = await getDOM('/en')
  29. expect($('#languages-selector a.active[href="/en"]').length).toBe(1)
  30. expect($('#languages-selector a[href="/ja"]').length).toBe(1)
  31. })
  32. })
  33. describe('notices', () => {
  34. test('displays a "localization in progress" notice for WIP languages', async () => {
  35. const $ = await getDOM('/de')
  36. expect($('.header-notifications.translation_notice').length).toBe(1)
  37. expect($('.header-notifications a[href="/en"]').length).toBe(1)
  38. })
  39. test('displays "complete" notice for non-WIP non-English languages', async () => {
  40. const $ = await getDOM('/ja')
  41. expect($('.header-notifications.translation_notice').length).toBe(1)
  42. expect($('.header-notifications a[href="/en"]').length).toBe(1)
  43. expect($('.header-notifications a[href*="github.com/contact"]').length).toBe(1)
  44. })
  45. test.skip('does not display any notices for English', async () => {
  46. const $ = await getDOM('/en')
  47. expect($('.header-notifications').length).toBe(0)
  48. })
  49. test('displays translation disclaimer notice on localized site-policy pages', async () => {
  50. const $ = await getDOM('/ja/github/site-policy/github-logo-policy')
  51. expect($('.header-notifications.translation_notice a[href="https://github.com/github/site-policy/issues"]').length).toBe(1)
  52. })
  53. })
  54. describe('mobile-only product dropdown links', () => {
  55. test('include github and admin, and emphasize the current product', async () => {
  56. const $ = await getDOM('/en/articles/enabling-required-status-checks')
  57. const github = $('#homepages a.active[href="/en/github"]')
  58. expect(github.length).toBe(1)
  59. expect(github.text().trim()).toBe('GitHub.com')
  60. expect(github.attr('class').includes('active')).toBe(true)
  61. const ghe = $(`#homepages a[href="/en/enterprise-server@${latest}/admin"]`)
  62. expect(ghe.length).toBe(1)
  63. expect(ghe.text().trim()).toBe('Enterprise Administrators')
  64. expect(ghe.attr('class').includes('active')).toBe(false)
  65. })
  66. test('point to homepages in the current page\'s language', async () => {
  67. const $ = await getDOM('/ja/github/administering-a-repository/defining-the-mergeability-of-pull-requests')
  68. expect($('#homepages a.active[href="/ja/github"]').length).toBe(1)
  69. expect($(`#homepages a[href="/ja/enterprise-server@${latest}/admin"]`).length).toBe(1)
  70. })
  71. test('emphasizes the product that corresponds to the current page', async () => {
  72. const $ = await getDOM(`/en/enterprise/${oldestSupported}/user/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address`)
  73. expect($(`#homepages a.active[href="/en/enterprise-server@${latest}/admin"]`).length).toBe(0)
  74. expect($('#homepages a[href="/en/github"]').length).toBe(1)
  75. expect($('#homepages a.active[href="/en/github"]').length).toBe(1)
  76. })
  77. })
  78. })
Tip!

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

Comments

Loading...