Skip to content

Commit

Permalink
[Discover] Fix multiline display in classic table (#103499)
Browse files Browse the repository at this point in the history
* Restore CSS that broke multiline display

* Add functional test
  • Loading branch information
kertal authored Jul 8, 2021
1 parent b5e22c9 commit b589fe5
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.kbnDocTableCell__dataField {
white-space: pre-wrap;
}

.kbnDocTableCell__toggleDetails {
padding: $euiSizeXS 0 0 0!important;
}
Expand Down
49 changes: 49 additions & 0 deletions test/functional/apps/discover/_doc_table_newline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'discover']);
const find = getService('find');
const log = getService('log');
const retry = getService('retry');
const security = getService('security');

describe('discover doc table newline handling', function describeIndexTests() {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'kibana_message_with_newline']);
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/message_with_newline');
await kibanaServer.uiSettings.replace({
defaultIndex: 'newline-test',
'doc_table:legacy': true,
});
await PageObjects.common.navigateToApp('discover');
});
after(async () => {
await security.testUser.restoreDefaults();
esArchiver.unload('test/functional/fixtures/es_archiver/message_with_newline');
await kibanaServer.uiSettings.unset('defaultIndex');
await kibanaServer.uiSettings.unset('doc_table:legacy');
});

it('should break text on newlines', async function () {
await PageObjects.discover.clickFieldListItemToggle('message');
const dscTableRows = await find.allByCssSelector('.kbnDocTable__row');

await retry.waitFor('height of multi-line content > single-line content', async () => {
const heightWithoutNewline = await dscTableRows[0].getAttribute('clientHeight');
const heightWithNewline = await dscTableRows[1].getAttribute('clientHeight');
log.debug(`Without newlines: ${heightWithoutNewline}, With newlines: ${heightWithNewline}`);
return Number(heightWithNewline) > Number(heightWithoutNewline);
});
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_discover'));
loadTestFile(require.resolve('./_discover_histogram'));
loadTestFile(require.resolve('./_doc_table'));
loadTestFile(require.resolve('./_doc_table_newline'));
loadTestFile(require.resolve('./_filter_editor'));
loadTestFile(require.resolve('./_errors'));
loadTestFile(require.resolve('./_field_data'));
Expand Down
14 changes: 14 additions & 0 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ export default async function ({ readConfigFile }) {
},
kibana: [],
},
kibana_message_with_newline: {
elasticsearch: {
cluster: [],
indices: [
{
names: ['message_with_newline'],
privileges: ['read', 'view_index_metadata'],
field_security: { grant: ['*'], except: [] },
},
],
run_as: [],
},
kibana: [],
},

kibana_timefield: {
elasticsearch: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"type": "doc",
"value": {
"id": "index-pattern:newline-test",
"index": ".kibana",
"source": {
"index-pattern": {
"fields": "[]",
"title": "newline-test"
},
"type": "index-pattern"
}
}
}

{
"type": "doc",
"value": {
"id": "1",
"index": "newline-test",
"source": {
"message" : "no new line"
}
}
}

{
"type": "doc",
"value": {
"id": "2",
"index": "newline-test",
"source": {
"message" : "two\nnew\nlines"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "index",
"value": {
"index": "newline-test",
"settings": {
"index": {
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}

0 comments on commit b589fe5

Please sign in to comment.