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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
- const { getDOM, getJSON } = require('../helpers/supertest')
- const describeInternalOnly = process.env.GITHUB_REPOSITORY === 'github/docs-internal' ? describe : describe.skip
- describe('breadcrumbs', () => {
- jest.setTimeout(300 * 1000)
- describe('rendering', () => {
- test('top-level product pages have breadcrumbs', async () => {
- const $ = await getDOM('/github')
- expect($('.breadcrumbs')).toHaveLength(1)
- })
- test('article pages have breadcrumbs with product, category, maptopic, and article', async () => {
- const $ = await getDOM('/github/getting-started-with-github/supported-browsers')
- const $breadcrumbs = $('.breadcrumbs a')
- expect($breadcrumbs).toHaveLength(4)
- expect($breadcrumbs.eq(0).attr('title')).toBe('product: GitHub.com')
- expect($breadcrumbs.eq(1).attr('title')).toBe('category: Getting started')
- expect($breadcrumbs.eq(2).attr('title')).toBe('maptopic: Using GitHub')
- expect($breadcrumbs.eq(3).attr('title')).toBe('article: Supported browsers')
- })
- test('maptopic pages include their own grayed-out breadcrumb', async () => {
- const $ = await getDOM('/github/getting-started-with-github/using-github')
- const $breadcrumbs = $('.breadcrumbs a')
- expect($breadcrumbs).toHaveLength(3)
- expect($breadcrumbs.eq(0).attr('title')).toBe('product: GitHub.com')
- expect($breadcrumbs.eq(1).attr('title')).toBe('category: Getting started')
- expect($breadcrumbs.eq(2).attr('title')).toBe('maptopic: Using GitHub')
- expect($breadcrumbs.eq(2).hasClass('color-text-tertiary')).toBe(true)
- })
- test('works for enterprise user pages', async () => {
- const $ = await getDOM('/en/enterprise/user/github/getting-started-with-github/supported-browsers')
- const $breadcrumbs = $('.breadcrumbs a')
- expect($breadcrumbs).toHaveLength(4)
- // The product is still GitHub.com on an Enterprise Server version
- expect($breadcrumbs.eq(0).attr('title')).toBe('product: GitHub.com')
- })
- test('parses Liquid variables inside titles', async () => {
- const $ = await getDOM('/en/enterprise/admin/enterprise-support')
- const $breadcrumbs = $('.breadcrumbs a')
- expect($breadcrumbs).toHaveLength(2)
- expect($breadcrumbs.eq(1).attr('title')).toBe('category: Working with GitHub Support')
- })
- test('English breadcrumbs link to English pages', async () => {
- const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account')
- const $breadcrumbs = $('.breadcrumbs a')
- expect($breadcrumbs.eq(0).attr('href')).toBe('/en/github')
- })
- test('localized breadcrumbs link to localize pages', async () => {
- const $ = await getDOM('/ja/github/setting-up-and-managing-your-github-user-account')
- const $breadcrumbs = $('.breadcrumbs a')
- expect($breadcrumbs.eq(0).attr('href')).toBe('/ja/github')
- })
- })
- describeInternalOnly('early access rendering', () => {
- test('top-level product pages have breadcrumbs', async () => {
- const $ = await getDOM('/early-access/github/articles/using-gist-playground')
- expect($('.breadcrumbs')).toHaveLength(1)
- })
- test('early access article pages have breadcrumbs with product, category, and article', async () => {
- const $ = await getDOM('/early-access/github/enforcing-best-practices-with-github-policies/about-github-policies')
- const $breadcrumbSpans = $('.breadcrumbs span')
- const $breadcrumbLinks = $('.breadcrumbs a')
- expect($breadcrumbSpans).toHaveLength(2)
- expect($breadcrumbLinks).toHaveLength(2)
- expect($breadcrumbSpans.eq(0).text()).toBe('Early Access documentation')
- expect($breadcrumbSpans.eq(1).text()).toBe('GitHub.com')
- expect($breadcrumbLinks.eq(0).attr('title')).toBe('category: Enforcing best practices with GitHub Policies')
- expect($breadcrumbLinks.eq(1).attr('title')).toBe('article: About GitHub Policies')
- expect($breadcrumbLinks.eq(1).hasClass('color-text-tertiary')).toBe(true)
- })
- })
- describe('context.breadcrumbs object', () => {
- test('works on product index pages', async () => {
- const breadcrumbs = await getJSON('/en/github?json=breadcrumbs')
- const expected = {
- product: {
- href: '/en/github',
- title: 'GitHub.com'
- }
- }
- expect(breadcrumbs).toEqual(expected)
- })
- test('works on category index pages', async () => {
- const breadcrumbs = await getJSON('/en/github/authenticating-to-github?json=breadcrumbs')
- const expected = {
- product: {
- href: '/en/github',
- title: 'GitHub.com'
- },
- category: {
- href: '/en/github/authenticating-to-github',
- title: 'Authentication'
- }
- }
- expect(breadcrumbs).toEqual(expected)
- })
- test('works on maptopic pages', async () => {
- const breadcrumbs = await getJSON('/en/github/authenticating-to-github/keeping-your-account-and-data-secure?json=breadcrumbs')
- const expected = {
- product: {
- href: '/en/github',
- title: 'GitHub.com'
- },
- category: {
- href: '/en/github/authenticating-to-github',
- title: 'Authentication'
- },
- maptopic: {
- href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure',
- title: 'Keeping your account and data secure'
- }
- }
- expect(breadcrumbs).toEqual(expected)
- })
- test('works on articles that DO have maptopics ', async () => {
- const breadcrumbs = await getJSON('/en/github/authenticating-to-github/creating-a-strong-password?json=breadcrumbs')
- const expected = {
- product: {
- href: '/en/github',
- title: 'GitHub.com'
- },
- category: {
- href: '/en/github/authenticating-to-github',
- title: 'Authentication'
- },
- maptopic: {
- href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure',
- title: 'Keeping your account and data secure'
- },
- article: {
- href: '/en/github/authenticating-to-github/creating-a-strong-password',
- title: 'Creating a strong password'
- }
- }
- expect(breadcrumbs).toEqual(expected)
- })
- test('works on articles that DO NOT have maptopics ', async () => {
- const breadcrumbs = await getJSON('/github/site-policy/github-privacy-statement?json=breadcrumbs')
- const expected = {
- product: {
- href: '/en/github',
- title: 'GitHub.com'
- },
- category: {
- href: '/en/github/site-policy',
- title: 'Site policy'
- },
- article: {
- href: '/en/github/site-policy/github-privacy-statement',
- title: 'GitHub Privacy Statement'
- }
- }
- expect(breadcrumbs).toEqual(expected)
- })
- test('returns an empty object on the landing page', async () => {
- const breadcrumbs = await getJSON('/en?json=breadcrumbs')
- expect(breadcrumbs).toEqual({})
- })
- })
- })
|