Skip to content

Commit 7845f8c

Browse files
authored
Merge pull request github#7580 from github/repo-sync
repo sync
2 parents 42f7448 + 76042bb commit 7845f8c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

middleware/contextualizers/generic-toc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = async function genericToc (req, res, next) {
5050
async function getTocItems (pagesArray, context, isRecursive, renderIntros) {
5151
return (await Promise.all(pagesArray.map(async (child) => {
5252
// Do not include hidden child items on a TOC page
53-
if (child.page.hidden) return
53+
if (child.page.hidden && !context.currentPath.includes('/early-access/')) return
5454

5555
return {
5656
title: child.renderedFullTitle,

tests/unit/early-access.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const fs = require('fs').promises
22
const path = require('path')
33
const { testViaActionsOnly } = require('../helpers/conditional-runs')
4+
const { getDOM } = require('../helpers/supertest')
5+
const got = require('got')
46

57
describe('cloning early-access', () => {
68
testViaActionsOnly('the content directory exists', async () => {
@@ -18,3 +20,25 @@ describe('cloning early-access', () => {
1820
expect(await fs.stat(eaDir)).toBeTruthy()
1921
})
2022
})
23+
24+
describe('rendering early-access', () => {
25+
jest.setTimeout(5 * 60 * 1000)
26+
27+
testViaActionsOnly('the top-level TOC renders locally', async () => {
28+
const $ = await getDOM('/en/early-access')
29+
expect($.html().includes('Hello, local developer! This page is not visible on production.')).toBe(true)
30+
expect($('ul a').length).toBeGreaterThan(5)
31+
})
32+
33+
testViaActionsOnly('the top-level TOC does not render on production', async () => {
34+
async function getEarlyAccess () {
35+
return await got('https://docs.github.com/en/early-access')
36+
}
37+
await expect(getEarlyAccess).rejects.toThrowError('Response code 404 (Not Found)')
38+
})
39+
40+
testViaActionsOnly('TOCs display on category pages', async () => {
41+
const $ = await getDOM('/en/early-access/github/enforcing-best-practices-with-github-policies')
42+
expect($('ul a').length).toBeGreaterThan(5)
43+
})
44+
})

0 commit comments

Comments
 (0)