1
0
mirror of synced 2025-12-25 02:17:36 -05:00

Merge branch 'main' of github.com:github/docs-internal into check-links-improvement-redux

This commit is contained in:
Sarah Schneider
2020-12-14 15:52:46 -05:00
156 changed files with 2362 additions and 559 deletions

View File

@@ -0,0 +1,9 @@
const runningActionsOnInternalRepo = process.env.GITHUB_ACTIONS === 'true' && process.env.GITHUB_REPOSITORY === 'github/docs-internal'
const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
const describeViaActionsOnly = runningActionsOnInternalRepo ? describe : describe.skip
module.exports = {
testViaActionsOnly,
describeViaActionsOnly
}

View File

@@ -15,6 +15,7 @@ const ALLOW_LIST = new Set([
'platform-samples',
'github-services',
'explore',
'enterprise-releases',
'markup',
'hubot',
'VisualStudio',
@@ -48,7 +49,8 @@ describe('check for repository references', () => {
'docs/index.yaml',
'lib/excluded-links.js',
'content/early-access',
'data/early-access'
'data/early-access',
'data/release-notes' // These include links to internal issues in Liquid comments
]
})

View File

@@ -1,6 +1,8 @@
const { getDOM, getJSON } = require('../helpers/supertest')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
const describeInternalOnly = process.env.GITHUB_REPOSITORY === 'github/docs-internal' ? describe : describe.skip
describe('breadcrumbs', () => {
jest.setTimeout(300 * 1000)
@@ -60,6 +62,27 @@ describe('breadcrumbs', () => {
})
})
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('text-gray-light')).toBe(true)
})
})
describe('context.breadcrumbs object', () => {
test('works on product index pages', async () => {
const breadcrumbs = await getJSON('/en/github?json=breadcrumbs')

View File

@@ -1,6 +1,7 @@
const lodash = require('lodash')
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const { get, getDOM, head } = require('../helpers/supertest')
const { describeViaActionsOnly } = require('../helpers/conditional-runs')
const path = require('path')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
const { loadPages } = require('../../lib/pages')
@@ -356,7 +357,7 @@ describe('server', () => {
})
})
describe.skip('Early Access articles', () => {
describeViaActionsOnly('Early Access articles', () => {
let hiddenPageHrefs, hiddenPages
beforeAll(async (done) => {

View File

@@ -1,7 +1,6 @@
const { eachOfLimit } = require('async')
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const { get } = require('../helpers/supertest')
const { getEnterpriseVersionNumber } = require('../../lib/patterns')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
const restRedirectFixtures = require('../fixtures/rest-redirects')
const graphqlRedirectFixtures = require('../fixtures/graphql-redirects')
@@ -126,29 +125,6 @@ describe('developer redirects', () => {
)
})
// TODO temporarily ensure we redirect old links using the new enterprise format
// for currently supported enterprise releases only
// EXAMPLE: /en/enterprise-server@2.20/v3/pulls/comments -> /en/enterprise-server@2.20/rest/reference/pulls#comments
// We can remove test after we update all the old `/v3` links to point to `/rest`
test('temporary rest reference enterprise redirects', async () => {
await eachOfLimit(
restRedirectFixtures,
MAX_CONCURRENT_REQUESTS,
async (newPath, oldPath) => {
const releaseNumber = oldPath.match(getEnterpriseVersionNumber)
if (!releaseNumber) return
if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return
oldPath = oldPath
.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/')
.replace('/user/', '/')
const res = await get(oldPath)
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
expect(res.headers.location).toBe(newPath)
}
)
})
// this fixtures file includes /v4 and /enterprise/v4 paths
test('graphql reference redirects', async () => {
await eachOfLimit(
@@ -164,28 +140,5 @@ describe('developer redirects', () => {
}
)
})
// TODO temporarily ensure we redirect old links using the new enterprise format
// for currently supported enterprise releases only
// EXAMPLE: /en/enterprise-server@2.20/v4/interface/actor -> /en/enterprise-server@2.20/graphql/reference/interfaces#actor
// We can remove test after we update all the old `/v4` links to point to `/graphql`
test('temporary rest reference enterprise redirects', async () => {
await eachOfLimit(
graphqlRedirectFixtures,
MAX_CONCURRENT_REQUESTS,
async (newPath, oldPath) => {
const releaseNumber = oldPath.match(getEnterpriseVersionNumber)
if (!releaseNumber) return
if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return
oldPath = oldPath
.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/')
.replace('/user/', '/')
const res = await get(oldPath)
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
expect(res.headers.location).toBe(newPath)
}
)
})
})
})

View File

@@ -11,11 +11,14 @@ describe('enterprise release notes', () => {
})
it('redirects to the release notes on enterprise.github.com if none are present for this version here', async () => {
const res = await get('/en/enterprise-server@2.21/admin/release-notes')
const res = await get('/en/enterprise-server@2.19/admin/release-notes')
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe('https://enterprise.github.com/releases/2.21.0/notes')
expect(res.headers.location).toBe('https://enterprise.github.com/releases/2.19.0/notes')
})
// We can't write this test until we have real release notes
it.todo('renders the release-notes layout if this version\'s release notes are in this repo')
it('renders the release-notes layout if this version\'s release notes are in this repo', async () => {
const res = await get('/en/enterprise-server@2.22/admin/release-notes')
expect(res.statusCode).toBe(200)
})
})

View File

@@ -1,9 +1,6 @@
const fs = require('fs').promises
const path = require('path')
const { GITHUB_ACTIONS, GITHUB_REPOSITORY } = process.env
const runningActionsOnInternalRepo = GITHUB_ACTIONS === 'true' && GITHUB_REPOSITORY === 'github/docs-internal'
const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
const { testViaActionsOnly } = require('../helpers/conditional-runs')
describe('cloning early-access', () => {
testViaActionsOnly('the content directory exists', async () => {

View File

@@ -1,7 +1,6 @@
const { liquid } = require('../../lib/render-content')
const { loadPageMap } = require('../../lib/pages')
const entities = new (require('html-entities').XmlEntities)()
const { set } = require('lodash')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
describe('liquid helper tags', () => {
@@ -15,11 +14,16 @@ describe('liquid helper tags', () => {
context.currentVersion = nonEnterpriseDefaultVersion
context.pages = pageMap
context.redirects = []
context.site = {}
context.site = {
data: {
reusables: {
example: 'a rose by any other name\nwould smell as sweet'
}
}
}
context.page = {
relativePath: 'desktop/index.md'
}
set(context.site, 'data.reusables.example', 'a rose by any other name\nwould smell as sweet')
done()
})
@@ -83,8 +87,6 @@ describe('liquid helper tags', () => {
})
describe('indented_data_reference tag', () => {
set(context.site, 'data.reusables.example', 'a rose by any other name\nwould smell as sweet')
test('without any number of spaces specified', async () => {
const template = '{% indented_data_reference site.data.reusables.example %}'
const expected = ` a rose by any other name
@@ -117,4 +119,47 @@ would smell as sweet`
expect(output).toBe(expected)
})
})
describe('data tag', () => {
test(
'handles bracketed array access within for-in loop',
async () => {
const template = `
{% for term in site.data.glossaries.external %}
### {% data glossaries.external[forloop.index0].term %}
{% data glossaries.external[forloop.index0].description %}
---
{% endfor %}`
const localContext = { ...context }
localContext.site = {
data: {
variables: {
fire_emoji: ':fire:'
},
glossaries: {
external: [
{ term: 'lit', description: 'Awesome things. {% data variables.fire_emoji %}' },
{ term: 'Zhu Li', description: '_"Zhu Li, do the thing!"_ :point_up:' }
]
}
}
}
const expected = `
### lit
Awesome things. :fire:
---
### Zhu Li
_"Zhu Li, do the thing!"_ :point_up:
---
`
const output = await liquid.parseAndRender(template, localContext)
expect(output).toBe(expected)
}
)
})
})