Skip to content

Commit

Permalink
Merge pull request github#30744 from github/repo-sync
Browse files Browse the repository at this point in the history
Repo sync
  • Loading branch information
docs-bot authored Dec 18, 2023
2 parents 7c2698b + 61f4f17 commit 0a8ba4e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 33 deletions.
2 changes: 0 additions & 2 deletions src/frame/components/context/MainContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export type MainContextT = {

enterpriseServerVersions: Array<string>

searchVersions: Record<string, string>
nonEnterpriseDefaultVersion: string

status: number
Expand Down Expand Up @@ -263,7 +262,6 @@ export const getMainContext = async (req: any, res: any): Promise<MainContextT>
// the product sidebar or the rest sidebar.
sidebarTree: (includeSidebarTree && req.context.sidebarTree) || null,
featureFlags: {},
searchVersions: req.context.searchVersions,
nonEnterpriseDefaultVersion: req.context.nonEnterpriseDefaultVersion,
status: res.statusCode,
fullUrl: req.protocol + '://' + req.get('host') + req.originalUrl,
Expand Down
2 changes: 0 additions & 2 deletions src/frame/middleware/context/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '#src/frame/lib/path-utils.js'
import productNames from '#src/products/lib/product-names.js'
import warmServer from '#src/frame/lib/warm-server.js'
import searchVersions from '#src/search/lib/versions.js'
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js'
import { getDataByLanguage, getUIDataMerged } from '#src/data-directory/lib/get-data.js'

Expand Down Expand Up @@ -59,7 +58,6 @@ export default async function contextualize(req, res, next) {
req.context.getDottedData = (dottedPath) => getDataByLanguage(dottedPath, req.language)
req.context.siteTree = siteTree
req.context.pages = pageMap
req.context.searchVersions = searchVersions
req.context.nonEnterpriseDefaultVersion = nonEnterpriseDefaultVersion
req.context.initialRestVersioningReleaseDate =
allVersions[nonEnterpriseDefaultVersion].apiVersions[0]
Expand Down
6 changes: 3 additions & 3 deletions src/ghes-releases/scripts/sync-automated-pipeline-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const { allVersions } = await import('#src/versions/lib/all-versions.js')
// Currently, this is only ghes- but if we had more than one type of
// numbered release it would get all of them.
const numberedReleaseBaseNames = Array.from(
new Set([
...Object.values(allVersions)
new Set(
Object.values(allVersions)
.filter((version) => version.hasNumberedReleases)
.map((version) => version.openApiBaseName),
]),
),
)

// A list of currently supported versions (calendar date inclusive)
Expand Down
13 changes: 0 additions & 13 deletions src/search/lib/versions.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/search/pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
const req = context.req as any
const res = context.res as any

const version = req.context.currentVersion

const searchVersion = req.context.searchVersions[Array.isArray(version) ? version[0] : version]
if (!searchVersion) {
// E.g. someone loaded `/en/[email protected]/search`
// That's going to 404 in the XHR later but it simply shouldn't be
// a valid starting page.
return {
notFound: true,
}
}

const mainContext = await getMainContext(req, res)
addUINamespaces(req, mainContext.data.ui, ['search_results'])

Expand Down
9 changes: 8 additions & 1 deletion src/search/tests/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, jest } from '@jest/globals'

import { getDOM } from '#src/tests/helpers/e2etest.js'
import { get, getDOM } from '#src/tests/helpers/e2etest.js'

describe('search results page', () => {
jest.setTimeout(5 * 60 * 1000)
Expand All @@ -27,4 +27,11 @@ describe('search results page', () => {
expect(h1Text).toMatch(/peterbe/)
expect($('title').text()).toMatch(/Search results for "peterbe"/)
})

test('invalid version prefix 404s', async () => {
const res = await get(
`/en/[email protected]/search?${new URLSearchParams({ query: 'peterbe' })}`,
)
expect(res.statusCode).toBe(404)
})
})

0 comments on commit 0a8ba4e

Please sign in to comment.