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

Merge branch 'main' into revert-20087-revert-20069-fix-homepage-versions-dropdown

This commit is contained in:
Sarah Schneider
2021-06-23 18:55:17 -04:00
committed by GitHub
58 changed files with 553 additions and 158 deletions

View File

@@ -1,7 +1,8 @@
const path = require('path')
const cheerio = require('cheerio')
const Page = require('../../lib/page')
const prerenderedObjects = require('../../lib/graphql/static/prerendered-objects')
const readJsonFile = require('../../lib/read-json-file')
const prerenderedObjects = readJsonFile('./lib/graphql/static/prerendered-objects.json')
const allVersions = require('../../lib/all-versions')
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
@@ -534,6 +535,48 @@ describe('Page class', () => {
expect(nonEnterpriseDefaultPlan in page.versions).toBe(false)
expect(page.versions['enterprise-server']).toBe('*')
})
test('feature versions frontmatter', async () => {
// This fixture file has the frontmatter:
//
// versions:
// fpt: '*'
// ghes: '*'
// feature: 'placeholder'
//
// and placeholder.yml has:
//
// versions:
// ghes: '<2.22'
// ghae: '*'
//
// So we expect to get the versioning from both.
const page = await Page.init({
relativePath: 'feature-versions-frontmatter.md',
basePath: path.join(__dirname, '../fixtures'),
languageCode: 'en'
})
// Test the raw page data.
expect(page.versions.fpt).toBe('*')
expect(page.versions.ghes).toBe('>2.21')
expect(page.versions.ghae).toBeUndefined()
// The `feature` prop gets deleted by lib/get-applicable-versions, so it's undefined.
expect(page.versions.feature).toBeUndefined()
// Test the resolved versioning, where GHES releases specified in frontmatter and in
// feature versions are combined (i.e., one doesn't overwrite the other).
// We can't test that GHES 2.21 is _not_ included here (which it shouldn't be),
// because lib/get-applicable-versions only returns currently supported versions,
// so as soon as 2.21 is deprecated, a test for that _not_ to exist will not be meaningful.
// But by testing that the _latest_ GHES version is returned, we can ensure that the
// the frontmatter GHES `*` is not being overwritten by the placeholder's GHES `<2.22`.
expect(page.applicableVersions.includes('free-pro-team@latest')).toBe(true)
expect(page.applicableVersions.includes(`enterprise-server@${latest}`)).toBe(true)
expect(page.applicableVersions.includes('github-ae@latest')).toBe(true)
expect(page.applicableVersions.includes('feature')).toBe(false)
expect(page.applicableVersions.includes('placeholder')).toBe(false)
})
})
describe('platform specific content', () => {