` (example: `ghes > 3.0`)
- const condParts = cond
- .split(/ (or|and) /)
- .filter(part => !(part === 'or' || part === 'and'))
-
- condParts
- .forEach(str => {
- const strParts = str.split(' ')
- // if length = 1, this should be a valid short version name.
- if (strParts.length === 1) {
- const version = strParts[0]
- const isValidVersion = validateVersion(version)
- if (!isValidVersion) {
- errors.push(`"${version}" is not a valid short version name`)
- }
+ const condParts = cond.split(/ (or|and) /).filter((part) => !(part === 'or' || part === 'and'))
+
+ condParts.forEach((str) => {
+ const strParts = str.split(' ')
+ // if length = 1, this should be a valid short version name.
+ if (strParts.length === 1) {
+ const version = strParts[0]
+ const isValidVersion = validateVersion(version)
+ if (!isValidVersion) {
+ errors.push(`"${version}" is not a valid short version name`)
}
+ }
- // if length = 2, this should be 'not' followed by a valid short version name.
- if (strParts.length === 2) {
- const [notKeyword, version] = strParts
- const isValidVersion = validateVersion(version)
- const isValid = notKeyword === 'not' && isValidVersion
- if (!isValid) {
- errors.push(`"${cond}" is not a valid conditional`)
- }
+ // if length = 2, this should be 'not' followed by a valid short version name.
+ if (strParts.length === 2) {
+ const [notKeyword, version] = strParts
+ const isValidVersion = validateVersion(version)
+ const isValid = notKeyword === 'not' && isValidVersion
+ if (!isValid) {
+ errors.push(`"${cond}" is not a valid conditional`)
}
+ }
- // if length = 3, this should be a range in the format: ghes > 3.0
- // where the first item is `ghes` (currently the only version with numbered releases),
- // the second item is a supported operator, and the third is a supported GHES release.
- if (strParts.length === 3) {
- const [version, operator, release] = strParts
- if (version !== 'ghes') {
- errors.push(`Found "${version}" inside "${cond}" with a "${operator}" operator; expected "ghes"`)
- }
- if (!allowedVersionOperators.includes(operator)) {
- errors.push(`Found a "${operator}" operator inside "${cond}", but "${operator}" is not supported`)
- }
- // NOTE: The following will throw errors when we deprecate a version until we run the script to remove the
- // deprecated versioning. If we deprecate a version before we have a working version of that script,
- // we can comment out this part of the test temporarily and re-enable it once the script is ready.
- if (!(supported.includes(release) || release === next)) {
- errors.push(`Found ${release} inside "${cond}", but ${release} is not a supported GHES release`)
- }
+ // if length = 3, this should be a range in the format: ghes > 3.0
+ // where the first item is `ghes` (currently the only version with numbered releases),
+ // the second item is a supported operator, and the third is a supported GHES release.
+ if (strParts.length === 3) {
+ const [version, operator, release] = strParts
+ if (version !== 'ghes') {
+ errors.push(
+ `Found "${version}" inside "${cond}" with a "${operator}" operator; expected "ghes"`
+ )
}
- })
+ if (!allowedVersionOperators.includes(operator)) {
+ errors.push(
+ `Found a "${operator}" operator inside "${cond}", but "${operator}" is not supported`
+ )
+ }
+ // NOTE: The following will throw errors when we deprecate a version until we run the script to remove the
+ // deprecated versioning. If we deprecate a version before we have a working version of that script,
+ // we can comment out this part of the test temporarily and re-enable it once the script is ready.
+ if (!(supported.includes(release) || release === next)) {
+ errors.push(
+ `Found ${release} inside "${cond}", but ${release} is not a supported GHES release`
+ )
+ }
+ }
+ })
})
return errors
diff --git a/tests/meta/orphan-tests.js b/tests/meta/orphan-tests.js
index bf77115a71d8..2b80cde45c7e 100644
--- a/tests/meta/orphan-tests.js
+++ b/tests/meta/orphan-tests.js
@@ -13,17 +13,12 @@ describe('check for orphan tests', () => {
const testDirectory = await fs.readdir(pathToTests)
// Filter out our exceptions
- let filteredList = testDirectory
- .filter(item => !EXCEPTIONS.includes(item))
+ let filteredList = testDirectory.filter((item) => !EXCEPTIONS.includes(item))
// Don't include directories
filteredList = await asyncFilter(
filteredList,
- async item => !(
- await fs.stat(
- path.join(pathToTests, item)
- )
- ).isDirectory()
+ async (item) => !(await fs.stat(path.join(pathToTests, item))).isDirectory()
)
expect(filteredList).toHaveLength(0)
diff --git a/tests/meta/repository-references.js b/tests/meta/repository-references.js
index aaefbdc4d438..dfedb06de9c0 100644
--- a/tests/meta/repository-references.js
+++ b/tests/meta/repository-references.js
@@ -35,7 +35,7 @@ const ALLOW_LIST = new Set([
'renaming',
'localization-support',
'docs',
- 'securitylab'
+ 'securitylab',
])
describe('check if a GitHub-owned private repository is referenced', () => {
@@ -69,15 +69,15 @@ describe('check if a GitHub-owned private repository is referenced', () => {
'**/*.pdf',
'**/*.ico',
'**/*.woff',
- 'script/deploy'
- ]
+ 'script/deploy',
+ ],
})
test.each(filenames)('in file %s', async (filename) => {
const file = await readFileAsync(filename, 'utf8')
const matches = Array.from(file.matchAll(REPO_REGEXP))
.map(([, repoName]) => repoName)
- .filter(repoName => !ALLOW_LIST.has(repoName))
+ .filter((repoName) => !ALLOW_LIST.has(repoName))
expect(matches).toHaveLength(0)
})
})
diff --git a/tests/rendering/block-robots.js b/tests/rendering/block-robots.js
index 8ca263d7d1cb..d7bc1e16c5c7 100644
--- a/tests/rendering/block-robots.js
+++ b/tests/rendering/block-robots.js
@@ -3,7 +3,7 @@ import languages from '../../lib/languages.js'
import { productMap } from '../../lib/all-products.js'
import enterpriseServerReleases from '../../lib/enterprise-server-releases.js'
-function allowIndex (path) {
+function allowIndex(path) {
return !blockIndex(path)
}
@@ -16,8 +16,8 @@ describe('block robots', () => {
it('allows crawling of generally available localized content', async () => {
Object.values(languages)
- .filter(language => !language.wip)
- .forEach(language => {
+ .filter((language) => !language.wip)
+ .forEach((language) => {
expect(allowIndex(`/${language.code}`)).toBe(true)
expect(allowIndex(`/${language.code}/articles/verifying-your-email-address`)).toBe(true)
})
@@ -25,8 +25,8 @@ describe('block robots', () => {
it('disallows crawling of WIP localized content', async () => {
Object.values(languages)
- .filter(language => language.wip)
- .forEach(language => {
+ .filter((language) => language.wip)
+ .forEach((language) => {
expect(allowIndex(`/${language.code}`)).toBe(false)
expect(allowIndex(`/${language.code}/articles/verifying-your-email-address`)).toBe(false)
})
@@ -34,10 +34,10 @@ describe('block robots', () => {
it('disallows crawling of WIP products', async () => {
const wipProductIds = Object.values(productMap)
- .filter(product => product.wip)
- .map(product => product.id)
+ .filter((product) => product.wip)
+ .map((product) => product.id)
- wipProductIds.forEach(id => {
+ wipProductIds.forEach((id) => {
const { href } = productMap[id]
const blockedPaths = [
// English
@@ -52,10 +52,10 @@ describe('block robots', () => {
`/ja${href}/overview`,
`/ja${href}/overview/intro`,
`/ja/enterprise/${enterpriseServerReleases.latest}/user${href}`,
- `/ja/enterprise/${enterpriseServerReleases.oldestSupported}/user${href}`
+ `/ja/enterprise/${enterpriseServerReleases.oldestSupported}/user${href}`,
]
- blockedPaths.forEach(path => {
+ blockedPaths.forEach((path) => {
expect(allowIndex(path)).toBe(false)
})
})
@@ -63,23 +63,25 @@ describe('block robots', () => {
it('disallows crawling of early access "hidden" products', async () => {
const hiddenProductIds = Object.values(productMap)
- .filter(product => product.hidden)
- .map(product => product.id)
+ .filter((product) => product.hidden)
+ .map((product) => product.id)
- hiddenProductIds.forEach(id => {
+ hiddenProductIds.forEach((id) => {
const { versions } = productMap[id]
- const blockedPaths = versions.map(version => {
- return [
- // English
- `/en/${version}/${id}`,
- `/en/${version}/${id}/some-early-access-article`,
- // Japanese
- `/ja/${version}/${id}`,
- `/ja/${version}/${id}/some-early-access-article`
- ]
- }).flat()
+ const blockedPaths = versions
+ .map((version) => {
+ return [
+ // English
+ `/en/${version}/${id}`,
+ `/en/${version}/${id}/some-early-access-article`,
+ // Japanese
+ `/ja/${version}/${id}`,
+ `/ja/${version}/${id}/some-early-access-article`,
+ ]
+ })
+ .flat()
- blockedPaths.forEach(path => {
+ blockedPaths.forEach((path) => {
expect(allowIndex(path)).toBe(false)
})
})
@@ -91,11 +93,13 @@ describe('block robots', () => {
expect(allowIndex('/en/actions/overview')).toBe(true)
expect(allowIndex('/en/actions/overview/intro')).toBe(true)
expect(allowIndex(`/en/enterprise/${enterpriseServerReleases.latest}/user/actions`)).toBe(true)
- expect(allowIndex(`/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/actions`)).toBe(true)
+ expect(
+ allowIndex(`/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/actions`)
+ ).toBe(true)
})
it('disallows crawling of deprecated enterprise releases', async () => {
- enterpriseServerReleases.deprecated.forEach(version => {
+ enterpriseServerReleases.deprecated.forEach((version) => {
const blockedPaths = [
// English
`/en/enterprise-server@${version}/actions`,
@@ -106,10 +110,10 @@ describe('block robots', () => {
`/ja/enterprise-server@${version}/actions`,
`/ja/enterprise/${version}/actions`,
`/ja/enterprise-server@${version}/actions/overview`,
- `/ja/enterprise/${version}/actions/overview`
+ `/ja/enterprise/${version}/actions/overview`,
]
- blockedPaths.forEach(path => {
+ blockedPaths.forEach((path) => {
expect(allowIndex(path)).toBe(false)
})
})
diff --git a/tests/rendering/breadcrumbs.js b/tests/rendering/breadcrumbs.js
index 58ebeb633dd3..7e91c0e0f816 100644
--- a/tests/rendering/breadcrumbs.js
+++ b/tests/rendering/breadcrumbs.js
@@ -1,7 +1,8 @@
import { getDOM, getJSON } from '../helpers/supertest.js'
import { jest } from '@jest/globals'
-const describeInternalOnly = process.env.GITHUB_REPOSITORY === 'github/docs-internal' ? describe : describe.skip
+const describeInternalOnly =
+ process.env.GITHUB_REPOSITORY === 'github/docs-internal' ? describe : describe.skip
describe('breadcrumbs', () => {
jest.setTimeout(300 * 1000)
@@ -13,7 +14,9 @@ describe('breadcrumbs', () => {
})
test('article pages have breadcrumbs with product, category, maptopic, and article', async () => {
- const $ = await getDOM('/github/authenticating-to-github/troubleshooting-ssh/using-ssh-over-the-https-port')
+ const $ = await getDOM(
+ '/github/authenticating-to-github/troubleshooting-ssh/using-ssh-over-the-https-port'
+ )
const $breadcrumbs = $('.breadcrumbs a')
expect($breadcrumbs).toHaveLength(4)
@@ -24,7 +27,9 @@ describe('breadcrumbs', () => {
})
test('maptopic pages include their own grayed-out breadcrumb', async () => {
- const $ = await getDOM('/github/authenticating-to-github/keeping-your-account-and-data-secure')
+ const $ = await getDOM(
+ '/github/authenticating-to-github/keeping-your-account-and-data-secure'
+ )
const $breadcrumbs = $('.breadcrumbs a')
expect($breadcrumbs).toHaveLength(3)
@@ -35,7 +40,9 @@ describe('breadcrumbs', () => {
})
test('works for enterprise user pages', async () => {
- const $ = await getDOM('/en/enterprise-server/github/authenticating-to-github/troubleshooting-ssh/recovering-your-ssh-key-passphrase')
+ const $ = await getDOM(
+ '/en/enterprise-server/github/authenticating-to-github/troubleshooting-ssh/recovering-your-ssh-key-passphrase'
+ )
const $breadcrumbs = $('.breadcrumbs a')
expect($breadcrumbs).toHaveLength(4)
// The product is still GitHub.com on an Enterprise Server version
@@ -69,7 +76,9 @@ describe('breadcrumbs', () => {
})
test('early access article pages have breadcrumbs with product, category, and article', async () => {
- const $ = await getDOM('/early-access/github/enforcing-best-practices-with-github-policies/about-github-policies')
+ const $ = await getDOM(
+ '/early-access/github/enforcing-best-practices-with-github-policies/about-github-policies'
+ )
const $breadcrumbSpans = $('.breadcrumbs span')
const $breadcrumbLinks = $('.breadcrumbs a')
@@ -77,7 +86,9 @@ describe('breadcrumbs', () => {
expect($breadcrumbLinks).toHaveLength(2)
expect($breadcrumbSpans[0].children[0].data).toBe('Early Access documentation')
expect($breadcrumbSpans[1].children[0].data).toBe('GitHub.com')
- expect($breadcrumbLinks[0].attribs.title).toBe('category: Enforcing best practices with GitHub Policies')
+ expect($breadcrumbLinks[0].attribs.title).toBe(
+ 'category: Enforcing best practices with GitHub Policies'
+ )
expect($breadcrumbLinks[1].attribs.title).toBe('article: About GitHub Policies')
expect($breadcrumbLinks[1].attribs.class.includes('color-text-tertiary')).toBe(true)
})
@@ -90,8 +101,8 @@ describe('breadcrumbs', () => {
{
documentType: 'product',
href: '/en/github',
- title: 'GitHub.com'
- }
+ title: 'GitHub.com',
+ },
]
expect(breadcrumbs).toEqual(expected)
})
@@ -102,84 +113,90 @@ describe('breadcrumbs', () => {
{
documentType: 'product',
href: '/en/github',
- title: 'GitHub.com'
+ title: 'GitHub.com',
},
{
documentType: 'category',
href: '/en/github/authenticating-to-github',
- title: 'Authentication'
- }
+ title: 'Authentication',
+ },
]
expect(breadcrumbs).toEqual(expected)
})
test('works on maptopic pages', async () => {
- const breadcrumbs = await getJSON('/en/github/authenticating-to-github/keeping-your-account-and-data-secure?json=breadcrumbs')
+ const breadcrumbs = await getJSON(
+ '/en/github/authenticating-to-github/keeping-your-account-and-data-secure?json=breadcrumbs'
+ )
const expected = [
{
documentType: 'product',
href: '/en/github',
- title: 'GitHub.com'
+ title: 'GitHub.com',
},
{
documentType: 'category',
href: '/en/github/authenticating-to-github',
- title: 'Authentication'
+ title: 'Authentication',
},
{
documentType: 'mapTopic',
href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure',
- title: 'Account security'
- }
+ title: 'Account security',
+ },
]
expect(breadcrumbs).toEqual(expected)
})
test('works on articles that DO have maptopics ', async () => {
- const breadcrumbs = await getJSON('/en/github/authenticating-to-github/creating-a-strong-password?json=breadcrumbs')
+ const breadcrumbs = await getJSON(
+ '/en/github/authenticating-to-github/creating-a-strong-password?json=breadcrumbs'
+ )
const expected = [
{
documentType: 'product',
href: '/en/github',
- title: 'GitHub.com'
+ title: 'GitHub.com',
},
{
documentType: 'category',
href: '/en/github/authenticating-to-github',
- title: 'Authentication'
+ title: 'Authentication',
},
{
documentType: 'mapTopic',
href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure',
- title: 'Account security'
+ title: 'Account security',
},
{
documentType: 'article',
href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-strong-password',
- title: 'Create a strong password'
- }
+ title: 'Create a strong password',
+ },
]
expect(breadcrumbs).toEqual(expected)
})
test('works on articles that DO NOT have maptopics ', async () => {
- const breadcrumbs = await getJSON('/github/site-policy/github-privacy-statement?json=breadcrumbs')
+ const breadcrumbs = await getJSON(
+ '/github/site-policy/github-privacy-statement?json=breadcrumbs'
+ )
const expected = [
{
documentType: 'product',
href: '/en/github',
- title: 'GitHub.com'
+ title: 'GitHub.com',
},
{
documentType: 'category',
href: '/en/github/site-policy',
- title: 'Site policy'
+ title: 'Site policy',
},
{
documentType: 'article',
href: '/en/github/site-policy/github-privacy-statement',
- title: 'GitHub Privacy Statement'
- }
+ title: 'GitHub Privacy Statement',
+ },
]
expect(breadcrumbs).toEqual(expected)
})
diff --git a/tests/rendering/events.js b/tests/rendering/events.js
index f0cb6b39e538..36399e3d81ee 100644
--- a/tests/rendering/events.js
+++ b/tests/rendering/events.js
@@ -20,9 +20,7 @@ describe('POST /events', () => {
const csrfRes = await agent.get('/en')
const $ = cheerio.load(csrfRes.text || '', { xmlMode: true })
csrfToken = $('meta[name="csrf-token"]').attr('content')
- nock('http://example.com')
- .post('/hydro')
- .reply(200, {})
+ nock('http://example.com').post('/hydro').reply(200, {})
})
afterEach(() => {
@@ -33,7 +31,7 @@ describe('POST /events', () => {
csrfToken = ''
})
- async function checkEvent (data, code) {
+ async function checkEvent(data, code) {
return agent
.post('/events')
.send(data)
@@ -68,220 +66,256 @@ describe('POST /events', () => {
// Location information
timezone: -7,
- user_language: 'en-US'
- }
+ user_language: 'en-US',
+ },
}
describe('page', () => {
const pageExample = { ...baseExample, type: 'page' }
- it('should record a page event', () =>
- checkEvent(pageExample, 200)
- )
+ it('should record a page event', () => checkEvent(pageExample, 200))
- it('should require a type', () =>
- checkEvent(baseExample, 400)
- )
+ it('should require a type', () => checkEvent(baseExample, 400))
it('should require an event_id in uuid', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- event_id: 'asdfghjkl'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ event_id: 'asdfghjkl',
+ },
+ },
+ 400
+ ))
it('should require a user in uuid', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- user: 'asdfghjkl'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ user: 'asdfghjkl',
+ },
+ },
+ 400
+ ))
it('should require a version', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- version: undefined
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ version: undefined,
+ },
+ },
+ 400
+ ))
it('should require created timestamp', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- timestamp: 1234
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ timestamp: 1234,
+ },
+ },
+ 400
+ ))
it('should allow page_event_id', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- page_event_id: baseExample.context.event_id
- }
- }, 200)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ page_event_id: baseExample.context.event_id,
+ },
+ },
+ 200
+ ))
it('should not allow a honeypot token', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- token: 'zxcv'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ token: 'zxcv',
+ },
+ },
+ 400
+ ))
it('should path be uri-reference', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- path: ' '
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ path: ' ',
+ },
+ },
+ 400
+ ))
it('should hostname be uri-reference', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- hostname: ' '
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ hostname: ' ',
+ },
+ },
+ 400
+ ))
it('should referrer be uri-reference', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- referrer: ' '
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ referrer: ' ',
+ },
+ },
+ 400
+ ))
it('should search a string', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- search: 1234
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ search: 1234,
+ },
+ },
+ 400
+ ))
it('should href be uri', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- href: '/example'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ href: '/example',
+ },
+ },
+ 400
+ ))
it('should site_language is a valid option', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- site_language: 'nl'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ site_language: 'nl',
+ },
+ },
+ 400
+ ))
it('should os a valid os option', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- os: 'ubuntu'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ os: 'ubuntu',
+ },
+ },
+ 400
+ ))
it('should os_version a string', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- os_version: 25
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ os_version: 25,
+ },
+ },
+ 400
+ ))
it('should browser a valid option', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- browser: 'opera'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ browser: 'opera',
+ },
+ },
+ 400
+ ))
it('should browser_version a string', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- browser_version: 25
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ browser_version: 25,
+ },
+ },
+ 400
+ ))
it('should viewport_width a number', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- viewport_width: -500
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ viewport_width: -500,
+ },
+ },
+ 400
+ ))
it('should viewport_height a number', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- viewport_height: '53px'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ viewport_height: '53px',
+ },
+ },
+ 400
+ ))
it('should timezone in number', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- timezone: 'GMT-0700'
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ timezone: 'GMT-0700',
+ },
+ },
+ 400
+ ))
it('should user_language is a string', () =>
- checkEvent({
- ...pageExample,
- context: {
- ...pageExample.context,
- user_language: true
- }
- }, 400)
- )
+ checkEvent(
+ {
+ ...pageExample,
+ context: {
+ ...pageExample.context,
+ user_language: true,
+ },
+ },
+ 400
+ ))
})
describe('exit', () => {
@@ -293,51 +327,44 @@ describe('POST /events', () => {
exit_dom_interactive: 0.2,
exit_dom_complete: 0.3,
exit_visit_duration: 5,
- exit_scroll_length: 0.5
+ exit_scroll_length: 0.5,
}
- it('should record an exit event', () =>
- checkEvent(exitExample, 200)
- )
+ it('should record an exit event', () => checkEvent(exitExample, 200))
it('should exit_render_duration is a positive number', () =>
- checkEvent({
- ...exitExample,
- exit_render_duration: -0.5
- }, 400)
- )
+ checkEvent(
+ {
+ ...exitExample,
+ exit_render_duration: -0.5,
+ },
+ 400
+ ))
it('exit_first_paint is a number', () =>
- checkEvent({ ...exitExample, exit_first_paint: 'afjdkl' }, 400)
- )
+ checkEvent({ ...exitExample, exit_first_paint: 'afjdkl' }, 400))
it('exit_dom_interactive is a number', () =>
- checkEvent({ ...exitExample, exit_dom_interactive: '202' }, 400)
- )
+ checkEvent({ ...exitExample, exit_dom_interactive: '202' }, 400))
it('exit_visit_duration is a number', () =>
- checkEvent({ ...exitExample, exit_visit_duration: '75' }, 400)
- )
+ checkEvent({ ...exitExample, exit_visit_duration: '75' }, 400))
it('exit_scroll_length is a number between 0 and 1', () =>
- checkEvent({ ...exitExample, exit_scroll_length: 1.1 }, 400)
- )
+ checkEvent({ ...exitExample, exit_scroll_length: 1.1 }, 400))
})
describe('link', () => {
const linkExample = {
...baseExample,
type: 'link',
- link_url: 'https://example.com'
+ link_url: 'https://example.com',
}
- it('should send a link event', () =>
- checkEvent(linkExample, 200)
- )
+ it('should send a link event', () => checkEvent(linkExample, 200))
it('link_url is a required uri formatted string', () =>
- checkEvent({ ...linkExample, link_url: 'foo' }, 400)
- )
+ checkEvent({ ...linkExample, link_url: 'foo' }, 400))
})
describe('search', () => {
@@ -345,36 +372,29 @@ describe('POST /events', () => {
...baseExample,
type: 'search',
search_query: 'github private instances',
- search_context: 'private'
+ search_context: 'private',
}
- it('should record a search event', () =>
- checkEvent(searchExample, 200)
- )
+ it('should record a search event', () => checkEvent(searchExample, 200))
it('search_query is required string', () =>
- checkEvent({ ...searchExample, search_query: undefined }, 400)
- )
+ checkEvent({ ...searchExample, search_query: undefined }, 400))
it('search_context is optional string', () =>
- checkEvent({ ...searchExample, search_context: undefined }, 200)
- )
+ checkEvent({ ...searchExample, search_context: undefined }, 200))
})
describe('navigate', () => {
const navigateExample = {
...baseExample,
type: 'navigate',
- navigate_label: 'drop down'
+ navigate_label: 'drop down',
}
- it('should record a navigate event', () =>
- checkEvent(navigateExample, 200)
- )
+ it('should record a navigate event', () => checkEvent(navigateExample, 200))
it('navigate_label is optional string', () =>
- checkEvent({ ...navigateExample, navigate_label: undefined }, 200)
- )
+ checkEvent({ ...navigateExample, navigate_label: undefined }, 200))
})
describe('survey', () => {
@@ -383,16 +403,13 @@ describe('POST /events', () => {
type: 'survey',
survey_vote: true,
survey_comment: 'I love this site.',
- survey_email: 'daisy@example.com'
+ survey_email: 'daisy@example.com',
}
- it('should record a survey event', () =>
- checkEvent(surveyExample, 200)
- )
+ it('should record a survey event', () => checkEvent(surveyExample, 200))
it('survey_vote is boolean', () =>
- checkEvent({ ...surveyExample, survey_vote: undefined }, 400)
- )
+ checkEvent({ ...surveyExample, survey_vote: undefined }, 400))
it('survey_comment is string', () => {
checkEvent({ ...surveyExample, survey_comment: 1234 }, 400)
@@ -409,24 +426,19 @@ describe('POST /events', () => {
type: 'experiment',
experiment_name: 'change-button-copy',
experiment_variation: 'treatment',
- experiment_success: true
+ experiment_success: true,
}
- it('should record an experiment event', () =>
- checkEvent(experimentExample, 200)
- )
+ it('should record an experiment event', () => checkEvent(experimentExample, 200))
it('experiment_name is required string', () =>
- checkEvent({ ...experimentExample, experiment_name: undefined }, 400)
- )
+ checkEvent({ ...experimentExample, experiment_name: undefined }, 400))
it('experiment_variation is required string', () =>
- checkEvent({ ...experimentExample, experiment_variation: undefined }, 400)
- )
+ checkEvent({ ...experimentExample, experiment_variation: undefined }, 400))
it('experiment_success is optional boolean', () =>
- checkEvent({ ...experimentExample, experiment_success: undefined }, 200)
- )
+ checkEvent({ ...experimentExample, experiment_success: undefined }, 200))
})
describe('redirect', () => {
@@ -434,47 +446,38 @@ describe('POST /events', () => {
...baseExample,
type: 'redirect',
redirect_from: 'http://example.com/a',
- redirect_to: 'http://example.com/b'
+ redirect_to: 'http://example.com/b',
}
- it('should record an redirect event', () =>
- checkEvent(redirectExample, 200)
- )
+ it('should record an redirect event', () => checkEvent(redirectExample, 200))
it('redirect_from is required url', () =>
- checkEvent({ ...redirectExample, redirect_from: ' ' }, 400)
- )
+ checkEvent({ ...redirectExample, redirect_from: ' ' }, 400))
it('redirect_to is required url', () =>
- checkEvent({ ...redirectExample, redirect_to: undefined }, 400)
- )
+ checkEvent({ ...redirectExample, redirect_to: undefined }, 400))
})
describe('clipboard', () => {
const clipboardExample = {
...baseExample,
type: 'clipboard',
- clipboard_operation: 'copy'
+ clipboard_operation: 'copy',
}
- it('should record an clipboard event', () =>
- checkEvent(clipboardExample, 200)
- )
+ it('should record an clipboard event', () => checkEvent(clipboardExample, 200))
it('clipboard_operation is required copy, paste, cut', () =>
- checkEvent({ ...clipboardExample, clipboard_operation: 'destroy' }, 400)
- )
+ checkEvent({ ...clipboardExample, clipboard_operation: 'destroy' }, 400))
})
describe('print', () => {
const printExample = {
...baseExample,
- type: 'print'
+ type: 'print',
}
- it('should record a print event', () =>
- checkEvent(printExample, 200)
- )
+ it('should record a print event', () => checkEvent(printExample, 200))
})
describe('preference', () => {
@@ -482,12 +485,10 @@ describe('POST /events', () => {
...baseExample,
type: 'preference',
preference_name: 'application',
- preference_value: 'cli'
+ preference_value: 'cli',
}
- it('should record an application event', () =>
- checkEvent(preferenceExample, 200)
- )
+ it('should record an application event', () => checkEvent(preferenceExample, 200))
it('preference_name is string', () => {
checkEvent({ ...preferenceExample, preference_name: null }, 400)
diff --git a/tests/rendering/head.js b/tests/rendering/head.js
index 71d0283292e5..f2d306dc7d51 100644
--- a/tests/rendering/head.js
+++ b/tests/rendering/head.js
@@ -24,8 +24,14 @@ describe('', () => {
const $ = await getDOM('/en/articles/about-pull-request-merges')
const $description = $('meta[name="description"]')
// plain text intro
- expect($description.attr('content').startsWith('You can merge pull requests by retaining')).toBe(true)
+ expect(
+ $description.attr('content').startsWith('You can merge pull requests by retaining')
+ ).toBe(true)
// HTML intro
- expect($('div.lead-mktg').html().startsWith('You can merge pull requests'))
+ expect(
+ $('div.lead-mktg')
+ .html()
+ .startsWith('
You can merge pull requests')
+ )
})
})
diff --git a/tests/rendering/header.js b/tests/rendering/header.js
index 44aa9aba7a71..d5e38de98371 100644
--- a/tests/rendering/header.js
+++ b/tests/rendering/header.js
@@ -10,7 +10,7 @@ describe('header', () => {
expect($('meta[name="site.data.ui.search.placeholder"]').length).toBe(1)
})
- test('includes a link to the homepage (in the current page\'s language)', async () => {
+ test("includes a link to the homepage (in the current page's language)", async () => {
let $ = await getDOM('/en')
expect($('#github-logo a[href="/en"]').length).toBe(2)
@@ -22,13 +22,19 @@ describe('header', () => {
describe('language links', () => {
test('lead to the same page in a different language', async () => {
const $ = await getDOM('/github/administering-a-repository/managing-a-branch-protection-rule')
- expect($('#languages-selector a[href="/ja/github/administering-a-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule"]').length).toBe(1)
+ expect(
+ $(
+ '#languages-selector a[href="/ja/github/administering-a-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule"]'
+ ).length
+ ).toBe(1)
})
test('display the native name and the English name for each translated language', async () => {
const $ = await getDOM('/en')
expect($('#languages-selector a[href="/en"]').text().trim()).toBe('English')
- expect($('#languages-selector a[href="/cn"]').text().trim()).toBe('็ฎไฝไธญๆ (Simplified Chinese)')
+ expect($('#languages-selector a[href="/cn"]').text().trim()).toBe(
+ '็ฎไฝไธญๆ (Simplified Chinese)'
+ )
expect($('#languages-selector a[href="/ja"]').text().trim()).toBe('ๆฅๆฌ่ช (Japanese)')
})
@@ -60,50 +66,54 @@ describe('header', () => {
test('displays translation disclaimer notice on localized site-policy pages', async () => {
const $ = await getDOM('/ja/github/site-policy/github-logo-policy')
- expect($('.header-notifications.translation_notice a[href="https://github.com/github/site-policy/issues"]').length).toBe(1)
+ expect(
+ $(
+ '.header-notifications.translation_notice a[href="https://github.com/github/site-policy/issues"]'
+ ).length
+ ).toBe(1)
})
- test('renders a link to the same page in user\'s preferred language, if available', async () => {
+ test("renders a link to the same page in user's preferred language, if available", async () => {
const headers = { 'accept-language': 'ja' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications.translation_notice').length).toBe(1)
expect($('.header-notifications a[href*="/ja"]').length).toBe(1)
})
- test('renders a link to the same page if user\'s preferred language is Chinese - PRC', async () => {
+ test("renders a link to the same page if user's preferred language is Chinese - PRC", async () => {
const headers = { 'accept-language': 'zh-CN' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications.translation_notice').length).toBe(1)
expect($('.header-notifications a[href*="/cn"]').length).toBe(1)
})
- test('does not render a link when user\'s preferred language is Chinese - Taiwan', async () => {
+ test("does not render a link when user's preferred language is Chinese - Taiwan", async () => {
const headers = { 'accept-language': 'zh-TW' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications').length).toBe(0)
})
- test('does not render a link when user\'s preferred language is English', async () => {
+ test("does not render a link when user's preferred language is English", async () => {
const headers = { 'accept-language': 'en' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications').length).toBe(0)
})
- test('renders a link to the same page in user\'s preferred language from multiple, if available', async () => {
+ test("renders a link to the same page in user's preferred language from multiple, if available", async () => {
const headers = { 'accept-language': 'ja, *;q=0.9' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications.translation_notice').length).toBe(1)
expect($('.header-notifications a[href*="/ja"]').length).toBe(1)
})
- test('renders a link to the same page in user\'s preferred language with weights, if available', async () => {
+ test("renders a link to the same page in user's preferred language with weights, if available", async () => {
const headers = { 'accept-language': 'ja;q=1.0, *;q=0.9' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications.translation_notice').length).toBe(1)
expect($('.header-notifications a[href*="/ja"]').length).toBe(1)
})
- test('renders a link to the user\'s 2nd preferred language if 1st is not available', async () => {
+ test("renders a link to the user's 2nd preferred language if 1st is not available", async () => {
const headers = { 'accept-language': 'zh-TW,zh;q=0.9,ja *;q=0.8' }
const $ = await getDOM('/en', headers)
expect($('.header-notifications.translation_notice').length).toBe(1)
@@ -131,14 +141,18 @@ describe('header', () => {
expect(ghe.attr('class').includes('active')).toBe(false)
})
- test('point to homepages in the current page\'s language', async () => {
- const $ = await getDOM('/ja/github/administering-a-repository/defining-the-mergeability-of-pull-requests')
+ test("point to homepages in the current page's language", async () => {
+ const $ = await getDOM(
+ '/ja/github/administering-a-repository/defining-the-mergeability-of-pull-requests'
+ )
expect($('#homepages a.active[href="/ja/github"]').length).toBe(1)
expect($(`#homepages a[href="/ja/enterprise-server@${latest}/admin"]`).length).toBe(1)
})
test('emphasizes the product that corresponds to the current page', async () => {
- const $ = await getDOM(`/en/enterprise/${oldestSupported}/user/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address`)
+ const $ = await getDOM(
+ `/en/enterprise/${oldestSupported}/user/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address`
+ )
expect($(`#homepages a.active[href="/en/enterprise-server@${latest}/admin"]`).length).toBe(0)
expect($('#homepages a[href="/en/github"]').length).toBe(1)
expect($('#homepages a.active[href="/en/github"]').length).toBe(1)
diff --git a/tests/rendering/learning-tracks.js b/tests/rendering/learning-tracks.js
index 14997bb94278..11de87e2722d 100644
--- a/tests/rendering/learning-tracks.js
+++ b/tests/rendering/learning-tracks.js
@@ -28,16 +28,20 @@ describe('learning tracks', () => {
const trackName = found[1]
// check all the links contain track name
- $(trackElem).find('a.Box-row').each((i, elem) => {
- expect($(elem).attr('href')).toEqual(expect.stringContaining(`?learn=${trackName}`))
- })
+ $(trackElem)
+ .find('a.Box-row')
+ .each((i, elem) => {
+ expect($(elem).attr('href')).toEqual(expect.stringContaining(`?learn=${trackName}`))
+ })
})
})
})
describe('navigation banner', () => {
test('render navigation banner when url includes correct learning track name', async () => {
- const $ = await getDOM('/en/actions/guides/setting-up-continuous-integration-using-workflow-templates?learn=continuous_integration')
+ const $ = await getDOM(
+ '/en/actions/guides/setting-up-continuous-integration-using-workflow-templates?learn=continuous_integration'
+ )
expect($('.learning-track-nav')).toHaveLength(1)
const $navLinks = $('.learning-track-nav a')
expect($navLinks).toHaveLength(2)
@@ -47,17 +51,23 @@ describe('navigation banner', () => {
})
test('does not include banner when url does not include `learn` param', async () => {
- const $ = await getDOM('/en/actions/guides/setting-up-continuous-integration-using-workflow-templates')
+ const $ = await getDOM(
+ '/en/actions/guides/setting-up-continuous-integration-using-workflow-templates'
+ )
expect($('.learning-track-nav')).toHaveLength(0)
})
test('does not include banner when url has incorrect `learn` param', async () => {
- const $ = await getDOM('/en/actions/guides/setting-up-continuous-integration-using-workflow-templates?learn=not_real')
+ const $ = await getDOM(
+ '/en/actions/guides/setting-up-continuous-integration-using-workflow-templates?learn=not_real'
+ )
expect($('.learning-track-nav')).toHaveLength(0)
})
test('does not include banner when url is not part of the learning track', async () => {
- const $ = await getDOM('/en/actions/learn-github-actions/introduction-to-github-actions?learn=continuous_integration')
+ const $ = await getDOM(
+ '/en/actions/learn-github-actions/introduction-to-github-actions?learn=continuous_integration'
+ )
expect($('.learning-track-nav')).toHaveLength(0)
})
})
diff --git a/tests/rendering/octicon.js b/tests/rendering/octicon.js
index 1f432593bc9c..9ae70e8c778d 100644
--- a/tests/rendering/octicon.js
+++ b/tests/rendering/octicon.js
@@ -30,12 +30,14 @@ describe('octicon tag', () => {
})
it('throws an error with invalid syntax', async () => {
- await expect(renderContent('{% octicon 123 %}')).rejects
- .toThrowError('Syntax Error in tag \'octicon\' - Valid syntax: octicon "" ')
+ await expect(renderContent('{% octicon 123 %}')).rejects.toThrowError(
+ 'Syntax Error in tag \'octicon\' - Valid syntax: octicon "" '
+ )
})
it('throws an error with a non-existant octicon', async () => {
- await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects
- .toThrowError('Octicon pizza-patrol does not exist')
+ await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects.toThrowError(
+ 'Octicon pizza-patrol does not exist'
+ )
})
})
diff --git a/tests/rendering/page-titles.js b/tests/rendering/page-titles.js
index 4c5621ae744e..ae0082da8230 100644
--- a/tests/rendering/page-titles.js
+++ b/tests/rendering/page-titles.js
@@ -16,7 +16,9 @@ describe('page titles', () => {
})
test('enterprise English article', async () => {
- const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/github/authenticating-to-github/authorizing-oauth-apps`)
+ const $ = await getDOM(
+ `/en/enterprise/${enterpriseServerReleases.latest}/user/github/authenticating-to-github/authorizing-oauth-apps`
+ )
expect($('title').text()).toBe('Authorizing OAuth Apps - GitHub Docs')
})
diff --git a/tests/rendering/rest.js b/tests/rendering/rest.js
index f54850e9fb46..8df4e75fe585 100644
--- a/tests/rendering/rest.js
+++ b/tests/rendering/rest.js
@@ -14,7 +14,7 @@ const fs = xFs.promises
const excludeFromResourceNameCheck = [
'endpoints-available-for-github-apps.md',
'permissions-required-for-github-apps.md',
- 'index.md'
+ 'index.md',
]
describe('REST references docs', () => {
@@ -24,13 +24,18 @@ describe('REST references docs', () => {
const { categories } = rest
const referenceDir = path.join(__dirname, '../../content/rest/reference')
const filenames = (await fs.readdir(referenceDir))
- .filter(filename => !excludeFromResourceNameCheck.find(excludedFile => filename.endsWith(excludedFile)))
- .map(filename => filename.replace('.md', ''))
+ .filter(
+ (filename) =>
+ !excludeFromResourceNameCheck.find((excludedFile) => filename.endsWith(excludedFile))
+ )
+ .map((filename) => filename.replace('.md', ''))
- const missingResource = 'Found a markdown file in content/rest/reference that is not represented by an OpenAPI REST operation category.'
+ const missingResource =
+ 'Found a markdown file in content/rest/reference that is not represented by an OpenAPI REST operation category.'
expect(difference(filenames, categories), missingResource).toEqual([])
- const missingFile = 'Found an OpenAPI REST operation category that is not represented by a markdown file in content/rest/reference.'
+ const missingFile =
+ 'Found an OpenAPI REST operation category that is not represented by a markdown file in content/rest/reference.'
expect(difference(categories, filenames), missingFile).toEqual([])
})
@@ -40,14 +45,18 @@ describe('REST references docs', () => {
})
test('loads Enterprise OpenAPI schema data', async () => {
- const operations = await getJSON(`/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/rest/reference/emojis?json=currentRestOperations`)
- const operation = operations.find(operation => operation.operationId === 'emojis/get')
+ const operations = await getJSON(
+ `/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/rest/reference/emojis?json=currentRestOperations`
+ )
+ const operation = operations.find((operation) => operation.operationId === 'emojis/get')
expect(isPlainObject(operation)).toBe(true)
expect(operation.description).toContain('GitHub Enterprise')
})
test('loads operations enabled for GitHub Apps', async () => {
- const operations = await getJSON('/en/free-pro-team@latest/rest/overview/endpoints-available-for-github-apps?json=rest.operationsEnabledForGitHubApps')
+ const operations = await getJSON(
+ '/en/free-pro-team@latest/rest/overview/endpoints-available-for-github-apps?json=rest.operationsEnabledForGitHubApps'
+ )
expect(operations['free-pro-team@latest'].actions.length).toBeGreaterThan(0)
expect(operations['enterprise-server@2.22'].actions.length).toBeGreaterThan(0)
})
diff --git a/tests/rendering/robots-txt.js b/tests/rendering/robots-txt.js
index ca57b97f5116..d7319d663f91 100644
--- a/tests/rendering/robots-txt.js
+++ b/tests/rendering/robots-txt.js
@@ -17,25 +17,33 @@ describe('robots.txt', () => {
it('allows indexing of the homepage and English content', async () => {
expect(robots.isAllowed('https://docs.github.com/')).toBe(true)
expect(robots.isAllowed('https://docs.github.com/en')).toBe(true)
- expect(robots.isAllowed('https://docs.github.com/en/articles/verifying-your-email-address')).toBe(true)
+ expect(
+ robots.isAllowed('https://docs.github.com/en/articles/verifying-your-email-address')
+ ).toBe(true)
})
it('allows indexing of generally available localized content', async () => {
Object.values(languages)
- .filter(language => !language.wip)
- .forEach(language => {
+ .filter((language) => !language.wip)
+ .forEach((language) => {
expect(robots.isAllowed(`https://docs.github.com/${language.code}`)).toBe(true)
- expect(robots.isAllowed(`https://docs.github.com/${language.code}/articles/verifying-your-email-address`)).toBe(true)
+ expect(
+ robots.isAllowed(
+ `https://docs.github.com/${language.code}/articles/verifying-your-email-address`
+ )
+ ).toBe(true)
})
})
it('disallows indexing of herokuapp.com domains', async () => {
const req = {
hostname: 'docs-internal-12345--my-branch.herokuapp.com',
- path: '/robots.txt'
+ path: '/robots.txt',
}
const res = new MockExpressResponse()
- const next = () => { /* no op */ }
+ const next = () => {
+ /* no op */
+ }
await robotsMiddleware(req, res, next)
expect(res._getString()).toEqual('User-agent: *\nDisallow: /')
diff --git a/tests/rendering/server.js b/tests/rendering/server.js
index 3c9585880e11..7ed15a4bf7ee 100644
--- a/tests/rendering/server.js
+++ b/tests/rendering/server.js
@@ -10,7 +10,9 @@ import { productMap } from '../../lib/all-products.js'
import { jest } from '@jest/globals'
const AZURE_STORAGE_URL = 'githubdocs.azureedge.net'
-const activeProducts = Object.values(productMap).filter(product => !product.wip && !product.hidden)
+const activeProducts = Object.values(productMap).filter(
+ (product) => !product.wip && !product.hidden
+)
jest.useFakeTimers()
@@ -39,11 +41,13 @@ describe('server', () => {
test('renders the homepage with links to exptected products in both the sidebar and page body', async () => {
const $ = await getDOM('/en')
const sidebarItems = $('.sidebar-products li a').get()
- const sidebarTitles = sidebarItems.map(el => $(el).text().trim())
- const sidebarHrefs = sidebarItems.map(el => $(el).attr('href'))
+ const sidebarTitles = sidebarItems.map((el) => $(el).text().trim())
+ const sidebarHrefs = sidebarItems.map((el) => $(el).attr('href'))
- const productTitles = activeProducts.map(prod => prod.name)
- const productHrefs = activeProducts.map(prod => prod.external ? prod.href : `/en${prod.href}`)
+ const productTitles = activeProducts.map((prod) => prod.name)
+ const productHrefs = activeProducts.map((prod) =>
+ prod.external ? prod.href : `/en${prod.href}`
+ )
const titlesInSidebarButNotProducts = lodash.difference(sidebarTitles, productTitles)
const titlesInProductsButNotSidebar = lodash.difference(productTitles, sidebarTitles)
@@ -51,23 +55,47 @@ describe('server', () => {
const hrefsInSidebarButNotProducts = lodash.difference(sidebarHrefs, productHrefs)
const hrefsInProductsButNotSidebar = lodash.difference(productHrefs, sidebarHrefs)
- expect(titlesInSidebarButNotProducts.length, `Found unexpected titles in sidebar: ${titlesInSidebarButNotProducts.join(', ')}`).toBe(0)
- expect(titlesInProductsButNotSidebar.length, `Found titles missing from sidebar: ${titlesInProductsButNotSidebar.join(', ')}`).toBe(0)
- expect(hrefsInSidebarButNotProducts.length, `Found unexpected hrefs in sidebar: ${hrefsInSidebarButNotProducts.join(', ')}`).toBe(0)
- expect(hrefsInProductsButNotSidebar.length, `Found hrefs missing from sidebar: ${hrefsInProductsButNotSidebar.join(', ')}`).toBe(0)
+ expect(
+ titlesInSidebarButNotProducts.length,
+ `Found unexpected titles in sidebar: ${titlesInSidebarButNotProducts.join(', ')}`
+ ).toBe(0)
+ expect(
+ titlesInProductsButNotSidebar.length,
+ `Found titles missing from sidebar: ${titlesInProductsButNotSidebar.join(', ')}`
+ ).toBe(0)
+ expect(
+ hrefsInSidebarButNotProducts.length,
+ `Found unexpected hrefs in sidebar: ${hrefsInSidebarButNotProducts.join(', ')}`
+ ).toBe(0)
+ expect(
+ hrefsInProductsButNotSidebar.length,
+ `Found hrefs missing from sidebar: ${hrefsInProductsButNotSidebar.join(', ')}`
+ ).toBe(0)
})
test('renders the Enterprise homepage with links to exptected products in both the sidebar and page body', async () => {
const $ = await getDOM(`/en/enterprise-server@${enterpriseServerReleases.latest}`)
const sidebarItems = $('.sidebar-products li a').get()
- const sidebarTitles = sidebarItems.map(el => $(el).text().trim())
- const sidebarHrefs = sidebarItems.map(el => $(el).attr('href'))
-
- const ghesProducts = activeProducts
- .filter(prod => prod.versions && prod.versions.includes(`enterprise-server@${enterpriseServerReleases.latest}`) || prod.external)
-
- const ghesProductTitles = ghesProducts.map(prod => prod.name)
- const ghesProductHrefs = ghesProducts.map(prod => prod.external ? prod.href : `/en${prod.href.includes('enterprise-server') ? prod.href : `/enterprise-server@${enterpriseServerReleases.latest}${prod.href}`}`)
+ const sidebarTitles = sidebarItems.map((el) => $(el).text().trim())
+ const sidebarHrefs = sidebarItems.map((el) => $(el).attr('href'))
+
+ const ghesProducts = activeProducts.filter(
+ (prod) =>
+ (prod.versions &&
+ prod.versions.includes(`enterprise-server@${enterpriseServerReleases.latest}`)) ||
+ prod.external
+ )
+
+ const ghesProductTitles = ghesProducts.map((prod) => prod.name)
+ const ghesProductHrefs = ghesProducts.map((prod) =>
+ prod.external
+ ? prod.href
+ : `/en${
+ prod.href.includes('enterprise-server')
+ ? prod.href
+ : `/enterprise-server@${enterpriseServerReleases.latest}${prod.href}`
+ }`
+ )
const firstSidebarTitle = sidebarTitles.shift()
const firstSidebarHref = sidebarHrefs.shift()
@@ -80,13 +108,24 @@ describe('server', () => {
expect(firstSidebarTitle).toBe('All products')
expect(firstSidebarHref).toBe('/en')
- expect(titlesInSidebarButNotProducts.length, `Found unexpected titles in sidebar: ${titlesInSidebarButNotProducts.join(', ')}`).toBe(0)
- expect(titlesInProductsButNotSidebar.length, `Found titles missing from sidebar: ${titlesInProductsButNotSidebar.join(', ')}`).toBe(0)
- expect(hrefsInSidebarButNotProducts.length, `Found unexpected hrefs in sidebar: ${hrefsInSidebarButNotProducts.join(', ')}`).toBe(0)
- expect(hrefsInProductsButNotSidebar.length, `Found hrefs missing from sidebar: ${hrefsInProductsButNotSidebar.join(', ')}`).toBe(0)
+ expect(
+ titlesInSidebarButNotProducts.length,
+ `Found unexpected titles in sidebar: ${titlesInSidebarButNotProducts.join(', ')}`
+ ).toBe(0)
+ expect(
+ titlesInProductsButNotSidebar.length,
+ `Found titles missing from sidebar: ${titlesInProductsButNotSidebar.join(', ')}`
+ ).toBe(0)
+ expect(
+ hrefsInSidebarButNotProducts.length,
+ `Found unexpected hrefs in sidebar: ${hrefsInSidebarButNotProducts.join(', ')}`
+ ).toBe(0)
+ expect(
+ hrefsInProductsButNotSidebar.length,
+ `Found hrefs missing from sidebar: ${hrefsInProductsButNotSidebar.join(', ')}`
+ ).toBe(0)
})
-
test('uses gzip compression', async () => {
const res = await get('/en')
expect(res.headers['content-encoding']).toBe('gzip')
@@ -163,15 +202,15 @@ describe('server', () => {
const $ = await getDOM('/_500')
expect($('h1').text()).toBe('Ooops!')
expect($('code').text().startsWith('Error: Intentional error')).toBe(true)
- expect($('code').text().includes(path.join('node_modules', 'express', 'lib', 'router'))).toBe(true)
+ expect($('code').text().includes(path.join('node_modules', 'express', 'lib', 'router'))).toBe(
+ true
+ )
expect($.text().includes('Still need help?')).toBe(true)
expect($.res.statusCode).toBe(500)
})
test('returns a 400 when POST-ed invalid JSON', async () => {
- const res = await post('/')
- .send('not real JSON')
- .set('Content-Type', 'application/json')
+ const res = await post('/').send('not real JSON').set('Content-Type', 'application/json')
expect(res.statusCode).toBe(400)
})
@@ -191,15 +230,21 @@ describe('server', () => {
test('injects site variables into rendered permissions statements frontmatter', async () => {
// markdown source: {% data variables.product.prodname_pages %} site
- const $ = await getDOM('/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site')
+ const $ = await getDOM(
+ '/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site'
+ )
expect($('div.permissions-statement').text()).toContain('GitHub Pages site')
})
// see issue 9678
test('does not use cached intros in map topics', async () => {
- let $ = await getDOM('/en/github/importing-your-projects-to-github/importing-a-git-repository-using-the-command-line')
+ let $ = await getDOM(
+ '/en/github/importing-your-projects-to-github/importing-a-git-repository-using-the-command-line'
+ )
const articleIntro = $('.lead-mktg').text()
- $ = await getDOM('/en/enterprise/2.16/user/importing-your-projects-to-github/importing-source-code-to-github')
+ $ = await getDOM(
+ '/en/enterprise/2.16/user/importing-your-projects-to-github/importing-source-code-to-github'
+ )
const mapTopicIntro = $('.map-topic').first().next().text()
expect(articleIntro).not.toEqual(mapTopicIntro)
})
@@ -220,7 +265,7 @@ describe('server', () => {
const categories = JSON.parse(res.text)
expect(Array.isArray(categories)).toBe(true)
expect(categories.length).toBeGreaterThan(1)
- categories.forEach(category => {
+ categories.forEach((category) => {
expect('name' in category).toBe(true)
expect('published_articles' in category).toBe(true)
})
@@ -229,19 +274,25 @@ describe('server', () => {
test('renders Markdown links that have Liquid hrefs', async () => {
// example from markdown source:
// 1. Go to {{ site.data.variables.product.product_name }}'s [Pricing]({{ site.data.variables.dotcom_billing.plans_url }}) page.
- const $ = await getDOM('/en/github/getting-started-with-github/signing-up-for-a-new-github-account')
+ const $ = await getDOM(
+ '/en/github/getting-started-with-github/signing-up-for-a-new-github-account'
+ )
expect($.text()).toContain("Go to GitHub's Pricing page.")
expect($('a[href="https://github.com/pricing"]').first().text()).toBe('Pricing')
})
test('renders liquid within liquid within liquid in body text', async () => {
const $ = await getDOM('/en/github/administering-a-repository/enabling-required-status-checks')
- expect($('ol li').first().text().trim()).toBe('On GitHub, navigate to the main page of the repository.')
+ expect($('ol li').first().text().trim()).toBe(
+ 'On GitHub, navigate to the main page of the repository.'
+ )
})
test('renders liquid within liquid within liquid in intros', async () => {
const $ = await getDOM('/en/github/administering-a-repository/about-merge-methods-on-github')
- expect($('div.lead-mktg').first().text().includes('merge their pull requests on GitHub')).toBe(true)
+ expect($('div.lead-mktg').first().text().includes('merge their pull requests on GitHub')).toBe(
+ true
+ )
})
test('renders product frontmatter callouts', async () => {
@@ -254,7 +305,13 @@ describe('server', () => {
test('renders liquid within liquid within product frontmatter callouts', async () => {
const $ = await getDOM('/en/articles/about-branch-restrictions')
const note = $('.product-callout').eq(0)
- expect(note.first().text().trim().startsWith('Protected branches are available in public repositories with GitHub Free')).toBe(true)
+ expect(
+ note
+ .first()
+ .text()
+ .trim()
+ .startsWith('Protected branches are available in public repositories with GitHub Free')
+ ).toBe(true)
})
test('handles whitespace control in liquid tags', async () => {
@@ -267,11 +324,15 @@ describe('server', () => {
test('renders liquid within liquid within liquid', async () => {
const $ = await getDOM('/en/articles/enabling-required-status-checks')
- expect($('ol li').first().text().trim()).toBe('On GitHub, navigate to the main page of the repository.')
+ expect($('ol li').first().text().trim()).toBe(
+ 'On GitHub, navigate to the main page of the repository.'
+ )
})
test('preserves liquid statements with liquid raw tags in page output', async () => {
- const $ = await getDOM('/en/pages/setting-up-a-github-pages-site-with-jekyll/troubleshooting-jekyll-build-errors-for-github-pages-sites')
+ const $ = await getDOM(
+ '/en/pages/setting-up-a-github-pages-site-with-jekyll/troubleshooting-jekyll-build-errors-for-github-pages-sites'
+ )
expect($.text().includes('{{ page.title }}')).toBe(true)
})
@@ -289,14 +350,18 @@ describe('server', () => {
})
test('renders mini TOC in articles that includes h4s when specified by frontmatter', async () => {
- const $ = await getDOM('/en/github/setting-up-and-managing-your-enterprise/enforcing-security-settings-in-your-enterprise-account')
+ const $ = await getDOM(
+ '/en/github/setting-up-and-managing-your-enterprise/enforcing-security-settings-in-your-enterprise-account'
+ )
expect($('h2#in-this-article').length).toBe(1)
expect($('h2#in-this-article + ul li.ml-0').length).toBeGreaterThan(0) // non-indented items
expect($('h2#in-this-article + ul li.ml-3').length).toBeGreaterThan(0) // indented items
})
test('does not render mini TOC in articles with only one heading', async () => {
- const $ = await getDOM('/en/github/visualizing-repository-data-with-graphs/about-repository-graphs')
+ const $ = await getDOM(
+ '/en/github/visualizing-repository-data-with-graphs/about-repository-graphs'
+ )
expect($('h2#in-this-article').length).toBe(0)
})
@@ -311,12 +376,16 @@ describe('server', () => {
})
test('renders mini TOC with correct links when headings contain markup', async () => {
- const $ = await getDOM('/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates')
+ const $ = await getDOM(
+ '/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates'
+ )
expect($('h2#in-this-article + ul li a[href="#package-ecosystem"]').length).toBe(1)
})
test('renders mini TOC with correct links when headings contain markup in localized content', async () => {
- const $ = await getDOM('/ja/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates')
+ const $ = await getDOM(
+ '/ja/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates'
+ )
expect($('h2#in-this-article + ul li a[href="#package-ecosystem"]').length).toBe(1)
})
})
@@ -328,37 +397,57 @@ describe('server', () => {
const oldestEnterprisePath = `/en/enterprise/${enterpriseServerReleases.oldestSupported}`
test('github articles on dotcom have images that point to local assets dir', async () => {
- const $ = await getDOM('/en/github/authenticating-to-github/configuring-two-factor-authentication')
+ const $ = await getDOM(
+ '/en/github/authenticating-to-github/configuring-two-factor-authentication'
+ )
expect($('img').first().attr('src').startsWith(localImageBasePath)).toBe(true)
})
test('github articles on GHE have images that point to local assets dir', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/user/github/authenticating-to-github/configuring-two-factor-authentication`)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/user/github/authenticating-to-github/configuring-two-factor-authentication`
+ )
const imageSrc = $('img').first().attr('src')
- expect(imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)).toBe(true)
+ expect(
+ imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)
+ ).toBe(true)
})
test('admin articles on latest version of GHE have images that point to local assets dir', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/admin/user-management/using-built-in-authentication`)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/admin/user-management/using-built-in-authentication`
+ )
const imageSrc = $('img').first().attr('src')
- expect(imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)).toBe(true)
+ expect(
+ imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)
+ ).toBe(true)
})
test('admin articles on older GHE versions have images that point to local assets dir', async () => {
- const $ = await getDOM(`${oldestEnterprisePath}/admin/user-management/using-built-in-authentication`)
+ const $ = await getDOM(
+ `${oldestEnterprisePath}/admin/user-management/using-built-in-authentication`
+ )
const imageSrc = $('img').first().attr('src')
- expect(imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)).toBe(true)
+ expect(
+ imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)
+ ).toBe(true)
})
test('links that point to /assets are not rewritten with a language code', async () => {
const $ = await getDOM('/en/github/site-policy/github-privacy-statement')
- expect($('#french').next().children('a').attr('href').startsWith(localImageBasePath)).toBe(true)
+ expect($('#french').next().children('a').attr('href').startsWith(localImageBasePath)).toBe(
+ true
+ )
})
test('github articles on GHAE have images that point to local assets dir', async () => {
- const $ = await getDOM('/en/github-ae@latest/github/administering-a-repository/changing-the-default-branch')
+ const $ = await getDOM(
+ '/en/github-ae@latest/github/administering-a-repository/changing-the-default-branch'
+ )
const imageSrc = $('img').first().attr('src')
- expect(imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)).toBe(true)
+ expect(
+ imageSrc.startsWith(localImageBasePath) || imageSrc.startsWith(legacyImageBasePath)
+ ).toBe(true)
})
test('admin articles on GHAE have images that point to local assets dir', async () => {
@@ -377,54 +466,95 @@ describe('server', () => {
test('dotcom articles on dotcom have Enterprise Admin links with latest GHE version', async () => {
const $ = await getDOM('/en/articles/setting-up-a-trial-of-github-enterprise-server')
- expect($(`a[href="${latestEnterprisePath}/admin/installation/setting-up-a-github-enterprise-server-instance"]`).length).toBe(2)
+ expect(
+ $(
+ `a[href="${latestEnterprisePath}/admin/installation/setting-up-a-github-enterprise-server-instance"]`
+ ).length
+ ).toBe(2)
})
test('dotcom articles on GHE have Enterprise user links', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/github/getting-started-with-github/set-up-git`)
- expect($(`a[href="${latestEnterprisePath}/articles/managing-files-on-github"]`).length).toBe(1)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/github/getting-started-with-github/set-up-git`
+ )
+ expect($(`a[href="${latestEnterprisePath}/articles/managing-files-on-github"]`).length).toBe(
+ 1
+ )
})
test('dotcom categories on GHE have Enterprise user links', async () => {
const $ = await getDOM(`${latestEnterprisePath}/github/managing-large-files`)
- expect($(`article a[href="${latestEnterprisePath}/github/managing-large-files/working-with-large-files/conditions-for-large-files"]`).length).toBe(1)
+ expect(
+ $(
+ `article a[href="${latestEnterprisePath}/github/managing-large-files/working-with-large-files/conditions-for-large-files"]`
+ ).length
+ ).toBe(1)
})
test('dotcom-only links on GHE are dotcom-only', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/github/setting-up-and-managing-your-github-profile/sending-your-github-enterprise-server-contributions-to-your-githubcom-profile`)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/github/setting-up-and-managing-your-github-profile/sending-your-github-enterprise-server-contributions-to-your-githubcom-profile`
+ )
expect($('article a[href="/en/articles/github-privacy-statement"]').length).toBe(1)
})
test('desktop links on GHE are dotcom-only', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/github/getting-started-with-github/set-up-git`)
- expect($('article a[href="/en/desktop/installing-and-configuring-github-desktop"]').length).toBe(1)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/github/getting-started-with-github/set-up-git`
+ )
+ expect(
+ $('article a[href="/en/desktop/installing-and-configuring-github-desktop"]').length
+ ).toBe(1)
})
test('admin articles that link to non-admin articles have Enterprise user links', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/admin/installation/configuring-the-default-visibility-of-new-repositories-on-your-appliance`)
- expect($(`article a[href="${latestEnterprisePath}/github/creating-cloning-and-archiving-repositories/about-repository-visibility"]`).length).toBeGreaterThan(0)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/admin/installation/configuring-the-default-visibility-of-new-repositories-on-your-appliance`
+ )
+ expect(
+ $(
+ `article a[href="${latestEnterprisePath}/github/creating-cloning-and-archiving-repositories/about-repository-visibility"]`
+ ).length
+ ).toBeGreaterThan(0)
})
test('admin articles that link to Enterprise user articles have Enterprise user links', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/admin/user-management/customizing-user-messages-for-your-enterprise`)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/admin/user-management/customizing-user-messages-for-your-enterprise`
+ )
expect($('article a[href*="about-writing-and-formatting-on-github"]').length).toBe(1)
})
test('articles that link to external links that contain /articles/ are not rewritten', async () => {
- const $ = await getDOM(`${latestEnterprisePath}/admin/installation/upgrading-github-enterprise-server`)
- expect($('article a[href="https://docs.microsoft.com/azure/backup/backup-azure-vms-first-look-arm"]').length).toBe(1)
+ const $ = await getDOM(
+ `${latestEnterprisePath}/admin/installation/upgrading-github-enterprise-server`
+ )
+ expect(
+ $(
+ 'article a[href="https://docs.microsoft.com/azure/backup/backup-azure-vms-first-look-arm"]'
+ ).length
+ ).toBe(1)
})
})
describe('article versions', () => {
test('includes links to all versions of each article', async () => {
- const articlePath = 'github/setting-up-and-managing-your-github-user-account/managing-user-account-settings/about-your-personal-dashboard'
- const $ = await getDOM(`/en/enterprise-server@${enterpriseServerReleases.latest}/${articlePath}`)
- expect($(`.article-versions a.active[href="/en/enterprise-server@${enterpriseServerReleases.latest}/${articlePath}"]`).length).toBe(2)
+ const articlePath =
+ 'github/setting-up-and-managing-your-github-user-account/managing-user-account-settings/about-your-personal-dashboard'
+ const $ = await getDOM(
+ `/en/enterprise-server@${enterpriseServerReleases.latest}/${articlePath}`
+ )
+ expect(
+ $(
+ `.article-versions a.active[href="/en/enterprise-server@${enterpriseServerReleases.latest}/${articlePath}"]`
+ ).length
+ ).toBe(2)
expect($(`.article-versions a.active[href="/en/${articlePath}"]`).length).toBe(0)
// 2.13 predates this feature, so it should be excluded:
- expect($(`.article-versions a[href="/en/enterprise/2.13/user/${articlePath}"]`).length).toBe(0)
+ expect($(`.article-versions a[href="/en/enterprise/2.13/user/${articlePath}"]`).length).toBe(
+ 0
+ )
})
test('is not displayed if article has only one version', async () => {
@@ -438,10 +568,12 @@ describe('server', () => {
beforeAll(async () => {
const $ = await getDOM('/early-access')
- hiddenPageHrefs = $('#article-contents ul > li > a').map((i, el) => $(el).attr('href')).get()
+ hiddenPageHrefs = $('#article-contents ul > li > a')
+ .map((i, el) => $(el).attr('href'))
+ .get()
const allPages = await loadPages()
- hiddenPages = allPages.filter(page => page.languageCode === 'en' && page.hidden)
+ hiddenPages = allPages.filter((page) => page.languageCode === 'en' && page.hidden)
})
test('exist in the set of English pages', async () => {
@@ -479,7 +611,9 @@ describe('server', () => {
test('redirects old articles to their slugified URL', async () => {
const res = await get('/articles/about-github-s-ip-addresses')
- expect(res.text).toBe('Moved Permanently. Redirecting to /en/github/authenticating-to-github/keeping-your-account-and-data-secure/about-githubs-ip-addresses')
+ expect(res.text).toBe(
+ 'Moved Permanently. Redirecting to /en/github/authenticating-to-github/keeping-your-account-and-data-secure/about-githubs-ip-addresses'
+ )
})
test('redirects / to /en', async () => {
@@ -501,9 +635,13 @@ describe('server', () => {
})
test('redirects /insights/foo paths to /enterprise/user/insights/foo', async () => {
- const res = await get('/en/insights/installing-and-configuring-github-insights/about-github-insights')
+ const res = await get(
+ '/en/insights/installing-and-configuring-github-insights/about-github-insights'
+ )
expect(res.statusCode).toBe(301)
- expect(res.headers.location).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/installing-and-updating-github-insights/about-github-insights`)
+ expect(res.headers.location).toBe(
+ `/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/installing-and-updating-github-insights/about-github-insights`
+ )
})
// this oneoff redirect is temporarily disabled because it introduces too much complexity
@@ -511,7 +649,9 @@ describe('server', () => {
test.skip('redirects versioned category page', async () => {
const res = await get('/en/github/receiving-notifications-about-activity-on-github')
expect(res.statusCode).toBe(301)
- expect(res.headers.location).toBe('/en/github/managing-subscriptions-and-notifications-on-github')
+ expect(res.headers.location).toBe(
+ '/en/github/managing-subscriptions-and-notifications-on-github'
+ )
})
})
@@ -524,7 +664,11 @@ describe('server', () => {
test('adds links to map topics on a category homepage', async () => {
const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account')
- expect($('article a[href="/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings"]').length).toBe(1)
+ expect(
+ $(
+ 'article a[href="/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings"]'
+ ).length
+ ).toBe(1)
expect($('article a[href="#managing-user-account-settings"]').length).toBe(0)
})
@@ -534,12 +678,20 @@ describe('server', () => {
})
test('map topic renders with h2 links to articles', async () => {
- const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings')
- expect($('a[href="/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings/changing-your-github-username"] h2').length).toBe(1)
+ const $ = await getDOM(
+ '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
+ )
+ expect(
+ $(
+ 'a[href="/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings/changing-your-github-username"] h2'
+ ).length
+ ).toBe(1)
})
test('map topic renders with one intro for every h2', async () => {
- const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings')
+ const $ = await getDOM(
+ '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
+ )
const $h2s = $('article a.link-with-intro')
expect($h2s.length).toBeGreaterThan(3)
$h2s.each((i, el) => {
@@ -548,8 +700,12 @@ describe('server', () => {
})
test('map topic intros are parsed', async () => {
- const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings')
- const $intro = $('a.link-with-intro[href*="what-does-the-available-for-hire-checkbox-do"] + p')
+ const $ = await getDOM(
+ '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
+ )
+ const $intro = $(
+ 'a.link-with-intro[href*="what-does-the-available-for-hire-checkbox-do"] + p'
+ )
expect($intro.length).toBe(1)
expect($intro.html()).toContain('Use the Available for hire')
})
@@ -559,7 +715,9 @@ describe('server', () => {
describe('URLs by language', () => {
// TODO re-enable this test once TOCs are auto-generated (after PR 11731 has landed)
test('heading IDs and links on translated pages are in English', async () => {
- const $ = await getDOM('/ja/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-strong-password')
+ const $ = await getDOM(
+ '/ja/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-strong-password'
+ )
expect($.res.statusCode).toBe(200)
expect($('h3[id="further-reading"]').length).toBe(1)
expect($('h3[id="ๅ่ใชใณใฏ"]').length).toBe(0)
@@ -570,13 +728,25 @@ describe('URLs by language', () => {
describe('GitHub Enterprise URLs', () => {
test('renders the GHE user docs homepage', async () => {
const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/github`)
- expect($(`article a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/github/authenticating-to-github"]`).length).toBe(1)
+ expect(
+ $(
+ `article a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/github/authenticating-to-github"]`
+ ).length
+ ).toBe(1)
})
test('renders the Enterprise Server homepage with correct links', async () => {
const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}`)
- expect($(`section.container-xl a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/admin"]`).length).toBe(1)
- expect($(`section.container-xl a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/github"]`).length).toBe(1)
+ expect(
+ $(
+ `section.container-xl a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/admin"]`
+ ).length
+ ).toBe(1)
+ expect(
+ $(
+ `section.container-xl a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/github"]`
+ ).length
+ ).toBe(1)
})
test('renders the Enterprise Admin category homepage', async () => {
@@ -599,17 +769,27 @@ describe('GitHub Enterprise URLs', () => {
})
test('renders an Enterprise Admin category article', async () => {
- const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/admin/installation/system-overview`)
- expect($.text()).toContain('your organization\'s private copy of GitHub')
+ const $ = await getDOM(
+ `/en/enterprise/${enterpriseServerReleases.latest}/admin/installation/system-overview`
+ )
+ expect($.text()).toContain("your organization's private copy of GitHub")
})
test('renders an Enterprise Admin map topic', async () => {
- const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/admin/enterprise-management/updating-the-virtual-machine-and-physical-resources`)
- expect($(`article a[href^="/en/enterprise-server@${enterpriseServerReleases.latest}/admin/enterprise-management/"]`).length).toBeGreaterThan(1)
+ const $ = await getDOM(
+ `/en/enterprise/${enterpriseServerReleases.latest}/admin/enterprise-management/updating-the-virtual-machine-and-physical-resources`
+ )
+ expect(
+ $(
+ `article a[href^="/en/enterprise-server@${enterpriseServerReleases.latest}/admin/enterprise-management/"]`
+ ).length
+ ).toBeGreaterThan(1)
})
test('renders an Enterprise Admin category article within a map topic', async () => {
- const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/admin/installation/upgrade-requirements`)
+ const $ = await getDOM(
+ `/en/enterprise/${enterpriseServerReleases.latest}/admin/installation/upgrade-requirements`
+ )
expect($.text()).toContain('Before upgrading GitHub Enterprise')
})
@@ -652,16 +832,24 @@ describe('GitHub Desktop URLs', () => {
test('renders a Desktop category with expected links', async () => {
const $ = await getDOM('/en/desktop/installing-and-configuring-github-desktop')
- expect($('article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]').length).toBeGreaterThan(1)
+ expect(
+ $('article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]').length
+ ).toBeGreaterThan(1)
})
test('renders a Desktop map topic', async () => {
- const $ = await getDOM('/en/desktop/installing-and-configuring-github-desktop/installing-and-authenticating-to-github-desktop')
- expect($('article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]').length).toBeGreaterThan(1)
+ const $ = await getDOM(
+ '/en/desktop/installing-and-configuring-github-desktop/installing-and-authenticating-to-github-desktop'
+ )
+ expect(
+ $('article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]').length
+ ).toBeGreaterThan(1)
})
test('renders a Desktop article within a map topic', async () => {
- const res = await get('/en/desktop/installing-and-configuring-github-desktop/installing-and-authenticating-to-github-desktop/installing-github-desktop')
+ const res = await get(
+ '/en/desktop/installing-and-configuring-github-desktop/installing-and-authenticating-to-github-desktop/installing-github-desktop'
+ )
expect(res.statusCode).toBe(200)
})
@@ -718,7 +906,7 @@ describe('extended Markdown', () => {
})
describe('search', () => {
- function findDupesInArray (arr) {
+ function findDupesInArray(arr) {
return lodash.filter(arr, (val, i, iteratee) => lodash.includes(iteratee, val, i + 1))
}
@@ -806,8 +994,17 @@ describe('static routes', () => {
it('serves schema files from the /data/graphql directory at /public', async () => {
expect((await get('/public/schema.docs.graphql')).statusCode).toBe(200)
- expect((await get(`/public/ghes-${enterpriseServerReleases.latest}/schema.docs-enterprise.graphql`)).statusCode).toBe(200)
- expect((await get(`/public/ghes-${enterpriseServerReleases.oldestSupported}/schema.docs-enterprise.graphql`)).statusCode).toBe(200)
+ expect(
+ (await get(`/public/ghes-${enterpriseServerReleases.latest}/schema.docs-enterprise.graphql`))
+ .statusCode
+ ).toBe(200)
+ expect(
+ (
+ await get(
+ `/public/ghes-${enterpriseServerReleases.oldestSupported}/schema.docs-enterprise.graphql`
+ )
+ ).statusCode
+ ).toBe(200)
expect((await get('/public/ghae/schema.docs-ghae.graphql')).statusCode).toBe(200)
})
@@ -819,7 +1016,8 @@ describe('static routes', () => {
})
describe('index pages', () => {
- const nonEnterpriseOnlyPath = '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
+ const nonEnterpriseOnlyPath =
+ '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
test('includes dotcom-only links in dotcom TOC', async () => {
const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account')
@@ -827,7 +1025,9 @@ describe('index pages', () => {
})
test('excludes dotcom-only from GHE TOC', async () => {
- const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/github/setting-up-and-managing-your-github-user-account`)
+ const $ = await getDOM(
+ `/en/enterprise/${enterpriseServerReleases.latest}/user/github/setting-up-and-managing-your-github-user-account`
+ )
expect($(`a[href="${nonEnterpriseOnlyPath}"]`).length).toBe(0)
})
diff --git a/tests/rendering/sidebar.js b/tests/rendering/sidebar.js
index dc17449e0f21..7142fe282fd2 100644
--- a/tests/rendering/sidebar.js
+++ b/tests/rendering/sidebar.js
@@ -7,16 +7,18 @@ describe('sidebar', () => {
let $homePage, $githubPage, $enterprisePage
beforeAll(async () => {
- [$homePage, $githubPage, $enterprisePage] = await Promise.all([
+ ;[$homePage, $githubPage, $enterprisePage] = await Promise.all([
getDOM('/en'),
getDOM('/en/github'),
- getDOM('/en/enterprise/admin')
+ getDOM('/en/enterprise/admin'),
])
})
test('highlights active product on Enterprise pages', async () => {
expect($enterprisePage('.sidebar-products li.sidebar-product').length).toBe(1)
- expect($enterprisePage('.sidebar-products li.sidebar-product > a').text().trim()).toBe('Enterprise administrators')
+ expect($enterprisePage('.sidebar-products li.sidebar-product > a').text().trim()).toBe(
+ 'Enterprise administrators'
+ )
})
test('highlights active product on GitHub pages', async () => {
@@ -32,7 +34,8 @@ describe('sidebar', () => {
})
test('adds an `is-current-page` class to the sidebar link to the current page', async () => {
- const url = '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
+ const url =
+ '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
const $ = await getDOM(url)
expect($('.sidebar-products .is-current-page').length).toBe(1)
expect($('.sidebar-products .is-current-page a').attr('href')).toContain(url)
diff --git a/tests/routing/deprecated-enterprise-versions.js b/tests/routing/deprecated-enterprise-versions.js
index 69525fa6c782..32700139e582 100644
--- a/tests/routing/deprecated-enterprise-versions.js
+++ b/tests/routing/deprecated-enterprise-versions.js
@@ -28,15 +28,21 @@ describe('enterprise deprecation', () => {
})
test('workaround for lost frontmatter redirects works in deprecated enterprise content >=2.13', async () => {
- const res = await get('/en/enterprise/2.15/user/articles/viewing-contributions-on-your-profile-page')
+ const res = await get(
+ '/en/enterprise/2.15/user/articles/viewing-contributions-on-your-profile-page'
+ )
expect(res.statusCode).toBe(301)
- expect(res.headers.location).toBe('/en/enterprise/2.15/user/articles/viewing-contributions-on-your-profile')
+ expect(res.headers.location).toBe(
+ '/en/enterprise/2.15/user/articles/viewing-contributions-on-your-profile'
+ )
})
test('can access redirects from redirects.json in deprecated enterprise content >2.17', async () => {
const res = await get('/enterprise/2.19/admin/categories/time')
expect(res.statusCode).toBe(301)
- expect(res.headers.location).toBe('/en/enterprise-server@2.19/admin/configuration/configuring-time-synchronization')
+ expect(res.headers.location).toBe(
+ '/en/enterprise-server@2.19/admin/configuration/configuring-time-synchronization'
+ )
})
test('handles requests for deprecated Enterprise pages ( >=2.13 )', async () => {
diff --git a/tests/routing/developer-site-redirects.js b/tests/routing/developer-site-redirects.js
index e95567a51bf1..3424e046b1ab 100644
--- a/tests/routing/developer-site-redirects.js
+++ b/tests/routing/developer-site-redirects.js
@@ -31,7 +31,7 @@ describe('developer redirects', () => {
test('graphql enterprise homepage', async () => {
const res = await get('/enterprise/v4', { followAllRedirects: true })
expect(res.statusCode).toBe(200)
- const finalPath = (new URL(res.request.url)).pathname
+ const finalPath = new URL(res.request.url).pathname
const expectedFinalPath = `/en/enterprise-server@${enterpriseServerReleases.latest}/graphql`
expect(finalPath).toBe(expectedFinalPath)
})
@@ -45,8 +45,12 @@ describe('developer redirects', () => {
const enterpriseRes = await get(`/enterprise${oldPath}`, { followAllRedirects: true })
expect(enterpriseRes.statusCode).toBe(200)
- const finalPath = (new URL(enterpriseRes.request.url)).pathname
- const expectedFinalPath = path.join('/', `enterprise-server@${enterpriseServerReleases.latest}`, newPath)
+ const finalPath = new URL(enterpriseRes.request.url).pathname
+ const expectedFinalPath = path.join(
+ '/',
+ `enterprise-server@${enterpriseServerReleases.latest}`,
+ newPath
+ )
expect(finalPath).toBe(`/en${expectedFinalPath}`)
})
@@ -113,18 +117,17 @@ describe('developer redirects', () => {
// this fixtures file includes /v3 and /enterprise/v3 paths
test('rest reference redirects', async () => {
- await eachOfLimit(
- restRedirectFixtures,
- MAX_CONCURRENT_REQUESTS,
- async (newPath, oldPath) => {
- // REST and GraphQL developer Enterprise paths with a version are only supported up to 2.21.
- // We make an exception to always redirect versionless paths to the latest version.
- newPath = newPath.replace('/enterprise-server/', `/enterprise-server@${enterpriseServerReleases.latest}/`)
- const res = await get(oldPath)
- expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
- expect(res.headers.location, `${oldPath} did not redirect to ${newPath}`).toBe(newPath)
- }
- )
+ await eachOfLimit(restRedirectFixtures, MAX_CONCURRENT_REQUESTS, async (newPath, oldPath) => {
+ // REST and GraphQL developer Enterprise paths with a version are only supported up to 2.21.
+ // We make an exception to always redirect versionless paths to the latest version.
+ newPath = newPath.replace(
+ '/enterprise-server/',
+ `/enterprise-server@${enterpriseServerReleases.latest}/`
+ )
+ const res = await get(oldPath)
+ expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
+ expect(res.headers.location, `${oldPath} did not redirect to ${newPath}`).toBe(newPath)
+ })
})
// this fixtures file includes /v4 and /enterprise/v4 paths
@@ -135,7 +138,10 @@ describe('developer redirects', () => {
async (newPath, oldPath) => {
// REST and GraphQL developer Enterprise paths with a version are only supported up to 2.21.
// We make an exception to always redirect versionless paths to the latest version.
- newPath = newPath.replace('/enterprise-server/', `/enterprise-server@${enterpriseServerReleases.latest}/`)
+ newPath = newPath.replace(
+ '/enterprise-server/',
+ `/enterprise-server@${enterpriseServerReleases.latest}/`
+ )
const res = await get(oldPath)
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
expect(res.headers.location, `${oldPath} did not redirect to ${newPath}`).toBe(newPath)
diff --git a/tests/routing/middleware/redirects/help-to-docs.js b/tests/routing/middleware/redirects/help-to-docs.js
index 2f827660f630..362c790d4bd1 100644
--- a/tests/routing/middleware/redirects/help-to-docs.js
+++ b/tests/routing/middleware/redirects/help-to-docs.js
@@ -7,49 +7,61 @@ describe('help.github.com redirect middleware', () => {
const req = {
hostname: 'help.github.com',
protocol: 'https',
- originalUrl: '/'
+ originalUrl: '/',
}
const res = new MockExpressResponse()
- const next = () => { /* no op */ }
+ const next = () => {
+ /* no op */
+ }
await middleware(req, res, next)
- expect(res._getString()).toEqual('Moved Permanently. Redirecting to https://docs.github.com/
')
+ expect(res._getString()).toEqual(
+ 'Moved Permanently. Redirecting to https://docs.github.com/
'
+ )
})
it('redirects help.github.com requests to deep pages', async () => {
const req = {
hostname: 'help.github.com',
protocol: 'https',
- originalUrl: '/en/actions/configuring-and-managing-workflows/using-environment-variables'
+ originalUrl: '/en/actions/configuring-and-managing-workflows/using-environment-variables',
}
const res = new MockExpressResponse()
- const next = () => { /* no op */ }
+ const next = () => {
+ /* no op */
+ }
await middleware(req, res, next)
- expect(res._getString()).toEqual('Moved Permanently. Redirecting to https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
')
+ expect(res._getString()).toEqual(
+ 'Moved Permanently. Redirecting to https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
'
+ )
})
it('preserves query params', async () => {
const req = {
hostname: 'help.github.com',
protocol: 'https',
- originalUrl: '/en?foo=bar'
+ originalUrl: '/en?foo=bar',
}
const res = new MockExpressResponse()
- const next = () => { /* no op */ }
+ const next = () => {
+ /* no op */
+ }
await middleware(req, res, next)
- expect(res._getString()).toEqual('Moved Permanently. Redirecting to https://docs.github.com/en?foo=bar
')
+ expect(res._getString()).toEqual(
+ 'Moved Permanently. Redirecting to https://docs.github.com/en?foo=bar
'
+ )
})
it('does not redirect docs.github.com requests', async () => {
const req = {
hostname: 'docs.github.com',
protocol: 'https',
- originalUrl: '/'
+ originalUrl: '/',
}
const res = new MockExpressResponse()
const next = jest.fn()
@@ -61,12 +73,14 @@ describe('help.github.com redirect middleware', () => {
const req = {
hostname: 'help.github.com',
protocol: 'https',
- originalUrl: '//evil.com//'
+ originalUrl: '//evil.com//',
}
const res = new MockExpressResponse()
const next = jest.fn()
await middleware(req, res, next)
const expectedRedirect = 'https://docs.github.com/evil.com//'
- expect(res._getString()).toEqual(`Moved Permanently. Redirecting to ${expectedRedirect}
`)
+ expect(res._getString()).toEqual(
+ `Moved Permanently. Redirecting to ${expectedRedirect}
`
+ )
})
})
diff --git a/tests/routing/redirects.js b/tests/routing/redirects.js
index 1937f67508a7..5d8b7efa8502 100644
--- a/tests/routing/redirects.js
+++ b/tests/routing/redirects.js
@@ -23,9 +23,10 @@ describe('redirects', () => {
test('page.redirects is an array', async () => {
const page = await Page.init({
- relativePath: 'github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches.md',
+ relativePath:
+ 'github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
page.buildRedirects()
expect(isPlainObject(page.redirects)).toBe(true)
@@ -35,7 +36,7 @@ describe('redirects', () => {
const page = await Page.init({
relativePath: 'github/index.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
page.buildRedirects()
expect(page.redirects[`/en/${nonEnterpriseDefaultVersion}/github`]).toBe('/en/github')
@@ -44,15 +45,21 @@ describe('redirects', () => {
expect(page.redirects[`/en/${nonEnterpriseDefaultVersion}/articles`]).toBe('/en/github')
expect(page.redirects['/common-issues-and-questions']).toBe('/en/github')
expect(page.redirects['/en/common-issues-and-questions']).toBe('/en/github')
- expect(page.redirects[`/en/enterprise/${enterpriseServerReleases.latest}/user/articles`]).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/github`)
- expect(page.redirects[`/en/enterprise/${enterpriseServerReleases.latest}/user/common-issues-and-questions`]).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/github`)
+ expect(page.redirects[`/en/enterprise/${enterpriseServerReleases.latest}/user/articles`]).toBe(
+ `/en/enterprise-server@${enterpriseServerReleases.latest}/github`
+ )
+ expect(
+ page.redirects[
+ `/en/enterprise/${enterpriseServerReleases.latest}/user/common-issues-and-questions`
+ ]
+ ).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/github`)
})
test('converts single `redirect_from` strings values into arrays', async () => {
const page = await Page.init({
relativePath: 'article-with-redirect-from-string.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
page.buildRedirects()
expect(page.redirects['/redirect-string']).toBe('/en/article-with-redirect-from-string')
@@ -96,13 +103,13 @@ describe('redirects', () => {
test('are absent from all redirected URLs', async () => {
const keys = Object.keys(redirects)
expect(keys.length).toBeGreaterThan(100)
- expect(keys.every(key => !key.endsWith('/') || key === '/')).toBe(true)
+ expect(keys.every((key) => !key.endsWith('/') || key === '/')).toBe(true)
})
test('are absent from all destination URLs', async () => {
const values = Object.values(redirects)
expect(values.length).toBeGreaterThan(100)
- expect(values.every(value => !value.endsWith('/'))).toBe(true)
+ expect(values.every((value) => !value.endsWith('/'))).toBe(true)
})
test('are redirected for HEAD requests (not just GET requests)', async () => {
@@ -128,9 +135,12 @@ describe('redirects', () => {
describe('localized redirects', () => {
test('redirect_from for renamed pages', async () => {
- const { res } = await get('/ja/desktop/contributing-to-projects/changing-a-remote-s-url-from-github-desktop')
+ const { res } = await get(
+ '/ja/desktop/contributing-to-projects/changing-a-remote-s-url-from-github-desktop'
+ )
expect(res.statusCode).toBe(301)
- const expected = '/ja/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/changing-a-remotes-url-from-github-desktop'
+ const expected =
+ '/ja/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/changing-a-remotes-url-from-github-desktop'
expect(res.headers.location).toBe(expected)
})
})
@@ -222,7 +232,9 @@ describe('redirects', () => {
test('admin/guides redirects to admin on <2.21', async () => {
const res = await get(`/en/enterprise-server@${lastBeforeRestoredAdminGuides}/admin/guides`)
expect(res.statusCode).toBe(301)
- expect(res.headers.location).toBe(enterpriseAdmin.replace(latest, lastBeforeRestoredAdminGuides))
+ expect(res.headers.location).toBe(
+ enterpriseAdmin.replace(latest, lastBeforeRestoredAdminGuides)
+ )
})
test('admin/guides does not redirect to admin on >=2.21', async () => {
@@ -238,7 +250,9 @@ describe('redirects', () => {
})
test('admin/guides redirects to admin in deep links on <2.21', async () => {
- const res = await get(`/en/enterprise-server@${lastBeforeRestoredAdminGuides}/admin/guides/installation/upgrading-github-enterprise`)
+ const res = await get(
+ `/en/enterprise-server@${lastBeforeRestoredAdminGuides}/admin/guides/installation/upgrading-github-enterprise`
+ )
expect(res.statusCode).toBe(301)
const redirectRes = await get(res.headers.location)
expect(redirectRes.statusCode).toBe(200)
@@ -247,7 +261,9 @@ describe('redirects', () => {
})
test('admin/guides still redirects to admin in deep links on >=2.21', async () => {
- const res = await get(`/en/enterprise-server@${firstRestoredAdminGuides}/admin/guides/installation/upgrading-github-enterprise`)
+ const res = await get(
+ `/en/enterprise-server@${firstRestoredAdminGuides}/admin/guides/installation/upgrading-github-enterprise`
+ )
expect(res.statusCode).toBe(301)
const redirectRes = await get(res.headers.location)
expect(redirectRes.statusCode).toBe(200)
@@ -264,7 +280,9 @@ describe('redirects', () => {
test('admin/guides redirects to admin on <2.21 (japanese)', async () => {
const res = await get(`/ja/enterprise-server@${lastBeforeRestoredAdminGuides}/admin/guides`)
expect(res.statusCode).toBe(301)
- expect(res.headers.location).toBe(japaneseEnterpriseAdmin.replace(latest, lastBeforeRestoredAdminGuides))
+ expect(res.headers.location).toBe(
+ japaneseEnterpriseAdmin.replace(latest, lastBeforeRestoredAdminGuides)
+ )
})
test('admin/guides does not redirect to admin on >=2.21 (japanese)', async () => {
@@ -307,7 +325,9 @@ describe('redirects', () => {
const japaneseUserArticle = userArticle.replace('/en/', '/ja/')
test('no product redirects to GitHub.com product on the latest version', async () => {
- const res = await get(`/en/enterprise/${enterpriseServerReleases.latest}/user/articles/creating-a-strong-password`)
+ const res = await get(
+ `/en/enterprise/${enterpriseServerReleases.latest}/user/articles/creating-a-strong-password`
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(userArticle)
})
@@ -319,7 +339,9 @@ describe('redirects', () => {
})
test('no language code redirects to english', async () => {
- const res = await get(`/enterprise/${enterpriseServerReleases.latest}/user/articles/creating-a-strong-password`)
+ const res = await get(
+ `/enterprise/${enterpriseServerReleases.latest}/user/articles/creating-a-strong-password`
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(userArticle)
})
@@ -343,13 +365,17 @@ describe('redirects', () => {
const japaneseUserArticle = userArticle.replace('/en/', '/ja/')
test('redirects to expected article', async () => {
- const res = await get(`/en/enterprise/${enterpriseServerReleases.latest}/user${redirectFromPath}`)
+ const res = await get(
+ `/en/enterprise/${enterpriseServerReleases.latest}/user${redirectFromPath}`
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(userArticle)
})
test('no language code redirects to english', async () => {
- const res = await get(`/enterprise/${enterpriseServerReleases.latest}/user${redirectFromPath}`)
+ const res = await get(
+ `/enterprise/${enterpriseServerReleases.latest}/user${redirectFromPath}`
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(userArticle)
})
@@ -368,23 +394,30 @@ describe('redirects', () => {
})
describe('desktop guide', () => {
- const desktopGuide = '/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request'
+ const desktopGuide =
+ '/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request'
const japaneseDesktopGuides = desktopGuide.replace('/en/', '/ja/')
test('no language code redirects to english', async () => {
- const res = await get('/desktop/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request')
+ const res = await get(
+ '/desktop/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request'
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(desktopGuide)
})
test('desktop/guides redirects to desktop', async () => {
- const res = await get('/en/desktop/guides/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request')
+ const res = await get(
+ '/en/desktop/guides/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request'
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(desktopGuide)
})
test('desktop/guides redirects to desktop (japanese)', async () => {
- const res = await get('/ja/desktop/guides/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request')
+ const res = await get(
+ '/ja/desktop/guides/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request'
+ )
expect(res.statusCode).toBe(301)
expect(res.headers.location).toBe(japaneseDesktopGuides)
})
diff --git a/tests/routing/release-notes.js b/tests/routing/release-notes.js
index 2e47c0591733..e33067ae9f1b 100644
--- a/tests/routing/release-notes.js
+++ b/tests/routing/release-notes.js
@@ -17,7 +17,7 @@ describe('release notes', () => {
expect(res.headers.location).toBe('https://enterprise.github.com/releases/2.19.0/notes')
})
- it('renders the release-notes layout if this version\'s release notes are in this repo', async () => {
+ it("renders the release-notes layout if this version's release notes are in this repo", async () => {
const res = await get('/en/enterprise-server@2.22/admin/release-notes')
expect(res.statusCode).toBe(200)
const $ = await getDOM('/en/enterprise-server@2.22/admin/release-notes')
diff --git a/tests/routing/top-developer-site-path-redirects.js b/tests/routing/top-developer-site-path-redirects.js
index 3202e050fd77..63de24ad40e8 100644
--- a/tests/routing/top-developer-site-path-redirects.js
+++ b/tests/routing/top-developer-site-path-redirects.js
@@ -17,13 +17,13 @@ describe('developer.github.com redirects', () => {
/^\/partnerships/,
'2.17',
'2.16',
- '2.15'
+ '2.15',
]
// test a subset of the top paths
const pathsToCheck = 50
const paths = topOldDeveloperSitePaths
- .filter(path => !ignoredPatterns.some(pattern => path.match(pattern)))
+ .filter((path) => !ignoredPatterns.some((pattern) => path.match(pattern)))
.slice(0, pathsToCheck)
const non200s = []
@@ -36,10 +36,14 @@ describe('developer.github.com redirects', () => {
}
// generate an object with empty values as the error message
- const errorMessage = JSON.stringify(non200s.reduce((acc, path) => {
- acc[path] = ''
- return acc
- }, {}), null, 2)
+ const errorMessage = JSON.stringify(
+ non200s.reduce((acc, path) => {
+ acc[path] = ''
+ return acc
+ }, {}),
+ null,
+ 2
+ )
expect(non200s, errorMessage).toEqual([])
})
diff --git a/tests/unit/actions-workflows.js b/tests/unit/actions-workflows.js
index 8dc67d284609..c9e79837e7ad 100644
--- a/tests/unit/actions-workflows.js
+++ b/tests/unit/actions-workflows.js
@@ -7,32 +7,28 @@ import { chain, difference, get } from 'lodash-es'
import allowedActions from '../../.github/allowed-actions.js'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const workflowsDir = path.join(__dirname, '../../.github/workflows')
-const workflows = fs.readdirSync(workflowsDir)
- .filter(filename => filename.endsWith('.yml') || filename.endsWith('.yaml'))
- .map(filename => {
+const workflows = fs
+ .readdirSync(workflowsDir)
+ .filter((filename) => filename.endsWith('.yml') || filename.endsWith('.yaml'))
+ .map((filename) => {
const fullpath = path.join(workflowsDir, filename)
const data = yaml.load(fs.readFileSync(fullpath, 'utf8'), { fullpath })
return { filename, fullpath, data }
})
-function actionsUsedInWorkflow (workflow) {
+function actionsUsedInWorkflow(workflow) {
return Object.keys(flat(workflow))
- .filter(key => key.endsWith('.uses'))
- .map(key => get(workflow, key))
+ .filter((key) => key.endsWith('.uses'))
+ .map((key) => get(workflow, key))
}
const scheduledWorkflows = workflows
- .map(workflow => workflow.data.on.schedule)
+ .map((workflow) => workflow.data.on.schedule)
.filter(Boolean)
.flat()
- .map(schedule => schedule.cron)
+ .map((schedule) => schedule.cron)
-const allUsedActions = chain(workflows)
- .map(actionsUsedInWorkflow)
- .flatten()
- .uniq()
- .sort()
- .value()
+const allUsedActions = chain(workflows).map(actionsUsedInWorkflow).flatten().uniq().sort().value()
describe('GitHub Actions workflows', () => {
test('all used actions are allowed in .github/allowed-actions.js', () => {
@@ -48,7 +44,7 @@ describe('GitHub Actions workflows', () => {
})
test('no scheduled workflows run on the hour', () => {
- const hourlySchedules = scheduledWorkflows.filter(schedule => {
+ const hourlySchedules = scheduledWorkflows.filter((schedule) => {
const hour = schedule.split(' ')[0]
// return any minute cron segments that equal 0, 00, 000, etc.
return !/[^0]/.test(hour)
diff --git a/tests/unit/data-directory/index.js b/tests/unit/data-directory/index.js
index 82c84325fd32..fe4a376ec69f 100644
--- a/tests/unit/data-directory/index.js
+++ b/tests/unit/data-directory/index.js
@@ -10,7 +10,7 @@ describe('data-directory', () => {
const expected = {
bar: { another_markup_language: 'yes' },
foo: { meaningOfLife: 42 },
- nested: { baz: 'I am markdown!' }
+ nested: { baz: 'I am markdown!' },
}
expect(data).toEqual(expected)
})
@@ -34,9 +34,9 @@ describe('data-directory', () => {
const ignorePatterns = []
// README is ignored by default
- expect('README' in await dataDirectory(fixturesDir)).toBe(false)
+ expect('README' in (await dataDirectory(fixturesDir))).toBe(false)
// README can be included by setting empty ignorePatterns array
- expect('README' in await dataDirectory(fixturesDir, { ignorePatterns })).toBe(true)
+ expect('README' in (await dataDirectory(fixturesDir, { ignorePatterns }))).toBe(true)
})
})
diff --git a/tests/unit/early-access.js b/tests/unit/early-access.js
index ea2ff77ee556..60c8a22ad90f 100644
--- a/tests/unit/early-access.js
+++ b/tests/unit/early-access.js
@@ -28,12 +28,14 @@ describe('rendering early-access', () => {
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(
+ $.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 () {
+ async function getEarlyAccess() {
return await got('https://docs.github.com/en/early-access')
}
await expect(getEarlyAccess).rejects.toThrowError('Response code 404 (Not Found)')
diff --git a/tests/unit/enterprise-versions.js b/tests/unit/enterprise-versions.js
index 1438aee43d5d..2034c751a24f 100644
--- a/tests/unit/enterprise-versions.js
+++ b/tests/unit/enterprise-versions.js
@@ -1,13 +1,7 @@
import patterns from '../../lib/patterns.js'
import xEnterpriseServerReleases from '../../lib/enterprise-server-releases.js'
-const {
- supported,
- deprecated,
- all,
- latest,
- oldestSupported,
- nextDeprecationDate
-} = xEnterpriseServerReleases
+const { supported, deprecated, all, latest, oldestSupported, nextDeprecationDate } =
+ xEnterpriseServerReleases
describe('enterpriseServerReleases module', () => {
test('includes an array of `supported` versions', async () => {
diff --git a/tests/unit/failbot.js b/tests/unit/failbot.js
index 87e99cd0e5af..e13c33670aaf 100644
--- a/tests/unit/failbot.js
+++ b/tests/unit/failbot.js
@@ -3,9 +3,11 @@ import nock from 'nock'
describe('FailBot', () => {
beforeEach(() => {
- nock('https://haystack.com').post('/').reply(200, (uri, requestBody) => {
- return requestBody
- })
+ nock('https://haystack.com')
+ .post('/')
+ .reply(200, (uri, requestBody) => {
+ return requestBody
+ })
})
afterEach(() => {
@@ -38,7 +40,7 @@ describe('FailBot', () => {
created_at: expect.any(String),
js_environment: expect.stringMatching(/^Node\.js\sv[\d.]+/),
message: 'Kaboom',
- rollup: expect.any(String)
+ rollup: expect.any(String),
})
})
})
diff --git a/tests/unit/feature-flags.js b/tests/unit/feature-flags.js
index da2a1debe6a8..e822589d166a 100644
--- a/tests/unit/feature-flags.js
+++ b/tests/unit/feature-flags.js
@@ -3,7 +3,7 @@ import readJsonFile from '../../lib/read-json-file.js'
const ffs = readJsonFile('./feature-flags.json')
describe('feature flags', () => {
- Object.keys(ffs).forEach(featureName => {
+ Object.keys(ffs).forEach((featureName) => {
expect(featureName.startsWith('FEATURE_')).toBe(true)
})
diff --git a/tests/unit/find-page.js b/tests/unit/find-page.js
index 00e32dd4fd23..9692558849fe 100644
--- a/tests/unit/find-page.js
+++ b/tests/unit/find-page.js
@@ -8,11 +8,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
describe('find page', () => {
jest.setTimeout(1000 * 1000)
- test('falls back to the English page if it can\'t find a localized page', async () => {
+ test("falls back to the English page if it can't find a localized page", async () => {
const page = await Page.init({
relativePath: 'page-that-does-not-exist-in-translations-dir.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
const englishPermalink = page.permalinks[0].href
@@ -20,7 +20,7 @@ describe('find page', () => {
// add named keys
const pageMap = {
- [englishPermalink]: page
+ [englishPermalink]: page,
}
const localizedPage = findPage(japanesePermalink, pageMap, {})
@@ -31,7 +31,7 @@ describe('find page', () => {
const page = await Page.init({
relativePath: 'page-with-redirects.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
const englishPermalink = page.permalinks[0].href
@@ -39,7 +39,7 @@ describe('find page', () => {
// add named keys
const pageMap = {
- [englishPermalink]: page
+ [englishPermalink]: page,
}
const redirectedPage = findPage(redirectToFind, pageMap, page.buildRedirects())
diff --git a/tests/unit/get-rss-feeds.js b/tests/unit/get-rss-feeds.js
index 2825d433b312..80f880fd6422 100644
--- a/tests/unit/get-rss-feeds.js
+++ b/tests/unit/get-rss-feeds.js
@@ -3,7 +3,10 @@ import { getChangelogItems } from '../../lib/changelog.js'
import fs from 'fs'
import path from 'path'
const parser = new Parser({ timeout: 5000 })
-const rssFeedContent = fs.readFileSync(path.join(process.cwd(), 'tests/fixtures/rss-feed.xml'), 'utf8')
+const rssFeedContent = fs.readFileSync(
+ path.join(process.cwd(), 'tests/fixtures/rss-feed.xml'),
+ 'utf8'
+)
describe('getChangelogItems module', () => {
let changelog
@@ -21,18 +24,18 @@ describe('getChangelogItems module', () => {
{
title: 'Authentication token format updates are generally available',
date: '2021-03-31T22:22:03.000Z',
- href: 'https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available'
+ href: 'https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available',
},
{
title: 'Compare REST API now supports pagination',
date: '2021-03-23T02:49:54.000Z',
- href: 'https://github.blog/changelog/2021-03-22-compare-rest-api-now-supports-pagination'
+ href: 'https://github.blog/changelog/2021-03-22-compare-rest-api-now-supports-pagination',
},
{
title: 'GitHub Discussions GraphQL API public beta',
date: '2021-02-23T18:21:40.000Z',
- href: 'https://github.blog/changelog/2021-02-23-github-discussions-graphql-api-public-beta'
- }
+ href: 'https://github.blog/changelog/2021-02-23-github-discussions-graphql-api-public-beta',
+ },
]
for (let i = 0; i < 3; i++) {
diff --git a/tests/unit/hydro.js b/tests/unit/hydro.js
index 1866738a67c8..993c6538a4cc 100644
--- a/tests/unit/hydro.js
+++ b/tests/unit/hydro.js
@@ -11,22 +11,27 @@ describe('hydro', () => {
reqheaders: {
Authorization: /^Hydro [\d\w]{64}$/,
'Content-Type': 'application/json',
- 'X-Hydro-App': 'docs-production'
- }
+ 'X-Hydro-App': 'docs-production',
+ },
})
// Respond with a 200 and store the body we sent
- .post('/').reply(200, (_, body) => { params = body })
+ .post('/')
+ .reply(200, (_, body) => {
+ params = body
+ })
})
describe('#publish', () => {
it('publishes a single event to Hydro', async () => {
await hydro.publish('event-name', { pizza: true })
expect(params).toEqual({
- events: [{
- schema: 'event-name',
- value: JSON.stringify({ pizza: true }),
- cluster: 'potomac'
- }]
+ events: [
+ {
+ schema: 'event-name',
+ value: JSON.stringify({ pizza: true }),
+ cluster: 'potomac',
+ },
+ ],
})
})
})
@@ -35,19 +40,22 @@ describe('hydro', () => {
it('publishes multiple events to Hydro', async () => {
await hydro.publishMany([
{ schema: 'event-name', value: { pizza: true } },
- { schema: 'other-name', value: { salad: false } }
+ { schema: 'other-name', value: { salad: false } },
])
expect(params).toEqual({
- events: [{
- schema: 'event-name',
- value: JSON.stringify({ pizza: true }),
- cluster: 'potomac'
- }, {
- schema: 'other-name',
- value: JSON.stringify({ salad: false }),
- cluster: 'potomac'
- }]
+ events: [
+ {
+ schema: 'event-name',
+ value: JSON.stringify({ pizza: true }),
+ cluster: 'potomac',
+ },
+ {
+ schema: 'other-name',
+ value: JSON.stringify({ salad: false }),
+ cluster: 'potomac',
+ },
+ ],
})
})
})
diff --git a/tests/unit/languages.js b/tests/unit/languages.js
index d4f4c41a4242..e10fb5acedb5 100644
--- a/tests/unit/languages.js
+++ b/tests/unit/languages.js
@@ -10,7 +10,7 @@ describe('languages module', () => {
})
test('every language is valid', () => {
- Object.values(languages).forEach(language => {
+ Object.values(languages).forEach((language) => {
const { valid, errors } = revalidator.validate(language, schema)
const expectation = JSON.stringify(errors, null, 2)
expect(valid, expectation).toBe(true)
diff --git a/tests/unit/liquid-helpers.js b/tests/unit/liquid-helpers.js
index 000e19e52265..c116096bd883 100644
--- a/tests/unit/liquid-helpers.js
+++ b/tests/unit/liquid-helpers.js
@@ -19,23 +19,24 @@ describe('liquid helper tags', () => {
'/en/desktop/contributing-and-collaborating-using-github-desktop': `/en/${nonEnterpriseDefaultVersion}/desktop/contributing-and-collaborating-using-github-desktop`,
'/ja/desktop/contributing-and-collaborating-using-github-desktop': `/ja/${nonEnterpriseDefaultVersion}/desktop/contributing-and-collaborating-using-github-desktop`,
'/en/desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories': `/en/${nonEnterpriseDefaultVersion}/desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories`,
- '/en/github/writing-on-github/basic-writing-and-formatting-syntax': `/en/${nonEnterpriseDefaultVersion}/github/writing-on-github/basic-writing-and-formatting-syntax`
+ '/en/github/writing-on-github/basic-writing-and-formatting-syntax': `/en/${nonEnterpriseDefaultVersion}/github/writing-on-github/basic-writing-and-formatting-syntax`,
}
context.site = {
data: {
reusables: {
- example: 'a rose by any other name\nwould smell as sweet'
- }
- }
+ example: 'a rose by any other name\nwould smell as sweet',
+ },
+ },
}
context.page = {
- relativePath: 'desktop/index.md'
+ relativePath: 'desktop/index.md',
}
})
test('link tag with relative path (English)', async () => {
const template = '{% link /contributing-and-collaborating-using-github-desktop %}'
- const expected = 'Contributing and collaborating using GitHub Desktop'
+ const expected =
+ 'Contributing and collaborating using GitHub Desktop'
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
@@ -43,7 +44,8 @@ describe('liquid helper tags', () => {
test('link tag with relative path (translated)', async () => {
context.currentLanguage = 'ja'
const template = '{% link /contributing-and-collaborating-using-github-desktop %}'
- const expected = ''
+ const expected =
+ ''
const output = await liquid.parseAndRender(template, context)
expect(output.includes(expected)).toBe(true)
// set this back to english
@@ -53,15 +55,18 @@ describe('liquid helper tags', () => {
test('link tag with local variable', async () => {
const template = `{% assign href = "/contributing-and-collaborating-using-github-desktop" %}
{% link {{ href }} %}`
- const expected = ''
+ const expected =
+ ''
const output = await liquid.parseAndRender(template, context)
expect(output.includes(expected)).toBe(true)
})
test('link tag with absolute path', async () => {
context.currentLanguage = 'en'
- const template = '{% link /desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories %}'
- const expected = 'Adding and cloning repositories'
+ const template =
+ '{% link /desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories %}'
+ const expected =
+ 'Adding and cloning repositories'
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
@@ -79,13 +84,15 @@ describe('liquid helper tags', () => {
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'
+ const expected =
+ '- Contributing and collaborating using GitHub Desktop'
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
test('link_as_article_card', async () => {
- const template = '{% link_as_article_card /contributing-and-collaborating-using-github-desktop %}'
+ const template =
+ '{% link_as_article_card /contributing-and-collaborating-using-github-desktop %}'
const expected = `
Contributing and collaborating using GitHub Desktop
@@ -130,32 +137,30 @@ would smell as sweet`
})
describe('data tag', () => {
- test(
- 'handles bracketed array access within for-in loop',
- async () => {
- const template = `
+ test('handles bracketed array access within for-in loop', async () => {
+ const template = `
{% for term in site.data.glossaries.external %}
### {% data glossaries.external[forloop.index0].term %}
{% data glossaries.external[forloop.index0].description %}
---
{% endfor %}`
- const localContext = { ...context }
- localContext.site = {
- data: {
- variables: {
- fire_emoji: ':fire:'
- },
- glossaries: {
- external: [
- { term: 'lit', description: 'Awesome things. {% data variables.fire_emoji %}' },
- { term: 'Zhu Li', description: '_"Zhu Li, do the thing!"_ :point_up:' }
- ]
- }
- }
- }
-
- const expected = `
+ const localContext = { ...context }
+ localContext.site = {
+ data: {
+ variables: {
+ fire_emoji: ':fire:',
+ },
+ glossaries: {
+ external: [
+ { term: 'lit', description: 'Awesome things. {% data variables.fire_emoji %}' },
+ { term: 'Zhu Li', description: '_"Zhu Li, do the thing!"_ :point_up:' },
+ ],
+ },
+ },
+ }
+
+ const expected = `
### lit
Awesome things. :fire:
@@ -166,9 +171,8 @@ _"Zhu Li, do the thing!"_ :point_up:
---
`
- const output = await liquid.parseAndRender(template, localContext)
- expect(output).toBe(expected)
- }
- )
+ const output = await liquid.parseAndRender(template, localContext)
+ expect(output).toBe(expected)
+ })
})
})
diff --git a/tests/unit/liquid.js b/tests/unit/liquid.js
index df630c93d68f..8066618786b5 100644
--- a/tests/unit/liquid.js
+++ b/tests/unit/liquid.js
@@ -72,7 +72,7 @@ describe('liquid template parser', () => {
currentVersion: 'free-pro-team@latest',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(shortVersionsTemplate, req.context)
@@ -85,7 +85,7 @@ describe('liquid template parser', () => {
currentVersion: 'github-ae@latest',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(shortVersionsTemplate, req.context)
@@ -97,11 +97,13 @@ describe('liquid template parser', () => {
currentVersion: 'enterprise-server@2.22',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(shortVersionsTemplate, req.context)
- expect(output.replace(/\s\s+/g, ' ').trim()).toBe('I am GHES I am GHES < 3.1 I am FTP or GHES < 3.0')
+ expect(output.replace(/\s\s+/g, ' ').trim()).toBe(
+ 'I am GHES I am GHES < 3.1 I am FTP or GHES < 3.0'
+ )
})
test('AND statements work as expected', async () => {
@@ -109,7 +111,7 @@ describe('liquid template parser', () => {
currentVersion: 'enterprise-server@3.0',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(shortVersionsTemplate, req.context)
@@ -121,7 +123,7 @@ describe('liquid template parser', () => {
currentVersion: 'github-ae@latest',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(negativeVersionsTemplate, req.context)
@@ -133,7 +135,7 @@ describe('liquid template parser', () => {
currentVersion: 'enterprise-server@3.0',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(negativeVersionsTemplate, req.context)
@@ -145,7 +147,7 @@ describe('liquid template parser', () => {
currentVersion: 'enterprise-server@3.1',
page: {},
allVersions,
- enterpriseServerReleases
+ enterpriseServerReleases,
}
await shortVersionsMiddleware(req, null, () => {})
const output = await liquid.parseAndRender(negativeVersionsTemplate, req.context)
@@ -169,7 +171,7 @@ describe('liquid template parser', () => {
page: {},
allVersions,
enterpriseServerReleases,
- site: siteData
+ site: siteData,
}
await featureVersionsMiddleware(req, null, () => {})
const outputFpt = await liquid.parseAndRender(featureVersionsTemplate, req.context)
@@ -182,7 +184,7 @@ describe('liquid template parser', () => {
page: {},
allVersions,
enterpriseServerReleases,
- site: siteData
+ site: siteData,
}
await featureVersionsMiddleware(req, null, () => {})
const outputFpt = await liquid.parseAndRender(featureVersionsTemplate, req.context)
@@ -195,7 +197,7 @@ describe('liquid template parser', () => {
page: {},
allVersions,
enterpriseServerReleases,
- site: siteData
+ site: siteData,
}
await featureVersionsMiddleware(req, null, () => {})
const outputFpt = await liquid.parseAndRender(featureVersionsTemplate, req.context)
diff --git a/tests/unit/openapi-schema.js b/tests/unit/openapi-schema.js
index cc8e408c19b4..19373a620ed4 100644
--- a/tests/unit/openapi-schema.js
+++ b/tests/unit/openapi-schema.js
@@ -20,12 +20,11 @@ describe('OpenAPI schema validation', () => {
// is not yet defined in allVersions (e.g., a GHEC static file can exist
// even though the version is not yet supported in the docs)
test('every OpenAPI version must have a schema file in the docs', () => {
- const decoratedFilenames = walk(schemasPath)
- .map(filename => path.basename(filename, '.json'))
+ const decoratedFilenames = walk(schemasPath).map((filename) => path.basename(filename, '.json'))
Object.values(allVersions)
- .map(version => version.openApiVersionName)
- .forEach(openApiBaseName => {
+ .map((version) => version.openApiVersionName)
+ .forEach((openApiBaseName) => {
expect(decoratedFilenames.includes(openApiBaseName)).toBe(true)
})
})
@@ -42,8 +41,8 @@ describe('OpenAPI schema validation', () => {
})
})
-function findOperation (method, path) {
- return nonEnterpriseDefaultVersionSchema.find(operation => {
+function findOperation(method, path) {
+ return nonEnterpriseDefaultVersionSchema.find((operation) => {
return operation.requestPath === path && operation.verb.toLowerCase() === method.toLowerCase()
})
}
@@ -52,22 +51,34 @@ describe('x-codeSamples for curl', () => {
test('GET', () => {
const operation = findOperation('GET', '/repos/{owner}/{repo}')
expect(isPlainObject(operation)).toBe(true)
- const { source } = operation['x-codeSamples'].find(sample => sample.lang === 'Shell')
- const expected = 'curl \\\n -H "Accept: application/vnd.github.v3+json" \\\n https://api.github.com/repos/octocat/hello-world'
+ const { source } = operation['x-codeSamples'].find((sample) => sample.lang === 'Shell')
+ const expected =
+ 'curl \\\n -H "Accept: application/vnd.github.v3+json" \\\n https://api.github.com/repos/octocat/hello-world'
expect(source).toEqual(expected)
})
test('operations with required preview headers', () => {
- const operationsWithRequiredPreviewHeaders = nonEnterpriseDefaultVersionSchema.filter(operation => {
- const previews = get(operation, 'x-github.previews', [])
- return previews.some(preview => preview.required)
- })
+ const operationsWithRequiredPreviewHeaders = nonEnterpriseDefaultVersionSchema.filter(
+ (operation) => {
+ const previews = get(operation, 'x-github.previews', [])
+ return previews.some((preview) => preview.required)
+ }
+ )
expect(operationsWithRequiredPreviewHeaders.length).toBeGreaterThan(0)
- const operationsWithHeadersInCodeSample = operationsWithRequiredPreviewHeaders.filter(operation => {
- const { source: codeSample } = operation['x-codeSamples'].find(sample => sample.lang === 'Shell')
- return codeSample.includes('-H "Accept: application/vnd.github') && !codeSample.includes('application/vnd.github.v3+json')
- })
- expect(operationsWithRequiredPreviewHeaders.length).toEqual(operationsWithHeadersInCodeSample.length)
+ const operationsWithHeadersInCodeSample = operationsWithRequiredPreviewHeaders.filter(
+ (operation) => {
+ const { source: codeSample } = operation['x-codeSamples'].find(
+ (sample) => sample.lang === 'Shell'
+ )
+ return (
+ codeSample.includes('-H "Accept: application/vnd.github') &&
+ !codeSample.includes('application/vnd.github.v3+json')
+ )
+ }
+ )
+ expect(operationsWithRequiredPreviewHeaders.length).toEqual(
+ operationsWithHeadersInCodeSample.length
+ )
})
})
@@ -75,7 +86,7 @@ describe('x-codeSamples for @octokit/core.js', () => {
test('GET', () => {
const operation = findOperation('GET', '/repos/{owner}/{repo}')
expect(isPlainObject(operation)).toBe(true)
- const { source } = operation['x-codeSamples'].find(sample => sample.lang === 'JavaScript')
+ const { source } = operation['x-codeSamples'].find((sample) => sample.lang === 'JavaScript')
const expected = dedent`await octokit.request('GET /repos/{owner}/{repo}', {
owner: 'octocat',
repo: 'hello-world'
@@ -86,7 +97,7 @@ describe('x-codeSamples for @octokit/core.js', () => {
test('POST', () => {
const operation = findOperation('POST', '/repos/{owner}/{repo}/git/trees')
expect(isPlainObject(operation)).toBe(true)
- const { source } = operation['x-codeSamples'].find(sample => sample.lang === 'JavaScript')
+ const { source } = operation['x-codeSamples'].find((sample) => sample.lang === 'JavaScript')
const expected = dedent`await octokit.request('POST /repos/{owner}/{repo}/git/trees', {
owner: 'octocat',
repo: 'hello-world',
@@ -106,7 +117,7 @@ describe('x-codeSamples for @octokit/core.js', () => {
test('PUT', () => {
const operation = findOperation('PUT', '/authorizations/clients/{client_id}/{fingerprint}')
expect(isPlainObject(operation)).toBe(true)
- const { source } = operation['x-codeSamples'].find(sample => sample.lang === 'JavaScript')
+ const { source } = operation['x-codeSamples'].find((sample) => sample.lang === 'JavaScript')
const expected = dedent`await octokit.request('PUT /authorizations/clients/{client_id}/{fingerprint}', {
client_id: 'client_id',
fingerprint: 'fingerprint',
@@ -116,10 +127,12 @@ describe('x-codeSamples for @octokit/core.js', () => {
})
test('operations with required preview headers', () => {
- const operationsWithRequiredPreviewHeaders = nonEnterpriseDefaultVersionSchema.filter(operation => {
- const previews = get(operation, 'x-github.previews', [])
- return previews.some(preview => preview.required)
- })
+ const operationsWithRequiredPreviewHeaders = nonEnterpriseDefaultVersionSchema.filter(
+ (operation) => {
+ const previews = get(operation, 'x-github.previews', [])
+ return previews.some((preview) => preview.required)
+ }
+ )
expect(operationsWithRequiredPreviewHeaders.length).toBeGreaterThan(0)
// Find something that looks like the following in each code sample:
@@ -130,11 +143,17 @@ describe('x-codeSamples for @octokit/core.js', () => {
]
}
*/
- const operationsWithHeadersInCodeSample = operationsWithRequiredPreviewHeaders.filter(operation => {
- const { source: codeSample } = operation['x-codeSamples'].find(sample => sample.lang === 'JavaScript')
- return codeSample.match(/mediaType: \{\s+previews: /g)
- })
- expect(operationsWithRequiredPreviewHeaders.length).toEqual(operationsWithHeadersInCodeSample.length)
+ const operationsWithHeadersInCodeSample = operationsWithRequiredPreviewHeaders.filter(
+ (operation) => {
+ const { source: codeSample } = operation['x-codeSamples'].find(
+ (sample) => sample.lang === 'JavaScript'
+ )
+ return codeSample.match(/mediaType: \{\s+previews: /g)
+ }
+ )
+ expect(operationsWithRequiredPreviewHeaders.length).toEqual(
+ operationsWithHeadersInCodeSample.length
+ )
})
// skipped because the definition is current missing the `content-type` parameter
@@ -142,7 +161,7 @@ describe('x-codeSamples for @octokit/core.js', () => {
test.skip('operation with content-type parameter', () => {
const operation = findOperation('POST', '/markdown/raw')
expect(isPlainObject(operation)).toBe(true)
- const { source } = operation['x-codeSamples'].find(sample => sample.lang === 'JavaScript')
+ const { source } = operation['x-codeSamples'].find((sample) => sample.lang === 'JavaScript')
const expected = dedent`await octokit.request('POST /markdown/raw', {
data: 'data',
headers: {
diff --git a/tests/unit/page.js b/tests/unit/page.js
index a7fd8fb71104..27a6e700a9e1 100644
--- a/tests/unit/page.js
+++ b/tests/unit/page.js
@@ -9,15 +9,18 @@ import nonEnterpriseDefaultVersion from '../../lib/non-enterprise-default-versio
// import getLinkData from '../../lib/get-link-data.js'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const prerenderedObjects = readJsonFile('./lib/graphql/static/prerendered-objects.json')
-const enterpriseServerVersions = Object.keys(allVersions).filter(v => v.startsWith('enterprise-server@'))
+const enterpriseServerVersions = Object.keys(allVersions).filter((v) =>
+ v.startsWith('enterprise-server@')
+)
// get the `free-pro-team` segment of `free-pro-team@latest`
const nonEnterpriseDefaultPlan = nonEnterpriseDefaultVersion.split('@')[0]
const opts = {
- relativePath: 'github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches.md',
+ relativePath:
+ 'github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
}
describe('Page class', () => {
@@ -31,7 +34,7 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'translated-toc-with-no-links-index.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'ja'
+ languageCode: 'ja',
})
expect(typeof page.title).toBe('string')
})
@@ -43,20 +46,20 @@ describe('Page class', () => {
article = await Page.init({
relativePath: 'sample-article.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
articleWithFM = await Page.init({
showMiniToc: false,
relativePath: article.relativePath,
basePath: article.basePath,
- languageCode: article.languageCode
+ languageCode: article.languageCode,
})
tocPage = await Page.init({
relativePath: 'sample-toc-index.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
})
@@ -80,22 +83,32 @@ describe('Page class', () => {
const context = {
page: { version: `enterprise-server@${enterpriseServerReleases.latest}` },
currentVersion: `enterprise-server@${enterpriseServerReleases.latest}`,
- currentPath: '/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches',
- currentLanguage: 'en'
+ currentPath:
+ '/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-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/${`enterprise-server@${enterpriseServerReleases.latest}`}/articles/about-pull-requests"]`).length).toBeGreaterThan(0)
+ expect(
+ $(
+ `a[href="/en/${`enterprise-server@${enterpriseServerReleases.latest}`}/articles/about-pull-requests"]`
+ ).length
+ ).toBeGreaterThan(0)
})
test('rewrites links on prerendered GraphQL page include the current language prefix and version', async () => {
- const graphqlVersion = allVersions[`enterprise-server@${enterpriseServerReleases.latest}`].miscVersionName
+ const graphqlVersion =
+ allVersions[`enterprise-server@${enterpriseServerReleases.latest}`].miscVersionName
const $ = cheerio.load(prerenderedObjects[graphqlVersion].html)
expect($('a[href^="/graphql/reference/input-objects"]').length).toBe(0)
- expect($(`a[href^="/en/enterprise-server@${enterpriseServerReleases.latest}/graphql/reference/input-objects"]`).length).toBeGreaterThan(0)
+ expect(
+ $(
+ `a[href^="/en/enterprise-server@${enterpriseServerReleases.latest}/graphql/reference/input-objects"]`
+ ).length
+ ).toBeGreaterThan(0)
})
test('rewrites links in the intro to include the current language prefix and version', async () => {
@@ -104,8 +117,9 @@ describe('Page class', () => {
const context = {
page: { version: nonEnterpriseDefaultVersion },
currentVersion: nonEnterpriseDefaultVersion,
- currentPath: '/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches',
- currentLanguage: 'en'
+ currentPath:
+ '/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches',
+ currentLanguage: 'en',
}
await page.render(context)
const $ = cheerio.load(page.intro)
@@ -115,21 +129,33 @@ describe('Page class', () => {
test('does not rewrite links that include deprecated enterprise release numbers', async () => {
const page = await Page.init({
- relativePath: 'admin/enterprise-management/updating-the-virtual-machine-and-physical-resources/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'
+ languageCode: 'en',
})
const context = {
page: { version: `enterprise-server@${enterpriseServerReleases.latest}` },
currentVersion: `enterprise-server@${enterpriseServerReleases.latest}`,
currentPath: `/en/enterprise-server@${enterpriseServerReleases.latest}/admin/enterprise-management/migrating-from-github-enterprise-1110x-to-2123`,
- currentLanguage: 'en'
+ 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-server@${enterpriseServerReleases.latest}/11.10.340/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)
+ expect(
+ page.markdown.includes(
+ '(/enterprise/11.10.340/admin/articles/upgrading-to-the-latest-release/)'
+ )
+ ).toBe(true)
+ expect(
+ $(
+ `a[href="/en/enterprise-server@${enterpriseServerReleases.latest}/11.10.340/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)
})
test('does not rewrite links to external redirects', async () => {
@@ -139,7 +165,7 @@ describe('Page class', () => {
page: { version: nonEnterpriseDefaultVersion },
currentVersion: nonEnterpriseDefaultVersion,
currentPath: `/en/${nonEnterpriseDefaultVersion}/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches`,
- currentLanguage: 'en'
+ currentLanguage: 'en',
}
const rendered = await page.render(context)
const $ = cheerio.load(rendered)
@@ -153,17 +179,19 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'page-versioned-for-all-enterprise-releases.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
// set version to the latest enterprise version
const context = {
currentVersion: `enterprise-server@${enterpriseServerReleases.latest}`,
currentLanguage: 'en',
- enterpriseServerVersions
+ enterpriseServerVersions,
}
let rendered = await page.render(context)
let $ = cheerio.load(rendered)
- expect($.text()).toBe('This text should render on any actively supported version of Enterprise Server')
+ expect($.text()).toBe(
+ 'This text should render on any actively supported version of Enterprise Server'
+ )
expect($.text()).not.toBe('This text should only render on non-Enterprise')
// change version to the oldest enterprise version, re-render, and test again;
@@ -171,7 +199,9 @@ describe('Page class', () => {
context.currentVersion = `enterprise-server@${enterpriseServerReleases.oldestSupported}`
rendered = await page.render(context)
$ = cheerio.load(rendered)
- expect($.text()).toBe('This text should render on any actively supported version of Enterprise Server')
+ expect($.text()).toBe(
+ 'This text should render on any actively supported version of Enterprise Server'
+ )
expect($.text()).not.toBe('This text should only render on non-Enterprise')
// change version to non-enterprise, re-render, and test again;
@@ -179,7 +209,9 @@ describe('Page class', () => {
context.currentVersion = nonEnterpriseDefaultVersion
rendered = await page.render(context)
$ = cheerio.load(rendered)
- expect($.text()).not.toBe('This text should render on any actively supported version of Enterprise Server')
+ expect($.text()).not.toBe(
+ 'This text should render on any actively supported version of Enterprise Server'
+ )
expect($.text()).toBe('This text should only render on non-Enterprise')
})
@@ -188,14 +220,16 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'page-versioned-for-next-enterprise-release.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
// set version to 3.0
const context = {
currentVersion: 'enterprise-server@3.0',
- currentLanguage: 'en'
+ currentLanguage: 'en',
}
- await expect(() => { return page.render(context) }).not.toThrow()
+ await expect(() => {
+ return page.render(context)
+ }).not.toThrow()
})
test('support next GitHub AE version in frontmatter', async () => {
@@ -203,14 +237,16 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'page-versioned-for-ghae-next.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
// set version to @latest
const context = {
currentVersion: 'github-ae@latest',
- currentLanguage: 'en'
+ currentLanguage: 'en',
}
- await expect(() => { return page.render(context) }).not.toThrow()
+ await expect(() => {
+ return page.render(context)
+ }).not.toThrow()
})
})
@@ -223,21 +259,21 @@ describe('Page class', () => {
let page = await Page.init({
relativePath: 'github/some-category/some-article.md',
basePath: path.join(__dirname, '../fixtures/products'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.parentProductId).toBe('github')
page = await Page.init({
relativePath: 'actions/some-category/some-article.md',
basePath: path.join(__dirname, '../fixtures/products'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.parentProductId).toBe('actions')
page = await Page.init({
relativePath: 'admin/some-category/some-article.md',
basePath: path.join(__dirname, '../fixtures/products'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.parentProductId).toBe('admin')
})
@@ -250,36 +286,68 @@ describe('Page class', () => {
test('has a key for every supported enterprise version (and no deprecated versions)', async () => {
const page = await Page.init(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)
+ 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)
})
test('sets versioned values', async () => {
const page = await Page.init(opts)
- const expectedPath = 'github/collaborating-with-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}`)
+ const expectedPath =
+ 'github/collaborating-with-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}`)
})
test('homepage permalinks', async () => {
const page = await Page.init({
relativePath: 'index.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
- expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe('/en')
- expect(page.permalinks.find(permalink => permalink.pageVersion === `enterprise-server@${enterpriseServerReleases.oldestSupported}`).href).toBe(`/en/enterprise-server@${enterpriseServerReleases.oldestSupported}`)
+ expect(
+ page.permalinks.find((permalink) => permalink.pageVersion === nonEnterpriseDefaultVersion)
+ .href
+ ).toBe('/en')
+ expect(
+ page.permalinks.find(
+ (permalink) =>
+ permalink.pageVersion ===
+ `enterprise-server@${enterpriseServerReleases.oldestSupported}`
+ ).href
+ ).toBe(`/en/enterprise-server@${enterpriseServerReleases.oldestSupported}`)
})
test('permalinks for dotcom-only pages', async () => {
const page = await Page.init({
- relativePath: 'github/authenticating-to-github/troubleshooting-ssh/using-ssh-over-the-https-port.md',
+ relativePath:
+ 'github/authenticating-to-github/troubleshooting-ssh/using-ssh-over-the-https-port.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
- const expectedPath = '/en/github/authenticating-to-github/troubleshooting-ssh/using-ssh-over-the-https-port'
- expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe(expectedPath)
+ const expectedPath =
+ '/en/github/authenticating-to-github/troubleshooting-ssh/using-ssh-over-the-https-port'
+ expect(
+ page.permalinks.find((permalink) => permalink.pageVersion === nonEnterpriseDefaultVersion)
+ .href
+ ).toBe(expectedPath)
expect(page.permalinks.length).toBe(1)
})
@@ -287,10 +355,17 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'products/admin/some-category/some-article.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ 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`)
- const pageVersions = page.permalinks.map(permalink => permalink.pageVersion)
+ expect(
+ page.permalinks.find(
+ (permalink) =>
+ permalink.pageVersion === `enterprise-server@${enterpriseServerReleases.latest}`
+ ).href
+ ).toBe(
+ `/en/enterprise-server@${enterpriseServerReleases.latest}/products/admin/some-category/some-article`
+ )
+ const pageVersions = page.permalinks.map((permalink) => permalink.pageVersion)
expect(pageVersions.length).toBeGreaterThan(1)
expect(pageVersions.includes(nonEnterpriseDefaultVersion)).toBe(false)
})
@@ -299,21 +374,30 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'products/actions/some-category/some-article.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
- expect(page.permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion).href).toBe('/en/products/actions/some-category/some-article')
+ expect(
+ page.permalinks.find((permalink) => permalink.pageVersion === nonEnterpriseDefaultVersion)
+ .href
+ ).toBe('/en/products/actions/some-category/some-article')
expect(page.permalinks.length).toBe(1)
})
test('permalinks for non-GitHub.com products with Enterprise versions', async () => {
const page = await Page.init({
- relativePath: '/insights/installing-and-configuring-github-insights/installing-and-updating-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'
+ languageCode: 'en',
})
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(
+ 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)
expect(pageVersions.includes(nonEnterpriseDefaultVersion)).toBe(false)
})
@@ -326,7 +410,7 @@ describe('Page class', () => {
page = await Page.init({
relativePath: 'article-with-learning-tracks.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
})
@@ -336,7 +420,7 @@ describe('Page class', () => {
'track_2',
'non_existing_track',
'{% if currentVersion == "free-pro-team@latest" %}dotcom_only_track{% endif %}',
- '{% if currentVersion != "free-pro-team@latest" %}enterprise_only_track{% endif %}'
+ '{% if currentVersion != "free-pro-team@latest" %}enterprise_only_track{% endif %}',
])
})
@@ -356,28 +440,30 @@ describe('Page class', () => {
title: 'title',
description: 'description',
guides,
- featured_track: '{% if currentVersion == "free-pro-team@latest" %}true{% else %}false{% endif %}'
+ featured_track:
+ '{% if currentVersion == "free-pro-team@latest" %}true{% else %}false{% endif %}',
},
track_2: {
title: 'title',
description: 'description',
guides,
- featured_track: '{% if enterpriseServerVersions contains currentVersion %}true{% else %}false{% endif %}'
+ featured_track:
+ '{% if enterpriseServerVersions contains currentVersion %}true{% else %}false{% endif %}',
},
dotcom_only_track: {
title: 'title',
description: 'description',
- guides
+ guides,
},
enterprise_only_track: {
title: 'title',
description: 'description',
- guides
- }
- }
- }
- }
- }
+ guides,
+ },
+ },
+ },
+ },
+ },
}
// Test that Liquid versioning is respected during rendering.
// Start with Dotcom.
@@ -387,7 +473,7 @@ describe('Page class', () => {
// expect(getLinkData).toHaveBeenCalledWith(guides, context)
// Tracks for dotcom should exclude enterprise_only_track and the featured track_1.
expect(page.learningTracks).toHaveLength(2)
- const dotcomTrackNames = page.learningTracks.map(t => t.trackName)
+ const dotcomTrackNames = page.learningTracks.map((t) => t.trackName)
expect(dotcomTrackNames.includes('track_2')).toBe(true)
expect(dotcomTrackNames.includes('dotcom_only_track')).toBe(true)
expect(page.featuredTrack.trackName === 'track_1').toBeTruthy()
@@ -398,7 +484,7 @@ describe('Page class', () => {
await page.render(context)
// Tracks for enterprise should exclude dotcom_only_track and the featured track_2.
expect(page.learningTracks).toHaveLength(2)
- const ghesTrackNames = page.learningTracks.map(t => t.trackName)
+ const ghesTrackNames = page.learningTracks.map((t) => t.trackName)
expect(ghesTrackNames.includes('track_1')).toBe(true)
expect(ghesTrackNames.includes('enterprise_only_track')).toBe(true)
expect(page.featuredTrack.trackName === 'track_1').toBeFalsy()
@@ -413,7 +499,7 @@ describe('Page class', () => {
page = await Page.init({
relativePath: 'article-with-includeGuides.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
})
@@ -434,15 +520,13 @@ describe('Page class', () => {
// const guides = ['/path/guide1', '/path/guide2', '/path/guide3']
const context = {
currentVersion: nonEnterpriseDefaultVersion,
- currentLanguage: 'en'
+ currentLanguage: 'en',
}
await page.render(context)
// expect(getLinkData).toHaveBeenCalledWith(guides, context)
expect(page.includeGuides).toHaveLength(3)
expect(page.allTopics).toHaveLength(4)
- expect(page.allTopics).toEqual(
- expect.arrayContaining(['Spring', 'Summer', 'Fall', 'Winter'])
- )
+ expect(page.allTopics).toEqual(expect.arrayContaining(['Spring', 'Summer', 'Fall', 'Winter']))
})
})
@@ -458,9 +542,9 @@ describe('Page class', () => {
describe('Page.getLanguageVariants()', () => {
it('returns an array of language variants of the given URL', () => {
const variants = Page.getLanguageVariants('/en')
- expect(variants.every(variant => variant.name)).toBe(true)
- expect(variants.every(variant => variant.code)).toBe(true)
- expect(variants.every(variant => variant.href)).toBe(true)
+ expect(variants.every((variant) => variant.name)).toBe(true)
+ expect(variants.every((variant) => variant.code)).toBe(true)
+ expect(variants.every((variant) => variant.href)).toBe(true)
})
it('works for the homepage', () => {
@@ -470,8 +554,12 @@ describe('Page class', () => {
})
it('works for enterprise URLs', () => {
- const variants = Page.getLanguageVariants(`/ja/enterprise/${enterpriseServerReleases.oldestSupported}/user/articles/github-glossary`)
- expect(variants.find(({ code }) => code === 'en').href).toBe(`/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/articles/github-glossary`)
+ const variants = Page.getLanguageVariants(
+ `/ja/enterprise/${enterpriseServerReleases.oldestSupported}/user/articles/github-glossary`
+ )
+ expect(variants.find(({ code }) => code === 'en').href).toBe(
+ `/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/articles/github-glossary`
+ )
// expect(variants.find(({ code }) => code === 'ja').href).toBe('/ja/enterprise/2.14/user/articles/github-glossary')
})
})
@@ -480,25 +568,25 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'article-with-mislocalized-frontmatter.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'ja'
+ languageCode: 'ja',
})
expect(page.mapTopic).toBe(true)
})
describe('page.versions frontmatter', () => {
test.skip('pages that apply to older enterprise versions', async () => {
- // There are none of these in the content at this time!
+ // There are none of these in the content at this time!
})
test.skip('pages that apply to newer enterprise versions', async () => {
- // There are none of these in the content at this time!
+ // There are none of these in the content at this time!
})
test('pages that use short names in versions frontmatter', async () => {
const page = await Page.init({
relativePath: 'short-versions.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.versions.fpt).toBe('*')
expect(page.versions.ghes).toBe('>3.0')
@@ -512,7 +600,7 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'index.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.versions).toBe('*')
})
@@ -521,7 +609,7 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'admin/index.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(nonEnterpriseDefaultPlan in page.versions).toBe(false)
@@ -546,22 +634,22 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'feature-versions-frontmatter.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ 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
+
+ // 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),
+ // 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
+ // 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)
@@ -574,9 +662,10 @@ describe('Page class', () => {
describe('platform specific content', () => {
test('page.defaultPlatform frontmatter', async () => {
const page = await Page.init({
- relativePath: 'actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service.md',
+ relativePath:
+ 'actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service.md',
basePath: path.join(__dirname, '../../content'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.defaultPlatform).toBeDefined()
expect(page.defaultPlatform).toBe('linux')
@@ -588,7 +677,7 @@ describe('Page class', () => {
const page = await Page.init({
relativePath: 'default-tool.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
expect(page.defaultTool).toBeDefined()
expect(page.defaultTool).toBe('cli')
@@ -598,11 +687,11 @@ describe('Page class', () => {
describe('catches errors thrown in Page class', () => {
test('frontmatter parsing error', async () => {
- async function getPage () {
+ async function getPage() {
return await Page.init({
relativePath: 'page-with-frontmatter-error.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
}
@@ -610,11 +699,11 @@ describe('catches errors thrown in Page class', () => {
})
test('missing versions frontmatter', async () => {
- async function getPage () {
+ async function getPage() {
return await Page.init({
relativePath: 'page-with-missing-product-versions.md',
basePath: path.join(__dirname, '../fixtures'),
- languageCode: 'en'
+ languageCode: 'en',
})
}
@@ -622,11 +711,11 @@ describe('catches errors thrown in Page class', () => {
})
test('English page with a version in frontmatter that its parent product is not available in', async () => {
- async function getPage () {
+ async function getPage() {
return await Page.init({
relativePath: 'admin/some-category/some-article-with-mismatched-versions-frontmatter.md',
basePath: path.join(__dirname, '../fixtures/products'),
- languageCode: 'en'
+ languageCode: 'en',
})
}
@@ -634,14 +723,16 @@ describe('catches errors thrown in Page class', () => {
})
test('non-English page with a version in frontmatter that its parent product is not available in', async () => {
- async function getPage () {
+ async function getPage() {
return await Page.init({
relativePath: 'admin/some-category/some-article-with-mismatched-versions-frontmatter.md',
basePath: path.join(__dirname, '../fixtures/products'),
- languageCode: 'es'
+ languageCode: 'es',
})
}
- await expect(getPage).rejects.toThrowError(/`versions` frontmatter.*? product is not available in/)
+ await expect(getPage).rejects.toThrowError(
+ /`versions` frontmatter.*? product is not available in/
+ )
})
})
diff --git a/tests/unit/pages.js b/tests/unit/pages.js
index df36514fc786..2319657ab01f 100644
--- a/tests/unit/pages.js
+++ b/tests/unit/pages.js
@@ -30,17 +30,26 @@ describe('pages module', () => {
})
test('every page has a `languageCode`', async () => {
- expect(pages.every(page => languageCodes.includes(page.languageCode))).toBe(true)
+ expect(pages.every((page) => languageCodes.includes(page.languageCode))).toBe(true)
})
test('every page has a non-empty `permalinks` array', async () => {
const brokenPages = pages
- .filter(page => !Array.isArray(page.permalinks) || page.permalinks.length === 0)
+ .filter((page) => !Array.isArray(page.permalinks) || page.permalinks.length === 0)
// Ignore pages that only have "next" versions specified and therefore no permalinks;
// These pages are not broken, they just won't render in the currently supported versions.
- .filter(page => !Object.values(page.versions).every(pageVersion => checkIfNextVersionOnly(pageVersion)))
-
- const expectation = JSON.stringify(brokenPages.map(page => page.fullPath), null, 2)
+ .filter(
+ (page) =>
+ !Object.values(page.versions).every((pageVersion) =>
+ checkIfNextVersionOnly(pageVersion)
+ )
+ )
+
+ const expectation = JSON.stringify(
+ brokenPages.map((page) => page.fullPath),
+ null,
+ 2
+ )
expect(brokenPages.length, expectation).toBe(0)
})
@@ -48,14 +57,14 @@ describe('pages module', () => {
const englishPages = chain(pages)
.filter(['languageCode', 'en'])
.filter('redirect_from')
- .map(pages => pick(pages, ['redirect_from', 'applicableVersions']))
+ .map((pages) => pick(pages, ['redirect_from', 'applicableVersions']))
.value()
const versionedRedirects = []
- englishPages.forEach(page => {
- page.redirect_from.forEach(redirect => {
- page.applicableVersions.forEach(version => {
+ englishPages.forEach((page) => {
+ page.redirect_from.forEach((redirect) => {
+ page.applicableVersions.forEach((version) => {
versionedRedirects.push(removeFPTFromPath(path.posix.join('/', version, redirect)))
})
})
@@ -66,31 +75,41 @@ describe('pages module', () => {
return acc
}, [])
- const message = `Found ${duplicates.length} duplicate redirect_from ${duplicates.length === 1 ? 'path' : 'paths'}.\n
+ const message = `Found ${duplicates.length} duplicate redirect_from ${
+ duplicates.length === 1 ? 'path' : 'paths'
+ }.\n
${duplicates.join('\n')}`
expect(duplicates.length, message).toBe(0)
})
test('every English page has a filename that matches its slugified title', async () => {
const nonMatches = pages
- .filter(page => {
+ .filter((page) => {
slugger.reset()
- return page.languageCode === 'en' && // only check English
- !page.relativePath.includes('index.md') && // ignore TOCs
- !page.allowTitleToDifferFromFilename && // ignore docs with override
- slugger.slug(entities.decode(page.title)) !== path.basename(page.relativePath, '.md')
+ return (
+ page.languageCode === 'en' && // only check English
+ !page.relativePath.includes('index.md') && // ignore TOCs
+ !page.allowTitleToDifferFromFilename && // ignore docs with override
+ slugger.slug(entities.decode(page.title)) !== path.basename(page.relativePath, '.md')
+ )
})
// make the output easier to read
- .map(page => {
- return JSON.stringify({
- file: path.basename(page.relativePath),
- title: page.title,
- path: page.fullPath
- }, null, 2)
+ .map((page) => {
+ return JSON.stringify(
+ {
+ file: path.basename(page.relativePath),
+ title: page.title,
+ path: page.fullPath,
+ },
+ null,
+ 2
+ )
})
const message = `
- Found ${nonMatches.length} ${nonMatches.length === 1 ? 'file' : 'files'} that do not match their slugified titles.\n
+ Found ${nonMatches.length} ${
+ nonMatches.length === 1 ? 'file' : 'files'
+ } that do not match their slugified titles.\n
${nonMatches.join('\n')}\n
To fix, run script/reconcile-filenames-with-ids.js\n\n`
@@ -100,11 +119,12 @@ describe('pages module', () => {
test('every page has valid frontmatter', async () => {
const frontmatterErrors = chain(pages)
// .filter(page => page.languageCode === 'en')
- .map(page => page.frontmatterErrors)
+ .map((page) => page.frontmatterErrors)
.flatten()
.value()
- const failureMessage = JSON.stringify(frontmatterErrors, null, 2) +
+ const failureMessage =
+ JSON.stringify(frontmatterErrors, null, 2) +
'\n\n' +
chain(frontmatterErrors).map('filepath').join('\n').value()
@@ -122,7 +142,7 @@ describe('pages module', () => {
} catch (error) {
liquidErrors.push({
filename: page.fullPath,
- error: error.message
+ error: error.message,
})
}
}
@@ -133,12 +153,12 @@ describe('pages module', () => {
test.skip('every non-English page has a matching English page', async () => {
const englishPaths = chain(pages)
- .filter(page => page.languageCode === 'en')
- .map(page => page.relativePath)
+ .filter((page) => page.languageCode === 'en')
+ .map((page) => page.relativePath)
.value()
const nonEnglishPaths = chain(pages)
- .filter(page => page.languageCode !== 'en')
- .map(page => page.relativePath)
+ .filter((page) => page.languageCode !== 'en')
+ .map((page) => page.relativePath)
.uniq()
.value()
@@ -166,7 +186,7 @@ describe('pages module', () => {
})
test('has an identical key list to the deep permalinks of the array', async () => {
- const allPermalinks = pages.flatMap(page => page.permalinks.map(pl => pl.href)).sort()
+ const allPermalinks = pages.flatMap((page) => page.permalinks.map((pl) => pl.href)).sort()
const allPageUrls = Object.keys(pageMap).sort()
expect(allPageUrls).toEqual(allPermalinks)
diff --git a/tests/unit/permalink.js b/tests/unit/permalink.js
index bf95c7d59bf6..1b5356753046 100644
--- a/tests/unit/permalink.js
+++ b/tests/unit/permalink.js
@@ -10,11 +10,18 @@ describe('Permalink class', () => {
test('derives info for unversioned homepage', () => {
const versions = {
'free-pro-team': '*',
- 'enterprise-server': '*'
+ 'enterprise-server': '*',
}
- const permalinks = Permalink.derive('en', 'index.md', 'Hello World', getApplicableVersions(versions))
+ const permalinks = Permalink.derive(
+ 'en',
+ 'index.md',
+ 'Hello World',
+ getApplicableVersions(versions)
+ )
expect(permalinks.length).toBeGreaterThan(1)
- const homepagePermalink = permalinks.find(permalink => permalink.pageVersion === nonEnterpriseDefaultVersion)
+ const homepagePermalink = permalinks.find(
+ (permalink) => permalink.pageVersion === nonEnterpriseDefaultVersion
+ )
expect(homepagePermalink.href).toBe('/en')
})
@@ -25,19 +32,34 @@ describe('Permalink class', () => {
})
test('derives info for enterprise server versioned homepage', () => {
- const permalink = new Permalink('en', `enterprise-server@${enterpriseServerReleases.latest}`, 'index.md', 'Hello World')
+ 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}`)
})
test('derives info for GitHub.com homepage', () => {
- const permalink = new Permalink('en', nonEnterpriseDefaultVersion, 'github/index.md', 'Hello World')
+ const permalink = new Permalink(
+ 'en',
+ nonEnterpriseDefaultVersion,
+ 'github/index.md',
+ 'Hello World'
+ )
expect(permalink.pageVersionTitle).toBe('GitHub.com')
expect(permalink.href).toBe('/en/github')
})
test('derives info for enterprise version of GitHub.com homepage', () => {
- const permalink = new Permalink('en', `enterprise-server@${enterpriseServerReleases.latest}`, 'github/index.md', 'Hello World')
+ 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`)
})
diff --git a/tests/unit/products.js b/tests/unit/products.js
index c44897574c48..df8c7a923951 100644
--- a/tests/unit/products.js
+++ b/tests/unit/products.js
@@ -14,7 +14,7 @@ describe('products module', () => {
})
test('every product is valid', () => {
- Object.values(productMap).forEach(product => {
+ Object.values(productMap).forEach((product) => {
const { valid, errors } = revalidator.validate(product, schema)
const expectation = JSON.stringify({ product, errors }, null, 2)
expect(valid, expectation).toBe(true)
@@ -28,8 +28,18 @@ describe('mobile-only products nav', () => {
expect((await getDOM('/github'))('#current-product').text().trim()).toBe('GitHub.com')
// Enterprise server
- expect((await getDOM('/en/enterprise/admin'))('#current-product').text().trim()).toBe('Enterprise administrators')
- 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('/en/enterprise/admin'))('#current-product').text().trim()).toBe(
+ 'Enterprise administrators'
+ )
+ 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')
@@ -54,7 +64,9 @@ describe('products middleware', () => {
})
test('adds res.context.currentProduct object', async () => {
- const currentProduct = await getJSON(`/en/${nonEnterpriseDefaultVersion}/github?json=currentProduct`)
+ const currentProduct = await getJSON(
+ `/en/${nonEnterpriseDefaultVersion}/github?json=currentProduct`
+ )
expect(currentProduct).toBe('github')
})
})
diff --git a/tests/unit/read-frontmatter.js b/tests/unit/read-frontmatter.js
index 7177d098779b..8adafbf65486 100644
--- a/tests/unit/read-frontmatter.js
+++ b/tests/unit/read-frontmatter.js
@@ -36,7 +36,7 @@ I am content.
const expectedError = {
filepath: 'path/to/file.md',
message: 'YML parsing error!',
- reason: 'invalid frontmatter entry'
+ reason: 'invalid frontmatter entry',
}
expect(errors[0]).toEqual(expectedError)
})
@@ -54,7 +54,7 @@ I am content.
const expectedError = {
filepath: 'path/to/file.md',
message: 'YML parsing error!',
- reason: 'bad indentation of a mapping entry'
+ reason: 'bad indentation of a mapping entry',
}
expect(errors[0]).toEqual(expectedError)
})
@@ -65,12 +65,12 @@ I am content.
const schema = {
properties: {
title: {
- type: 'string'
+ type: 'string',
},
meaning_of_life: {
- type: 'number'
- }
- }
+ type: 'number',
+ },
+ },
}
const { data, content, errors } = parse(fixture1, { schema })
@@ -85,9 +85,9 @@ I am content.
properties: {
meaning_of_life: {
type: 'number',
- minimum: 50
- }
- }
+ minimum: 50,
+ },
+ },
}
const { data, content, errors } = parse(fixture1, { schema })
@@ -100,7 +100,7 @@ I am content.
property: 'meaning_of_life',
expected: 50,
actual: 42,
- message: 'must be greater than or equal to 50'
+ message: 'must be greater than or equal to 50',
}
expect(errors[0]).toEqual(expectedError)
})
@@ -110,9 +110,9 @@ I am content.
properties: {
yet_another_key: {
type: 'string',
- required: true
- }
- }
+ required: true,
+ },
+ },
}
const { errors } = parse(fixture1, { schema })
@@ -122,7 +122,7 @@ I am content.
property: 'yet_another_key',
expected: true,
actual: undefined,
- message: 'is required'
+ message: 'is required',
}
expect(errors[0]).toEqual(expectedError)
})
@@ -132,9 +132,9 @@ I am content.
const schema = {
properties: {
age: {
- type: 'number'
- }
- }
+ type: 'number',
+ },
+ },
}
it('creates errors for undocumented keys if `validateKeyNames` is true', () => {
@@ -144,13 +144,13 @@ I am content.
{
property: 'title',
message: 'not allowed. Allowed properties are: age',
- filepath: 'path/to/file.md'
+ filepath: 'path/to/file.md',
},
{
property: 'meaning_of_life',
message: 'not allowed. Allowed properties are: age',
- filepath: 'path/to/file.md'
- }
+ filepath: 'path/to/file.md',
+ },
]
expect(errors).toEqual(expectedErrors)
})
@@ -166,20 +166,21 @@ I am content.
const schema = {
properties: {
meaning_of_life: {
- type: 'number'
+ type: 'number',
},
title: {
- type: 'string'
- }
- }
+ type: 'string',
+ },
+ },
}
const { errors } = parse(fixture1, { schema, validateKeyOrder: true, filepath })
const expectedErrors = [
{
property: 'keys',
- message: 'keys must be in order. Current: title,meaning_of_life; Expected: meaning_of_life,title',
- filepath: 'path/to/file.md'
- }
+ message:
+ 'keys must be in order. Current: title,meaning_of_life; Expected: meaning_of_life,title',
+ filepath: 'path/to/file.md',
+ },
]
expect(errors).toEqual(expectedErrors)
})
@@ -188,12 +189,12 @@ I am content.
const schema = {
properties: {
title: {
- type: 'string'
+ type: 'string',
},
meaning_of_life: {
- type: 'number'
- }
- }
+ type: 'number',
+ },
+ },
}
const { errors } = parse(fixture1, { schema, validateKeyOrder: true })
expect(errors.length).toBe(0)
@@ -204,16 +205,16 @@ I am content.
properties: {
title: {
type: 'string',
- required: true
+ required: true,
},
yet_another_key: {
- type: 'string'
+ type: 'string',
},
meaning_of_life: {
type: 'number',
- required: true
- }
- }
+ required: true,
+ },
+ },
}
const { errors } = parse(fixture1, { schema, validateKeyOrder: true })
expect(errors.length).toBe(0)
diff --git a/tests/unit/redis-accessor.js b/tests/unit/redis-accessor.js
index 2454ab8d6891..58296f1889b8 100644
--- a/tests/unit/redis-accessor.js
+++ b/tests/unit/redis-accessor.js
@@ -14,7 +14,12 @@ describe('RedisAccessor', () => {
test('has expected instance properties', async () => {
const instance = new RedisAccessor()
- expect(Object.keys(instance).sort()).toEqual(['_allowGetFailures', '_allowSetFailures', '_client', '_prefix'])
+ expect(Object.keys(instance).sort()).toEqual([
+ '_allowGetFailures',
+ '_allowSetFailures',
+ '_client',
+ '_prefix',
+ ])
})
test('has expected static methods', async () => {
@@ -124,14 +129,14 @@ describe('RedisAccessor', () => {
expect(
RedisAccessor.translateSetArguments({
newOnly: true,
- expireIn: 20
+ expireIn: 20,
})
).toEqual(['NX', 'PX', 20])
expect(
RedisAccessor.translateSetArguments({
existingOnly: true,
- expireIn: 20
+ expireIn: 20,
})
).toEqual(['XX', 'PX', 20])
@@ -139,48 +144,46 @@ describe('RedisAccessor', () => {
RedisAccessor.translateSetArguments({
existingOnly: true,
expireIn: 20,
- rollingExpiration: false
+ rollingExpiration: false,
})
).toEqual(['XX', 'PX', 20, 'KEEPTTL'])
expect(
RedisAccessor.translateSetArguments({
existingOnly: true,
- rollingExpiration: false
+ rollingExpiration: false,
})
).toEqual(['XX', 'KEEPTTL'])
})
test('throws a misconfiguration error if options `newOnly` and `existingOnly` are both set to true', async () => {
- expect(
- () => RedisAccessor.translateSetArguments({ newOnly: true, existingOnly: true })
- ).toThrowError(
- new TypeError('Misconfiguration: entry cannot be both new and existing')
- )
+ expect(() =>
+ RedisAccessor.translateSetArguments({ newOnly: true, existingOnly: true })
+ ).toThrowError(new TypeError('Misconfiguration: entry cannot be both new and existing'))
})
test('throws a misconfiguration error if option `expireIn` is set to a finite number that rounds to less than 1', async () => {
- const misconfigurationError = new TypeError('Misconfiguration: cannot set a TTL of less than 1 millisecond')
+ const misconfigurationError = new TypeError(
+ 'Misconfiguration: cannot set a TTL of less than 1 millisecond'
+ )
- expect(
- () => RedisAccessor.translateSetArguments({ expireIn: 0 })
- ).toThrowError(misconfigurationError)
+ expect(() => RedisAccessor.translateSetArguments({ expireIn: 0 })).toThrowError(
+ misconfigurationError
+ )
- expect(
- () => RedisAccessor.translateSetArguments({ expireIn: -1 })
- ).toThrowError(misconfigurationError)
+ expect(() => RedisAccessor.translateSetArguments({ expireIn: -1 })).toThrowError(
+ misconfigurationError
+ )
- expect(
- () => RedisAccessor.translateSetArguments({ expireIn: 0.4 })
- ).toThrowError(misconfigurationError)
+ expect(() => RedisAccessor.translateSetArguments({ expireIn: 0.4 })).toThrowError(
+ misconfigurationError
+ )
})
test('throws a misconfiguration error if option `rollingExpiration` is set to false but `newOnly` is set to true', async () => {
- expect(
- () => RedisAccessor.translateSetArguments({ newOnly: true, rollingExpiration: false })
- ).toThrowError(
- new TypeError('Misconfiguration: cannot keep an existing TTL on a new entry')
- )
+ expect(() =>
+ RedisAccessor.translateSetArguments({ newOnly: true, rollingExpiration: false })
+ ).toThrowError(new TypeError('Misconfiguration: cannot keep an existing TTL on a new entry'))
})
})
@@ -236,8 +239,7 @@ Error: Redis ReplyError`
await expect(instance.set('myKey', 'myValue')).rejects.toThrowError(
new Error(`Failed to set value in Redis.
Key: myPrefix:myKey
-Error: Redis ReplyError`
- )
+Error: Redis ReplyError`)
)
expect(consoleErrorSpy).not.toBeCalled()
@@ -345,8 +347,7 @@ Error: Redis ReplyError`
await expect(instance.get('myKey')).rejects.toThrowError(
new Error(`Failed to get value from Redis.
Key: myPrefix:myKey
-Error: Redis ReplyError`
- )
+Error: Redis ReplyError`)
)
expect(consoleErrorSpy).not.toBeCalled()
diff --git a/tests/unit/render-content.js b/tests/unit/render-content.js
index 417061d641a5..1f490a7b290c 100644
--- a/tests/unit/render-content.js
+++ b/tests/unit/render-content.js
@@ -4,44 +4,36 @@ import { EOL } from 'os'
// Use platform-specific line endings for realistic tests when templates have
// been loaded from disk
-const nl = str => str.replace(/\n/g, EOL)
+const nl = (str) => str.replace(/\n/g, EOL)
describe('renderContent', () => {
- test(
- 'takes a template and a context and returns a string (async)',
- async () => {
- const template = 'my favorite color is {{ color }}.'
- const context = { color: 'orange' }
- const output = await renderContent(template, context)
- expect(output, 'my favorite color is orange.
')
- }
- )
+ test('takes a template and a context and returns a string (async)', async () => {
+ const template = 'my favorite color is {{ color }}.'
+ const context = { color: 'orange' }
+ const output = await renderContent(template, context)
+ expect(output, 'my favorite color is orange.
')
+ })
test('preserves content within {% raw %} tags', async () => {
- const template = nl(
- 'For example: {% raw %}{% include cool_header.html %}{% endraw %}.'
- )
+ const template = nl('For example: {% raw %}{% include cool_header.html %}{% endraw %}.')
const expected = 'For example: {% include cool_header.html %}.
'
const output = await renderContent(template)
expect(output).toBe(expected)
})
- test(
- 'removes extra newlines to prevent lists from breaking',
- async () => {
- const template = nl(`
+ test('removes extra newlines to prevent lists from breaking', async () => {
+ const template = nl(`
1. item one
1. item two
1. item three`)
- const html = await renderContent(template)
- const $ = cheerio.load(html, { xmlMode: true })
- expect($('ol').length).toBe(1)
- expect($('ol > li').length).toBe(3)
- }
- )
+ const html = await renderContent(template)
+ const $ = cheerio.load(html, { xmlMode: true })
+ expect($('ol').length).toBe(1)
+ expect($('ol > li').length).toBe(3)
+ })
test('removes extra newlines from lists of links', async () => {
const template = nl(`- item
@@ -75,32 +67,29 @@ describe('renderContent', () => {
expect(err).toBeTruthy()
})
- test(
- 'warns and throws on rendering errors when the file name is passed',
- async () => {
- const template = 1
- const context = {}
-
- let err
- let warned = false
-
- const error = console.error
- console.error = message => {
- expect(message, 'renderContent failed on file: name')
- console.error = error
- warned = true
- }
-
- try {
- await renderContent(template, context, { filename: 'name' })
- } catch (_err) {
- err = _err
- }
-
- expect(err).toBeTruthy()
- expect(warned).toBeTruthy()
+ test('warns and throws on rendering errors when the file name is passed', async () => {
+ const template = 1
+ const context = {}
+
+ let err
+ let warned = false
+
+ const error = console.error
+ console.error = (message) => {
+ expect(message, 'renderContent failed on file: name')
+ console.error = error
+ warned = true
+ }
+
+ try {
+ await renderContent(template, context, { filename: 'name' })
+ } catch (_err) {
+ err = _err
}
- )
+
+ expect(err).toBeTruthy()
+ expect(warned).toBeTruthy()
+ })
test('renders empty templates', async () => {
const template = ''
@@ -113,7 +102,7 @@ describe('renderContent', () => {
const template = '
'
const context = {}
const output = await renderContent(template, context, {
- encodeEntities: true
+ encodeEntities: true,
})
expect(output).toBe('<p><beep></beep></p>')
})
@@ -128,29 +117,22 @@ describe('renderContent', () => {
const html = await renderContent(template)
const $ = cheerio.load(html, { xmlMode: true })
expect(
- $.html().includes(
- '"
About issues."'
- )
+ $.html().includes('"
About issues."')
).toBeTruthy()
})
- test(
- 'does not render newlines around inline code in tables',
- async () => {
- const template = nl(`
+ test('does not render newlines around inline code in tables', async () => {
+ const template = nl(`
| Package manager | formats |
| --- | --- |
| Python | \`requirements.txt\`, \`pipfile.lock\`
`)
- const html = await renderContent(template)
- const $ = cheerio.load(html, { xmlMode: true })
- expect(
- $.html().includes(
- '
requirements.txt
,
pipfile.lock
'
- )
- ).toBeTruthy()
- }
- )
+ const html = await renderContent(template)
+ const $ = cheerio.load(html, { xmlMode: true })
+ expect(
+ $.html().includes('
requirements.txt
,
pipfile.lock
')
+ ).toBeTruthy()
+ })
test('does not render newlines around emphasis in code', async () => {
const template = nl(`
@@ -253,18 +235,15 @@ some code
)
})
- test(
- 'renders a copy button for code blocks with {:copy} annotation',
- async () => {
- const template = nl(`
+ test('renders a copy button for code blocks with {:copy} annotation', async () => {
+ const template = nl(`
\`\`\`js{:copy}
some code
\`\`\`\
`)
- const html = await renderContent(template)
- const $ = cheerio.load(html)
- const el = $('button.js-btn-copy')
- expect(el.data('clipboard-text')).toBe('some code')
- }
- )
+ const html = await renderContent(template)
+ const $ = cheerio.load(html)
+ const el = $('button.js-btn-copy')
+ expect(el.data('clipboard-text')).toBe('some code')
+ })
})
diff --git a/tests/unit/search/parse-page-sections-into-records.js b/tests/unit/search/parse-page-sections-into-records.js
index 5142c744a1e5..b2dc67f5cd3f 100644
--- a/tests/unit/search/parse-page-sections-into-records.js
+++ b/tests/unit/search/parse-page-sections-into-records.js
@@ -5,8 +5,14 @@ import cheerio from 'cheerio'
import parsePageSectionsIntoRecords from '../../../script/search/parse-page-sections-into-records.js'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const fixtures = {
- pageWithSections: fs.readFileSync(path.join(__dirname, 'fixtures/page-with-sections.html'), 'utf8'),
- pageWithoutSections: fs.readFileSync(path.join(__dirname, 'fixtures/page-without-sections.html'), 'utf8')
+ pageWithSections: fs.readFileSync(
+ path.join(__dirname, 'fixtures/page-with-sections.html'),
+ 'utf8'
+ ),
+ pageWithoutSections: fs.readFileSync(
+ path.join(__dirname, 'fixtures/page-without-sections.html'),
+ 'utf8'
+ ),
}
describe('search parsePageSectionsIntoRecords module', () => {
@@ -26,7 +32,7 @@ describe('search parsePageSectionsIntoRecords module', () => {
heading: 'First heading',
title: 'I am the page title',
content: "Here's a paragraph. And another.",
- topics: ['topic1', 'topic2', 'GitHub Actions', 'Actions']
+ topics: ['topic1', 'topic2', 'GitHub Actions', 'Actions'],
},
{
objectID: '/example/href#second',
@@ -36,8 +42,8 @@ describe('search parsePageSectionsIntoRecords module', () => {
heading: 'Second heading',
title: 'I am the page title',
content: "Here's a paragraph in the second section. And another.",
- topics: ['topic1', 'topic2', 'GitHub Actions', 'Actions']
- }
+ topics: ['topic1', 'topic2', 'GitHub Actions', 'Actions'],
+ },
]
expect(records).toEqual(expected)
@@ -57,8 +63,8 @@ describe('search parsePageSectionsIntoRecords module', () => {
breadcrumbs: 'Education / map topic',
title: 'A page without sections',
content: 'First paragraph. Second paragraph.',
- topics: ['key1', 'key2', 'key3', 'Education']
- }
+ topics: ['key1', 'key2', 'key3', 'Education'],
+ },
]
expect(records).toEqual(expected)
})
diff --git a/tests/unit/search/rank.js b/tests/unit/search/rank.js
index e4b51cffd41c..72907da83f62 100644
--- a/tests/unit/search/rank.js
+++ b/tests/unit/search/rank.js
@@ -5,7 +5,7 @@ test('search custom rankings', () => {
['https://docs.github.com/en/github/actions', 3],
['https://docs.github.com/en/rest/reference', 2],
['https://docs.github.com/en/graphql', 1],
- ['https://docs.github.com/en/github/site-policy', 0]
+ ['https://docs.github.com/en/github/site-policy', 0],
]
expectedRankings.forEach(([url, expectedRanking]) => {
diff --git a/tests/unit/search/topics.js b/tests/unit/search/topics.js
index 9a3014a330c9..7250b09647f2 100644
--- a/tests/unit/search/topics.js
+++ b/tests/unit/search/topics.js
@@ -7,8 +7,8 @@ import allowedTopics from '../../../data/allowed-topics.js'
const contentDir = path.join(process.cwd(), 'content')
const topics = walk(contentDir, { includeBasePath: true })
- .filter(filename => filename.endsWith('.md') && !filename.includes('README'))
- .map(filename => {
+ .filter((filename) => filename.endsWith('.md') && !filename.includes('README'))
+ .map((filename) => {
const fileContent = fs.readFileSync(filename, 'utf8')
const { data } = readFrontmatter(fileContent)
return data.topics || []
diff --git a/tests/unit/toc-links.js b/tests/unit/toc-links.js
index c5536ffdbda7..9cdddb3877f1 100644
--- a/tests/unit/toc-links.js
+++ b/tests/unit/toc-links.js
@@ -10,15 +10,16 @@ describe('toc links', () => {
test('every toc link works without redirects', async () => {
const pages = await loadPages()
- const englishIndexPages = pages
- .filter(page => page.languageCode === 'en' && page.relativePath.endsWith('index.md'))
+ const englishIndexPages = pages.filter(
+ (page) => page.languageCode === 'en' && page.relativePath.endsWith('index.md')
+ )
const issues = []
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
+ if (!page.permalinks.some((permalink) => permalink.pageVersion === pageVersion)) continue
// build fake context object for rendering the page
const context = {
@@ -26,7 +27,7 @@ describe('toc links', () => {
pages,
redirects: {},
currentLanguage: 'en',
- currentVersion: pageVersion
+ currentVersion: pageVersion,
}
// ensure all toc pages can render
@@ -36,7 +37,7 @@ describe('toc links', () => {
issues.push({
'TOC path': page.relativePath,
error: err.message,
- pageVersion
+ pageVersion,
})
}
}
diff --git a/tests/unit/versions.js b/tests/unit/versions.js
index 45c20691948d..1423c76a8d6a 100644
--- a/tests/unit/versions.js
+++ b/tests/unit/versions.js
@@ -15,7 +15,7 @@ describe('versions module', () => {
})
test('every version is valid', () => {
- Object.values(allVersions).forEach(versionObj => {
+ Object.values(allVersions).forEach((versionObj) => {
const { valid, errors } = revalidator.validate(versionObj, schema)
const expectation = JSON.stringify({ versionObj, errors }, null, 2)
expect(valid, expectation).toBe(true)
diff --git a/webpack.config.js b/webpack.config.js
index 276eae1cfa01..f5652e573ffb 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -10,22 +10,22 @@ module.exports = {
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
- publicPath: '/dist'
+ publicPath: '/dist',
},
stats: 'errors-only',
resolve: {
- extensions: ['.tsx', '.ts', '.js', '.css', '.scss']
+ extensions: ['.tsx', '.ts', '.js', '.css', '.scss'],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
- exclude: /node_modules/
+ exclude: /node_modules/,
},
{
test: /\.css$/i,
- use: ['style-loader', 'css-loader']
+ use: ['style-loader', 'css-loader'],
},
{
test: /\.s[ac]ss$/i,
@@ -35,13 +35,13 @@ module.exports = {
loader: 'css-loader',
options: {
sourceMap: true,
- url: false
- }
+ url: false,
+ },
},
{
// Needed to resolve image url()s within @primer/css
loader: 'resolve-url-loader',
- options: {}
+ options: {},
},
{
loader: 'sass-loader',
@@ -51,30 +51,28 @@ module.exports = {
includePaths: ['./stylesheets', './node_modules'],
options: {
sourceMap: true,
- sourceMapContents: false
- }
- }
- }
- }
- ]
- }
- ]
+ sourceMapContents: false,
+ },
+ },
+ },
+ },
+ ],
+ },
+ ],
},
plugins: [
new MiniCssExtractPlugin({
- filename: 'index.css'
+ filename: 'index.css',
}),
new CopyWebpackPlugin({
- patterns: [
- { from: 'node_modules/@primer/css/fonts', to: 'fonts' }
- ]
+ patterns: [{ from: 'node_modules/@primer/css/fonts', to: 'fonts' }],
}),
new EnvironmentPlugin({
NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
- DEBUG: false
+ DEBUG: false,
}),
new ProvidePlugin({
- process: 'process/browser'
- })
- ]
+ process: 'process/browser',
+ }),
+ ],
}