Skip to content

Commit aa3e324

Browse files
authored
Merge pull request #26947 from github/repo-sync
Repo sync
2 parents c380715 + 764530d commit aa3e324

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

components/article/PlatformPicker.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ function showPlatformSpecificContent(platform: string) {
2222
.filter((el) => platforms.some((platform) => el.classList.contains(platform.value)))
2323
.forEach((el) => {
2424
el.style.display = el.classList.contains(platform) ? '' : 'none'
25+
26+
// hack: special handling for minitoc links -- we can't pass the tool classes
27+
// directly to the Primer NavList.Item generated <li>, it gets passed down
28+
// to the child <a>. So if we find an <a> that has the tool class and its
29+
// parent is an <li>, we hide/unhide that element as well.
30+
if (el.tagName === 'A' && el.parentElement && el.parentElement.tagName === 'LI') {
31+
el.parentElement.style.display = el.classList.contains(platform) ? '' : 'none'
32+
}
2533
})
2634

2735
// find all platform-specific *inline* elements and hide or show as appropriate

tests/fixtures/content/get-started/liquid/platform-specific.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ versions:
77
ghae: '*'
88
ghec: '*'
99
type: how_to
10+
defaultPlatform: windows
1011
---
1112

1213
## General

tests/rendering-fixtures/playwright-rendering.spec.ts

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ test.describe('platform picker', () => {
7272
await expect(page.getByRole('heading', { name: /Macintosh/ })).not.toBeVisible()
7373
})
7474

75+
test('minitoc matches picker', async ({ page }) => {
76+
// default platform set to windows in fixture fronmatter
77+
await page.goto('/get-started/liquid/platform-specific')
78+
await expect(
79+
page.getByTestId('minitoc').getByRole('link', { name: 'Macintosh until 1999' }),
80+
).not.toBeVisible()
81+
await expect(
82+
page.getByTestId('minitoc').getByRole('link', { name: 'Windows 95 was awesome' }),
83+
).toBeVisible()
84+
await page.getByTestId('platform-picker').getByRole('link', { name: 'Linux' }).click()
85+
await expect(
86+
page.getByTestId('minitoc').getByRole('link', { name: 'Macintosh until 1999' }),
87+
).not.toBeVisible()
88+
await expect(
89+
page.getByTestId('minitoc').getByRole('link', { name: 'The year of Linux on the desktop' }),
90+
).toBeVisible()
91+
})
92+
7593
test('remember last clicked OS', async ({ page }) => {
7694
await page.goto('/get-started/liquid/platform-specific')
7795
await page.getByTestId('platform-picker').getByRole('link', { name: 'Windows' }).click()
@@ -97,20 +115,6 @@ test.describe('tool picker', () => {
97115
await expect(page.getByText('this is cli content')).not.toBeVisible()
98116
await expect(page.getByText('this is desktop content')).not.toBeVisible()
99117
await expect(page.getByText('this is webui content')).toBeVisible()
100-
101-
// Go to page again so that we start with the default webui content and can
102-
// check the minitoc links
103-
await page.goto('/get-started/liquid/tool-specific')
104-
await expect(
105-
page.getByTestId('minitoc').getByRole('link', { name: 'Webui section' }),
106-
).toBeVisible()
107-
await expect(
108-
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
109-
).not.toBeVisible()
110-
await page.getByTestId('tool-picker').getByRole('link', { name: 'Web browser' }).click()
111-
await expect(
112-
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
113-
).not.toBeVisible()
114118
})
115119

116120
test('prefer default tool', async ({ page }) => {
@@ -132,6 +136,24 @@ test.describe('tool picker', () => {
132136
await expect(page.getByText('this is desktop content')).not.toBeVisible()
133137
await expect(page.getByText('this is webui content')).toBeVisible()
134138
})
139+
140+
test('minitoc matches picker', async ({ page }) => {
141+
// default tool set to desktop in fixture fronmatter
142+
await page.goto('/get-started/liquid/tool-specific')
143+
await expect(
144+
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
145+
).toBeVisible()
146+
await expect(
147+
page.getByTestId('minitoc').getByRole('link', { name: 'Webui section' }),
148+
).not.toBeVisible()
149+
await page.getByTestId('tool-picker').getByRole('link', { name: 'Web browser' }).click()
150+
await expect(
151+
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
152+
).not.toBeVisible()
153+
await expect(
154+
page.getByTestId('minitoc').getByRole('link', { name: 'Webui section' }),
155+
).toBeVisible()
156+
})
135157
})
136158

137159
test('filter article cards', async ({ page }) => {

0 commit comments

Comments
 (0)