Skip to content

Commit

Permalink
[Discover][Embeddable] Fix search highlighting (elastic#197607)
Browse files Browse the repository at this point in the history
- Closes elastic#197195

## Summary

This PR fixes the search highlights for saved search panels on
Dashboard.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
jughosta authored Oct 25, 2024
1 parent 59ef6d4 commit 2b645d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const updateSearchSource = (
) => {
const { sortDir } = defaults;
searchSource.setField('size', sampleSize);
searchSource.setField('highlightAll', true);
searchSource.setField(
'sort',
getSortForSearchSource({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
});
});
}

0 comments on commit 2b645d5

Please sign in to comment.