From 5b6852dffbca0c6848b682d49253526a96f53dfb Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 24 May 2022 16:10:03 -0400 Subject: [PATCH] rest reference pages should have body and lead in sync search (#27961) * rest reference pages should have body and lead in sync-search * tests passing --- components/rest/RestReferencePage.tsx | 5 ++++- tests/rendering/rest.js | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/rest/RestReferencePage.tsx b/components/rest/RestReferencePage.tsx index 41f84db0f2e7..e19455c63c38 100644 --- a/components/rest/RestReferencePage.tsx +++ b/components/rest/RestReferencePage.tsx @@ -97,7 +97,10 @@ export const RestReferencePage = ({ restOperations }: StructuredContentT) => { never render anything. It always just return null. */} {loadClientsideRedirectExceptions && } {lazyLoadHighlightJS && } -
+

{title}

{intro && ( diff --git a/tests/rendering/rest.js b/tests/rendering/rest.js index 559d38f36bcd..8b21d2ba1d0e 100644 --- a/tests/rendering/rest.js +++ b/tests/rendering/rest.js @@ -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' @@ -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) {