From b13ac1bd85dfb718bb72388b2cd122563e68c126 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Mon, 21 Jun 2021 14:40:38 -0400 Subject: [PATCH 1/2] only hide TOC items on non-early access content; we want it to display on EA pages --- middleware/contextualizers/generic-toc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/contextualizers/generic-toc.js b/middleware/contextualizers/generic-toc.js index fb796dd0a344..7983328603dc 100644 --- a/middleware/contextualizers/generic-toc.js +++ b/middleware/contextualizers/generic-toc.js @@ -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, From 7919725e0f093a883a4e6de360369f70d33e0d64 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Mon, 21 Jun 2021 14:40:56 -0400 Subject: [PATCH 2/2] add a few more early access tests --- tests/unit/early-access.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unit/early-access.js b/tests/unit/early-access.js index 362e3bbc1f81..5ccd5339e5e0 100644 --- a/tests/unit/early-access.js +++ b/tests/unit/early-access.js @@ -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 () => { @@ -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) + }) +})