1
0
mirror of synced 2025-12-23 21:07:12 -05:00

remove feature flagged code

This commit is contained in:
Sarah Schneider
2021-05-20 10:01:33 -04:00
parent b4ab2c52b6
commit 5978edb47b
18 changed files with 68 additions and 592 deletions

View File

@@ -1,11 +1,8 @@
require('../../lib/feature-flags')
const { liquid } = require('../../lib/render-content')
const { loadPageMap } = require('../../lib/pages')
const entities = new (require('html-entities').XmlEntities)()
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
const testOldSiteTree = process.env.FEATURE_NEW_SITETREE ? test.skip : test
describe('liquid helper tags', () => {
jest.setTimeout(60 * 1000)
@@ -79,19 +76,6 @@ describe('liquid helper tags', () => {
expect(output).toBe(expected)
})
testOldSiteTree('homepage_link_with_intro tag', async () => {
const template = '{% homepage_link_with_intro /github/writing-on-github/basic-writing-and-formatting-syntax %}'
const page = process.env.FEATURE_NEW_SITETREE
? pageMap['/en/github/writing-on-github/basic-writing-and-formatting-syntax']
: pageMap['/en/github/writing-on-github/basic-writing-and-formatting-syntax']
const expected = `<a class="link-with-intro Bump-link--hover no-underline d-block offset-lg-2 col-lg-8 mb-5" href="/en/github/writing-on-github/basic-writing-and-formatting-syntax">
<h4 class="link-with-intro-title h4-mktg">${page.title}<span class="Bump-link-symbol">→</span></h4>
<p class="link-with-intro-intro f5">${page.intro}</p>
</a>`
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
test('link_in_list tag', async () => {
const template = '{% link_in_list /contributing-and-collaborating-using-github-desktop %}'
const expected = '- <a class="article-link link Bump-link--hover no-underline" href="/en/desktop/contributing-and-collaborating-using-github-desktop">Contributing and collaborating using GitHub Desktop</a>'

View File

@@ -1,4 +1,3 @@
require('../../lib/feature-flags')
const path = require('path')
const cheerio = require('cheerio')
const Page = require('../../lib/page')
@@ -16,9 +15,7 @@ jest.mock('../../lib/get-link-data')
const nonEnterpriseDefaultPlan = nonEnterpriseDefaultVersion.split('@')[0]
const opts = {
relativePath: process.env.FEATURE_NEW_SITETREE
? 'github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches.md'
: 'github/collaborating-with-issues-and-pull-requests/about-branches.md',
relativePath: 'github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches.md',
basePath: path.join(__dirname, '../../content'),
languageCode: 'en'
}
@@ -40,7 +37,7 @@ describe('Page class', () => {
})
describe('showMiniToc page property', () => {
let article, articleWithFM, tocPage, mapTopic
let article, articleWithFM, tocPage
beforeAll(async () => {
article = await Page.init({
@@ -61,13 +58,6 @@ describe('Page class', () => {
basePath: path.join(__dirname, '../fixtures'),
languageCode: 'en'
})
mapTopic = await Page.init({
mapTopic: true,
relativePath: article.relativePath,
basePath: article.basePath,
languageCode: article.languageCode
})
})
test('is true by default on articles', () => {
@@ -78,13 +68,10 @@ describe('Page class', () => {
expect(articleWithFM.showMiniToc).toBe(false)
})
// products, categories, and map topics have index.md pages
test('is undefined by default on index.md pages', () => {
expect(tocPage.showMiniToc).toBeUndefined()
})
test('is undefined by default on map topics', () => {
expect(mapTopic.showMiniToc).toBeUndefined()
})
})
describe('page.render(context)', () => {
@@ -93,9 +80,7 @@ describe('Page class', () => {
const context = {
page: { version: `enterprise-server@${enterpriseServerReleases.latest}` },
currentVersion: `enterprise-server@${enterpriseServerReleases.latest}`,
currentPath: process.env.FEATURE_NEW_SITETREE
? '/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches'
: '/en/github/collaborating-with-issues-and-pull-requests/about-branches',
currentPath: '/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches',
currentLanguage: 'en'
}
const rendered = await page.render(context)
@@ -119,9 +104,7 @@ describe('Page class', () => {
const context = {
page: { version: nonEnterpriseDefaultVersion },
currentVersion: nonEnterpriseDefaultVersion,
currentPath: process.env.FEATURE_NEW_SITETREE
? '/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches'
: '/en/github/collaborating-with-issues-and-pull-requests/about-branches',
currentPath: '/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches',
currentLanguage: 'en'
}
await page.render(context)
@@ -132,9 +115,7 @@ describe('Page class', () => {
test('does not rewrite links that include deprecated enterprise release numbers', async () => {
const page = await Page.init({
relativePath: process.env.FEATURE_NEW_SITETREE
? 'admin/enterprise-management/updating-the-virtual-machine-and-physical-resources/migrating-from-github-enterprise-1110x-to-2123.md'
: 'admin/enterprise-management/migrating-from-github-enterprise-1110x-to-2123.md',
relativePath: 'admin/enterprise-management/updating-the-virtual-machine-and-physical-resources/migrating-from-github-enterprise-1110x-to-2123.md',
basePath: path.join(__dirname, '../../content'),
languageCode: 'en'
})
@@ -157,9 +138,7 @@ describe('Page class', () => {
const context = {
page: { version: nonEnterpriseDefaultVersion },
currentVersion: nonEnterpriseDefaultVersion,
currentPath: process.env.FEATURE_NEW_SITETREE
? `/en/${nonEnterpriseDefaultVersion}/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches`
: `/en/${nonEnterpriseDefaultVersion}/github/collaborating-with-issues-and-pull-requests/about-branches`,
currentPath: `/en/${nonEnterpriseDefaultVersion}/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches`,
currentLanguage: 'en'
}
const rendered = await page.render(context)
@@ -278,9 +257,7 @@ describe('Page class', () => {
test('sets versioned values', async () => {
const page = await Page.init(opts)
const expectedPath = process.env.FEATURE_NEW_SITETREE
? 'github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches'
: 'github/collaborating-with-issues-and-pull-requests/about-branches'
const expectedPath = 'github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches'
expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe(`/en/${expectedPath}`)
expect(page.permalinks.find(permalink => permalink.pageVersion === `enterprise-server@${enterpriseServerReleases.oldestSupported}`).href).toBe(`/en/enterprise-server@${enterpriseServerReleases.oldestSupported}/${expectedPath}`)
})
@@ -297,15 +274,11 @@ describe('Page class', () => {
test('permalinks for dotcom-only pages', async () => {
const page = await Page.init({
relativePath: process.env.FEATURE_NEW_SITETREE
? 'github/getting-started-with-github/signing-up-for-github/signing-up-for-a-new-github-account.md'
: 'github/getting-started-with-github/signing-up-for-a-new-github-account.md',
relativePath: 'github/getting-started-with-github/signing-up-for-github/signing-up-for-a-new-github-account.md',
basePath: path.join(__dirname, '../../content'),
languageCode: 'en'
})
const expectedPath = process.env.FEATURE_NEW_SITETREE
? '/en/github/getting-started-with-github/signing-up-for-github/signing-up-for-a-new-github-account'
: '/en/github/getting-started-with-github/signing-up-for-a-new-github-account'
const expectedPath = '/en/github/getting-started-with-github/signing-up-for-github/signing-up-for-a-new-github-account'
expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe(expectedPath)
expect(page.permalinks.length).toBe(1)
})
@@ -334,15 +307,11 @@ describe('Page class', () => {
test('permalinks for non-GitHub.com products with Enterprise versions', async () => {
const page = await Page.init({
relativePath: process.env.FEATURE_NEW_SITETREE
? '/insights/installing-and-configuring-github-insights/installing-and-updating-github-insights/about-github-insights.md'
: '/insights/installing-and-configuring-github-insights/about-github-insights.md',
relativePath: '/insights/installing-and-configuring-github-insights/installing-and-updating-github-insights/about-github-insights.md',
basePath: path.join(__dirname, '../../content'),
languageCode: 'en'
})
const expectedPath = process.env.FEATURE_NEW_SITETREE
? `/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/installing-and-updating-github-insights/about-github-insights`
: `/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/about-github-insights`
const expectedPath = `/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/installing-and-updating-github-insights/about-github-insights`
expect(page.permalinks.find(permalink => permalink.pageVersion === `enterprise-server@${enterpriseServerReleases.latest}`).href).toBe(expectedPath)
const pageVersions = page.permalinks.map(permalink => permalink.pageVersion)
expect(pageVersions.length).toBeGreaterThan(1)
@@ -524,9 +493,7 @@ describe('Page class', () => {
// Note this test will go out of date when we deprecate 2.20
test('pages that apply to newer enterprise versions', async () => {
const page = await Page.init({
relativePath: process.env.FEATURE_NEW_SITETREE
? 'github/administering-a-repository/releasing-projects-on-github/comparing-releases.md'
: 'github/administering-a-repository/comparing-releases.md',
relativePath: 'github/administering-a-repository/releasing-projects-on-github/comparing-releases.md',
basePath: path.join(__dirname, '../../content'),
languageCode: 'en'
})

View File

@@ -1,4 +1,3 @@
require('../../lib/feature-flags')
const path = require('path')
const { loadPages, loadPageMap } = require('../../lib/pages')
const languageCodes = Object.keys(require('../../lib/languages'))
@@ -11,8 +10,6 @@ const entities = new Entities()
const { chain, difference } = require('lodash')
const checkIfNextVersionOnly = require('../../lib/check-if-next-version-only')
const testOldSiteTree = process.env.FEATURE_NEW_SITETREE ? test.skip : test
describe('pages module', () => {
jest.setTimeout(60 * 1000)
@@ -47,7 +44,7 @@ describe('pages module', () => {
// **TODO** fix duplicate redirects after new site tree feature flag is enabled
// we can't put this in tests/redirects because duplicate routes have already been
// overwritten during context.pages.redirects object assignment and can't be searched for
testOldSiteTree('redirect_from routes are unique across English pages', () => {
test.skip('redirect_from routes are unique across English pages', () => {
const sourceRedirectFrom = chain(pages)
.filter(['languageCode', 'en'])
.filter('redirect_from')