Skip to content

Commit

Permalink
Upgrade EUI to v31.4.0 (elastic#89648)
Browse files Browse the repository at this point in the history
* Bump EUI to v31.4.0

* fix datagrid functional tests

* fix Lens unit tests

* fix table cell filter test

* Fix discover grid doc view test

* stabilize data table tests

* fix dashboard embeddable datagrid test

* Fix x-pack functional tests

* fix ml accessibility tests

* Fix discover grid context test

* Adapt expected nr of documents being displayed

* stabilize Lens a11y tests and skip data table

* Fix 2 ml functional tests

* enable lens datatable test; disable axe rule for datatable

* fix ml test

* fix Lens table test

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Joe Reuter <[email protected]>
Co-authored-by: Matthias Wilhelm <[email protected]>
Co-authored-by: Michail Yasonik <[email protected]>
  • Loading branch information
5 people committed Feb 5, 2021
1 parent 6582eaa commit be3b93b
Show file tree
Hide file tree
Showing 22 changed files with 207 additions and 150 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@elastic/datemath": "link:packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^7.12.0-canary",
"@elastic/ems-client": "7.11.0",
"@elastic/eui": "31.3.0",
"@elastic/eui": "31.4.0",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/node-crypto": "1.2.1",
Expand Down
4 changes: 4 additions & 0 deletions test/accessibility/services/a11y/analyze_with_axe.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export function analyzeWithAxe(context, options, callback) {
id: 'aria-roles',
selector: '[data-test-subj="comboBoxSearchInput"] *',
},
{
id: 'aria-required-parent',
selector: '[class=*"euiDataGridRowCell"][role="gridcell"] ',
},
],
});
return window.axe.run(context, options);
Expand Down
7 changes: 5 additions & 2 deletions test/functional/apps/dashboard/embeddable_data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('saved search filters', function () {
it('are added when a cell filter is clicked', async function () {
await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search');
await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`);
await find.clickByCssSelector(`[role="gridcell"]:nth-child(3)`);
// needs a short delay between becoming visible & being clickable
await PageObjects.common.sleep(250);
await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`);
await PageObjects.header.waitUntilLoadingHasFinished();
await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`);
await find.clickByCssSelector(`[role="gridcell"]:nth-child(3)`);
await PageObjects.common.sleep(250);
await find.clickByCssSelector(`[data-test-subj="filterForButton"]`);
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(2);
Expand Down
1 change: 1 addition & 0 deletions test/functional/apps/discover/_data_grid_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('discover data grid context tests', () => {
before(async () => {
await esArchiver.load('discover');
await esArchiver.loadIfNeeded('logstash_functional');
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await kibanaServer.uiSettings.update(defaultSettings);
Expand Down
6 changes: 2 additions & 4 deletions test/functional/apps/discover/_data_grid_doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
};

describe('discover data grid doc table', function describeIndexTests() {
const defaultRowsLimit = 25;

before(async function () {
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');
Expand All @@ -38,10 +36,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({});
});

it('should show the first 50 rows by default', async function () {
it('should show the first 12 rows by default', async function () {
// with the default range the number of hits is ~14000
const rows = await dataGrid.getDocTableRows();
expect(rows.length).to.be(defaultRowsLimit);
expect(rows.length).to.be(12);
});

it('should refresh the table content when changing time window', async function () {
Expand Down
7 changes: 4 additions & 3 deletions test/functional/apps/discover/_data_grid_field_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dataGrid.clickDocSortAsc();
await PageObjects.discover.waitUntilSearchingHasFinished();

await retry.try(async function tryingForTime() {
const rowData = await dataGrid.getFields();
expect(rowData[0][0].startsWith(expectedTimeStamp)).to.be.ok();
await retry.waitFor('first cell contains expected timestamp', async () => {
const cell = await dataGrid.getCellElement(1, 2);
const text = await cell.getVisibleText();
return text === expectedTimeStamp;
});
});

Expand Down
18 changes: 10 additions & 8 deletions test/functional/apps/visualize/_data_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should apply correct filter', async () => {
await PageObjects.visChart.filterOnTableCell(1, 3);
await PageObjects.visChart.waitForVisualizationRenderingStabilized();
const data = await PageObjects.visChart.getTableVisContent();
expect(data).to.be.eql([
['png', '1,373'],
['gif', '918'],
['Other', '445'],
]);
await retry.try(async () => {
await PageObjects.visChart.filterOnTableCell(1, 3);
await PageObjects.visChart.waitForVisualizationRenderingStabilized();
const data = await PageObjects.visChart.getTableVisContent();
expect(data).to.be.eql([
['png', '1,373'],
['gif', '918'],
['Other', '445'],
]);
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const filterBar = getService('filterBar');
const renderable = getService('renderable');
const retry = getService('retry');
const dashboardAddPanel = getService('dashboardAddPanel');
const PageObjects = getPageObjects([
'common',
Expand Down Expand Up @@ -66,13 +67,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.clickNewDashboard();
await dashboardAddPanel.addVisualization(vizName1);

// hover and click on cell to filter
await PageObjects.visChart.filterOnTableCell(1, 2);
await retry.try(async () => {
// hover and click on cell to filter
await PageObjects.visChart.filterOnTableCell(1, 2);

await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.be(1);
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.be(1);
});

await filterBar.removeAllFilters();
});
Expand Down
35 changes: 19 additions & 16 deletions test/functional/apps/visualize/_embedding_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const filterBar = getService('filterBar');
const renderable = getService('renderable');
const embedding = getService('embedding');
const retry = getService('retry');
const PageObjects = getPageObjects([
'visualize',
'visEditor',
Expand Down Expand Up @@ -80,23 +81,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should allow to change timerange from the visualization in embedded mode', async () => {
await PageObjects.visChart.filterOnTableCell(1, 7);
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
await retry.try(async () => {
await PageObjects.visChart.filterOnTableCell(1, 7);
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();

const data = await PageObjects.visChart.getTableVisContent();
expect(data).to.be.eql([
['03:00', '0B', '1'],
['03:00', '1.953KB', '1'],
['03:00', '3.906KB', '1'],
['03:00', '5.859KB', '2'],
['03:10', '0B', '1'],
['03:10', '5.859KB', '1'],
['03:10', '7.813KB', '1'],
['03:15', '0B', '1'],
['03:15', '1.953KB', '1'],
['03:20', '1.953KB', '1'],
]);
const data = await PageObjects.visChart.getTableVisContent();
expect(data).to.be.eql([
['03:00', '0B', '1'],
['03:00', '1.953KB', '1'],
['03:00', '3.906KB', '1'],
['03:00', '5.859KB', '2'],
['03:10', '0B', '1'],
['03:10', '5.859KB', '1'],
['03:10', '7.813KB', '1'],
['03:15', '0B', '1'],
['03:15', '1.953KB', '1'],
['03:20', '1.953KB', '1'],
]);
});
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/visualize_chart_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export function VisualizeChartPageProvider({ getService, getPageObjects }: FtrPr
public async filterOnTableCell(columnIndex: number, rowIndex: number) {
await retry.try(async () => {
const cell = await dataGrid.getCellElement(rowIndex, columnIndex);
await cell.moveMouseTo();
await cell.focus();
const filterBtn = await testSubjects.findDescendant(
'tbvChartCell__filterForCellValue',
cell
Expand Down
108 changes: 57 additions & 51 deletions test/functional/services/data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { chunk } from 'lodash';
import { FtrProviderContext } from '../ftr_provider_context';
import { WebElementWrapper } from './lib/web_element_wrapper';

Expand All @@ -31,14 +32,11 @@ export function DataGridProvider({ getService, getPageObjects }: FtrProviderCont
const columns = $('.euiDataGridHeaderCell__content')
.toArray()
.map((cell) => $(cell).text());
const rows = $.findTestSubjects('dataGridRow')
const cells = $.findTestSubjects('dataGridRowCell')
.toArray()
.map((row) =>
$(row)
.find('.euiDataGridRowCell__truncate')
.toArray()
.map((cell) => $(cell).text())
);
.map((cell) => $(cell).text());

const rows = chunk(cells, columns.length);

return {
columns,
Expand All @@ -56,20 +54,18 @@ export function DataGridProvider({ getService, getPageObjects }: FtrProviderCont
cellDataTestSubj: string
): Promise<string[][]> {
const $ = await element.parseDomContent();
return $('[data-test-subj="dataGridRow"]')
const columnNumber = $('.euiDataGridHeaderCell__content').length;
const cells = $.findTestSubjects('dataGridRowCell')
.toArray()
.map((row) =>
$(row)
.findTestSubjects('dataGridRowCell')
.toArray()
.map((cell) =>
$(cell)
.findTestSubject(cellDataTestSubj)
.text()
.replace(/&nbsp;/g, '')
.trim()
)
.map((cell) =>
$(cell)
.findTestSubject(cellDataTestSubj)
.text()
.replace(/&nbsp;/g, '')
.trim()
);

return chunk(cells, columnNumber);
}

/**
Expand All @@ -90,62 +86,72 @@ export function DataGridProvider({ getService, getPageObjects }: FtrProviderCont
* @param columnIndex column index starting from 1 (1 means 1st column)
*/
public async getCellElement(rowIndex: number, columnIndex: number) {
const table = await find.byCssSelector('.euiDataGrid');
const $ = await table.parseDomContent();
const columnNumber = $('.euiDataGridHeaderCell__content').length;
return await find.byCssSelector(
`[data-test-subj="dataGridWrapper"] [data-test-subj="dataGridRow"]:nth-of-type(${
rowIndex + 1
})
[data-test-subj="dataGridRowCell"]:nth-of-type(${columnIndex})`
`[data-test-subj="dataGridWrapper"] [data-test-subj="dataGridRowCell"]:nth-of-type(${
columnNumber * (rowIndex - 1) + columnIndex + 1
})`
);
}
public async getFields() {
const rows = await find.allByCssSelector('.euiDataGridRow');

const result = [];
for (const row of rows) {
const cells = await row.findAllByClassName('euiDataGridRowCell__truncate');
const cellsText = [];
let cellIdx = 0;
for (const cell of cells) {
if (cellIdx > 0) {
cellsText.push(await cell.getVisibleText());
}
cellIdx++;
const cells = await find.allByCssSelector('.euiDataGridRowCell');

const rows: string[][] = [];
let rowIdx = -1;
for (const cell of cells) {
if (await cell.elementHasClass('euiDataGridRowCell--firstColumn')) {
// first column contains expand icon
rowIdx++;
rows[rowIdx] = [];
}
if (!(await cell.elementHasClass('euiDataGridRowCell--controlColumn'))) {
rows[rowIdx].push(await cell.getVisibleText());
}
result.push(cellsText);
}
return result;
return rows;
}

public async getTable(selector: string = 'docTable') {
return await testSubjects.find(selector);
}

public async getBodyRows(): Promise<WebElementWrapper[]> {
const table = await this.getTable();
return await table.findAllByTestSubject('dataGridRow');
public async getBodyRows(): Promise<WebElementWrapper[][]> {
return this.getDocTableRows();
}

/**
* Returns an array of rows (which are array of cells)
*/
public async getDocTableRows() {
const table = await this.getTable();
return await table.findAllByTestSubject('dataGridRow');
}

public async getAnchorRow(): Promise<WebElementWrapper> {
const table = await this.getTable();
return await table.findByTestSubject('~docTableAnchorRow');
const cells = await table.findAllByCssSelector('.euiDataGridRowCell');

const rows: WebElementWrapper[][] = [];
let rowIdx = -1;
for (const cell of cells) {
if (await cell.elementHasClass('euiDataGridRowCell--firstColumn')) {
rowIdx++;
rows[rowIdx] = [];
}
rows[rowIdx].push(cell);
}
return rows;
}

public async getRow(options: SelectOptions): Promise<WebElementWrapper> {
return options.isAnchorRow
? await this.getAnchorRow()
: (await this.getBodyRows())[options.rowIndex];
/**
* Returns an array of cells for that row
*/
public async getRow(options: SelectOptions): Promise<WebElementWrapper[]> {
return (await this.getBodyRows())[options.rowIndex];
}

public async clickRowToggle(
options: SelectOptions = { isAnchorRow: false, rowIndex: 0 }
): Promise<void> {
const row = await this.getRow(options);
const toggle = await row.findByTestSubject('~docTableExpandToggleColumn');
const toggle = await row[0];
await toggle.click();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ describe('DatatableComponent', () => {
/>
);

wrapper.find('[data-test-subj="dataGridRowCell"]').first().simulate('focus');

wrapper.find('[data-test-subj="lensDatatableFilterOut"]').first().simulate('click');

expect(onDispatchEvent).toHaveBeenCalledWith({
Expand Down Expand Up @@ -200,7 +202,9 @@ describe('DatatableComponent', () => {
/>
);

wrapper.find('[data-test-subj="lensDatatableFilterFor"]').at(3).simulate('click');
wrapper.find('[data-test-subj="dataGridRowCell"]').at(1).simulate('focus');

wrapper.find('[data-test-subj="lensDatatableFilterFor"]').first().simulate('click');

expect(onDispatchEvent).toHaveBeenCalledWith({
name: 'filter',
Expand Down Expand Up @@ -278,7 +282,9 @@ describe('DatatableComponent', () => {
/>
);

wrapper.find('[data-test-subj="lensDatatableFilterFor"]').at(1).simulate('click');
wrapper.find('[data-test-subj="dataGridRowCell"]').at(0).simulate('focus');

wrapper.find('[data-test-subj="lensDatatableFilterFor"]').first().simulate('click');

expect(onDispatchEvent).toHaveBeenCalledWith({
name: 'filter',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/accessibility/apps/lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
operation: 'date_histogram',
field: 'timestamp',
operation: 'terms',
field: 'DestCityName',
});

await PageObjects.lens.configureDimension({
Expand Down
Loading

0 comments on commit be3b93b

Please sign in to comment.