Skip to content

Commit cc30840

Browse files
authored
Merge pull request #18193 from github/repo-sync
repo sync
2 parents 7db4b41 + cb4be85 commit cc30840

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

components/rest/RestReferencePage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export const RestReferencePage = ({ restOperations }: StructuredContentT) => {
9797
never render anything. It always just return null. */}
9898
{loadClientsideRedirectExceptions && <ClientSideRedirectExceptions />}
9999
{lazyLoadHighlightJS && <ClientSideHighlightJS />}
100-
<div className={cx(styles.restOperation, 'px-3 px-md-6 my-4 container-xl')}>
100+
<div
101+
className={cx(styles.restOperation, 'px-3 px-md-6 my-4 container-xl')}
102+
data-search="article-body"
103+
>
101104
<h1 className="mb-3">{title}</h1>
102105
{intro && (
103106
<Lead data-testid="lead" data-search="lead" className="markdown-body">

tests/rendering/rest.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { jest } from '@jest/globals'
1+
import { jest, test } from '@jest/globals'
22
import slugger from 'github-slugger'
33

44
import { getDOM } from '../helpers/e2etest.js'
@@ -63,6 +63,20 @@ describe('REST references docs', () => {
6363
const errorMessage = formatErrors(differences)
6464
expect(Object.keys(differences).length, errorMessage).toBe(0)
6565
})
66+
67+
test('REST reference pages have DOM markers needed for extracting search content', async () => {
68+
// Pick an arbitrary REST reference page that is build from React
69+
const $ = await getDOM('/en/rest/actions/artifacts')
70+
const rootSelector = '[data-search=article-body]'
71+
const $root = $(rootSelector)
72+
expect($root.length).toBe(1)
73+
// Within that, should expect a "lead" text.
74+
// Note! Not all REST references pages have a lead. The one in this
75+
// test does.
76+
const leadSelector = '[data-search=lead] p'
77+
const $lead = $root.find(leadSelector)
78+
expect($lead.length).toBe(1)
79+
})
6680
})
6781

6882
function formatErrors(differences) {

0 commit comments

Comments
 (0)