Merge branch 'main' of github.com:github/docs-internal into add-release-notes-tests
This commit is contained in:
@@ -17,22 +17,35 @@ describe('browser search', () => {
|
||||
|
||||
it('works on the homepage', async () => {
|
||||
await page.goto('http://localhost:4001/en')
|
||||
await page.click('#search-input-container input[type="search"]')
|
||||
await page.type('#search-input-container input[type="search"]', 'actions')
|
||||
await page.click('[data-testid=site-search-input]')
|
||||
await page.type('[data-testid=site-search-input]', 'actions')
|
||||
await page.waitForSelector('.ais-Hits')
|
||||
const hits = await page.$$('.ais-Hits-item')
|
||||
expect(hits.length).toBeGreaterThan(5)
|
||||
})
|
||||
|
||||
it('works on article pages', async () => {
|
||||
it('works on mobile landing pages', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
await page.click('#search-input-container input[type="search"]')
|
||||
await page.type('#search-input-container input[type="search"]', 'workflows')
|
||||
await page.click('[data-testid=mobile-menu-button]')
|
||||
await page.click('[data-testid=mobile-header] [data-testid=site-search-input]')
|
||||
await page.type('[data-testid=mobile-header] [data-testid=site-search-input]', 'workflows')
|
||||
await page.waitForSelector('.ais-Hits')
|
||||
const hits = await page.$$('.ais-Hits-item')
|
||||
expect(hits.length).toBeGreaterThan(5)
|
||||
})
|
||||
|
||||
it('works on desktop landing pages', async () => {
|
||||
const initialViewport = page.viewport()
|
||||
await page.setViewport({ width: 1024, height: 768 })
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
await page.click('[data-testid=desktop-header] [data-testid=site-search-input]')
|
||||
await page.type('[data-testid=desktop-header] [data-testid=site-search-input]', 'workflows')
|
||||
await page.waitForSelector('.ais-Hits')
|
||||
const hits = await page.$$('.ais-Hits-item')
|
||||
expect(hits.length).toBeGreaterThan(5)
|
||||
page.setViewport(initialViewport)
|
||||
})
|
||||
|
||||
it('works on 404 error page', async () => {
|
||||
await page.goto('http://localhost:4001/en/404')
|
||||
await page.click('#search-input-container input[type="search"]')
|
||||
@@ -205,26 +218,43 @@ describe('platform specific content', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('card filters', () => {
|
||||
describe('code examples', () => {
|
||||
it('loads correctly', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
const shownCards = await page.$$('.js-filter-card:not(.d-none)')
|
||||
const shownNoResult = await page.$('.js-filter-card-no-results:not(.d-none)')
|
||||
const maxCards = await page.$eval('.js-filter-card-show-more', btn => parseInt(btn.dataset.jsFilterCardMax))
|
||||
expect(shownCards.length).toBe(maxCards)
|
||||
const shownCards = await page.$$('[data-testid=code-example-card]')
|
||||
const shownNoResult = await page.$('[data-testid=code-examples-no-results]')
|
||||
expect(shownCards.length).toBeGreaterThan(0)
|
||||
expect(shownNoResult).toBeNull()
|
||||
})
|
||||
|
||||
it('filters cards', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
await page.click('input.js-filter-card-filter')
|
||||
await page.type('input.js-filter-card-filter', 'issues')
|
||||
const shownCards = await page.$$('.js-filter-card:not(.d-none)')
|
||||
const showMoreClasses = await page.$eval('.js-filter-card-show-more', btn => Object.values(btn.classList))
|
||||
expect(showMoreClasses).toContain('d-none')
|
||||
await page.click('[data-testid=code-examples-input]')
|
||||
await page.type('[data-testid=code-examples-input]', 'issues')
|
||||
const shownCards = await page.$$('[data-testid=code-example-card]')
|
||||
expect(shownCards.length).toBeGreaterThan(1)
|
||||
})
|
||||
|
||||
it('shows more cards', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
const initialCards = await page.$$('[data-testid=code-example-card]')
|
||||
await page.click('[data-testid=code-examples-show-more]')
|
||||
const moreCards = await page.$$('[data-testid=code-example-card]')
|
||||
expect(moreCards.length).toBe(initialCards.length * 2)
|
||||
})
|
||||
|
||||
it('displays no result message', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
await page.click('[data-testid=code-examples-input]')
|
||||
await page.type('[data-testid=code-examples-input]', 'this should not work')
|
||||
const shownCards = await page.$$('[data-testid=code-example-card]')
|
||||
expect(shownCards.length).toBe(0)
|
||||
const noResultsMessage = await page.$('[data-testid=code-examples-no-results]')
|
||||
expect(noResultsMessage).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('filter cards', () => {
|
||||
it('works with select input', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions/guides')
|
||||
await page.select('.js-filter-card-filter-dropdown[name="type"]', 'overview')
|
||||
@@ -246,24 +276,6 @@ describe('card filters', () => {
|
||||
shownCardsAttrib.map(attrib => expect(attrib).toBe('overview'))
|
||||
expect(shownCards.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('shows more cards', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
const maxCards = await page.$eval('.js-filter-card-show-more', btn => parseInt(btn.dataset.jsFilterCardMax))
|
||||
await page.click('.js-filter-card-show-more')
|
||||
const shownCards = await page.$$('.js-filter-card:not(.d-none)')
|
||||
expect(shownCards.length).toBe(maxCards * 2)
|
||||
})
|
||||
|
||||
it('displays no result message', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
await page.click('input.js-filter-card-filter')
|
||||
await page.type('input.js-filter-card-filter', 'this should not work')
|
||||
const shownCards = await page.$$('.js-filter-card:not(.d-none)')
|
||||
expect(shownCards.length).toBe(0)
|
||||
const noResultsClasses = await page.$eval('.js-filter-card-no-results', elem => Object.values(elem.classList))
|
||||
expect(noResultsClasses).not.toContain('d-none')
|
||||
})
|
||||
})
|
||||
|
||||
describe('language banner', () => {
|
||||
@@ -312,7 +324,7 @@ describe('GraphQL Explorer', () => {
|
||||
describe('nextjs query param', () => {
|
||||
jest.setTimeout(60 * 1000)
|
||||
|
||||
it('conditionally renders through nextjs pipeline depending on FEATURE_NEXTJS value', async () => {
|
||||
it('landing page renders through nextjs pipeline depending on FEATURE_NEXTJS value', async () => {
|
||||
const flagVal = require('../../feature-flags.json').FEATURE_NEXTJS
|
||||
await page.goto('http://localhost:4001/en/actions?nextjs=')
|
||||
const IS_NEXTJS_PAGE = await page.evaluate(() => window.IS_NEXTJS_PAGE)
|
||||
@@ -320,12 +332,4 @@ describe('nextjs query param', () => {
|
||||
flagVal === true ? expect(nextWrapper).toBeDefined() : expect(nextWrapper).toBeNull()
|
||||
flagVal === true ? expect(IS_NEXTJS_PAGE).toBe(true) : expect(IS_NEXTJS_PAGE).toBe(false)
|
||||
})
|
||||
|
||||
it('does not render through nextjs pipeline when nextjs query param is missing', async () => {
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
const nextWrapper = await page.$('#__next')
|
||||
const IS_NEXTJS_PAGE = await page.evaluate(() => window.IS_NEXTJS_PAGE)
|
||||
expect(nextWrapper).toBeNull()
|
||||
expect(IS_NEXTJS_PAGE).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('featuredLinks', () => {
|
||||
|
||||
test('landing page intro links have expected properties', async () => {
|
||||
const $ = await getDOM('/en')
|
||||
const $featuredLinks = $('.featured-links a')
|
||||
const $featuredLinks = $('[data-testid=article-list] a')
|
||||
expect($featuredLinks).toHaveLength(9)
|
||||
expect($featuredLinks.eq(0).attr('href')).toBe('/en/github/getting-started-with-github/set-up-git')
|
||||
expect($featuredLinks.eq(0).children('h4').text().startsWith('Set up Git')).toBe(true)
|
||||
@@ -36,7 +36,7 @@ describe('featuredLinks', () => {
|
||||
|
||||
test('Enterprise user intro links have expected values', async () => {
|
||||
const $ = await getDOM(`/en/enterprise/${enterpriseServerReleases.latest}/user/insights`)
|
||||
const $featuredLinks = $('.featured-links a')
|
||||
const $featuredLinks = $('[data-testid=article-list] a')
|
||||
expect($featuredLinks).toHaveLength(6)
|
||||
expect($featuredLinks.eq(0).attr('href')).toBe(`/en/enterprise-server@${enterpriseServerReleases.latest}/insights/installing-and-configuring-github-insights/about-github-insights`)
|
||||
expect($featuredLinks.eq(0).children('h4').text().startsWith('About GitHub Insights')).toBe(true)
|
||||
@@ -44,21 +44,21 @@ describe('featuredLinks', () => {
|
||||
})
|
||||
|
||||
// If any of these tests fail, check to see if the content has changed and update text if needed.
|
||||
test('featured links respect versioning', async () => {
|
||||
test('product articles links respect versioning', async () => {
|
||||
const enterpriseVersionedLandingPage = `/en/enterprise-server@${enterpriseServerReleases.latest}/packages`
|
||||
const $ = await getDOM(enterpriseVersionedLandingPage)
|
||||
const $featuredLinks = $('.all-articles-list a')
|
||||
let msg = `Featured links are not rendered as expected on ${enterpriseVersionedLandingPage}`
|
||||
expect($featuredLinks.length, msg).toBeGreaterThan(2)
|
||||
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)
|
||||
|
||||
// Confirm that the following Enterprise link IS included on this Enterprise page.
|
||||
msg = `Enterprise featured link is not rendered as expected on ${enterpriseVersionedLandingPage}`
|
||||
expect($featuredLinks.text().includes('Working with a GitHub Packages registry'), msg).toBe(true)
|
||||
msg = `Enterprise article link is not rendered as expected on ${enterpriseVersionedLandingPage}`
|
||||
expect($productArticlesLinks.text().includes('Working with a GitHub Packages registry'), msg).toBe(true)
|
||||
|
||||
// Confirm that the following Dotcom-only links are NOT included on this Enterprise page.
|
||||
msg = `Dotcom-only featured link is rendered, but should not be, on ${enterpriseVersionedLandingPage}`
|
||||
expect($featuredLinks.text().includes('Enabling improved container support with the Container registry')).toBe(false)
|
||||
expect($featuredLinks.text().includes('Migrating to the Container registry from the Docker registry'), msg).toBe(false)
|
||||
msg = `Dotcom-only article link is rendered, but should not be, on ${enterpriseVersionedLandingPage}`
|
||||
expect($productArticlesLinks.text().includes('Enabling improved container support with the Container registry')).toBe(false)
|
||||
expect($productArticlesLinks.text().includes('Migrating to the Container registry from the Docker registry'), msg).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -251,6 +251,16 @@ describe('server', () => {
|
||||
const $ = await getDOM('/github/getting-started-with-github')
|
||||
expect($('h2#in-this-article').length).toBe(0)
|
||||
})
|
||||
|
||||
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')
|
||||
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')
|
||||
expect($('h2#in-this-article + ul li a[href="#package-ecosystem"]').length).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('image asset paths', () => {
|
||||
|
||||
@@ -20,15 +20,15 @@ describe('sidebar', () => {
|
||||
})
|
||||
|
||||
test('highlights active product on GitHub pages', async () => {
|
||||
expect($githubPage('.sidebar li.sidebar-product').length).toBe(1)
|
||||
expect($githubPage('.sidebar li.sidebar-product > a').text().trim()).toBe('GitHub.com')
|
||||
expect($githubPage('.sidebar-products li.sidebar-product').length).toBe(1)
|
||||
expect($githubPage('.sidebar-products li.sidebar-product > a').text().trim()).toBe('GitHub.com')
|
||||
})
|
||||
|
||||
test('includes links to external products like the CLI, Atom, Electron, and CodeQL', async () => {
|
||||
expect($homePage('.sidebar a[href="https://cli.github.com/manual"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar a[href="https://atom.io/docs"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar a[href="https://electronjs.org/docs"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar a[href="https://codeql.github.com/docs"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar-products a[href="https://cli.github.com/manual"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar-products a[href="https://atom.io/docs"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar-products a[href="https://electronjs.org/docs"]')).toHaveLength(1)
|
||||
expect($homePage('.sidebar-products a[href="https://codeql.github.com/docs"]')).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('adds an `is-current-page` class to the sidebar link to the current page', async () => {
|
||||
|
||||
Reference in New Issue
Block a user