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
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