[Discover] Revert default grid back to legacy (#98508)

This commit is contained in:
Matthias Wilhelm 2021-04-30 10:29:41 +02:00 committed by GitHub
parent 036821d46a
commit a8d4145afb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 184 additions and 84 deletions

View file

@ -157,7 +157,7 @@ export const getUiSettings: () => Record<string, UiSettingsParams> = () => ({
name: i18n.translate('discover.advancedSettings.docTableVersionName', {
defaultMessage: 'Use legacy table',
}),
value: false,
value: true,
description: i18n.translate('discover.advancedSettings.docTableVersionDescription', {
defaultMessage:
'Discover uses a new table layout that includes better data sorting, drag-and-drop columns, and a full screen ' +

View file

@ -117,7 +117,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
});
it('saved search', async () => {
await dashboardExpect.savedSearchRowCount(11);
await dashboardExpect.savedSearchRowCount(10);
});
});

View file

@ -20,7 +20,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const browser = getService('browser');
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'timePicker']);
const PageObjects = getPageObjects([
'common',
'dashboard',
'discover',
'header',
'visualize',
'timePicker',
]);
describe('dashboard filter bar', () => {
before(async () => {
@ -174,13 +181,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('are added when a cell magnifying glass is clicked', async function () {
await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search');
await PageObjects.dashboard.waitForRenderComplete();
const documentCell = await dataGrid.getCellElement(1, 3);
await documentCell.click();
const expandCellContentButton = await documentCell.findByClassName(
'euiDataGridRowCell__expandButtonIcon'
);
await expandCellContentButton.click();
await testSubjects.click('filterForButton');
const isLegacyDefault = PageObjects.discover.useLegacyTable();
if (isLegacyDefault) {
await testSubjects.click('docTableCellFilter');
} else {
const documentCell = await dataGrid.getCellElement(1, 3);
await documentCell.click();
const expandCellContentButton = await documentCell.findByClassName(
'euiDataGridRowCell__expandButtonIcon'
);
await expandCellContentButton.click();
await testSubjects.click('filterForButton');
}
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(1);
});

View file

@ -12,9 +12,16 @@ import { PIE_CHART_VIS_NAME } from '../../page_objects/dashboard_page';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardExpect = getService('dashboardExpect');
const pieChart = getService('pieChart');
const dashboardVisualizations = getService('dashboardVisualizations');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'timePicker']);
const PageObjects = getPageObjects([
'dashboard',
'header',
'visualize',
'timePicker',
'discover',
]);
const browser = getService('browser');
const log = getService('log');
const kibanaServer = getService('kibanaServer');
@ -49,16 +56,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
name: 'saved search',
fields: ['bytes', 'agent'],
});
const initialRows = await dataGrid.getDocTableRows();
expect(initialRows.length).to.be(11);
// Set to time range with no data
await PageObjects.timePicker.setAbsoluteRange(
'Jan 1, 2000 @ 00:00:00.000',
'Jan 1, 2000 @ 01:00:00.000'
);
const noResults = await dataGrid.hasNoResults();
expect(noResults).to.be.ok();
const isLegacyDefault = await PageObjects.discover.useLegacyTable();
if (isLegacyDefault) {
await dashboardExpect.docTableFieldCount(150);
// Set to time range with no data
await PageObjects.timePicker.setAbsoluteRange(
'Jan 1, 2000 @ 00:00:00.000',
'Jan 1, 2000 @ 01:00:00.000'
);
await dashboardExpect.docTableFieldCount(0);
} else {
const initialRows = await dataGrid.getDocTableRows();
expect(initialRows.length).to.above(10);
// Set to time range with no data
await PageObjects.timePicker.setAbsoluteRange(
'Jan 1, 2000 @ 00:00:00.000',
'Jan 1, 2000 @ 01:00:00.000'
);
const noResults = await dataGrid.hasNoResults();
expect(noResults).to.be.ok();
}
});
it('Timepicker start, end, interval values are set by url', async () => {

View file

@ -45,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const marks = $('mark')
.toArray()
.map((mark) => $(mark).text());
expect(marks.length).to.be(11);
expect(marks.length).to.above(10);
});
it('removing a filter removes highlights', async function () {

View file

@ -40,10 +40,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({});
});
it('should show the first 11 rows by default', async function () {
it('should show 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(11);
expect(rows.length).to.be.above(0);
});
it('should refresh the table content when changing time window', async function () {

View file

@ -33,14 +33,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('shows a list of records of indices with date & date_nanos fields in the right order', async function () {
const rowData1 = await PageObjects.discover.getDocTableField(1);
expect(rowData1).to.be('Jan 1, 2019 @ 12:10:30.124000000');
const rowData2 = await PageObjects.discover.getDocTableField(2);
expect(rowData2).to.be('Jan 1, 2019 @ 12:10:30.123498765');
const rowData3 = await PageObjects.discover.getDocTableField(3);
expect(rowData3).to.be('Jan 1, 2019 @ 12:10:30.123456789');
const rowData4 = await PageObjects.discover.getDocTableField(4);
expect(rowData4).to.be('Jan 1, 2019 @ 12:10:30.123000000');
const isLegacy = await PageObjects.discover.useLegacyTable();
const rowData1 = await PageObjects.discover.getDocTableIndex(1);
expect(rowData1).to.contain('Jan 1, 2019 @ 12:10:30.124000000');
const rowData2 = await PageObjects.discover.getDocTableIndex(isLegacy ? 3 : 2);
expect(rowData2).to.contain('Jan 1, 2019 @ 12:10:30.123498765');
const rowData3 = await PageObjects.discover.getDocTableIndex(isLegacy ? 5 : 3);
expect(rowData3).to.contain('Jan 1, 2019 @ 12:10:30.123456789');
const rowData4 = await PageObjects.discover.getDocTableIndex(isLegacy ? 7 : 4);
expect(rowData4).to.contain('Jan 1, 2019 @ 12:10:30.123000000');
});
});
}

View file

@ -90,8 +90,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(await PageObjects.discover.getDocHeader()).to.contain('relatedContent');
});
const field = await PageObjects.discover.getDocTableField(1, 3);
expect(field).to.include.string('"og:description":');
const field = await PageObjects.discover.getDocTableIndex(1);
expect(field).to.contain('og:description');
const marks = await PageObjects.discover.getMarks();
expect(marks.length).to.be(0);

View file

@ -94,8 +94,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(await PageObjects.discover.getDocHeader()).to.contain('relatedContent');
});
const field = await PageObjects.discover.getDocTableField(1, 3);
expect(field).to.include.string('relatedContent.url');
const field = await PageObjects.discover.getDocTableIndex(1);
expect(field).to.contain('relatedContent.url');
const marks = await PageObjects.discover.getMarks();
expect(marks.length).to.be.above(0);

View file

@ -29,25 +29,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('verify the large string book present', async function () {
const ExpectedDoc =
'mybookProject Gutenberg EBook of Hamlet, by William Shakespeare' +
const expectedText =
'Project Gutenberg EBook of Hamlet, by William Shakespeare' +
' This eBook is for the use of anyone anywhere in the United States' +
' and most other parts of the world at no cost and with almost no restrictions whatsoever.' +
' You may copy it, give it away or re-use it under the terms of the' +
' Project Gutenberg License included with this eBook or online at www.gutenberg.org.' +
' If you are not located in the United States,' +
' youll have to check the laws of the country where you are' +
' located before using this ebook.' +
' Title: Hamlet Author: William Shakespeare Release Date: November 1998 [EBook #1524]' +
' Last Updated: December 30, 2017 Language: English Character set encoding:' +
' _id:1 _type: - _index:testlargestring _score:0';
' located before using this ebook.';
let rowData;
await PageObjects.common.navigateToApp('discover');
await retry.try(async function tryingForTime() {
rowData = await PageObjects.discover.getDocTableIndex(1);
log.debug('rowData.length=' + rowData.length);
expect(rowData.substring(0, 200)).to.be(ExpectedDoc.substring(0, 200));
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.contain(expectedText);
});
});

View file

@ -12,7 +12,6 @@ import { FtrProviderContext } from './ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const retry = getService('retry');
const dataGrid = getService('dataGrid');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
@ -100,15 +99,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('doc view includes runtime fields', async function () {
// navigate to doc view
await dataGrid.clickRowToggle();
const table = await PageObjects.discover.getDocTable();
const useLegacyTable = await PageObjects.discover.useLegacyTable();
await table.clickRowToggle();
// click the open action
await retry.try(async () => {
const rowActions = await dataGrid.getRowActions({ rowIndex: 0 });
const rowActions = await table.getRowActions({ rowIndex: 0 });
if (!rowActions.length) {
throw new Error('row actions empty, trying again');
}
await rowActions[0].click();
const idxToClick = useLegacyTable ? 1 : 0;
await rowActions[idxToClick].click();
});
const hasDocHit = await testSubjects.exists('doc-hit');

View file

@ -19,7 +19,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const toasts = getService('toasts');
const deployment = getService('deployment');
const dataGrid = getService('dataGrid');
describe('shared links', function describeIndexTests() {
let baseUrl: string;
@ -130,13 +129,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
return url.includes('sort:!(!(%27@timestamp%27,desc))');
});
const row = await dataGrid.getRow({ rowIndex: 0 });
const firstRowText = await Promise.all(
row.map(async (cell) => await cell.getVisibleText())
);
// sorting requested by ES should be correct
expect(firstRowText).to.contain('Sep 22, 2015 @ 23:50:13.253');
await retry.waitFor('document table to contain the right timestamp', async () => {
const firstRowText = await PageObjects.discover.getDocTableIndex(1);
return firstRowText.includes('Sep 22, 2015 @ 23:50:13.253');
});
});
});
});

View file

@ -101,7 +101,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
log.debug('Checking area, bar and heatmap charts rendered');
await dashboardExpect.seriesElementCount(15);
log.debug('Checking saved searches rendered');
await dashboardExpect.savedSearchRowCount(11);
await dashboardExpect.savedSearchRowCount(10);
log.debug('Checking input controls rendered');
await dashboardExpect.inputControlItemCount(3);
log.debug('Checking tag cloud rendered');

View file

@ -24,7 +24,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
const renderable = getService('renderable');
const listingTable = getService('listingTable');
const elasticChart = getService('elasticChart');
const PageObjects = getPageObjects(['common', 'header', 'visualize']);
const PageObjects = getPageObjects(['common', 'header', 'visualize', 'discover']);
interface SaveDashboardOptions {
/**
@ -223,12 +223,18 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
*/
public async expectToolbarPaginationDisplayed() {
const subjects = ['pagination-button-previous', 'pagination-button-next'];
const isLegacyDefault = PageObjects.discover.useLegacyTable();
if (isLegacyDefault) {
const subjects = ['btnPrevPage', 'btnNextPage', 'toolBarPagerText'];
await Promise.all(subjects.map(async (subj) => await testSubjects.existOrFail(subj)));
} else {
const subjects = ['pagination-button-previous', 'pagination-button-next'];
await Promise.all(subjects.map(async (subj) => await testSubjects.existOrFail(subj)));
const paginationListExists = await find.existsByCssSelector('.euiPagination__list');
if (!paginationListExists) {
throw new Error(`expected discover data grid pagination list to exist`);
await Promise.all(subjects.map(async (subj) => await testSubjects.existOrFail(subj)));
const paginationListExists = await find.existsByCssSelector('.euiPagination__list');
if (!paginationListExists) {
throw new Error(`expected discover data grid pagination list to exist`);
}
}
}

View file

@ -21,6 +21,7 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
const config = getService('config');
const defaultFindTimeout = config.get('timeouts.find');
const dataGrid = getService('dataGrid');
const kibanaServer = getService('kibanaServer');
class DiscoverPage {
public async getChartTimespan() {
@ -28,6 +29,15 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
return await el.getVisibleText();
}
public async getDocTable() {
const isLegacyDefault = await this.useLegacyTable();
if (isLegacyDefault) {
return docTable;
} else {
return dataGrid;
}
}
public async findFieldByName(name: string) {
const fieldSearch = await testSubjects.find('fieldFilterSearchInput');
await fieldSearch.type(name);
@ -78,7 +88,12 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
}
public async getColumnHeaders() {
return await dataGrid.getHeaderFields();
const isLegacy = await this.useLegacyTable();
if (isLegacy) {
return await docTable.getHeaderFields('embeddedSavedSearchDocTable');
}
const table = await this.getDocTable();
return await table.getHeaderFields();
}
public async openLoadSavedSearchPanel() {
@ -180,16 +195,28 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
}
public async getDocHeader() {
const docHeader = await dataGrid.getHeaders();
const table = await this.getDocTable();
const docHeader = await table.getHeaders();
return docHeader.join();
}
public async getDocTableRows() {
await header.waitUntilLoadingHasFinished();
return await dataGrid.getBodyRows();
const table = await this.getDocTable();
return await table.getBodyRows();
}
public async useLegacyTable() {
return (await kibanaServer.uiSettings.get('doc_table:legacy')) !== false;
}
public async getDocTableIndex(index: number) {
const isLegacyDefault = await this.useLegacyTable();
if (isLegacyDefault) {
const row = await find.byCssSelector(`tr.kbnDocTable__row:nth-child(${index})`);
return await row.getVisibleText();
}
const row = await dataGrid.getRow({ rowIndex: index - 1 });
const result = await Promise.all(row.map(async (cell) => await cell.getVisibleText()));
// Remove control columns
@ -201,10 +228,19 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
return await row.getVisibleText();
}
public async getDocTableField(index: number, cellIdx: number = 2) {
public async getDocTableField(index: number, cellIdx: number = -1) {
const isLegacyDefault = await this.useLegacyTable();
const usedDefaultCellIdx = isLegacyDefault ? 0 : 2;
const usedCellIdx = cellIdx === -1 ? usedDefaultCellIdx : cellIdx;
if (isLegacyDefault) {
const fields = await find.allByCssSelector(
`tr.kbnDocTable__row:nth-child(${index}) [data-test-subj='docTableField']`
);
return await fields[usedCellIdx].getVisibleText();
}
const row = await dataGrid.getRow({ rowIndex: index - 1 });
const result = await Promise.all(row.map(async (cell) => await cell.getVisibleText()));
return result[cellIdx];
return result[usedCellIdx];
}
public async skipToEndOfDocTable() {
@ -230,11 +266,21 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
}
public async clickDocSortDown() {
await dataGrid.clickDocSortAsc();
const isLegacyDefault = await this.useLegacyTable();
if (isLegacyDefault) {
await find.clickByCssSelector('.fa-sort-down');
} else {
await dataGrid.clickDocSortAsc();
}
}
public async clickDocSortUp() {
await dataGrid.clickDocSortDesc();
const isLegacyDefault = await this.useLegacyTable();
if (isLegacyDefault) {
await find.clickByCssSelector('.fa-sort-up');
} else {
await dataGrid.clickDocSortDesc();
}
}
public async isShowingDocViewer() {
@ -300,7 +346,11 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
}
public async clickFieldSort(field: string, text = 'Sort New-Old') {
await dataGrid.clickDocSortAsc(field, text);
const isLegacyDefault = await this.useLegacyTable();
if (isLegacyDefault) {
return await testSubjects.click(`docTableHeaderFieldSort_${field}`);
}
return await dataGrid.clickDocSortAsc(field, text);
}
public async clickFieldListItemToggle(field: string) {
@ -372,7 +422,13 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
}
public async removeHeaderColumn(name: string) {
await dataGrid.clickRemoveColumn(name);
const isLegacyDefault = await this.useLegacyTable();
if (isLegacyDefault) {
await testSubjects.moveMouseTo(`docTableHeader-${name}`);
await testSubjects.click(`docTableRemoveHeader-${name}`);
} else {
await dataGrid.clickRemoveColumn(name);
}
}
public async openSidebarFieldFilter() {

View file

@ -47,6 +47,14 @@ export function DashboardExpectProvider({ getService, getPageObjects }: FtrProvi
});
}
async docTableFieldCount(expectedCount: number) {
log.debug(`DashboardExpect.docTableFieldCount(${expectedCount})`);
await retry.try(async () => {
const docTableCells = await testSubjects.findAll('docTableField', findTimeout);
expect(docTableCells.length).to.be(expectedCount);
});
}
async fieldSuggestions(expectedFields: string[]) {
log.debug(`DashboardExpect.fieldSuggestions(${expectedFields})`);
const fields = await filterBar.getFilterEditorFields();
@ -200,14 +208,14 @@ export function DashboardExpectProvider({ getService, getPageObjects }: FtrProvi
await this.textWithinTestSubjectsExists(values, 'markdownBody');
}
async savedSearchRowCount(expectedCount: number) {
log.debug(`DashboardExpect.savedSearchRowCount(${expectedCount})`);
async savedSearchRowCount(expectedMinCount: number) {
log.debug(`DashboardExpect.savedSearchRowCount(${expectedMinCount})`);
await retry.try(async () => {
const savedSearchRows = await testSubjects.findAll(
'docTableExpandToggleColumn',
findTimeout
);
expect(savedSearchRows.length).to.be(expectedCount);
expect(savedSearchRows.length).to.be.above(expectedMinCount);
});
}

View file

@ -106,6 +106,10 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
.map((field: any) => $(field).text().trim());
}
public async getHeaders(selector?: string): Promise<string[]> {
return this.getHeaderFields(selector);
}
public async getTableDocViewRow(
detailsRow: WebElementWrapper,
fieldName: string

View file

@ -179,7 +179,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
log.debug('Checking area, bar and heatmap charts rendered');
await dashboardExpect.seriesElementCount(15);
log.debug('Checking saved searches rendered');
await dashboardExpect.savedSearchRowCount(11);
await dashboardExpect.savedSearchRowCount(10);
log.debug('Checking input controls rendered');
await dashboardExpect.inputControlItemCount(3);
log.debug('Checking tag cloud rendered');

View file

@ -75,9 +75,7 @@ export default function ({ getService, getPageObjects }) {
expect(hitCount).to.be('1');
});
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be(
'nameABC Companyname.keywordABC CompanyregionEASTregion.keywordEAST_iddoc1_indexdlstest_score0_type -'
);
expect(rowData).to.contain('EAST');
});
after('logout', async () => {
await PageObjects.security.forceLogout();

View file

@ -16,7 +16,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const inspector = getService('inspector');
const PageObjects = getPageObjects(['discover', 'common', 'timePicker', 'header', 'context']);
const searchSessions = getService('searchSessions');
const dataGrid = getService('dataGrid');
const retry = getService('retry');
describe('discover async search', () => {
@ -67,14 +66,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it('navigation to context cleans the session', async () => {
await PageObjects.common.clearAllToasts();
await dataGrid.clickRowToggle({ rowIndex: 0 });
const table = await PageObjects.discover.getDocTable();
const isLegacy = await PageObjects.discover.useLegacyTable();
await table.clickRowToggle({ rowIndex: 0 });
await retry.try(async () => {
const rowActions = await dataGrid.getRowActions({ rowIndex: 0 });
const rowActions = await table.getRowActions({ rowIndex: 0 });
if (!rowActions.length) {
throw new Error('row actions empty, trying again');
}
await rowActions[1].click();
const idxToClick = isLegacy ? 0 : 1;
await rowActions[idxToClick].click();
});
await PageObjects.context.waitUntilContextLoadingHasFinished();