Skip to content
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

repo sync #24582

Merged
merged 1 commit into from
Mar 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
6 changes: 5 additions & 1 deletion components/guides/ArticleCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export const ArticleCards = () => {
</div>
</div>

<ul ref={articleCardRef} className="d-flex flex-wrap mr-0 mr-md-n6 mr-lg-n8">
<ul
data-testid="article-cards"
ref={articleCardRef}
className="d-flex flex-wrap mr-0 mr-md-n6 mr-lg-n8"
>
{guides.slice(0, numVisible).map((card) => {
return (
<ArticleCard
Expand Down
30 changes: 1 addition & 29 deletions tests/browser/browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jest } from '@jest/globals'
import { latest, oldestSupported } from '../../lib/enterprise-server-releases.js'
import { oldestSupported } from '../../lib/enterprise-server-releases.js'

jest.useFakeTimers({ legacyFakeTimers: true })

Expand Down Expand Up @@ -454,34 +454,6 @@ describe('code examples', () => {
})
})

describe('filter cards', () => {
it('works with select input', async () => {
await page.goto('http://localhost:4000/en/code-security/guides')
// 2nd element is 'Overview'
await page.click('[data-testid=card-filter-types] button')
await page.click('[data-testid=types-dropdown] > div > ul > li:nth-child(2)')
const shownCards = await page.$$('[data-testid=article-card]')
const shownCardTypes = await page.$$eval('[data-testid=article-card-type]', (cardTypes) =>
cardTypes.map((cardType) => cardType.textContent)
)
shownCardTypes.map((type) => expect(type).toBe('Overview'))
expect(shownCards.length).toBeGreaterThan(0)
})

it('works with select input on an Enterprise version', async () => {
await page.goto(`http://localhost:4000/en/enterprise-server@${latest}/code-security/guides`)
// 2nd element is 'Overview'
await page.click('[data-testid=card-filter-types] button')
await page.click('[data-testid=types-dropdown] > div > ul > li:nth-child(2)')
const shownCards = await page.$$('[data-testid=article-card]')
const shownCardTypes = await page.$$eval('[data-testid=article-card-type]', (cardTypes) =>
cardTypes.map((cardType) => cardType.textContent)
)
shownCardTypes.map((type) => expect(type).toBe('Overview'))
expect(shownCards.length).toBeGreaterThan(0)
})
})

// Skipping because next/links are disabled by default for now
// Docs Engineering issue: 962
describe.skip('next/link client-side navigation', () => {
Expand Down
19 changes: 19 additions & 0 deletions tests/fixtures/content/code-security/getting-started/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Get started articles
intro: code security get started articles
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
type: quick_start
topics:
- Pull requests
- Fundamentals
children:
- /quickstart
- /securing-your-organization
---

## Introduction
Code security get started articles
15 changes: 15 additions & 0 deletions tests/fixtures/content/code-security/getting-started/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Secure quickstart
intro: intro
allowTitleToDifferFromFilename: true
versions:
fpt: '*'
ghec: '*'
type: quick_start
topics:
- Codespaces
---

## Introduction

In this guide, you'll create a codespace from a template repository and explore some of the essential features available to you within the codespace.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Securing your organization
intro: a secure intro
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
type: how_to
topics:
- Organizations
- Dependencies
- Vulnerabilities
- Advanced Security
shortTitle: Secure your organization
---

## Introduction
secure your org
18 changes: 18 additions & 0 deletions tests/fixtures/content/code-security/guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Guides
intro: Guides
layout: product-guides
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
topics:
- Advanced Security
- Code scanning
- Actions
- Repositories
includeGuides:
- /code-security/getting-started/quickstart
- /code-security/getting-started/securing-your-organization
---
22 changes: 22 additions & 0 deletions tests/fixtures/content/code-security/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Code security documentation
shortTitle: Code security
intro: 'Code security'
layout: product-landing
featuredLinks:
startHere:
- /code-security/getting-started/quickstart
- /code-security/getting-started/securing-your-organization
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
children:
- /getting-started
- /guides
---




2 changes: 1 addition & 1 deletion tests/fixtures/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ children:
- search
- get-started
- early-access
- code-security
# - account-and-profile
# - authentication
# - repositories
# - admin
# - billing
# - site-policy
# - organizations
# - code-security
# - pull-requests
# - issues
# - actions
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/data/allowed-topics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Advanced Security', 'Code scanning', 'Actions', 'Repositories', '2FA']
28 changes: 28 additions & 0 deletions tests/rendering-fixtures/playwright-rendering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,31 @@ test.describe('platform picker', () => {
await expect(page.getByRole('heading', { name: /Macintosh/ })).not.toBeVisible()
})
})

test('filter article cards', async ({ page }) => {
await page.goto('/code-security/guides')
const articleCards = page.getByTestId('article-cards')
await expect(articleCards.getByText('Secure quickstart')).toBeVisible()
await expect(articleCards.getByText('Securing your organization')).toBeVisible()

// For both the type and topic dropdowns, with the Primer component we use it
// ends creating a button to open the dropdowns so that's why we're clicking
// a button here to expand the option items.

// all the articles are displayed, filter by topic
await page.getByTestId('card-filter-topics').getByRole('button', { name: 'All' }).click()
await page.getByTestId('topics-dropdown').getByText('Organizations').click()
await expect(articleCards.getByText('Secure quickstart')).not.toBeVisible()
await expect(articleCards.getByText('Securing your organization')).toBeVisible()

// now show all the articles again and then filter by type
await page
.getByTestId('card-filter-topics')
.getByRole('button', { name: 'Organizations' })
.click()
await page.getByTestId('topics-dropdown').getByText('All').click()
await page.getByTestId('card-filter-types').getByRole('button', { name: 'All' }).click()
await page.getByTestId('types-dropdown').getByText('Quickstart').click()
await expect(articleCards.getByText('Secure quickstart')).toBeVisible()
await expect(articleCards.getByText('Securing your organization')).not.toBeVisible()
})