Skip to content

Commit

Permalink
[7.8] [Discover] Reload route when Reset Search is clicked (#66288) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal authored May 21, 2020
1 parent 931ed76 commit f3a6655
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ <h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
class="kuiLink"
type="button"
id="reload_saved_search"
data-test-subj="resetSavedSearch"
ng-click="resetQuery()"
>
{{::'kbn.discover.reloadSavedSearchButton' | i18n: {defaultMessage: 'Reset search'} }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ function discoverController(

$scope.resetQuery = function() {
history.push(`/discover/${encodeURIComponent($route.current.params.id)}`);
$route.reload();
};

$scope.newQuery = function() {
Expand Down
17 changes: 17 additions & 0 deletions test/functional/apps/discover/_discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ export default function({ getService, getPageObjects }) {
const isVisible = await PageObjects.discover.hasNoResults();
expect(isVisible).to.be(false);
});

it('should reload the saved search with persisted query to show the initial hit count', async function() {
// apply query some changes
await queryBar.setQuery('test');
await queryBar.submitQuery();
await retry.try(async function() {
expect(await PageObjects.discover.getHitCount()).to.be('22');
});

// reset to persisted state
await PageObjects.discover.clickResetSavedSearchButton();
const expectedHitCount = '14,004';
await retry.try(async function() {
expect(await queryBar.getQueryString()).to.be('');
expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount);
});
});
});

describe('query #2, which has an empty time range', () => {
Expand Down
6 changes: 6 additions & 0 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
await testSubjects.click('discoverOpenButton');
}

public async clickResetSavedSearchButton() {
await testSubjects.moveMouseTo('resetSavedSearch');
await testSubjects.click('resetSavedSearch');
await header.waitUntilLoadingHasFinished();
}

public async closeLoadSavedSearchPanel() {
await testSubjects.click('euiFlyoutCloseButton');
}
Expand Down

0 comments on commit f3a6655

Please sign in to comment.