diff --git a/feature-flags.json b/feature-flags.json
index 3bb2f19b5324..64c69f19d789 100644
--- a/feature-flags.json
+++ b/feature-flags.json
@@ -1,5 +1,4 @@
{
"FEATURE_TEST_TRUE": true,
- "FEATURE_TEST_FALSE": false,
- "FEATURE_NEW_VERSIONS": true
+ "FEATURE_TEST_FALSE": false
}
diff --git a/includes/article-version-switcher.html b/includes/article-version-switcher.html
index d93b17a39958..af2f6ee005b8 100644
--- a/includes/article-version-switcher.html
+++ b/includes/article-version-switcher.html
@@ -2,11 +2,7 @@
- {% if process.env.FEATURE_NEW_VERSIONS %}
{{ site.data.ui.pages.article_version }} {{ allVersions[currentVersion].versionTitle }}
- {% else %}
- {{ site.data.ui.pages.article_version }} {{ productNames[currentVersion] }}
- {% endif %}
@@ -16,11 +12,7 @@
href="{{ permalink.href }}"
class="d-block py-2 {% if currentPath == permalink.href %}link-blue active{% else %}link-gray-dark no-underline{% endif %}"
>
- {% if process.env.FEATURE_NEW_VERSIONS %}
{{ allVersions[permalink.pageVersion].versionTitle }}
- {% else %}
- {{ productNames[permalink.pageVersion] }}
- {% endif %}
{% endfor %}
${page.intro}
` - const output = entities.decode(await liquid.parseAndRender(template, context)) - expect(output).toBe(expected) - }) - - testFeatureNewVersions('homepage_link_with_intro tag', async () => { + test('homepage_link_with_intro tag', async () => { const template = '{% homepage_link_with_intro /github/writing-on-github/basic-writing-and-formatting-syntax %}' const page = pages[`/en/${nonEnterpriseDefaultVersion}/github/writing-on-github/basic-writing-and-formatting-syntax`] const expected = ` @@ -81,17 +66,6 @@ describe('liquid helper tags', () => { expect(output).toBe(expected) }) - testFeatureOldVersions('homepage_link_with_intro tag', async () => { - const template = '{% homepage_link_with_intro /github/writing-on-github/basic-writing-and-formatting-syntax %}' - const page = pages['/en/github/writing-on-github/basic-writing-and-formatting-syntax'] - const expected = ` -${page.intro}
-` - 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 = '- Contributing and collaborating using GitHub Desktop' diff --git a/tests/unit/liquid.js b/tests/unit/liquid.js index 85d74b5d2e70..4fbe06059a2e 100644 --- a/tests/unit/liquid.js +++ b/tests/unit/liquid.js @@ -1,4 +1,3 @@ -require('../../lib/feature-flags') const { liquid } = require('../../lib/render-content') const template = ` {% if page.version ver_gt "2.13" %}up to date{% endif %} diff --git a/tests/unit/page.js b/tests/unit/page.js index f776b2d5c2d2..8537190e5e71 100644 --- a/tests/unit/page.js +++ b/tests/unit/page.js @@ -1,16 +1,10 @@ -require('../../lib/feature-flags') const path = require('path') const cheerio = require('cheerio') const Page = require('../../lib/page') const enterpriseServerReleases = require('../../lib/enterprise-server-releases') const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version') // get the `free-pro-team` segment of `free-pro-team@latest` -const nonEnterpriseDefaultPlan = process.env.FEATURE_NEW_VERSIONS && nonEnterpriseDefaultVersion.split('@')[0] - -const testFeatureNewVersions = process.env.FEATURE_NEW_VERSIONS ? test : test.skip -const testFeatureOldVersions = process.env.FEATURE_NEW_VERSIONS ? test.skip : test -const describeFeatureNewVersions = process.env.FEATURE_NEW_VERSIONS ? describe : describe.skip -const describeFeatureOldVersions = process.env.FEATURE_NEW_VERSIONS ? describe.skip : describe +const nonEnterpriseDefaultPlan = nonEnterpriseDefaultVersion.split('@')[0] const opts = { relativePath: 'github/collaborating-with-issues-and-pull-requests/about-branches.md', @@ -25,16 +19,7 @@ describe('Page class', () => { expect(page.fullPath.includes(page.relativePath)).toBe(true) }) - testFeatureNewVersions('does not error out on translated TOC with no links', () => { - const page = new Page({ - relativePath: 'translated-toc-with-no-links-index.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), - languageCode: 'ja' - }) - expect(typeof page.title).toBe('string') - }) - - testFeatureOldVersions('does not error out on translated TOC with no links', () => { + test('does not error out on translated TOC with no links', () => { const page = new Page({ relativePath: 'translated-toc-with-no-links-index.md', basePath: path.join(__dirname, '../fixtures'), @@ -43,51 +28,7 @@ describe('Page class', () => { expect(typeof page.title).toBe('string') }) - describeFeatureNewVersions('showMiniToc page property', () => { - const article = new Page({ - relativePath: 'sample-article.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), - languageCode: 'en' - }) - - const articleWithFM = new Page({ - showMiniToc: false, - relativePath: article.relativePath, - basePath: article.basePath, - languageCode: article.languageCode - }) - - const tocPage = new Page({ - relativePath: 'sample-toc-index.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), - languageCode: 'en' - }) - - const mapTopic = new Page({ - mapTopic: true, - relativePath: article.relativePath, - basePath: article.basePath, - languageCode: article.languageCode - }) - - test('is true by default on articles', () => { - expect(article.showMiniToc).toBe(true) - }) - - test('is false on articles when set in frontmatter', () => { - expect(articleWithFM.showMiniToc).toBe(false) - }) - - 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() - }) - }) - - describeFeatureOldVersions('showMiniToc page property', () => { + describe('showMiniToc page property', () => { const article = new Page({ relativePath: 'sample-article.md', basePath: path.join(__dirname, '../fixtures'), @@ -132,7 +73,7 @@ describe('Page class', () => { }) describe('page.render(context)', () => { - testFeatureNewVersions('rewrites links to include the current language prefix and version', async () => { + test('rewrites links to include the current language prefix and version', async () => { const page = new Page(opts) const context = { page: { version: nonEnterpriseDefaultVersion }, @@ -148,23 +89,7 @@ describe('Page class', () => { expect($(`a[href="/en/${nonEnterpriseDefaultVersion}/articles/about-pull-requests"]`).length).toBeGreaterThan(0) }) - testFeatureOldVersions('rewrites links to include the current language prefix', async () => { - const page = new Page(opts) - const context = { - page: { version: 'dotcom' }, - currentVersion: 'dotcom', - currentPath: '/en/github/collaborating-with-issues-and-pull-requests/about-branches', - currentLanguage: 'en' - } - const rendered = await page.render(context) - const $ = cheerio.load(rendered) - expect(page.markdown.includes('(/articles/about-pull-requests)')).toBe(true) - expect(page.markdown.includes('(/en/articles/about-pull-requests)')).toBe(false) - expect($('a[href="/articles/about-pull-requests"]').length).toBe(0) - expect($('a[href="/en/articles/about-pull-requests"]').length).toBeGreaterThan(0) - }) - - testFeatureNewVersions('does not rewrite links that include deprecated enterprise release numbers', async () => { + test('does not rewrite links that include deprecated enterprise release numbers', async () => { const page = new Page({ relativePath: 'admin/enterprise-management/migrating-from-github-enterprise-1110x-to-2123.md', basePath: path.join(__dirname, '../../content'), @@ -183,26 +108,7 @@ describe('Page class', () => { expect($('a[href="/en/enterprise/11.10.340/admin/articles/upgrading-to-the-latest-release"]').length).toBeGreaterThan(0) }) - testFeatureOldVersions('does not rewrite links that include deprecated enterprise release numbers', async () => { - const page = new Page({ - relativePath: 'enterprise/admin/enterprise-management/migrating-from-github-enterprise-1110x-to-2123.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - const context = { - page: { version: enterpriseServerReleases.latest }, - currentVersion: enterpriseServerReleases.latest, - currentPath: `/en/enterprise/${enterpriseServerReleases.latest}/admin/enterprise-management/migrating-from-github-enterprise-1110x-to-2123`, - currentLanguage: 'en' - } - const rendered = await page.render(context) - const $ = cheerio.load(rendered) - expect(page.markdown.includes('(/enterprise/11.10.340/admin/articles/upgrading-to-the-latest-release/)')).toBe(true) - expect($(`a[href="/en/enterprise/${enterpriseServerReleases.latest}/admin/articles/upgrading-to-the-latest-release"]`).length).toBe(0) - expect($('a[href="/en/enterprise/11.10.340/admin/articles/upgrading-to-the-latest-release"]').length).toBeGreaterThan(0) - }) - - testFeatureNewVersions('does not rewrite links to external redirects', async () => { + test('does not rewrite links to external redirects', async () => { const page = new Page(opts) page.markdown = `${page.markdown}\n\nSee [Capistrano](/capistrano).` const context = { @@ -215,20 +121,6 @@ describe('Page class', () => { const $ = cheerio.load(rendered) expect($('a[href="/capistrano"]').length).toBe(1) }) - - testFeatureOldVersions('does not rewrite links to external redirects', async () => { - const page = new Page(opts) - page.markdown = `${page.markdown}\n\nSee [Capistrano](/capistrano).` - const context = { - page: { version: 'dotcom' }, - currentVersion: 'dotcom', - currentPath: '/en/github/collaborating-with-issues-and-pull-requests/about-branches', - currentLanguage: 'en' - } - const rendered = await page.render(context) - const $ = cheerio.load(rendered) - expect($('a[href="/capistrano"]').length).toBe(1) - }) }) test('preserves `languageCode`', () => { @@ -236,30 +128,7 @@ describe('Page class', () => { expect(page.languageCode).toBe('en') }) - testFeatureNewVersions('parentProductId getter', () => { - let page = new Page({ - relativePath: 'github/some-category/some-article.md', - basePath: path.join(__dirname, '../fixtures/new-versions/products'), - languageCode: 'en' - }) - expect(page.parentProductId).toBe('github') - - page = new Page({ - relativePath: 'actions/some-category/some-article.md', - basePath: path.join(__dirname, '../fixtures/new-versions/products'), - languageCode: 'en' - }) - expect(page.parentProductId).toBe('actions') - - page = new Page({ - relativePath: 'admin/some-category/some-article.md', - basePath: path.join(__dirname, '../fixtures/new-versions/products'), - languageCode: 'en' - }) - expect(page.parentProductId).toBe('admin') - }) - - testFeatureOldVersions('parentProductId getter', () => { + test('parentProductId getter', () => { let page = new Page({ relativePath: 'github/some-category/some-article.md', basePath: path.join(__dirname, '../fixtures/products'), @@ -275,11 +144,11 @@ describe('Page class', () => { expect(page.parentProductId).toBe('actions') page = new Page({ - relativePath: 'enterprise/some-category/some-article.md', + relativePath: 'admin/some-category/some-article.md', basePath: path.join(__dirname, '../fixtures/products'), languageCode: 'en' }) - expect(page.parentProductId).toBe('enterpriseServer') + expect(page.parentProductId).toBe('admin') }) describe('permalinks', () => { @@ -288,33 +157,20 @@ describe('Page class', () => { expect(Array.isArray(page.permalinks)).toBe(true) }) - testFeatureNewVersions('has a key for every supported enterprise version (and no deprecated versions)', () => { + test('has a key for every supported enterprise version (and no deprecated versions)', () => { const page = new Page(opts) const pageVersions = page.permalinks.map(permalink => permalink.pageVersion) expect(enterpriseServerReleases.supported.every(version => pageVersions.includes(`enterprise-server@${version}`))).toBe(true) expect(enterpriseServerReleases.deprecated.every(version => !pageVersions.includes(`enterprise-server@${version}`))).toBe(true) }) - testFeatureOldVersions('has a key for every supported enterprise version (and no deprecated versions)', () => { - const page = new Page(opts) - const pageVersions = page.permalinks.map(permalink => permalink.pageVersion) - expect(enterpriseServerReleases.supported.every(version => pageVersions.includes(version))).toBe(true) - expect(enterpriseServerReleases.deprecated.every(version => !pageVersions.includes(version))).toBe(true) - }) - - testFeatureNewVersions('sets versioned values', () => { + test('sets versioned values', () => { const page = new Page(opts) expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe(`/en/${nonEnterpriseDefaultVersion}/github/collaborating-with-issues-and-pull-requests/about-branches`) expect(page.permalinks.find(permalink => permalink.pageVersion === `enterprise-server@${enterpriseServerReleases.oldestSupported}`).href).toBe(`/en/enterprise-server@${enterpriseServerReleases.oldestSupported}/github/collaborating-with-issues-and-pull-requests/about-branches`) }) - testFeatureOldVersions('sets dotcom and enterprise values', () => { - const page = new Page(opts) - expect(page.permalinks.find(permalink => permalink.pageVersion === 'dotcom').href).toBe('/en/github/collaborating-with-issues-and-pull-requests/about-branches') - expect(page.permalinks.find(permalink => permalink.pageVersion === enterpriseServerReleases.oldestSupported).href).toBe(`/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/github/collaborating-with-issues-and-pull-requests/about-branches`) - }) - - testFeatureNewVersions('homepage permalinks', () => { + test('homepage permalinks', () => { const page = new Page({ relativePath: 'index.md', basePath: path.join(__dirname, '../../content'), @@ -325,16 +181,7 @@ describe('Page class', () => { expect(page.permalinks.find(permalink => permalink.pageVersion === 'homepage').href).toBe('/en') }) - testFeatureOldVersions('homepage permalinks', () => { - const page = new Page({ - relativePath: 'index.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - expect(page.permalinks[0].href).toBe('/en') - }) - - testFeatureNewVersions('permalinks for dotcom-only pages', () => { + test('permalinks for dotcom-only pages', () => { const page = new Page({ relativePath: 'github/getting-started-with-github/signing-up-for-a-new-github-account.md', basePath: path.join(__dirname, '../../content'), @@ -344,20 +191,10 @@ describe('Page class', () => { expect(page.permalinks.length).toBe(1) }) - testFeatureOldVersions('permalinks for dotcom-only pages', () => { - const page = new Page({ - relativePath: 'github/getting-started-with-github/signing-up-for-a-new-github-account.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - expect(page.permalinks.find(permalink => permalink.pageVersion === 'dotcom').href).toBe('/en/github/getting-started-with-github/signing-up-for-a-new-github-account') - expect(page.permalinks.length).toBe(1) - }) - - testFeatureNewVersions('permalinks for enterprise-only pages', () => { + test('permalinks for enterprise-only pages', () => { const page = new Page({ relativePath: 'products/admin/some-category/some-article.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), + basePath: path.join(__dirname, '../fixtures'), languageCode: 'en' }) expect(page.permalinks.find(permalink => permalink.pageVersion === `enterprise-server@${enterpriseServerReleases.latest}`).href).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/products/admin/some-category/some-article`) @@ -366,39 +203,17 @@ describe('Page class', () => { expect(pageVersions.includes(nonEnterpriseDefaultVersion)).toBe(false) }) - testFeatureOldVersions('permalinks for enterprise-only pages', () => { - const page = new Page({ - relativePath: 'products/enterprise/some-category/some-article.md', - basePath: path.join(__dirname, '../fixtures'), - languageCode: 'en' - }) - expect(page.permalinks.find(permalink => permalink.pageVersion === enterpriseServerReleases.latest).href).toBe(`/en/enterprise/${enterpriseServerReleases.latest}/user/products/enterprise/some-category/some-article`) - const pageVersions = page.permalinks.map(permalink => permalink.pageVersion) - expect(pageVersions.length).toBeGreaterThan(1) - expect(pageVersions.includes('dotcom')).toBe(false) - }) - - testFeatureNewVersions('permalinks for non-GitHub.com products without Enterprise versions', () => { - const page = new Page({ - relativePath: 'products/actions/some-category/some-article.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), - languageCode: 'en' - }) - expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe(`/en/${nonEnterpriseDefaultVersion}/products/actions/some-category/some-article`) - expect(page.permalinks.length).toBe(1) - }) - - testFeatureOldVersions('permalinks for non-GitHub.com products without Enterprise versions', () => { + test('permalinks for non-GitHub.com products without Enterprise versions', () => { const page = new Page({ relativePath: 'products/actions/some-category/some-article.md', basePath: path.join(__dirname, '../fixtures'), languageCode: 'en' }) - expect(page.permalinks.find(permalink => permalink.pageVersion === 'dotcom').href).toBe('/en/products/actions/some-category/some-article') + expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe(`/en/${nonEnterpriseDefaultVersion}/products/actions/some-category/some-article`) expect(page.permalinks.length).toBe(1) }) - testFeatureNewVersions('permalinks for non-GitHub.com products with Enterprise versions', () => { + test('permalinks for non-GitHub.com products with Enterprise versions', () => { const page = new Page({ relativePath: '/insights/installing-and-configuring-github-insights/about-github-insights.md', basePath: path.join(__dirname, '../../content'), @@ -409,18 +224,6 @@ describe('Page class', () => { expect(pageVersions.length).toBeGreaterThan(1) expect(pageVersions.includes(nonEnterpriseDefaultVersion)).toBe(false) }) - - testFeatureOldVersions('permalinks for non-GitHub.com products with Enterprise versions', () => { - const page = new Page({ - relativePath: '/insights/installing-and-configuring-github-insights/about-github-insights.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - expect(page.permalinks.find(permalink => permalink.pageVersion === enterpriseServerReleases.latest).href).toBe(`/en/enterprise/${enterpriseServerReleases.latest}/user/insights/installing-and-configuring-github-insights/about-github-insights`) - const pageVersions = page.permalinks.map(permalink => permalink.pageVersion) - expect(pageVersions.length).toBeGreaterThan(1) - expect(pageVersions.includes('dotcom')).toBe(false) - }) }) describe('Page.parseFrontmatter()', () => { @@ -453,16 +256,7 @@ describe('Page class', () => { }) }) - testFeatureNewVersions('fixes translated frontmatter that includes verdadero', async () => { - const page = new Page({ - relativePath: 'article-with-mislocalized-frontmatter.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), - languageCode: 'ja' - }) - expect(page.mapTopic).toBe(true) - }) - - testFeatureOldVersions('fixes translated frontmatter that includes verdadero', async () => { + test('fixes translated frontmatter that includes verdadero', async () => { const page = new Page({ relativePath: 'article-with-mislocalized-frontmatter.md', basePath: path.join(__dirname, '../fixtures'), @@ -476,7 +270,7 @@ describe('Page class', () => { // There are none of these in the content at this time! }) - testFeatureNewVersions('pages that apply to newer enterprise versions', async () => { + test('pages that apply to newer enterprise versions', async () => { const page = new Page({ relativePath: 'github/administering-a-repository/managing-the-automatic-deletion-of-branches.md', basePath: path.join(__dirname, '../../content'), @@ -486,17 +280,7 @@ describe('Page class', () => { expect(page.versions['enterprise-server']).toBe('>=2.19') }) - testFeatureOldVersions('pages that apply to newer enterprise versions', async () => { - const page = new Page({ - relativePath: 'github/administering-a-repository/managing-the-automatic-deletion-of-branches.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - expect('dotcom' in page.productVersions).toBe(true) - expect(page.productVersions.enterprise).toBe('>=2.19') - }) - - testFeatureNewVersions('index page', async () => { + test('index page', async () => { const page = new Page({ relativePath: 'index.md', basePath: path.join(__dirname, '../../content'), @@ -506,27 +290,7 @@ describe('Page class', () => { expect(page.versions['enterprise-server']).toBe('*') }) - testFeatureOldVersions('index page', async () => { - const page = new Page({ - relativePath: 'index.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - expect(page.productVersions.dotcom).toBe('*') - }) - - // Note there is no more enterprise/index.md page with the latest versioning changes - testFeatureOldVersions('enterprise index page', async () => { - const page = new Page({ - relativePath: 'enterprise/index.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - expect('dotcom' in page.productVersions).toBe(false) - expect(page.productVersions.enterprise).toBe('*') - }) - - testFeatureNewVersions('enterprise admin index page', async () => { + test('enterprise admin index page', async () => { const page = new Page({ relativePath: 'admin/index.md', basePath: path.join(__dirname, '../../content'), @@ -536,34 +300,11 @@ describe('Page class', () => { expect(nonEnterpriseDefaultPlan in page.versions).toBe(false) expect(page.versions['enterprise-server']).toBe('*') }) - - testFeatureOldVersions('enterprise admin index page', async () => { - const page = new Page({ - relativePath: 'enterprise/admin/index.md', - basePath: path.join(__dirname, '../../content'), - languageCode: 'en' - }) - - expect('dotcom' in page.productVersions).toBe(false) - expect(page.productVersions.enterprise).toBe('*') - }) }) }) describe('catches errors thrown in Page class', () => { - testFeatureNewVersions('frontmatter parsing error', () => { - function getPage () { - return new Page({ - relativePath: 'page-with-frontmatter-error.md', - basePath: path.join(__dirname, '../fixtures/new-versions'), - languageCode: 'en' - }) - } - - expect(getPage).toThrowError('invalid frontmatter entry') - }) - - testFeatureOldVersions('frontmatter parsing error', () => { + test('frontmatter parsing error', () => { function getPage () { return new Page({ relativePath: 'page-with-frontmatter-error.md', @@ -575,7 +316,7 @@ describe('catches errors thrown in Page class', () => { expect(getPage).toThrowError('invalid frontmatter entry') }) - testFeatureNewVersions('missing versions frontmatter', () => { + test('missing versions frontmatter', () => { function getPage () { return new Page({ relativePath: 'page-with-missing-product-versions.md', @@ -586,16 +327,4 @@ describe('catches errors thrown in Page class', () => { expect(getPage).toThrowError('versions') }) - - testFeatureOldVersions('missing productVersions', () => { - function getPage () { - return new Page({ - relativePath: 'page-with-missing-product-versions.md', - basePath: path.join(__dirname, '../fixtures'), - languageCode: 'en' - }) - } - - expect(getPage).toThrowError('productVersions') - }) }) diff --git a/tests/unit/pages.js b/tests/unit/pages.js index 633fa9c9c9c9..6109520bd077 100644 --- a/tests/unit/pages.js +++ b/tests/unit/pages.js @@ -1,4 +1,3 @@ -require('../../lib/feature-flags') const path = require('path') const loadPages = require('../../lib/pages') const languageCodes = Object.keys(require('../../lib/languages')) diff --git a/tests/unit/permalink.js b/tests/unit/permalink.js index 62884cbe3277..ba07c5f614ec 100644 --- a/tests/unit/permalink.js +++ b/tests/unit/permalink.js @@ -1,17 +1,13 @@ -require('../../lib/feature-flags') const Permalink = require('../../lib/permalink') const enterpriseServerReleases = require('../../lib/enterprise-server-releases') const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version') -const testFeatureNewVersions = process.env.FEATURE_NEW_VERSIONS ? test : test.skip -const testFeatureOldVersions = process.env.FEATURE_NEW_VERSIONS ? test.skip : test - // Permalink constructor requires: languageCode, pageVersion, relativePath, title // Permalink.derive requires: languageCode, relativePath, title, versions (<- FM prop) describe('Permalink class', () => { // We can only use Permalink.derive to get the special 'homepage' permalink - testFeatureNewVersions('derives info for unversioned homepage', () => { + test('derives info for unversioned homepage', () => { const versions = { 'free-pro-team': '*', 'enterprise-server': '*' @@ -22,68 +18,35 @@ describe('Permalink class', () => { expect(homepagePermalink.href).toBe('/en') }) - testFeatureOldVersions('derives info for homepage', () => { - const permalink = new Permalink('en', 'dotcom', 'index.md', 'Hello World') - expect(permalink.pageVersionTitle).toBe('GitHub.com') - expect(permalink.href).toBe('/en') - }) - - testFeatureNewVersions('derives info for non-enterprise versioned homepage', () => { + test('derives info for non-enterprise versioned homepage', () => { const permalink = new Permalink('en', nonEnterpriseDefaultVersion, 'index.md', 'Hello World') expect(permalink.pageVersionTitle).toBe('Free, Pro, and Team') expect(permalink.href).toBe(`/en/${nonEnterpriseDefaultVersion}`) }) - testFeatureNewVersions('derives info for enterprise server versioned homepage', () => { + test('derives info for enterprise server versioned homepage', () => { const permalink = new Permalink('en', `enterprise-server@${enterpriseServerReleases.latest}`, 'index.md', 'Hello World') expect(permalink.pageVersionTitle).toBe(`Enterprise Server ${enterpriseServerReleases.latest}`) expect(permalink.href).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}`) }) - testFeatureNewVersions('derives info for GitHub.com homepage', () => { + test('derives info for GitHub.com homepage', () => { const permalink = new Permalink('en', nonEnterpriseDefaultVersion, 'github/index.md', 'Hello World') expect(permalink.pageVersionTitle).toBe('Free, Pro, and Team') expect(permalink.href).toBe(`/en/${nonEnterpriseDefaultVersion}/github`) }) - testFeatureOldVersions('derives info for GitHub.com homepage', () => { - const permalink = new Permalink('en', 'dotcom', 'github/index.md', 'Hello World') - expect(permalink.pageVersionTitle).toBe('GitHub.com') - expect(permalink.href).toBe('/en/github') - }) - - testFeatureNewVersions('derives info for enterprise version of GitHub.com homepage', () => { + test('derives info for enterprise version of GitHub.com homepage', () => { const permalink = new Permalink('en', `enterprise-server@${enterpriseServerReleases.latest}`, 'github/index.md', 'Hello World') expect(permalink.pageVersionTitle).toBe(`Enterprise Server ${enterpriseServerReleases.latest}`) expect(permalink.href).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/github`) }) - testFeatureOldVersions('derives info for enterprise version of GitHub.com homepage', () => { - const permalink = new Permalink('en', enterpriseServerReleases.latest, 'github/index.md', 'Hello World') - expect(permalink.pageVersionTitle).toBe(`Enterprise Server ${enterpriseServerReleases.latest}`) - expect(permalink.href).toBe(`/en/enterprise/${enterpriseServerReleases.latest}/user/github`) - }) - - // Note enterprise/index.md no longer exists after the latest versioning changes - testFeatureOldVersions('derives info for enterprise homepage', () => { - const permalink = new Permalink('en', enterpriseServerReleases.latest, 'enterprise/index.md', 'Hello World') - expect(permalink.pageVersionTitle).toBe(`Enterprise Server ${enterpriseServerReleases.latest}`) - expect(permalink.href).toBe(`/en/enterprise/${enterpriseServerReleases.latest}`) - }) - - testFeatureNewVersions('preserves input properties', () => { + test('preserves input properties', () => { const permalink = new Permalink('en', nonEnterpriseDefaultVersion, 'index.md', 'Hello World') expect(permalink.languageCode).toBe('en') expect(permalink.pageVersion).toBe(nonEnterpriseDefaultVersion) expect(permalink.relativePath).toBe('index.md') expect(permalink.title).toBe('Hello World') }) - - testFeatureOldVersions('preserves input properties', () => { - const permalink = new Permalink('en', 'dotcom', 'index.md', 'Hello World') - expect(permalink.languageCode).toBe('en') - expect(permalink.pageVersion).toBe('dotcom') - expect(permalink.relativePath).toBe('index.md') - expect(permalink.title).toBe('Hello World') - }) }) diff --git a/tests/unit/products.js b/tests/unit/products.js index a8cd1cbd9973..c57744b02079 100644 --- a/tests/unit/products.js +++ b/tests/unit/products.js @@ -1,13 +1,9 @@ -require('../../lib/feature-flags') const revalidator = require('revalidator') const products = require('../../lib/all-products') const schema = require('../../lib/products-schema') const { getDOM, getJSON } = require('../helpers') const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version') -const testFeatureNewVersions = process.env.FEATURE_NEW_VERSIONS ? test : test.skip -const testFeatureOldVersions = process.env.FEATURE_NEW_VERSIONS ? test.skip : test - describe('products module', () => { test('is an object with product ids as keys', () => { expect('github' in products).toBe(true) @@ -26,7 +22,7 @@ describe('products module', () => { describe('mobile-only products nav', () => { jest.setTimeout(5 * 60 * 1000) - testFeatureNewVersions('renders current product on various product pages for each product', async () => { + test('renders current product on various product pages for each product', async () => { // Note the unversioned homepage at `/` does not have a product selected in the mobile dropdown expect((await getDOM('/github'))('#current-product').text().trim()).toBe('GitHub.com') @@ -41,22 +37,6 @@ describe('mobile-only products nav', () => { // localized expect((await getDOM('/ja/desktop'))('#current-product').text().trim()).toBe('GitHub Desktop') }) - - testFeatureOldVersions('renders current product on various product pages for each product', async () => { - expect((await getDOM('/'))('#current-product').text().trim()).toBe('GitHub.com') - expect((await getDOM('/github'))('#current-product').text().trim()).toBe('GitHub.com') - - // Enterprise user and server - expect((await getDOM('/en/enterprise/admin'))('#current-product').text().trim()).toBe('Enterprise Server') - expect((await getDOM('/en/enterprise/user/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address'))('#current-product').text().trim()).toBe('GitHub.com') - - expect((await getDOM('/desktop'))('#current-product').text().trim()).toBe('GitHub Desktop') - - expect((await getDOM('/actions'))('#current-product').text().trim()).toBe('GitHub Actions') - - // localized - expect((await getDOM('/ja/desktop'))('#current-product').text().trim()).toBe('GitHub Desktop') - }) }) describe('products middleware', () => { @@ -67,20 +47,13 @@ describe('products middleware', () => { expect(Array.isArray(products)).toBe(true) }) - testFeatureNewVersions('adds res.context.currentProduct string on homepage', async () => { + test('adds res.context.currentProduct string on homepage', async () => { const currentProduct = await getJSON('/en?json=currentProduct') expect(currentProduct).toBe('homepage') }) - testFeatureNewVersions('adds res.context.currentProduct object', async () => { + test('adds res.context.currentProduct object', async () => { const currentProduct = await getJSON(`/en/${nonEnterpriseDefaultVersion}/github?json=currentProduct`) expect(currentProduct).toBe('github') }) - - testFeatureOldVersions('adds res.context.currentProduct object', async () => { - const currentProduct = await getJSON('/en?json=currentProduct') - expect('id' in currentProduct).toBe(true) - expect('name' in currentProduct).toBe(true) - expect('dir' in currentProduct).toBe(true) - }) }) diff --git a/tests/unit/toc-links.js b/tests/unit/toc-links.js index 8f345c016afd..5673ca00f5ae 100644 --- a/tests/unit/toc-links.js +++ b/tests/unit/toc-links.js @@ -1,10 +1,6 @@ -require('../../lib/feature-flags') const loadPages = require('../../lib/pages') const renderContent = require('../../lib/render-content') const allVersions = Object.keys(require('../../lib/all-versions')) -const { oldVersions } = require('../../lib/old-versions-utils') - -const versions = process.env.FEATURE_NEW_VERSIONS ? allVersions : oldVersions describe('toc links', () => { jest.setTimeout(3 * 60 * 1000) @@ -17,7 +13,7 @@ describe('toc links', () => { const issues = [] - for (const pageVersion of versions) { + for (const pageVersion of allVersions) { for (const page of englishIndexPages) { // skip page if it doesn't have a permalink for the current product version if (!page.permalinks.some(permalink => permalink.pageVersion === pageVersion)) continue diff --git a/tests/unit/versions.js b/tests/unit/versions.js index 191adb22ea93..93e6728ab685 100644 --- a/tests/unit/versions.js +++ b/tests/unit/versions.js @@ -1,4 +1,3 @@ -require('../../lib/feature-flags') const revalidator = require('revalidator') const allVersions = require('../../lib/all-versions') const { latest } = require('../../lib/enterprise-server-releases') @@ -6,9 +5,7 @@ const schema = require('../../lib/versions-schema') const { getJSON } = require('../helpers') const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version') -const describeIf = process.env.FEATURE_NEW_VERSIONS ? describe : describe.skip - -describeIf('versions module', () => { +describe('versions module', () => { test('is an object with versions as keys', () => { expect(nonEnterpriseDefaultVersion in allVersions).toBe(true) expect(`enterprise-server@${latest}` in allVersions).toBe(true) @@ -23,7 +20,7 @@ describeIf('versions module', () => { }) }) -describeIf('versions middleware', () => { +describe('versions middleware', () => { jest.setTimeout(5 * 60 * 1000) test('adds res.context.allVersions object', async () => {