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

[7.9] Fix view saved search through a visualization (#73040) #74044

Merged
merged 1 commit into from
Aug 1, 2020
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 @@ -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