mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Fix _source formatting * Update unit test * Add functional test * Fix CI error, move functional test to the end
This commit is contained in:
parent
2dd01b6887
commit
c74da9cac9
3 changed files with 18 additions and 3 deletions
|
@ -48,7 +48,7 @@ export function createSourceFormat(FieldFormat) {
|
|||
SourceFormat.prototype._convert = {
|
||||
text: (value) => toJson(value),
|
||||
html: function sourceToHtml(source, field, hit) {
|
||||
if (!field) return this.getConverterFor('text')(source, field, hit);
|
||||
if (!field) return _.escape(this.getConverterFor('text')(source));
|
||||
|
||||
const highlights = (hit && hit.highlight) || {};
|
||||
const formatted = field.indexPattern.formatHit(hit);
|
||||
|
|
|
@ -43,8 +43,9 @@ describe('_source formatting', function () {
|
|||
}));
|
||||
|
||||
it('should use the text content type if a field is not passed', function () {
|
||||
const hit = _.first(hits);
|
||||
expect(convertHtml(hit._source)).to.be(`<span ng-non-bindable>${JSON.stringify(hit._source)}</span>`);
|
||||
const hit = { 'foo': 'bar', 'number': 42, 'hello': '<h1>World</h1>', 'also': 'with "quotes" or \'single quotes\'' };
|
||||
// eslint-disable-next-line
|
||||
expect(convertHtml(hit)).to.be('<span ng-non-bindable>{"foo":"bar","number":42,"hello":"<h1>World</h1>","also":"with \\"quotes\\" or 'single quotes'"}</span>');
|
||||
});
|
||||
|
||||
it('uses the _source, field, and hit to create a <dl>', function () {
|
||||
|
|
|
@ -175,5 +175,19 @@ export default function ({ getService, getPageObjects }) {
|
|||
'2015-09-20', '4,757',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should show correct data for a data table with top hits', async () => {
|
||||
await PageObjects.visualize.navigateToNewVisualization();
|
||||
await PageObjects.visualize.clickDataTable();
|
||||
await PageObjects.visualize.clickNewSearch();
|
||||
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
|
||||
await PageObjects.visualize.clickMetricEditor();
|
||||
await PageObjects.visualize.selectAggregation('Top Hit', 'metrics');
|
||||
await PageObjects.visualize.selectField('_source', 'metrics');
|
||||
await PageObjects.visualize.clickGo();
|
||||
const data = await PageObjects.visualize.getTableVisData();
|
||||
log.debug(data);
|
||||
expect(data.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue