[Discover] Fix data-title attribute in savedsearch embeddable (#149078)

## Summary

Fixes an error where the `data-title` attribute in the `DiscoverGrid`
component was not getting updated when using a custom panel title via
the saved search embeddable `searchTitle` prop.

[This functional test was returning a false
positive](https://github.com/elastic/kibana/blob/main/test/functional/apps/dashboard/group5/data_shared_attributes.ts#L110-L124).
The previous test left a context menu open so the test was changing the
panel title of the first embeddable (a Lens embeddable) rather than the
saved search embeddable. As a result the bug in the saved search
embeddable was unnoticed.
This commit is contained in:
Nick Peihl 2023-01-19 09:22:22 -05:00 committed by GitHub
parent 55bb5c3070
commit ff5101d3c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 18 additions and 17 deletions

View file

@ -461,6 +461,7 @@ export class SavedSearchEmbeddable
);
searchProps.sharedItemTitle = this.panelTitle;
searchProps.searchTitle = this.panelTitle;
searchProps.rowHeightState = this.input.rowHeight || this.savedSearch.rowHeight;
searchProps.rowsPerPageState = this.input.rowsPerPage || this.savedSearch.rowsPerPage;
searchProps.filters = this.savedSearch.searchSource.getField('filter') as Filter[];

View file

@ -41,7 +41,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('are hidden in view mode', async function () {
await PageObjects.dashboard.saveDashboard(dashboardName);
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.expectMissingEditPanelAction();
await dashboardPanelActions.expectMissingRemovePanelAction();
});
@ -79,6 +78,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('visualization object edit menu', () => {
it('opens a visualization when edit link is clicked', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.header.waitUntilLoadingHasFinished();
const currentUrl = await browser.getCurrentUrl();
@ -120,6 +120,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('opens a saved search when edit link is clicked', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.header.waitUntilLoadingHasFinished();
const queryName = await PageObjects.discover.getCurrentQueryName();
@ -148,6 +149,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
before('expand panel to "full screen"', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
});

View file

@ -42,19 +42,19 @@ export class DashboardPanelActionsService extends FtrService {
}
async toggleContextMenu(parent?: WebElementWrapper) {
this.log.debug('toggleContextMenu');
this.log.debug(`toggleContextMenu(${parent})`);
await (parent ? parent.moveMouseTo() : this.testSubjects.moveMouseTo('dashboardPanelTitle'));
const toggleMenuItem = await this.findContextMenu(parent);
await toggleMenuItem.click();
}
async expectContextMenuToBeOpen() {
this.log.debug('expectContextMenuToBeOpen');
await this.testSubjects.existOrFail('embeddablePanelContextMenuOpen');
}
async openContextMenu(parent?: WebElementWrapper) {
this.log.debug(`openContextMenu(${parent}`);
if (await this.testSubjects.exists('embeddablePanelContextMenuOpen')) return;
await this.toggleContextMenu(parent);
await this.expectContextMenuToBeOpen();
}
@ -64,7 +64,9 @@ export class DashboardPanelActionsService extends FtrService {
}
async clickContextMenuMoreItem() {
const hasMoreSubPanel = await this.testSubjects.exists('embeddablePanelMore-mainMenu');
this.log.debug('clickContextMenuMoreItem');
await this.expectContextMenuToBeOpen();
const hasMoreSubPanel = await this.hasContextMenuMoreItem();
if (hasMoreSubPanel) {
await this.testSubjects.click('embeddablePanelMore-mainMenu');
}
@ -77,7 +79,7 @@ export class DashboardPanelActionsService extends FtrService {
async clickEdit() {
this.log.debug('clickEdit');
await this.openContextMenu();
await this.expectContextMenuToBeOpen();
const isActionVisible = await this.testSubjects.exists(EDIT_PANEL_DATA_TEST_SUBJ);
if (!isActionVisible) await this.clickContextMenuMoreItem();
await this.testSubjects.clickWhenNotDisabledWithoutRetry(EDIT_PANEL_DATA_TEST_SUBJ);
@ -98,7 +100,7 @@ export class DashboardPanelActionsService extends FtrService {
async clickExpandPanelToggle() {
this.log.debug(`clickExpandPanelToggle`);
await this.openContextMenu();
await this.expectContextMenuToBeOpen();
const isActionVisible = await this.testSubjects.exists(TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ);
if (!isActionVisible) await this.clickContextMenuMoreItem();
await this.testSubjects.click(TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ);
@ -342,7 +344,6 @@ export class DashboardPanelActionsService extends FtrService {
await this.customizePanel(panel);
await this.testSubjects.click('resetCustomEmbeddablePanelTitle');
await this.testSubjects.click('saveNewTitleButton');
await this.toggleContextMenu(panel);
}
async getActionWebElementByText(text: string): Promise<WebElementWrapper> {

View file

@ -80,7 +80,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('dashboard panel- more options in view mode', async () => {
await dashboardPanelActions.toggleContextMenu(header);
await dashboardPanelActions.openContextMenuMorePanel(header);
await a11y.testAppSnapshot();
});
@ -89,7 +88,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardPanelActions.openContextMenuMorePanel(header);
await dashboardPanelActions.clickExpandPanelToggle();
await a11y.testAppSnapshot();
await dashboardPanelActions.toggleContextMenu(header);
await dashboardPanelActions.openContextMenuMorePanel(header);
await dashboardPanelActions.clickExpandPanelToggle();
});

View file

@ -88,7 +88,7 @@ export default function canvasLensTest({ getService, getPageObjects }: FtrProvid
it('edits lens by-value embeddable', async () => {
const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount();
await dashboardPanelActions.toggleContextMenu();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.lens.saveAndReturn();
await retry.try(async () => {

View file

@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('edits map by-value embeddable', async () => {
const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount();
await dashboardPanelActions.toggleContextMenu();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.maps.saveMap('canvas test map');
const embeddableCount = await PageObjects.canvas.getEmbeddableCount();

View file

@ -71,7 +71,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('edits tsvb by-value embeddable', async () => {
const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount();
await dashboardPanelActions.toggleContextMenu();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.visualize.saveVisualizationAndReturn();
await retry.try(async () => {
@ -93,7 +93,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('edits vega by-value embeddable', async () => {
const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount();
await dashboardPanelActions.toggleContextMenu();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.visualize.saveVisualizationAndReturn();
await retry.try(async () => {

View file

@ -130,7 +130,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it(`does not allow a visualization to be edited`, async () => {
await PageObjects.dashboard.gotoDashboardEditMode('A Dashboard');
await panelActions.openContextMenu();
await panelActions.expectMissingEditPanelAction();
});
@ -141,7 +140,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it(`does not allow a map to be edited`, async () => {
await PageObjects.dashboard.gotoDashboardEditMode('dashboard with map');
await panelActions.openContextMenu();
await panelActions.expectMissingEditPanelAction();
});
});
@ -187,14 +185,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it(`allows a visualization to be edited`, async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardEditMode('A Dashboard');
await panelActions.openContextMenu();
await panelActions.expectExistsEditPanelAction();
});
it(`allows a map to be edited`, async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardEditMode('dashboard with map');
await panelActions.openContextMenu();
await panelActions.expectExistsEditPanelAction();
});

View file

@ -45,6 +45,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.dashboard.switchToEditMode();
}
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.maps.clickAddLayer();
await PageObjects.maps.selectEMSBoundariesSource();

View file

@ -58,6 +58,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('should show the open button for a compatible saved visualization with annotations and reference line', async () => {
await PageObjects.dashboard.switchToEditMode();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.lens.createLayer('annotations');
@ -87,6 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('should bring both dashboard context and visualization context to discover', async () => {
await PageObjects.dashboard.switchToEditMode();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await savedQueryManagementComponent.openSavedQueryManagementComponent();
await queryBar.switchQueryLanguage('lucene');