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 #7580

Merged
merged 7 commits into from
Jun 22, 2021
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
2 changes: 1 addition & 1 deletion middleware/contextualizers/generic-toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = async function genericToc (req, res, next) {
async function getTocItems (pagesArray, context, isRecursive, renderIntros) {
return (await Promise.all(pagesArray.map(async (child) => {
// Do not include hidden child items on a TOC page
if (child.page.hidden) return
if (child.page.hidden && !context.currentPath.includes('/early-access/')) return

return {
title: child.renderedFullTitle,
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/early-access.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const fs = require('fs').promises
const path = require('path')
const { testViaActionsOnly } = require('../helpers/conditional-runs')
const { getDOM } = require('../helpers/supertest')
const got = require('got')

describe('cloning early-access', () => {
testViaActionsOnly('the content directory exists', async () => {
Expand All @@ -18,3 +20,25 @@ describe('cloning early-access', () => {
expect(await fs.stat(eaDir)).toBeTruthy()
})
})

describe('rendering early-access', () => {
jest.setTimeout(5 * 60 * 1000)

testViaActionsOnly('the top-level TOC renders locally', async () => {
const $ = await getDOM('/en/early-access')
expect($.html().includes('Hello, local developer! This page is not visible on production.')).toBe(true)
expect($('ul a').length).toBeGreaterThan(5)
})

testViaActionsOnly('the top-level TOC does not render on production', async () => {
async function getEarlyAccess () {
return await got('https://docs.github.com/en/early-access')
}
await expect(getEarlyAccess).rejects.toThrowError('Response code 404 (Not Found)')
})

testViaActionsOnly('TOCs display on category pages', async () => {
const $ = await getDOM('/en/early-access/github/enforcing-best-practices-with-github-policies')
expect($('ul a').length).toBeGreaterThan(5)
})
})