2019-03-05 10:15:44 +01:00
|
|
|
/*
|
2021-01-20 02:52:56 +01:00
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
2021-02-04 03:12:39 +01:00
|
|
|
* 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.
|
2019-03-05 10:15:44 +01:00
|
|
|
*/
|
|
|
|
|
2019-03-25 17:56:48 +01:00
|
|
|
import expect from '@kbn/expect';
|
2020-12-18 15:38:07 +01:00
|
|
|
|
2019-03-05 10:15:44 +01:00
|
|
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
|
|
|
|
2020-05-22 09:08:58 +02:00
|
|
|
export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
2021-08-17 18:21:17 +02:00
|
|
|
const { visualBuilder, timePicker, visualize, visChart } = getPageObjects([
|
2021-05-13 22:32:58 +02:00
|
|
|
'visualBuilder',
|
|
|
|
'timePicker',
|
|
|
|
'visualize',
|
2021-08-17 18:21:17 +02:00
|
|
|
'visChart',
|
2021-05-13 22:32:58 +02:00
|
|
|
]);
|
2019-09-18 18:53:22 +02:00
|
|
|
const retry = getService('retry');
|
2019-05-27 23:26:28 +02:00
|
|
|
|
|
|
|
async function cleanupMarkdownData(variableName: 'variable' | 'label', checkedValue: string) {
|
|
|
|
await visualBuilder.markdownSwitchSubTab('data');
|
|
|
|
await visualBuilder.setMarkdownDataVariable('', variableName);
|
|
|
|
await visualBuilder.markdownSwitchSubTab('markdown');
|
|
|
|
const rerenderedTable = await visualBuilder.getMarkdownTableVariables();
|
2020-05-22 09:08:58 +02:00
|
|
|
rerenderedTable.forEach((row) => {
|
2020-09-04 19:07:13 +02:00
|
|
|
if (variableName === 'label') {
|
|
|
|
expect(row.key).to.include.string(checkedValue);
|
|
|
|
} else {
|
|
|
|
expect(row.key).to.not.include.string(checkedValue);
|
|
|
|
}
|
2019-05-27 23:26:28 +02:00
|
|
|
});
|
|
|
|
}
|
2019-03-05 10:15:44 +01:00
|
|
|
|
2019-09-20 19:36:05 +02:00
|
|
|
describe('visual builder', function describeIndexTests() {
|
2019-03-05 10:15:44 +01:00
|
|
|
describe('markdown', () => {
|
|
|
|
before(async () => {
|
2021-05-13 22:32:58 +02:00
|
|
|
await visualize.initTests();
|
2019-03-05 10:15:44 +01:00
|
|
|
await visualBuilder.resetPage();
|
|
|
|
await visualBuilder.clickMarkdown();
|
2019-11-21 00:02:04 +01:00
|
|
|
await timePicker.setAbsoluteRange(
|
|
|
|
'Sep 22, 2015 @ 06:00:00.000',
|
|
|
|
'Sep 22, 2015 @ 11:00:00.000'
|
|
|
|
);
|
2021-03-29 16:31:01 +02:00
|
|
|
await visualBuilder.markdownSwitchSubTab('options');
|
|
|
|
await visualBuilder.setMetricsDataTimerangeMode('Last value');
|
2021-04-30 10:48:10 +02:00
|
|
|
await visualBuilder.setDropLastBucket(true);
|
2021-03-29 16:31:01 +02:00
|
|
|
await visualBuilder.markdownSwitchSubTab('markdown');
|
2019-03-05 10:15:44 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render subtabs and table variables markdown components', async () => {
|
|
|
|
const tabs = await visualBuilder.getSubTabs();
|
|
|
|
expect(tabs).to.have.length(3);
|
|
|
|
|
|
|
|
const variables = await visualBuilder.getMarkdownTableVariables();
|
|
|
|
expect(variables).not.to.be.empty();
|
|
|
|
expect(variables).to.have.length(5);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow printing raw timestamp of data', async () => {
|
|
|
|
await visualBuilder.enterMarkdown('{{ count.data.raw.[0].[0] }}');
|
|
|
|
const text = await visualBuilder.getMarkdownText();
|
|
|
|
expect(text).to.be('1442901600000');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow printing raw value of data', async () => {
|
|
|
|
await visualBuilder.enterMarkdown('{{ count.data.raw.[0].[1] }}');
|
|
|
|
const text = await visualBuilder.getMarkdownText();
|
|
|
|
expect(text).to.be('6');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render html as plain text', async () => {
|
|
|
|
const html = '<h1>hello world</h1>';
|
|
|
|
await visualBuilder.enterMarkdown(html);
|
|
|
|
const markdownText = await visualBuilder.getMarkdownText();
|
|
|
|
expect(markdownText).to.be(html);
|
|
|
|
});
|
|
|
|
|
2021-08-17 18:21:17 +02:00
|
|
|
it('markdown variables should be clickable', async () => {
|
|
|
|
await visualBuilder.clearMarkdown();
|
|
|
|
const [firstVariable] = await visualBuilder.getMarkdownTableVariables();
|
|
|
|
await firstVariable.selector.click();
|
|
|
|
await visChart.waitForVisualizationRenderingStabilized();
|
|
|
|
const markdownText = await visualBuilder.getMarkdownText();
|
|
|
|
expect(markdownText).to.be('46');
|
|
|
|
});
|
|
|
|
|
2019-03-05 10:15:44 +01:00
|
|
|
it('should render mustache list', async () => {
|
|
|
|
const list = '{{#each _all}}\n{{ data.formatted.[0] }} {{ data.raw.[0] }}\n{{/each}}';
|
|
|
|
const expectedRenderer = 'Sep 22, 2015 @ 06:00:00.000,6 1442901600000,6';
|
|
|
|
await visualBuilder.enterMarkdown(list);
|
|
|
|
const markdownText = await visualBuilder.getMarkdownText();
|
|
|
|
expect(markdownText).to.be(expectedRenderer);
|
|
|
|
});
|
2019-05-27 23:26:28 +02:00
|
|
|
it('should render markdown table', async () => {
|
|
|
|
const TABLE =
|
|
|
|
'| raw | formatted |\n|-|-|\n| {{count.last.raw}} | {{count.last.formatted}} |';
|
|
|
|
const DATA = '46';
|
|
|
|
|
|
|
|
await visualBuilder.enterMarkdown(TABLE);
|
|
|
|
const text = await visualBuilder.getMarkdownText();
|
2020-05-22 09:08:58 +02:00
|
|
|
const tableValues = text.split('\n').map((row) => row.split(' '))[1]; // [46, 46]
|
2019-05-27 23:26:28 +02:00
|
|
|
|
2020-05-22 09:08:58 +02:00
|
|
|
tableValues.forEach((value) => {
|
2019-05-27 23:26:28 +02:00
|
|
|
expect(value).to.be.equal(DATA);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should change variable name', async () => {
|
|
|
|
const VARIABLE = 'variable';
|
|
|
|
await visualBuilder.markdownSwitchSubTab('data');
|
|
|
|
|
|
|
|
await visualBuilder.setMarkdownDataVariable(VARIABLE, VARIABLE);
|
|
|
|
await visualBuilder.markdownSwitchSubTab('markdown');
|
|
|
|
const table = await visualBuilder.getMarkdownTableVariables();
|
|
|
|
|
|
|
|
table.forEach((row, index) => {
|
|
|
|
// exception: last index for variable is always: {{count.label}}
|
2020-09-04 19:07:13 +02:00
|
|
|
if (index === table.length - 1) {
|
|
|
|
expect(row.key).to.not.include.string(VARIABLE);
|
|
|
|
} else {
|
|
|
|
expect(row.key).to.include.string(VARIABLE);
|
|
|
|
}
|
2019-05-27 23:26:28 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
await cleanupMarkdownData(VARIABLE, VARIABLE);
|
|
|
|
});
|
2019-06-12 13:25:36 +02:00
|
|
|
|
2019-09-18 18:53:22 +02:00
|
|
|
it('series count should be 2 after cloning', async () => {
|
2019-06-12 13:25:36 +02:00
|
|
|
await visualBuilder.markdownSwitchSubTab('data');
|
|
|
|
await visualBuilder.cloneSeries();
|
|
|
|
|
2020-02-28 04:22:42 +01:00
|
|
|
await retry.try(async function seriesCountCheck() {
|
2019-09-18 18:53:22 +02:00
|
|
|
const seriesLength = (await visualBuilder.getSeries()).length;
|
|
|
|
expect(seriesLength).to.be.equal(2);
|
|
|
|
});
|
2019-06-12 13:25:36 +02:00
|
|
|
});
|
|
|
|
|
2019-09-18 18:53:22 +02:00
|
|
|
it('aggregation count should be 2 after cloning', async () => {
|
2019-06-12 13:25:36 +02:00
|
|
|
await visualBuilder.markdownSwitchSubTab('data');
|
|
|
|
await visualBuilder.createNewAgg();
|
|
|
|
|
2020-02-28 04:22:42 +01:00
|
|
|
await retry.try(async function aggregationCountCheck() {
|
2019-09-18 18:53:22 +02:00
|
|
|
const aggregationLength = await visualBuilder.getAggregationCount();
|
|
|
|
expect(aggregationLength).to.be.equal(2);
|
|
|
|
});
|
2019-06-12 13:25:36 +02:00
|
|
|
});
|
[TSVB] Support custom field format (#101245)
* [TSVB] Support custom field format
Add format_label response processor for series vis data and bucket key formatting to process_bucket for table vis data
* Add ignore_field_formatting for series to support value formatting for all panel types except markdown
* Fix type issue for visData and rename getCustomFieldFormatter to createCustomFieldFormatter
* Update vis.test to cover custom field formats logic and add a migration script to set ignore_field_formatting to true for the series
* Move createCustomFieldFormatter to a separate file, make formatting respect only active metrics field name, refactor vis files and fix label formatting only for grouped by terms series
* Remove services, add getFieldFormatsService to use it in format_label and get_table_data, replace getCustomFieldFormatter with createCustomFieldFormatter
* Update plugin.ts
* Update start for plugin.ts
* Add formatting for annotations and markdown values
* Refactor some code
* Update some naming and conditions
* Fix formatting of data type labels
* In process_bucket fix case for no getFieldFormatByName
* Add field formatting functional tests for all panel types
* Update tests to make them run correctly for firefox
* Update _tsvb_markdown test setup
* Move series ignoreFieldFormatting check to a separate file, change convertSeriesToVars signature, update migration script and refactor a bit functional tests
* Fix type check for timeseries_visualization.tsx
* Update migrations.js test expected version to 7.15
* Fix tests in _tsvb_chart.ts
* Fix merge conflict remove process_bucket.js
* Update process_bucket.test.ts
* Fix markdown labels formatting
* Add ignore_field_formatting for annotations, enhanced migration script to set that flag to true, refactor data_format_picker
* Fix migration script and add disabling for ignore component when string index pattern is used
* Add supporting URL and color formatters in tsvb table
* Fix eslint
* Remove ignore formatting component, add field formatting option to TSVB data format picker and make it default, remove migration script, update tests and refactor some files
* Fix failing tests, refactor create_field_formatter and add test to it, update some other files
* Fix series formatting for top hit when it has not numeric result
* Handle no fieldFormatMap case for table/vis.js
* Remove "Default" option form DataFormatPicker when index pattern is string, fix markdown variables issue and refactor some code
* Chore(TSVB): Replace aggregations lookup with map
* Fix types, update test expected data and remove unused translations
* Fix i18 check and useEffect in agg.tsx
* Handle aggregations field formatting case
* Fix agg_utils, vis and check_if_numeric_metric tests
* Correct typo and refactor condition in std_metric
* Fix type check
* Get rid of IFieldType
* Add URL and color formatting for topN and metric tabs, fix setting initial custom formatter and switching formatter in agg.tsx
* Update tsvb.asciidoc
* Remove link icon from Date format field help text, update click logic for top N in case of custom field format and fix CI
* Remove unused import
* Revert top N bar extra logic for click
* Refactor some code in agg.tsx
* Add URL and color formatting to Gauge
* Fix bug with terms formatting, refactor some code, update create_field_formatter
* Add comments to _gauge.scss
* Remove unnecessary await
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
2021-09-13 10:51:32 +02:00
|
|
|
|
|
|
|
describe('applying field formats from Advanced Settings for values', () => {
|
|
|
|
before(async () => {
|
|
|
|
await visualBuilder.resetPage();
|
|
|
|
await visualBuilder.clickMarkdown();
|
|
|
|
await visualBuilder.markdownSwitchSubTab('markdown');
|
|
|
|
await visualBuilder.enterMarkdown('{{ average_of_bytes.last.formatted }}');
|
|
|
|
await visualBuilder.markdownSwitchSubTab('data');
|
|
|
|
await visualBuilder.selectAggType('Average');
|
|
|
|
await visualBuilder.setFieldForAggregation('bytes');
|
|
|
|
await visualBuilder.clickSeriesOption();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should apply field formatting by default', async () => {
|
|
|
|
const text = await visualBuilder.getMarkdownText();
|
|
|
|
expect(text).to.be('5.588KB');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should apply TSVB formatting', async () => {
|
|
|
|
await visualBuilder.changeDataFormatter('percent');
|
|
|
|
|
|
|
|
const text = await visualBuilder.getMarkdownText();
|
|
|
|
expect(text).to.be('572,241.265%');
|
|
|
|
});
|
|
|
|
});
|
2019-03-05 10:15:44 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|