diff --git a/components/Search.tsx b/components/Search.tsx index a06baea9f2fa..973ed138bb64 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -23,7 +23,8 @@ type Props = { // Homepage and 404 should be `isStandalone`, all others not // `updateSearchParams` should be false on the GraphQL explorer page export function Search({ isStandalone = false, updateSearchParams = true, children }: Props) { - const [query, setQuery] = useState('') + const router = useRouter() + const [query, setQuery] = useState(router.query.query || '') const [results, setResults] = useState>([]) const [activeHit, setActiveHit] = useState(0) const inputRef = useRef(null) @@ -32,18 +33,14 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr // Figure out language and version for index const { languages, searchVersions, nonEnterpriseDefaultVersion } = useMainContext() - const router = useRouter() // fall back to the non-enterprise default version (FPT currently) on the homepage, 404 page, etc. const version = searchVersions[currentVersion] || searchVersions[nonEnterpriseDefaultVersion] const language = (Object.keys(languages).includes(router.locale || '') && router.locale) || 'en' // If the user shows up with a query in the URL, go ahead and search for it useEffect(() => { - const params = new URLSearchParams(location.search) - if (params.has('query')) { - const xquery = params.get('query')?.trim() || '' - setQuery(xquery) - /* await */ fetchSearchResults(xquery) + if (router.query.query) { + /* await */ fetchSearchResults((router.query.query as string).trim()) } }, []) @@ -183,7 +180,7 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
diff --git a/components/Survey.tsx b/components/Survey.tsx index b4b81b2c1218..ceb786c5b472 100644 --- a/components/Survey.tsx +++ b/components/Survey.tsx @@ -35,7 +35,7 @@ export const Survey = () => { } return ( -
+

{t`able_to_find`} @@ -128,7 +128,7 @@ export const Survey = () => { )} - {state === ViewState.END &&

{t`feedback`}

} + {state === ViewState.END &&

{t`feedback`}

} ) } diff --git a/components/context/ProductSubLandingContext.tsx b/components/context/ProductSubLandingContext.tsx index 704a16013923..9c01841ee763 100644 --- a/components/context/ProductSubLandingContext.tsx +++ b/components/context/ProductSubLandingContext.tsx @@ -5,7 +5,7 @@ export type FeaturedTrack = { trackName: string title: string description: string - guides?: Array<{ href: string; page: { type: string }; title: string; intro: string }> + guides?: Array<{ href: string; page?: { type: string }; title: string; intro: string }> } | null export type ArticleGuide = { diff --git a/components/release-notes/GHESReleaseNotes.tsx b/components/release-notes/GHESReleaseNotes.tsx index bf79b99c06bc..93d6e4da8807 100644 --- a/components/release-notes/GHESReleaseNotes.tsx +++ b/components/release-notes/GHESReleaseNotes.tsx @@ -36,7 +36,7 @@ export function GHESReleaseNotes({ context }: Props) { {prevRelease ? ( {prevRelease} @@ -51,7 +51,7 @@ export function GHESReleaseNotes({ context }: Props) { {nextRelease ? ( {nextRelease} diff --git a/components/sublanding/ArticleCard.tsx b/components/sublanding/ArticleCard.tsx index 19f2ad009f40..d9004383013d 100644 --- a/components/sublanding/ArticleCard.tsx +++ b/components/sublanding/ArticleCard.tsx @@ -7,16 +7,17 @@ type Props = { export const ArticleCard = ({ card, typeLabel }: Props) => { return ( -
+

{card.title}

-
{typeLabel}
+
{typeLabel}

{card.intro}

{card.topics.length > 0 && (
{card.topics.map((topic) => { return ( diff --git a/components/sublanding/ArticleCards.tsx b/components/sublanding/ArticleCards.tsx index c94cb0306eff..4b4cc9d2d2bb 100644 --- a/components/sublanding/ArticleCards.tsx +++ b/components/sublanding/ArticleCards.tsx @@ -50,6 +50,7 @@ export const ArticleCards = () => { className="form-select f4 text-bold border-0 rounded-0 border-top box-shadow-none pl-0" name="type" aria-label="guide types" + data-testid="card-filter-dropdown" onChange={onChangeTypeFilter} > @@ -70,6 +71,7 @@ export const ArticleCards = () => { value={topicFilter} className="form-select f4 text-bold border-0 rounded-0 border-top box-shadow-none pl-0" name="topics" + data-testid="card-filter-dropdown" aria-label="guide topics" onChange={onChangeTopicFilter} > diff --git a/components/sublanding/LearningTrack.tsx b/components/sublanding/LearningTrack.tsx index 2e55420b1fc1..0b394fc6529b 100644 --- a/components/sublanding/LearningTrack.tsx +++ b/components/sublanding/LearningTrack.tsx @@ -53,7 +53,7 @@ export const LearningTrack = ({ track }: Props) => {
{guide.title}
- {t('guide_types')[guide.page.type]} + {t('guide_types')[guide.page?.type || '']}
{track?.guides && track?.guides?.indexOf(guide) + 1 === MAX_VISIBLE_GUIDES ? ( diff --git a/components/sublanding/SubLandingHero.tsx b/components/sublanding/SubLandingHero.tsx index 2da02fc4d53e..385d891e8c46 100644 --- a/components/sublanding/SubLandingHero.tsx +++ b/components/sublanding/SubLandingHero.tsx @@ -26,7 +26,7 @@ export const SubLandingHero = () => { )}
- {t('guide_types')[guide.page.type]} + {t('guide_types')[guide.page?.type || '']}

{guide.title}

diff --git a/content/codespaces/managing-your-codespaces/managing-access-and-security-for-your-codespaces.md b/content/codespaces/managing-your-codespaces/managing-access-and-security-for-your-codespaces.md index bb705b64bb66..b94f2dbabbdf 100644 --- a/content/codespaces/managing-your-codespaces/managing-access-and-security-for-your-codespaces.md +++ b/content/codespaces/managing-your-codespaces/managing-access-and-security-for-your-codespaces.md @@ -9,7 +9,7 @@ topics: {% data reusables.codespaces.release-stage %} -When you enable access and security for a repository owned by your user account, any codespaces that are created for that repository will have read and write permissions to all other repositories you own. If you want to restrict the repositories a codespace can access, you can limit to it to either the repository the codespace was opened for or specific repositories. You should only enable access and security for repositories you trust. +When you enable access and security for a repository owned by your user account, any codespaces that are created for that repository will have read permissions to all other repositories you own. If you want to restrict the repositories a codespace can access, you can limit to it to either the repository the codespace was opened for or specific repositories. You should only enable access and security for repositories you trust. {% data reusables.user_settings.access_settings %} {% data reusables.user_settings.codespaces-tab %} diff --git a/lib/rest/static/decorated/api.github.com.json b/lib/rest/static/decorated/api.github.com.json index e84fa7e1d64c..978ce27b4f5a 100644 --- a/lib/rest/static/decorated/api.github.com.json +++ b/lib/rest/static/decorated/api.github.com.json @@ -73494,6 +73494,16 @@ }, "descriptionHTML": "

Set to open or resolved to only list secret scanning alerts in a specific state.

" }, + { + "name": "secret_types", + "in": "query", + "description": "Set to a comma seperate list of secret_types to only list secret scanning alerts in for those types. Set to `all` to list all the secret scanning alerts. Default is `all`", + "required": false, + "schema": { + "type": "string" + }, + "descriptionHTML": "

Set to a comma seperate list of secret_types to only list secret scanning alerts in for those types. Set to all to list all the secret scanning alerts. Default is all

" + }, { "name": "page", "description": "Page number of the results to fetch.", diff --git a/lib/rest/static/decorated/ghes-3.1.json b/lib/rest/static/decorated/ghes-3.1.json index 4f345beb9e3d..ec9ea5b76ab3 100644 --- a/lib/rest/static/decorated/ghes-3.1.json +++ b/lib/rest/static/decorated/ghes-3.1.json @@ -71285,6 +71285,16 @@ }, "descriptionHTML": "

Set to open or resolved to only list secret scanning alerts in a specific state.

" }, + { + "name": "secret_types", + "in": "query", + "description": "Set to a comma seperate list of secret_types to only list secret scanning alerts in for those types. Set to `all` to list all the secret scanning alerts. Default is `all`", + "required": false, + "schema": { + "type": "string" + }, + "descriptionHTML": "

Set to a comma seperate list of secret_types to only list secret scanning alerts in for those types. Set to all to list all the secret scanning alerts. Default is all

" + }, { "name": "page", "description": "Page number of the results to fetch.", diff --git a/lib/rest/static/dereferenced/api.github.com.deref.json b/lib/rest/static/dereferenced/api.github.com.deref.json index d3acd48f4ad5..2d02990a8dde 100644 --- a/lib/rest/static/dereferenced/api.github.com.deref.json +++ b/lib/rest/static/dereferenced/api.github.com.deref.json @@ -323443,6 +323443,15 @@ ] } }, + { + "name": "secret_types", + "in": "query", + "description": "Set to a comma seperate list of secret_types to only list secret scanning alerts in for those types. Set to `all` to list all the secret scanning alerts. Default is `all`", + "required": false, + "schema": { + "type": "string" + } + }, { "name": "page", "description": "Page number of the results to fetch.", diff --git a/lib/rest/static/dereferenced/ghes-3.1.deref.json b/lib/rest/static/dereferenced/ghes-3.1.deref.json index d5076a61183d..735f3f270f57 100644 --- a/lib/rest/static/dereferenced/ghes-3.1.deref.json +++ b/lib/rest/static/dereferenced/ghes-3.1.deref.json @@ -307187,6 +307187,15 @@ ] } }, + { + "name": "secret_types", + "in": "query", + "description": "Set to a comma seperate list of secret_types to only list secret scanning alerts in for those types. Set to `all` to list all the secret scanning alerts. Default is `all`", + "required": false, + "schema": { + "type": "string" + } + }, { "name": "page", "description": "Page number of the results to fetch.", diff --git a/middleware/is-next-request.js b/middleware/is-next-request.js index 3bcddfebb1c1..93d8c3c69c8a 100644 --- a/middleware/is-next-request.js +++ b/middleware/is-next-request.js @@ -5,29 +5,6 @@ const versionIds = Object.keys(require('../lib/all-versions')) const { FEATURE_NEXTJS } = process.env; -const enabledSubSections = [ - // 'actions', - // 'admin', - "billing", - // "code-security", - // "codespaces", - "communities", - "desktop", - // "developers", - "discussions", - // 'early-access', - "education", - // 'github', - // "graphql", - // 'insights', - // "issues", - "organizations", - 'packages', - "pages", - "rest", - "sponsors", -]; - const homePageExp = pathToRegexp('/:locale/:versionId?') const productPageExp = pathToRegexp('/:locale/:versionId?/:productId') const subSectionExp = pathToRegexp('/:locale/:versionId?/:productId/:subSection*') @@ -53,8 +30,7 @@ module.exports = function isNextRequest(req, res, next) { } else if (productPageMatch && productIds.includes(productPageMatch[3])) { req.renderWithNextjs = true } else if (subSectionMatch) { - // depending on whether versionId is included the productId is in a different place - req.renderWithNextjs = enabledSubSections.includes(subSectionMatch[2]) || enabledSubSections.includes(subSectionMatch[3]) + req.renderWithNextjs = true } } } diff --git a/stylesheets/search.scss b/stylesheets/search.scss index f77abf851581..a0f5fdd294a1 100644 --- a/stylesheets/search.scss +++ b/stylesheets/search.scss @@ -86,7 +86,7 @@ header { margin-bottom: 0; } - @include breakpoint(md) { + @include breakpoint(lg) { #search-results-container { display: none; position: absolute; diff --git a/tests/browser/browser.js b/tests/browser/browser.js index 832ef659668e..73f9188902f4 100644 --- a/tests/browser/browser.js +++ b/tests/browser/browser.js @@ -43,7 +43,7 @@ describe('browser search', () => { await page.waitForSelector('.ais-Hits') const hits = await page.$$('.ais-Hits-item') expect(hits.length).toBeGreaterThan(5) - page.setViewport(initialViewport) + await page.setViewport(initialViewport) }) it('works on 404 error page', async () => { @@ -71,8 +71,10 @@ describe('browser search', () => { interceptedRequest.continue() }) - await newPage.click('#search-input-container input[type="search"]') - await newPage.type('#search-input-container input[type="search"]', 'test') + await newPage.click('[data-testid=mobile-menu-button]') + const searchInput = await newPage.$('[data-testid=mobile-header] [data-testid=site-search-input]') + await searchInput.click() + await searchInput.type('test') await newPage.waitForSelector('.search-result') }) @@ -92,8 +94,10 @@ describe('browser search', () => { interceptedRequest.continue() }) - await newPage.click('#search-input-container input[type="search"]') - await newPage.type('#search-input-container input[type="search"]', 'test') + await newPage.click('[data-testid=mobile-menu-button]') + const searchInput = await newPage.$('[data-testid=mobile-header] [data-testid=site-search-input]') + await searchInput.click() + await searchInput.type('test') await newPage.waitForSelector('.search-result') }) }) @@ -117,20 +121,20 @@ describe('survey', () => { }) // When I click the "Yes" button - await page.click('.js-survey [for=survey-yes]') + await page.click('[data-testid=survey-form] [for=survey-yes]') // (sent a POST request to /events) // I see the request for my email - await page.waitForSelector('.js-survey [type="email"]') + await page.waitForSelector('[data-testid=survey-form] [type="email"]') // When I fill in my email and submit the form - await page.type('.js-survey [type="email"]', 'test@example.com') + await page.type('[data-testid=survey-form] [type="email"]', 'test@example.com') await sleep(1000) - await page.click('.js-survey [type="submit"]') + await page.click('[data-testid=survey-form] [type="submit"]') // (sent a PUT request to /events/{id}) // I see the feedback - await page.waitForSelector('.js-survey [data-help-end]') + await page.waitForSelector('[data-testid=survey-end]') }) }) @@ -257,23 +261,23 @@ describe('code examples', () => { 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') - const shownCards = await page.$$('.js-filter-card:not(.d-none)') - const shownCardsAttrib = await page.$$eval('.js-filter-card:not(.d-none)', cards => - cards.map(card => card.dataset.type) + await page.select('[data-testid=card-filter-dropdown][name="type"]', 'overview') + const shownCards = await page.$$('[data-testid=article-card]') + const shownCardTypes = await page.$$eval('[data-testid=article-card-type]', cardTypes => + cardTypes.map(cardType => cardType.textContent) ) - shownCardsAttrib.map(attrib => expect(attrib).toBe('overview')) + shownCardTypes.map(type => expect(type).toBe('Overview')) expect(shownCards.length).toBeGreaterThan(0) }) it('works with select input on an Enterprise version', async () => { await page.goto(`http://localhost:4001/en/enterprise-server@${latest}/actions/guides`) - await page.select('.js-filter-card-filter-dropdown[name="type"]', 'overview') - const shownCards = await page.$$('.js-filter-card:not(.d-none)') - const shownCardsAttrib = await page.$$eval('.js-filter-card:not(.d-none)', cards => - cards.map(card => card.dataset.type) + await page.select('[data-testid=card-filter-dropdown][name="type"]', 'overview') + const shownCards = await page.$$('[data-testid=article-card]') + const shownCardTypes = await page.$$eval('[data-testid=article-card-type]', cardTypes => + cardTypes.map(cardType => cardType.textContent) ) - shownCardsAttrib.map(attrib => expect(attrib).toBe('overview')) + shownCardTypes.map(type => expect(type).toBe('Overview')) expect(shownCards.length).toBeGreaterThan(0) }) }) diff --git a/tests/rendering/sidebar.js b/tests/rendering/sidebar.js index e65829daa13e..08d72cb4e094 100644 --- a/tests/rendering/sidebar.js +++ b/tests/rendering/sidebar.js @@ -34,12 +34,12 @@ describe('sidebar', () => { test('adds an `is-current-page` class to the sidebar link to the current page', async () => { const url = '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings' const $ = await getDOM(url) - expect($('.sidebar .is-current-page').length).toBe(1) - expect($('.sidebar .is-current-page a').attr('href')).toContain(url) + expect($('.sidebar-products .is-current-page').length).toBe(1) + expect($('.sidebar-products .is-current-page a').attr('href')).toContain(url) }) test('does not display Early Access as a product', async () => { - expect($homePage('.sidebar li.sidebar-product[title*="Early"]').length).toBe(0) - expect($homePage('.sidebar li.sidebar-product[title*="early"]').length).toBe(0) + expect($homePage('.sidebar-products li.sidebar-product[title*="Early"]').length).toBe(0) + expect($homePage('.sidebar-products li.sidebar-product[title*="early"]').length).toBe(0) }) })