Skip to content

Commit

Permalink
Fix view saved search through a visualization (#73040) (#73065)
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof authored Jul 23, 2020
1 parent 216000a commit d4829e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function LinkedSearch({ savedSearch, eventEmitter }: LinkedSearchProps) {
}, [eventEmitter]);
const onClickViewInDiscover = useCallback(() => {
application.navigateToApp('discover', {
path: `#/${savedSearch.id}`,
path: `#/view/${savedSearch.id}`,
});
}, [application, savedSearch.id]);

Expand Down Expand Up @@ -128,7 +128,12 @@ export function LinkedSearch({ savedSearch, eventEmitter }: LinkedSearchProps) {
<div style={{ width: 260 }}>
<EuiText size="s">
<p>
<EuiButtonEmpty flush="left" onClick={onClickViewInDiscover} size="xs">
<EuiButtonEmpty
data-test-subj="viewSavedSearch"
flush="left"
onClick={onClickViewInDiscover}
size="xs"
>
<FormattedMessage
id="visDefaultEditor.sidebar.savedSearch.goToDiscoverButtonText"
defaultMessage="View this search in Discover"
Expand Down
22 changes: 22 additions & 0 deletions test/functional/apps/visualize/_linked_saved_searches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const filterBar = getService('filterBar');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects([
'common',
'discover',
Expand All @@ -35,12 +37,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('saved search visualizations from visualize app', function describeIndexTests() {
describe('linked saved searched', () => {
const savedSearchName = 'vis_saved_search';
let discoverSavedSearchUrlPath: string;

before(async () => {
await PageObjects.common.navigateToApp('discover');
await filterBar.addFilter('extension.raw', 'is', 'jpg');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.discover.saveSearch(savedSearchName);
discoverSavedSearchUrlPath = (await browser.getCurrentUrl()).split('?')[0];
});

it('should create a visualization from a saved search', async () => {
Expand All @@ -54,6 +58,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

it('should have a valid link to the saved search from the visualization', async () => {
await testSubjects.click('showUnlinkSavedSearchPopover');
await testSubjects.click('viewSavedSearch');
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.waitFor('wait discover load its breadcrumbs', async () => {
const discoverBreadcrumb = await PageObjects.discover.getCurrentQueryName();
return discoverBreadcrumb === savedSearchName;
});

const discoverURLPath = (await browser.getCurrentUrl()).split('?')[0];
expect(discoverURLPath).to.equal(discoverSavedSearchUrlPath);

// go back to visualize
await browser.goBack();
await PageObjects.header.waitUntilLoadingHasFinished();
});

it('should respect the time filter when linked to a saved search', async () => {
await PageObjects.timePicker.setAbsoluteRange(
'Sep 19, 2015 @ 06:31:44.000',
Expand Down

0 comments on commit d4829e6

Please sign in to comment.