[Lens] Fix URL query loss on redirect (#81475)

This commit is contained in:
Joe Reuter 2020-10-27 11:43:56 +01:00 committed by GitHub
parent 2dcfe2a99f
commit db0816f4a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View file

@ -97,9 +97,12 @@ export async function mountApp(
const redirectTo = (routeProps: RouteComponentProps<{ id?: string }>, savedObjectId?: string) => {
if (!savedObjectId) {
routeProps.history.push('/');
routeProps.history.push({ pathname: '/', search: routeProps.history.location.search });
} else {
routeProps.history.push(`/edit/${savedObjectId}`);
routeProps.history.push({
pathname: `/edit/${savedObjectId}`,
search: routeProps.history.location.search,
});
}
};

View file

@ -66,5 +66,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000');
await filterBar.hasFilter('ip', '97.220.3.248', false, true);
});
it('keeps time range and pinned filters after refreshing directly after saving', async () => {
// restore defaults so visualization becomes saveable
await security.testUser.restoreDefaults();
await PageObjects.lens.configureDimension({
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});
await PageObjects.lens.save('persistentcontext');
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
const timeRange = await PageObjects.timePicker.getTimeConfig();
expect(timeRange.start).to.equal('Sep 7, 2015 @ 06:31:44.000');
expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000');
await filterBar.hasFilter('ip', '97.220.3.248', false, true);
});
});
}