docs/tests/content/featured-links.js

134 строки
5.6 KiB
JavaScript
Исходник Обычный вид История

import fs from 'fs/promises'
import path from 'path'
import { fileURLToPath } from 'url'
import { beforeAll, jest } from '@jest/globals'
import nock from 'nock'
import japaneseCharacters from 'japanese-characters'
import '../../lib/feature-flags.js'
import { getDOM, getJSON } from '../helpers/e2etest.js'
import enterpriseServerReleases from '../../lib/enterprise-server-releases.js'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
describe('featuredLinks', () => {
jest.setTimeout(3 * 60 * 1000)
beforeAll(async () => {
const packagesFeedFixturePayload = await fs.readFile(
path.join(__dirname, '../fixtures/github-blog-feed-packages-2021.xml'),
'utf-8'
)
nock('https://github.blog')
.get('/changelog/label/packages/feed')
.reply(200, packagesFeedFixturePayload)
})
afterAll(() => nock.cleanAll())
describe('rendering', () => {
test('non-TOC pages do not have intro links', async () => {
const $ = await getDOM('/en/get-started/quickstart/set-up-git')
expect($('[data-testid=article-list]')).toHaveLength(0)
})
test('landing page intro links have expected properties', async () => {
const $ = await getDOM('/en')
const $featuredLinks = $('[data-testid=article-list] a')
expect($featuredLinks).toHaveLength(9)
2021-10-19 14:41:47 +03:00
expect($featuredLinks.eq(0).attr('href')).toBe('/en/get-started/quickstart/set-up-git')
expect($featuredLinks.eq(0).children('h3').text().startsWith('Set up Git')).toBe(true)
expect($featuredLinks.eq(0).children('p').text().startsWith('At the heart of GitHub')).toBe(
true
)
2021-10-19 14:41:47 +03:00
expect($featuredLinks.eq(8).attr('href')).toBe('/en/pages')
expect($featuredLinks.eq(8).children('h3').text().startsWith('GitHub Pages')).toBe(true)
expect($featuredLinks.eq(8).children('p').text().startsWith('You can create a website')).toBe(
true
)
})
test('localized intro links link to localized pages', async () => {
const $jaPages = await getDOM('/ja')
const $enPages = await getDOM('/en')
const $jaFeaturedLinks = $jaPages('[data-testid=article-list] a')
const $enFeaturedLinks = $enPages('[data-testid=article-list] a')
expect($jaFeaturedLinks.length).toBe($enFeaturedLinks.length)
expect($jaFeaturedLinks.eq(0).attr('href').startsWith('/ja')).toBe(true)
// Footer translations change very rarely if ever, so we can more
// reliably test those text values for the language
const footerText = []
$jaPages('footer a').each((index, element) => {
footerText.push($jaPages(element).text())
})
expect(footerText.some((elem) => japaneseCharacters.presentIn(elem)))
})
test('Enterprise user intro links have expected values', async () => {
2021-08-25 21:36:35 +03:00
const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/get-started`)
const $featuredLinks = $('[data-testid=article-list] a')
expect($featuredLinks).toHaveLength(11)
expect($featuredLinks.eq(0).attr('href')).toBe(
2021-08-25 21:36:35 +03:00
`/en/enterprise-server@${enterpriseServerReleases.latest}/github/getting-started-with-github/githubs-products`
)
expect($featuredLinks.eq(0).children('h3').text().startsWith("GitHub's products")).toBe(true)
expect(
2021-08-25 21:36:35 +03:00
$featuredLinks
.eq(0)
.children('p')
.text()
.startsWith("An overview of GitHub's products and pricing plans.")
).toBe(true)
})
Packages content redesign (#18847) * Add actions category name as first commit * Package reorganization: rename articles for "Learning..." and "Managing..." categories (#18880) * Initial prep work for Packages reorg * Make changes for Learning and Managing categories * Match file name to revised article title * Rework packages guides (#18902) * Create new directory * Delete guides directory and index.md link * Remove duplicated redirects to fix test * fix folder name * delete temporary directory of old content * Add Gradle article * Update landing page with new links * Update test to fix CI failure for deleted articles * Update links and titles for reorg-ed articles * Fix broken links Co-authored-by: hubwriter <hubwriter@github.com> * Update more changed article titles in links (#18911) * remove test line to test PR build failure * Add sections to permissions article * Add draft reusable * restore versioning tests * Remove accidental inclusion of new reusable from a different branch * Package registry content redesign updates (#18930) * Update container registry product variable * First round of edits * Update tidbit * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> * Update docker-vs-container-registry.md * Update authentication section to resolve bug/confusion * Revisions * Last touchups * Migration from intro article Co-authored-by: hubwriter <hubwriter@github.com> * Add versioned diagrams * Add packages actions revisions (#18956) * Add refreshed content * Update content/packages/managing-github-packages-using-github-actions-workflows/example-workflows-for-publishing-a-package.md Due to tightness of time on this I'm going to commit this suggestion so that I can merge this PR into the Packages megabranch. Co-authored-by: hubwriter <hubwriter@github.com> * Packages reorg: "Introduction to GitHub Packages" article (#18906) * Initial commit. Remove stray comma * Initial CC work - WiP * More changes for the Introduction article * Make changes as per Jessica's review * Fix broken reusable ref * improve test failure message and add clarifying comments * Packages reorganization: More updates to the 'Learn GitHub Packages' articles" (#18961) * Viewing - WiP * More updates to the 'Learn...' category * revisions to intro article * Add permissions article and make a few other streamlined updates * Fix links :herb: Co-authored-by: jmarlena <> * Apply suggestions from code review * Apply product input * Fix versioning * Apply some straight-forward suggested changes :zap: Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Add "GitHub Packages" before container registry mention * Standardize visibility & permsisions section into a reusable * Add link * Replace outdated link * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * :scissors: cut note * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Superseded rewrite? * bye single-use reusable * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Condense packages & actions conceptual content * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * remove "package registries" * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Add reusable * Add these redirects from the deleted containers conceptual article * Incorporate changes from main into retitled articles :dizzy: * Missing endif * Fix unexpected redirect behavior * Revamp and consolidate actions access settings * Further reading section * Last fix for now * standardize steps * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: jmarlena <> Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2021-05-01 02:28:27 +03:00
// If any of these tests fail, check to see if the content has changed and update text if needed.
test('product articles links respect versioning', async () => {
Packages content redesign (#18847) * Add actions category name as first commit * Package reorganization: rename articles for "Learning..." and "Managing..." categories (#18880) * Initial prep work for Packages reorg * Make changes for Learning and Managing categories * Match file name to revised article title * Rework packages guides (#18902) * Create new directory * Delete guides directory and index.md link * Remove duplicated redirects to fix test * fix folder name * delete temporary directory of old content * Add Gradle article * Update landing page with new links * Update test to fix CI failure for deleted articles * Update links and titles for reorg-ed articles * Fix broken links Co-authored-by: hubwriter <hubwriter@github.com> * Update more changed article titles in links (#18911) * remove test line to test PR build failure * Add sections to permissions article * Add draft reusable * restore versioning tests * Remove accidental inclusion of new reusable from a different branch * Package registry content redesign updates (#18930) * Update container registry product variable * First round of edits * Update tidbit * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> * Update docker-vs-container-registry.md * Update authentication section to resolve bug/confusion * Revisions * Last touchups * Migration from intro article Co-authored-by: hubwriter <hubwriter@github.com> * Add versioned diagrams * Add packages actions revisions (#18956) * Add refreshed content * Update content/packages/managing-github-packages-using-github-actions-workflows/example-workflows-for-publishing-a-package.md Due to tightness of time on this I'm going to commit this suggestion so that I can merge this PR into the Packages megabranch. Co-authored-by: hubwriter <hubwriter@github.com> * Packages reorg: "Introduction to GitHub Packages" article (#18906) * Initial commit. Remove stray comma * Initial CC work - WiP * More changes for the Introduction article * Make changes as per Jessica's review * Fix broken reusable ref * improve test failure message and add clarifying comments * Packages reorganization: More updates to the 'Learn GitHub Packages' articles" (#18961) * Viewing - WiP * More updates to the 'Learn...' category * revisions to intro article * Add permissions article and make a few other streamlined updates * Fix links :herb: Co-authored-by: jmarlena <> * Apply suggestions from code review * Apply product input * Fix versioning * Apply some straight-forward suggested changes :zap: Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Add "GitHub Packages" before container registry mention * Standardize visibility & permsisions section into a reusable * Add link * Replace outdated link * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * :scissors: cut note * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Superseded rewrite? * bye single-use reusable * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Condense packages & actions conceptual content * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * remove "package registries" * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Add reusable * Add these redirects from the deleted containers conceptual article * Incorporate changes from main into retitled articles :dizzy: * Missing endif * Fix unexpected redirect behavior * Revamp and consolidate actions access settings * Further reading section * Last fix for now * standardize steps * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: jmarlena <> Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2021-05-01 02:28:27 +03:00
const enterpriseVersionedLandingPage = `/en/enterprise-server@${enterpriseServerReleases.latest}/packages`
const $ = await getDOM(enterpriseVersionedLandingPage)
const $productArticlesLinks = $('[data-testid=product-articles-list] a')
let msg = `Product article links are not rendered as expected on ${enterpriseVersionedLandingPage}`
expect($productArticlesLinks.length, msg).toBeGreaterThan(2)
Packages content redesign (#18847) * Add actions category name as first commit * Package reorganization: rename articles for "Learning..." and "Managing..." categories (#18880) * Initial prep work for Packages reorg * Make changes for Learning and Managing categories * Match file name to revised article title * Rework packages guides (#18902) * Create new directory * Delete guides directory and index.md link * Remove duplicated redirects to fix test * fix folder name * delete temporary directory of old content * Add Gradle article * Update landing page with new links * Update test to fix CI failure for deleted articles * Update links and titles for reorg-ed articles * Fix broken links Co-authored-by: hubwriter <hubwriter@github.com> * Update more changed article titles in links (#18911) * remove test line to test PR build failure * Add sections to permissions article * Add draft reusable * restore versioning tests * Remove accidental inclusion of new reusable from a different branch * Package registry content redesign updates (#18930) * Update container registry product variable * First round of edits * Update tidbit * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> * Update docker-vs-container-registry.md * Update authentication section to resolve bug/confusion * Revisions * Last touchups * Migration from intro article Co-authored-by: hubwriter <hubwriter@github.com> * Add versioned diagrams * Add packages actions revisions (#18956) * Add refreshed content * Update content/packages/managing-github-packages-using-github-actions-workflows/example-workflows-for-publishing-a-package.md Due to tightness of time on this I'm going to commit this suggestion so that I can merge this PR into the Packages megabranch. Co-authored-by: hubwriter <hubwriter@github.com> * Packages reorg: "Introduction to GitHub Packages" article (#18906) * Initial commit. Remove stray comma * Initial CC work - WiP * More changes for the Introduction article * Make changes as per Jessica's review * Fix broken reusable ref * improve test failure message and add clarifying comments * Packages reorganization: More updates to the 'Learn GitHub Packages' articles" (#18961) * Viewing - WiP * More updates to the 'Learn...' category * revisions to intro article * Add permissions article and make a few other streamlined updates * Fix links :herb: Co-authored-by: jmarlena <> * Apply suggestions from code review * Apply product input * Fix versioning * Apply some straight-forward suggested changes :zap: Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Add "GitHub Packages" before container registry mention * Standardize visibility & permsisions section into a reusable * Add link * Replace outdated link * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * :scissors: cut note * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Superseded rewrite? * bye single-use reusable * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Condense packages & actions conceptual content * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * remove "package registries" * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Add reusable * Add these redirects from the deleted containers conceptual article * Incorporate changes from main into retitled articles :dizzy: * Missing endif * Fix unexpected redirect behavior * Revamp and consolidate actions access settings * Further reading section * Last fix for now * standardize steps * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: jmarlena <> Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2021-05-01 02:28:27 +03:00
// Confirm that the following Enterprise link IS included on this Enterprise page.
msg = `Enterprise article link is not rendered as expected on ${enterpriseVersionedLandingPage}`
expect(
$productArticlesLinks.text().includes('Working with a GitHub Packages registry'),
msg
).toBe(true)
Packages content redesign (#18847) * Add actions category name as first commit * Package reorganization: rename articles for "Learning..." and "Managing..." categories (#18880) * Initial prep work for Packages reorg * Make changes for Learning and Managing categories * Match file name to revised article title * Rework packages guides (#18902) * Create new directory * Delete guides directory and index.md link * Remove duplicated redirects to fix test * fix folder name * delete temporary directory of old content * Add Gradle article * Update landing page with new links * Update test to fix CI failure for deleted articles * Update links and titles for reorg-ed articles * Fix broken links Co-authored-by: hubwriter <hubwriter@github.com> * Update more changed article titles in links (#18911) * remove test line to test PR build failure * Add sections to permissions article * Add draft reusable * restore versioning tests * Remove accidental inclusion of new reusable from a different branch * Package registry content redesign updates (#18930) * Update container registry product variable * First round of edits * Update tidbit * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> * Update docker-vs-container-registry.md * Update authentication section to resolve bug/confusion * Revisions * Last touchups * Migration from intro article Co-authored-by: hubwriter <hubwriter@github.com> * Add versioned diagrams * Add packages actions revisions (#18956) * Add refreshed content * Update content/packages/managing-github-packages-using-github-actions-workflows/example-workflows-for-publishing-a-package.md Due to tightness of time on this I'm going to commit this suggestion so that I can merge this PR into the Packages megabranch. Co-authored-by: hubwriter <hubwriter@github.com> * Packages reorg: "Introduction to GitHub Packages" article (#18906) * Initial commit. Remove stray comma * Initial CC work - WiP * More changes for the Introduction article * Make changes as per Jessica's review * Fix broken reusable ref * improve test failure message and add clarifying comments * Packages reorganization: More updates to the 'Learn GitHub Packages' articles" (#18961) * Viewing - WiP * More updates to the 'Learn...' category * revisions to intro article * Add permissions article and make a few other streamlined updates * Fix links :herb: Co-authored-by: jmarlena <> * Apply suggestions from code review * Apply product input * Fix versioning * Apply some straight-forward suggested changes :zap: Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Add "GitHub Packages" before container registry mention * Standardize visibility & permsisions section into a reusable * Add link * Replace outdated link * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * :scissors: cut note * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Superseded rewrite? * bye single-use reusable * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Condense packages & actions conceptual content * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * remove "package registries" * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Add reusable * Add these redirects from the deleted containers conceptual article * Incorporate changes from main into retitled articles :dizzy: * Missing endif * Fix unexpected redirect behavior * Revamp and consolidate actions access settings * Further reading section * Last fix for now * standardize steps * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: jmarlena <> Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2021-05-01 02:28:27 +03:00
// Confirm that the following Dotcom-only links are NOT included on this Enterprise page.
msg = `Dotcom-only article link is rendered, but should not be, on ${enterpriseVersionedLandingPage}`
expect($productArticlesLinks.text().includes('Working with the Container registry')).toBe(
false
)
expect(
$productArticlesLinks
.text()
.includes('Migrating to the Container registry from the Docker registry'),
msg
).toBe(false)
})
})
describe('context.page object', () => {
test('returns modified array of links', async () => {
const gettingStartedLinks = await getJSON('/en?json=featuredLinks.gettingStarted')
const expectedFirstLink = {
href: '/en/get-started/quickstart/set-up-git',
title: 'Set up Git',
}
expect(gettingStartedLinks[0].href).toEqual(expectedFirstLink.href)
expect(gettingStartedLinks[0].title).toEqual(expectedFirstLink.title)
expect(gettingStartedLinks[0].intro.startsWith('At the heart of GitHub')).toBe(true)
})
test('returns raw array of links on the page object', async () => {
const rawGettingStartedLinks = await getJSON('/en?json=page.featuredLinks.gettingStarted')
expect(rawGettingStartedLinks[0]).toEqual('/get-started/quickstart/set-up-git')
})
})
})