* Scaffold files for migration * Move user-agent into unit suite * Nothing to move from browser suite * Migrate tests to translations/content * Migrate existing translation test to meta * No graphql tests to migrate * Migrate lint-translation-reporter * Migrate lint-translation-reporter * Remove languages-schema, unused * Restore languages-schema * Restore languages-schema * Migrate rendering * Migrate routing * Migrate most of unit * Remove dead files, comment out tests that aren't expected to work yet * Migrate from get-redirect * Migrate page and pages * Migrate linting code * Fix lint issues * Found a few more * Run prettier * Move crowdin-config test and helper * Update crowdin-config.js * Remove translation linting, crowdin config lint, reduce file count * Remove test that's been skipped for a year * Restore linting with note to remove later * Update lint-translation-reporter.js * Clean up rendering suite * Update rendering.js * Remove excessive describe blocks * Redirect tests * Clean up unit * Remove test that's never called * Don't compare early access * Rename test suites * Update "content" tests * Update files.js * Update search.js * Update files.js * Update files.js
46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
import { describe, jest } from '@jest/globals'
|
|
|
|
import { getDOM, getJSON } from '../helpers/e2etest.js'
|
|
import nonEnterpriseDefaultVersion from '../../lib/non-enterprise-default-version.js'
|
|
|
|
describe('mobile-only products nav', () => {
|
|
const cases = [
|
|
// Note the unversioned homepage at `/` does not have a product selected in the mobile dropdown
|
|
['/repositories', 'Repositories'],
|
|
// Enterprise server
|
|
['/en/enterprise/admin', 'Enterprise administrators'],
|
|
[
|
|
'/en/enterprise/get-started/importing-your-projects-to-github/importing-source-code-to-github/importing-a-git-repository-using-the-command-line',
|
|
'Get started',
|
|
],
|
|
|
|
['/desktop', 'GitHub Desktop'],
|
|
['/actions', 'GitHub Actions'],
|
|
]
|
|
|
|
test.each(cases)('on %p, renders current product %p', async (url, name) => {
|
|
expect((await getDOM(url))('[data-testid=product-picker] summary').text().trim()).toBe(name)
|
|
})
|
|
})
|
|
|
|
describe('products middleware', () => {
|
|
jest.setTimeout(5 * 60 * 1000)
|
|
|
|
test('adds res.context.activeProducts array', async () => {
|
|
const products = await getJSON('/en?json=activeProducts')
|
|
expect(Array.isArray(products)).toBe(true)
|
|
})
|
|
|
|
test('adds res.context.currentProduct string on homepage', async () => {
|
|
const currentProduct = await getJSON('/en?json=currentProduct')
|
|
expect(currentProduct).toBe('homepage')
|
|
})
|
|
|
|
test('adds res.context.currentProduct object', async () => {
|
|
const currentProduct = await getJSON(
|
|
`/en/${nonEnterpriseDefaultVersion}/actions?json=currentProduct`
|
|
)
|
|
expect(currentProduct).toBe('actions')
|
|
})
|
|
})
|