Skip to content

repo sync #24186

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 2 commits into from
Feb 27, 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
33 changes: 33 additions & 0 deletions .github/actions/get-docs-early-access/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Clone and add docs-early-access

description: Clone docs-early-access and copy its content into the repo

inputs:
token:
description: PAT
required: true

runs:
using: 'composite'
steps:
- name: Figure out which branch to checkout
id: check-early-access
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
GITHUB_TOKEN: ${{ inputs.token }}
shell: bash
run: node .github/actions-scripts/what-docs-early-access-branch.js

- name: Clone
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
repository: github/docs-early-access
token: ${{ inputs.token }}
path: docs-early-access
ref: ${{ steps.check-early-access.outputs.branch }}

- name: Merge docs-early-access repo's folders
shell: bash
run: |
.github/actions-scripts/merge-early-access.sh
rm -fr docs-early-access
20 changes: 1 addition & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,10 @@ jobs:

- uses: ./.github/actions/node-npm-setup

- name: Figure out which docs-early-access branch to checkout, if internal repo
- uses: ./.github/actions/get-docs-early-access
if: ${{ github.repository == 'github/docs-internal' }}
id: check-early-access
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }}
run: node .github/actions-scripts/what-docs-early-access-branch.js

- name: Check out docs-early-access too, if internal repo
if: ${{ github.repository == 'github/docs-internal' }}
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
repository: github/docs-early-access
token: ${{ secrets.DOCUBOT_REPO_PAT }}
path: docs-early-access
ref: ${{ steps.check-early-access.outputs.branch }}

- name: Merge docs-early-access repo's folders
if: ${{ github.repository == 'github/docs-internal' }}
run: |
.github/actions-scripts/merge-early-access.sh
rm -fr docs-early-access

- name: Check the test fixture data (if applicable)
if: ${{ matrix.test-group == 'rendering-fixtures' }}
Expand Down
13 changes: 13 additions & 0 deletions tests/fixtures/content/early-access/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Early Access documentation
hidden: true
versions: '*'
children:
- /secrets
---

👋 Hello, local test developer! This page is not visible on production.

These are the Early Access pages for {{ allVersions[currentVersion].versionTitle }}:

{{ earlyAccessPageLinks }}
7 changes: 7 additions & 0 deletions tests/fixtures/content/early-access/secrets/deeper/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Deeper secrets
versions: '*'
hidden: true
children:
- /mariana-trench
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Mariana Trench
versions: '*'
hidden: true
---

## This is a deep early-access article

Exists to test stuff like breadcrumbs.
8 changes: 8 additions & 0 deletions tests/fixtures/content/early-access/secrets/early-days.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Early days
hidden: true
versions:
fpt: '*'
---

This page is only available in **free, pro, & team**.
8 changes: 8 additions & 0 deletions tests/fixtures/content/early-access/secrets/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: GitHub Secrets
versions: '*'
hidden: true
children:
- /early-days
- /deeper
---
14 changes: 14 additions & 0 deletions tests/fixtures/content/get-started/quickstart/dynamic-title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: '{% ifversion fpt %}Hello{% else %}Greetings{% endif %} {% data variables.product.product_name %}'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
type: quick_start
---

## Introduction

This page has a single `title` and it uses Liquid that depends on
`ifversion` and `data variables...`.
1 change: 1 addition & 0 deletions tests/fixtures/content/get-started/quickstart/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ versions:
children:
- /hello-world
- /link-rewriting
- /dynamic-title
---
2 changes: 1 addition & 1 deletion tests/fixtures/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ children:
# as if the URL had been `/en/free-pro-team@latest/get-started/anything`.
- search
- get-started
- early-access
# - account-and-profile
# - authentication
# - repositories
Expand All @@ -42,7 +43,6 @@ children:
# - pages
# - education
# - desktop
# - early-access
# - support
childGroups:
- name: Get started
Expand Down
83 changes: 83 additions & 0 deletions tests/rendering-fixtures/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { getDOM } from '../helpers/e2etest.js'

describe('breadcrumbs', () => {
test('top-level product pages have breadcrumbs and breadcrumbs should exist regardless of header or in-article', async () => {
const $ = await getDOM('/get-started')
const links = $('[data-testid=breadcrumbs-in-article] a')
expect(links.attr('class').includes('d-none')).toBe(false)
})

test('links always prefixed with language', async () => {
const $ = await getDOM('/get-started/quickstart/hello-world')
const links = $('[data-testid=breadcrumbs-in-article] a')
links.each((i, element) => {
expect($(element).attr('href').startsWith('/en/')).toBe(true)
})
expect.assertions(3)
})

test('top-level hidden /search page has no breadcrumbs', async () => {
const $ = await getDOM('/search')
const links = $('[data-testid=breadcrumbs-in-article] a')
expect(links.length).toBe(0)
const headers = $('[data-testid=breadcrumbs-header]')
expect(headers.length).toBe(0)
})

test('short titles are preferred', async () => {
const $ = await getDOM('/get-started/foo/bar')
const links = $('[data-testid=breadcrumbs-in-article] a:last-child')
expect(links.text()).toBe('Bar')
})

test('article pages have breadcrumbs in article with product, category, maptopic, and article and last breadcrumb is not viewable', async () => {
const $ = await getDOM('/get-started/quickstart/hello-world')
const links = $('[data-testid=breadcrumbs-in-article] a')
expect(links.length).toBe(3)
expect($(links[0]).text()).toBe('Get started')
expect($(links[0]).attr('class').includes('d-none')).toBe(false)
expect($(links[1]).text()).toBe('Quickstart')
expect($(links[1]).attr('class').includes('d-none')).toBe(false)
expect($(links[2]).text()).toBe('Hello World')
expect($(links[2]).attr('class').includes('d-none')).toBe(true)
})

test('works for enterprise-server articles too', async () => {
const $ = await getDOM('/enterprise-server@latest/get-started/quickstart/hello-world')
const links = $('[data-testid=breadcrumbs-in-article] a')
expect(links.length).toBe(3)
expect($(links[0]).text()).toBe('Get started')
expect($(links[1]).text()).toBe('Quickstart')
expect($(links[2]).text()).toBe('Hello World')
})

test('works for titles that depend on Liquid', async () => {
const $fpt = await getDOM('/get-started/quickstart/dynamic-title')
const fptLinks = $fpt('[data-testid=breadcrumbs-in-article] a')
expect($fpt(fptLinks[2]).text()).toBe('Hello GitHub')

const $ghec = await getDOM('/enterprise-cloud@latest/get-started/quickstart/dynamic-title')
const ghecLinks = $ghec('[data-testid=breadcrumbs-in-article] a')
expect($ghec(ghecLinks[2]).text()).toBe('Greetings GitHub Enterprise Cloud')
})

// Note, early access always work for fixture content
test('top-level product pages have breadcrumbs', async () => {
const $ = await getDOM('/early-access/secrets/deeper/mariana-trench')
expect($('[data-testid=breadcrumbs-in-article]').length).toBe(1)
expect($('[data-testid=breadcrumbs-header]').length).toBe(1)
})

test('early access article pages have breadcrumbs with product, category, and article', async () => {
const $ = await getDOM('/early-access/secrets/deeper/mariana-trench')
const $breadcrumbTitles = $(
'[data-testid=breadcrumbs-in-article] [data-testid=breadcrumb-title]'
)
const $breadcrumbLinks = $('[data-testid=breadcrumbs-in-article] a')

expect($breadcrumbTitles.length).toBe(0)
expect($breadcrumbLinks.length).toBe(2)
expect($breadcrumbLinks[0].attribs.title).toBe('Deeper secrets')
expect($breadcrumbLinks[1].attribs.title).toBe('Mariana Trench')
})
})
Loading