1
0
mirror of synced 2025-12-25 02:17:36 -05:00

Rewrite links in Page.intro with language (#16550)

* Add defaultLanguage behavior

* Add a million logs because I'm confused

* Rewrite intro links

* Undo changes to detect-language

* Add a test
This commit is contained in:
Jason Etcovitch
2020-11-19 15:53:35 -05:00
committed by GitHub
parent 4053c9d59b
commit 52dbd92144
2 changed files with 21 additions and 0 deletions

View File

@@ -90,6 +90,21 @@ describe('Page class', () => {
expect($(`a[href="/en/${nonEnterpriseDefaultVersion}/articles/about-pull-requests"]`).length).toBeGreaterThan(0)
})
test('rewrites links in the intro to include the current language prefix and version', async () => {
const page = new Page(opts)
page.rawIntro = '[Pull requests](/articles/about-pull-requests)'
const context = {
page: { version: nonEnterpriseDefaultVersion },
currentVersion: nonEnterpriseDefaultVersion,
currentPath: '/en/github/collaborating-with-issues-and-pull-requests/about-branches',
currentLanguage: 'en'
}
await page.render(context)
const $ = cheerio.load(page.intro)
expect($('a[href="/articles/about-pull-requests"]').length).toBe(0)
expect($(`a[href="/en/${nonEnterpriseDefaultVersion}/articles/about-pull-requests"]`).length).toBeGreaterThan(0)
})
test('does not rewrite links that include deprecated enterprise release numbers', async () => {
const page = new Page({
relativePath: 'admin/enterprise-management/migrating-from-github-enterprise-1110x-to-2123.md',