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

[Discover] Fix columns management of saved search embeddable #140799

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class SavedSearchEmbeddable
this.searchProps &&
(titleChanged ||
this.isFetchRequired(this.searchProps) ||
this.isInputChangedAndRerenderRequired(this.searchProps))
this.isRerenderRequired(this.searchProps))
) {
this.pushContainerStateParamsToProps(this.searchProps);
}
Expand Down Expand Up @@ -420,11 +420,14 @@ export class SavedSearchEmbeddable
);
}

private isInputChangedAndRerenderRequired(searchProps?: SearchProps) {
private isRerenderRequired(searchProps?: SearchProps) {
if (!searchProps) {
return false;
}
return this.input.rowsPerPage !== searchProps.rowsPerPageState;
return (
this.input.rowsPerPage !== searchProps.rowsPerPageState ||
(this.input.columns && !isEqual(this.input.columns, searchProps.columns))
);
}

private async pushContainerStateParamsToProps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dataGrid.checkCurrentRowsPerPageToBe(10);
});

it('should render duplicate saved search embeddables', async () => {
it('should control columns correctly', async () => {
await PageObjects.dashboard.switchToEditMode();

const cell = await dataGrid.getCellElement(0, 2);
expect(await cell.getVisibleText()).to.be('Sep 22, 2015 @ 23:50:13.253');
await dataGrid.clickMoveColumnLeft('agent');

const cellAfter = await dataGrid.getCellElement(0, 2);
expect(await cellAfter.getVisibleText()).to.be(
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)'
);

await dataGrid.clickRemoveColumn('agent');
expect(await cell.getVisibleText()).to.be('Sep 22, 2015 @ 23:50:13.253');
});

it('should render duplicate saved search embeddables', async () => {
await addSearchEmbeddableToDashboard();
const [firstGridCell, secondGridCell] = await dataGrid.getAllCellElements();
const firstGridCellContent = await firstGridCell.getVisibleText();
Expand Down
28 changes: 17 additions & 11 deletions test/functional/services/data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,30 +254,36 @@ export class DataGridService extends FtrService {
});
}

public async clickDocSortAsc(field?: string, sortText = 'Sort Old-New') {
private async clickColumnMenuField(field?: string) {
if (field) {
await this.openColMenuByField(field);
} else {
await this.find.clickByCssSelector('.euiDataGridHeaderCell__button');
}
}

public async clickDocSortAsc(field?: string, sortText = 'Sort Old-New') {
await this.clickColumnMenuField(field);
await this.find.clickByButtonText(sortText);
}

public async clickDocSortDesc(field?: string, sortText = 'Sort New-Old') {
if (field) {
await this.openColMenuByField(field);
} else {
await this.find.clickByCssSelector('.euiDataGridHeaderCell__button');
}
await this.clickColumnMenuField(field);
await this.find.clickByButtonText(sortText);
}

public async clickMoveColumnRight(field?: string) {
await this.clickColumnMenuField(field);
await this.find.clickByButtonText('Move right');
}

public async clickMoveColumnLeft(field?: string) {
await this.clickColumnMenuField(field);
await this.find.clickByButtonText('Move left');
}

public async clickRemoveColumn(field?: string) {
if (field) {
await this.openColMenuByField(field);
} else {
await this.find.clickByCssSelector('.euiDataGridHeaderCell__button');
}
await this.clickColumnMenuField(field);
await this.find.clickByButtonText('Remove column');
}

Expand Down