Skip to content

Commit

Permalink
Merge pull request #18193 from github/repo-sync
Browse files Browse the repository at this point in the history
repo sync
  • Loading branch information
Octomerger authored May 24, 2022
2 parents 7db4b41 + cb4be85 commit cc30840
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion components/rest/RestReferencePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export const RestReferencePage = ({ restOperations }: StructuredContentT) => {
never render anything. It always just return null. */}
{loadClientsideRedirectExceptions && <ClientSideRedirectExceptions />}
{lazyLoadHighlightJS && <ClientSideHighlightJS />}
<div className={cx(styles.restOperation, 'px-3 px-md-6 my-4 container-xl')}>
<div
className={cx(styles.restOperation, 'px-3 px-md-6 my-4 container-xl')}
data-search="article-body"
>
<h1 className="mb-3">{title}</h1>
{intro && (
<Lead data-testid="lead" data-search="lead" className="markdown-body">
Expand Down
16 changes: 15 additions & 1 deletion tests/rendering/rest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { jest } from '@jest/globals'
import { jest, test } from '@jest/globals'
import slugger from 'github-slugger'

import { getDOM } from '../helpers/e2etest.js'
Expand Down Expand Up @@ -63,6 +63,20 @@ describe('REST references docs', () => {
const errorMessage = formatErrors(differences)
expect(Object.keys(differences).length, errorMessage).toBe(0)
})

test('REST reference pages have DOM markers needed for extracting search content', async () => {
// Pick an arbitrary REST reference page that is build from React
const $ = await getDOM('/en/rest/actions/artifacts')
const rootSelector = '[data-search=article-body]'
const $root = $(rootSelector)
expect($root.length).toBe(1)
// Within that, should expect a "lead" text.
// Note! Not all REST references pages have a lead. The one in this
// test does.
const leadSelector = '[data-search=lead] p'
const $lead = $root.find(leadSelector)
expect($lead.length).toBe(1)
})
})

function formatErrors(differences) {
Expand Down

0 comments on commit cc30840

Please sign in to comment.