Skip to content

Repo sync #26947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/article/PlatformPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ function showPlatformSpecificContent(platform: string) {
.filter((el) => platforms.some((platform) => el.classList.contains(platform.value)))
.forEach((el) => {
el.style.display = el.classList.contains(platform) ? '' : 'none'

// hack: special handling for minitoc links -- we can't pass the tool classes
// directly to the Primer NavList.Item generated <li>, it gets passed down
// to the child <a>. So if we find an <a> that has the tool class and its
// parent is an <li>, we hide/unhide that element as well.
if (el.tagName === 'A' && el.parentElement && el.parentElement.tagName === 'LI') {
el.parentElement.style.display = el.classList.contains(platform) ? '' : 'none'
}
})

// find all platform-specific *inline* elements and hide or show as appropriate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ versions:
ghae: '*'
ghec: '*'
type: how_to
defaultPlatform: windows
---

## General
Expand Down
50 changes: 36 additions & 14 deletions tests/rendering-fixtures/playwright-rendering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ test.describe('platform picker', () => {
await expect(page.getByRole('heading', { name: /Macintosh/ })).not.toBeVisible()
})

test('minitoc matches picker', async ({ page }) => {
// default platform set to windows in fixture fronmatter
await page.goto('/get-started/liquid/platform-specific')
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Macintosh until 1999' }),
).not.toBeVisible()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Windows 95 was awesome' }),
).toBeVisible()
await page.getByTestId('platform-picker').getByRole('link', { name: 'Linux' }).click()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Macintosh until 1999' }),
).not.toBeVisible()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'The year of Linux on the desktop' }),
).toBeVisible()
})

test('remember last clicked OS', async ({ page }) => {
await page.goto('/get-started/liquid/platform-specific')
await page.getByTestId('platform-picker').getByRole('link', { name: 'Windows' }).click()
Expand All @@ -97,20 +115,6 @@ test.describe('tool picker', () => {
await expect(page.getByText('this is cli content')).not.toBeVisible()
await expect(page.getByText('this is desktop content')).not.toBeVisible()
await expect(page.getByText('this is webui content')).toBeVisible()

// Go to page again so that we start with the default webui content and can
// check the minitoc links
await page.goto('/get-started/liquid/tool-specific')
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Webui section' }),
).toBeVisible()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
).not.toBeVisible()
await page.getByTestId('tool-picker').getByRole('link', { name: 'Web browser' }).click()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
).not.toBeVisible()
})

test('prefer default tool', async ({ page }) => {
Expand All @@ -132,6 +136,24 @@ test.describe('tool picker', () => {
await expect(page.getByText('this is desktop content')).not.toBeVisible()
await expect(page.getByText('this is webui content')).toBeVisible()
})

test('minitoc matches picker', async ({ page }) => {
// default tool set to desktop in fixture fronmatter
await page.goto('/get-started/liquid/tool-specific')
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
).toBeVisible()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Webui section' }),
).not.toBeVisible()
await page.getByTestId('tool-picker').getByRole('link', { name: 'Web browser' }).click()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Desktop section' }),
).not.toBeVisible()
await expect(
page.getByTestId('minitoc').getByRole('link', { name: 'Webui section' }),
).toBeVisible()
})
})

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