Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve currently loaded Saved Query in Discover when page reloads #52323

Merged
merged 3 commits into from
Dec 6, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import { getIndexPatternId } from '../helpers/get_index_pattern_id';
import { registerTimefilterWithGlobalStateFactory } from '../../../../../ui/public/timefilter/setup_router';
import { FilterStateManager } from '../../../../data/public/filter/filter_manager';

const { savedQueryService } = data.query.savedQueries;
const { getSavedQuery } = data.query.savedQueries;

const fetchStatuses = {
UNINITIALIZED: 'uninitialized',
Expand Down Expand Up @@ -972,7 +972,7 @@ function discoverController(
return;
}
if (!$scope.savedQuery || newSavedQueryId !== $scope.savedQuery.id) {
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery) => {
getSavedQuery(newSavedQueryId).then((savedQuery) => {
$scope.$evalAsync(() => {
$scope.savedQuery = savedQuery;
updateStateFromSavedQuery(savedQuery);
Expand Down
12 changes: 12 additions & 0 deletions test/functional/apps/discover/_saved_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker']);
const browser = getService('browser');

const defaultSettings = {
defaultIndex: 'logstash-*',
Expand Down Expand Up @@ -86,6 +87,17 @@ export default function ({ getService, getPageObjects }) {
expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime);
});

it('preserves the currently loaded query when the page is reloaded', async () => {
await browser.refresh();
const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes();
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);
expect(timePickerValues.start).to.not.eql(PageObjects.timePicker.defaultStartTime);
expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime);
expect(await PageObjects.discover.getHitCount()).to.be('2,792');
expect(await savedQueryManagementComponent.getCurrentlyLoadedQueryID()).to.be('OkResponse');
});


it('allows saving changes to a currently loaded query via the saved query management component', async () => {
await queryBar.setQuery('response:404');
await savedQueryManagementComponent.updateCurrentlyLoadedQuery(
Expand Down
9 changes: 9 additions & 0 deletions test/functional/services/saved_query_management_component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export function SavedQueryManagementComponentProvider({ getService }: FtrProvide
const retry = getService('retry');

class SavedQueryManagementComponent {
public async getCurrentlyLoadedQueryID() {
await this.openSavedQueryManagementComponent();
try {
return await testSubjects.getVisibleText('~saved-query-list-item-selected');
} catch {
return undefined;
}
}

public async saveNewQuery(
name: string,
description: string,
Expand Down