Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
const automatedPageContext = getAutomatedPageContextFromRequest(req)
const enabledForApps = await getEnabledForApps(currentVersion, apiVersion)

// If getEnabledForApps came back as undefined, it means that nothing
// could be found for that `apiVersion`
if (!enabledForApps) {
return {
notFound: true,
}
}

return {
props: {
mainContext,
Expand Down
11 changes: 10 additions & 1 deletion tests/rendering/rest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jest, test } from '@jest/globals'
import { slug } from 'github-slugger'

import { getDOM } from '../helpers/e2etest.js'
import { get, getDOM } from '../helpers/e2etest.js'
import getRest, { getEnabledForApps, categoriesWithoutSubcategories } from '../../lib/rest/index.js'
import { isApiVersioned, allVersions } from '../../lib/all-versions.js'
import { getDiffOpenAPIContentRest } from '../../script/rest/test-open-api-schema.js'
Expand Down Expand Up @@ -61,6 +61,15 @@ describe('REST references docs', () => {
}
})

test('404 if unrecognized apiVersion', async () => {
const res = await get(
`/en/rest/overview/endpoints-available-for-github-apps?${new URLSearchParams({
apiVersion: 'junk',
})}`
)
expect(res.statusCode).toBe(404)
})

test('test the latest version of the OpenAPI schema categories/subcategories to see if it matches the content/rest directory', async () => {
const differences = await getDiffOpenAPIContentRest()
const errorMessage = formatErrors(differences)
Expand Down