diff --git a/src/plugins/discover/public/embeddable/utils/update_search_source.ts b/src/plugins/discover/public/embeddable/utils/update_search_source.ts index d866e4d05b4d7..47140911b0980 100644 --- a/src/plugins/discover/public/embeddable/utils/update_search_source.ts +++ b/src/plugins/discover/public/embeddable/utils/update_search_source.ts @@ -52,6 +52,7 @@ export const updateSearchSource = ( ) => { const { sortDir } = defaults; searchSource.setField('size', sampleSize); + searchSource.setField('highlightAll', true); searchSource.setField( 'sort', getSortForSearchSource({ diff --git a/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts b/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts index c6f5fd9724629..aeee4cd709b1f 100644 --- a/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts +++ b/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts @@ -19,6 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); + const find = getService('find'); const { common, dashboard, header, discover } = getPageObjects([ 'common', 'dashboard', @@ -143,5 +144,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addSearchEmbeddableToDashboard(); await testSubjects.existOrFail('unifiedDataTableToolbar'); }); + + it('should display search highlights', async () => { + await addSearchEmbeddableToDashboard(); + await queryBar.setQuery('Mozilla'); + await queryBar.submitQuery(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); + const marks = await find.allByCssSelector('.unifiedDataTable__cellValue mark'); + const highlights = await Promise.all( + marks.map(async (highlight) => await highlight.getVisibleText()) + ); + expect(highlights.length).to.be.greaterThan(0); + expect(highlights.every((text) => text === 'Mozilla')).to.be(true); + }); }); }