1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/tests/routing/top-developer-site-path-redirects.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

51 lines
1.4 KiB
JavaScript

import { head } from '../helpers/supertest.js'
import readJsonFile from '../../lib/read-json-file.js'
import { jest } from '@jest/globals'
const topOldDeveloperSitePaths = readJsonFile('tests/fixtures/top-old-developer-site-paths.json')
jest.useFakeTimers()
describe('developer.github.com redirects', () => {
jest.setTimeout(30 * 60 * 1000)
it('responds with 200 for the top historical request paths', async () => {
// ignore paths that are not (yet?) being redirected from developer.github.com to docs.github.com
const ignoredPatterns = [
/^\/changes/,
'/forum', // can be top-level or nest under a GHE route
/^\/partnerships/,
'2.17',
'2.16',
'2.15',
]
// test a subset of the top paths
const pathsToCheck = 50
const paths = topOldDeveloperSitePaths
.filter((path) => !ignoredPatterns.some((pattern) => path.match(pattern)))
.slice(0, pathsToCheck)
const non200s = []
for (const path of paths) {
const { statusCode } = await head(path, { followRedirects: true })
if (statusCode !== 200) {
non200s.push(path)
}
}
// generate an object with empty values as the error message
const errorMessage = JSON.stringify(
non200s.reduce((acc, path) => {
acc[path] = ''
return acc
}, {}),
null,
2
)
expect(non200s, errorMessage).toEqual([])
})
})