[TSVB][AggBased] Carry filters/query when navigating from dashboard -> editor -> lens (#172566)

## Summary

Closes https://github.com/elastic/kibana/issues/170076


![tsvb](5da192c6-2de4-4e02-a1c0-fa2a8fc72d44)

This bug happens when navigating from dashboard to legacy editor to
lens. From legacy editor to Lens works as expected

### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Stratoula Kalafateli 2023-12-05 18:42:45 +02:00 committed by GitHub
parent 07f62bf560
commit a5e7e3eb51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 9 deletions

View file

@ -309,6 +309,8 @@ export const getTopNavConfig = (
vis,
data.query.timefilter.timefilter
);
const searchFilters = data.query.filterManager.getAppFilters();
const searchQuery = data.query.queryString.getQuery();
const updatedWithMeta = {
...navigateToLensConfig,
embeddableId,
@ -319,6 +321,8 @@ export const getTopNavConfig = (
description: visInstance?.panelDescription || vis.description,
panelTimeRange: visInstance?.panelTimeRange,
isEmbeddable: Boolean(originatingApp),
...(searchFilters && { searchFilters }),
...(searchQuery && { searchQuery }),
};
if (navigateToLensConfig) {
hideLensBadge();

View file

@ -9,14 +9,16 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../ftr_provider_context';
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const { visualize, visualBuilder, lens, timeToVisualize, dashboard, canvas } = getPageObjects([
'visualBuilder',
'visualize',
'lens',
'timeToVisualize',
'dashboard',
'canvas',
]);
const { visualize, visualBuilder, lens, timeToVisualize, dashboard, canvas, header } =
getPageObjects([
'visualBuilder',
'visualize',
'lens',
'timeToVisualize',
'dashboard',
'canvas',
'header',
]);
const dashboardCustomizePanel = getService('dashboardCustomizePanel');
const dashboardBadgeActions = getService('dashboardBadgeActions');
const dashboardPanelActions = getService('dashboardPanelActions');
@ -24,6 +26,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const retry = getService('retry');
const panelActions = getService('dashboardPanelActions');
const dashboardAddPanel = getService('dashboardAddPanel');
const filterBar = getService('filterBar');
describe('Dashboard to TSVB to Lens', function describeIndexTests() {
before(async () => {
@ -32,8 +35,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it('should convert a by value TSVB viz to a Lens viz', async () => {
await visualBuilder.resetPage();
await testSubjects.click('visualizeSaveButton');
// adds filters
await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'css' });
await header.waitUntilLoadingHasFinished();
await testSubjects.click('visualizeSaveButton');
await timeToVisualize.saveFromModal('My TSVB to Lens viz 1', {
addToDashboard: 'new',
saveToLibrary: false,
@ -58,6 +64,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(await dimensions[1].getVisibleText()).to.be('Count of records');
});
expect(await filterBar.hasFilter('extension', 'css')).to.be(true);
await lens.replaceInDashboard();
await retry.try(async () => {
const embeddableCount = await canvas.getEmbeddableCount();