kibana/test/interpreter_functional/test_suites/run_pipeline/metric.ts
Yaroslav Kuznietsov eef094bafb
[Canvas] TagCloud (#106858)
* Added `tagCloud` to canvas.

* Added `icon` to the `tagCloud` element.

* Added column name support at `tag_cloud`.

* Added condition to `vis_dimension` not to pass invalid index.

Added check of accessor index, if such column exists at vis_dimension.
Removed checks of column existance from TagCloudChart.
Added test for accessing data by column name in addition to a column number.
Updated tag_cloud element in Canvas.
Fixed types. Removed almost all `any` and `as` types.

* Added test suites for `vis_dimension` function.

* Added tests for DatatableColumn accessors at tag_cloud_fn and to_ast.

* Refactored metrics, tagcloud and tests.

Added valid functional tests to metrics and tag_cloud.
Fixed types of metrics_vis.
Added handling of empty data at tag_cloud renderer.

* Added storybook ( still doesn't work ).

* Fixed some mistakes.

* Added working storybook with mocks.

* Added clear storybook for tag_cloud_vis_renderer.

* Updated the location of vis_dimension test after movement of the function.

* Fixed unused type.

* Fixed tests and added handling of the column name at `visualizations/**/*/prepare_log_table.ts`

* Reduced the complexity of checking the accessor at `tag_cloud_chart.tsx`

* Added comments at unclear places of code.

* Added the logic for disabling elements for renderers from disabled plugins.

* removed garbage from `kibana.yml`.

* Fixed element_strings.test error.

* Made changes, based on nits.

* Fixed mistake.

* Removed `disabled` flag for `expression_*` plugins.

* recovered lost comments at the unclear places.

* removed dead code.

* fixed test errors.

* Fixed test error, I hope.

* fixed more tests.

* fixed code, based on nits.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-09-06 04:13:38 -04:00

94 lines
3.4 KiB
TypeScript

/*
* 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 { ExpectExpression, expectExpressionProvider, ExpressionResult } from './helpers';
import { FtrProviderContext } from '../../../functional/ftr_provider_context';
export default function ({
getService,
updateBaselines,
}: FtrProviderContext & { updateBaselines: boolean }) {
let expectExpression: ExpectExpression;
describe('metricVis pipeline expression tests', () => {
before(() => {
expectExpression = expectExpressionProvider({ getService, updateBaselines });
});
describe('correctly renders metric', () => {
let dataContext: ExpressionResult;
before(async () => {
const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
aggs={aggCount id="1" enabled=true schema="metric"}
aggs={aggMax id="1" enabled=true schema="metric" field="bytes"}
aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw" size=4 order="desc" orderBy="1"}`;
// we execute the part of expression that fetches the data and store its response
dataContext = await expectExpression('partial_metric_test', expression).getResponse();
});
it('with empty data', async () => {
const expression = 'metricVis metric={visdimension 0}';
await (
await expectExpression('metric_empty_data', expression, {
...dataContext,
rows: [],
}).toMatchSnapshot()
).toMatchScreenshot();
});
it('with single metric data', async () => {
const expression = 'metricVis metric={visdimension 0}';
await (
await expectExpression(
'metric_single_metric_data',
expression,
dataContext
).toMatchSnapshot()
).toMatchScreenshot();
});
it('with multiple metric data', async () => {
const expression = 'metricVis metric={visdimension 0} metric={visdimension 1}';
await (
await expectExpression(
'metric_multi_metric_data',
expression,
dataContext
).toMatchSnapshot()
).toMatchScreenshot();
});
it('with metric and bucket data', async () => {
const expression = 'metricVis metric={visdimension 0} bucket={visdimension 2}';
await (
await expectExpression('metric_all_data', expression, dataContext).toMatchSnapshot()
).toMatchScreenshot();
});
it('with percentageMode option', async () => {
const expression =
'metricVis metric={visdimension 0} percentageMode=true colorRange={range from=0 to=1000}';
await (
await expectExpression(
'metric_percentage_mode',
expression,
dataContext
).toMatchSnapshot()
).toMatchScreenshot();
});
});
describe('throws error at metric', () => {
it('with invalid data', async () => {
const expression = 'metricVis metric={visdimension 0}';
await (
await expectExpression('metric_invalid_data', expression).toMatchSnapshot()
).toMatchScreenshot();
});
});
});
}