[Discover] Fix saved search embeddable rendering (#140264) (#140476)

* [Discover] fix rendering issue

* [Discover] add functional test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit c80de81964)

Co-authored-by: Dmitry Tomashevich <39378793+dimaanj@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2022-09-12 05:07:03 -06:00 committed by GitHub
parent 879e738202
commit eefb087116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View file

@ -469,6 +469,8 @@ export class SavedSearchEmbeddable
ReactDOM.unmountComponentAtNode(this.node);
}
this.node = domNode;
this.renderReactComponent(this.node, this.searchProps!);
}
private renderReactComponent(domNode: HTMLElement, searchProps: SearchProps) {

View file

@ -77,5 +77,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dataGrid.checkCurrentRowsPerPageToBe(10);
});
it('should render duplicate saved search embeddables', async () => {
await PageObjects.dashboard.switchToEditMode();
await addSearchEmbeddableToDashboard();
const [firstGridCell, secondGridCell] = await dataGrid.getAllCellElements();
const firstGridCellContent = await firstGridCell.getVisibleText();
const secondGridCellContent = await secondGridCell.getVisibleText();
expect(firstGridCellContent).to.be.equal(secondGridCellContent);
});
});
}

View file

@ -80,15 +80,24 @@ export class DataGridService extends FtrService {
.map((cell) => $(cell).text());
}
private getCellElementSelector(rowIndex: number = 0, columnIndex: number = 0) {
return `[data-test-subj="euiDataGridBody"] [data-test-subj="dataGridRowCell"][data-gridcell-column-index="${columnIndex}"][data-gridcell-row-index="${rowIndex}"]`;
}
/**
* Returns a grid cell element by row & column indexes.
* @param rowIndex data row index starting from 0 (0 means 1st row)
* @param columnIndex column index starting from 0 (0 means 1st column)
*/
public async getCellElement(rowIndex: number = 0, columnIndex: number = 0) {
return await this.find.byCssSelector(
`[data-test-subj="euiDataGridBody"] [data-test-subj="dataGridRowCell"][data-gridcell-column-index="${columnIndex}"][data-gridcell-row-index="${rowIndex}"]`
);
return await this.find.byCssSelector(this.getCellElementSelector(rowIndex, columnIndex));
}
/**
* The same as getCellElement, but useful when multiple data grids are on the page.
*/
public async getAllCellElements(rowIndex: number = 0, columnIndex: number = 0) {
return await this.find.allByCssSelector(this.getCellElementSelector(rowIndex, columnIndex));
}
public async getDocCount(): Promise<number> {