* [maps] remove tile_map plugin * initial bounds * update embeddable query context * start editor * remove tile_map from tsconfig and i18n cleanup * implement view in maps button * tslint * remove empty lines * remove tileMap from limits.yml * remove region_map and maps_legacy plugins * region_map vis with Map embeddable * make MapComponent * lint * clean up * shorten text * lint * remove region_map from interpreter functional tests * update docs * add migration for removing ui_settings * remove tile_map and region_map functional tests * tslint * call handlers.done when layers are loaded * fix visualize create menu test * eslint * add owner comment to ui_settings/saved_objects/migrations.ts * remove deleted plugins from codeowners * review feedback * use correct value for TILE_MAP_RENDER * down select mapModules for getLayerDescriptors callback Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
104 lines
4.9 KiB
TypeScript
104 lines
4.9 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 expect from '@kbn/expect';
|
|
import { ExpectExpression, expectExpressionProvider } from './helpers';
|
|
import { FtrProviderContext } from '../../../functional/ftr_provider_context';
|
|
|
|
// this file showcases how to use testing utilities defined in helpers.ts together with the kbn_tp_run_pipeline
|
|
// test plugin to write automated tests for interpreter
|
|
export default function ({
|
|
getService,
|
|
updateBaselines,
|
|
}: FtrProviderContext & { updateBaselines: boolean }) {
|
|
let expectExpression: ExpectExpression;
|
|
describe('basic visualize loader pipeline expression tests', () => {
|
|
before(() => {
|
|
expectExpression = expectExpressionProvider({ getService, updateBaselines });
|
|
});
|
|
|
|
// we should not use this for tests like the ones below. this should be unit tested.
|
|
// - tests against a single function could easily be written as unit tests (and should be)
|
|
describe('kibana function', () => {
|
|
it('returns kibana_context', async () => {
|
|
const result = await expectExpression('returns_kibana_context', 'kibana').getResponse();
|
|
expect(result).to.have.property('type', 'kibana_context');
|
|
});
|
|
|
|
it('correctly sets timeRange', async () => {
|
|
const result = await expectExpression(
|
|
'correctly_sets_timerange',
|
|
'kibana',
|
|
{},
|
|
{ timeRange: 'test' }
|
|
).getResponse();
|
|
expect(result).to.have.property('timeRange', 'test');
|
|
});
|
|
});
|
|
|
|
// rather we want to use this to do integration tests.
|
|
describe('full expression', () => {
|
|
const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
|
|
aggs={aggCount id="1" enabled=true schema="metric"}
|
|
aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw" size=4 order="desc" orderBy="1"}
|
|
| metricVis metric={visdimension 1 format="number"} bucket={visdimension 0}
|
|
`;
|
|
|
|
// we can execute an expression and validate the result manually:
|
|
// const response = await expectExpression(expression).getResponse();
|
|
// expect(response)....
|
|
|
|
// we can also do snapshot comparison of result of our expression
|
|
// to update the snapshots run the tests with --updateBaselines
|
|
it('runs the expression and compares final output', async () => {
|
|
await expectExpression('final_output_test', expression).toMatchSnapshot();
|
|
});
|
|
|
|
// its also possible to check snapshot at every step of expression (after execution of each function)
|
|
it('runs the expression and compares output at every step', async () => {
|
|
await expectExpression('step_output_test', expression).steps.toMatchSnapshot();
|
|
});
|
|
|
|
// and we can do screenshot comparison of the rendered output of expression (if expression returns renderable)
|
|
it('runs the expression and compares screenshots', async () => {
|
|
await expectExpression('final_screenshot_test', expression).toMatchScreenshot();
|
|
});
|
|
|
|
// it is also possible to combine different checks
|
|
it('runs the expression and combines different checks', async () => {
|
|
await (
|
|
await expectExpression('combined_test', expression).steps.toMatchSnapshot()
|
|
).toMatchScreenshot();
|
|
});
|
|
});
|
|
|
|
// if we want to do multiple different tests using the same data, or reusing a part of expression its
|
|
// possible to retrieve the intermediate result and reuse it in later expressions
|
|
describe('reusing partial results', () => {
|
|
it('does some screenshot comparisons', async () => {
|
|
const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
|
|
aggs={aggCount id="1" enabled=true schema="metric"}
|
|
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
|
|
const context = await expectExpression('partial_test', expression).getResponse();
|
|
|
|
// we reuse that response to render 2 different charts and compare screenshots with baselines
|
|
const tagCloudExpr = `tagcloud metric={visdimension 1 format="number"} bucket={visdimension 0}`;
|
|
await (
|
|
await expectExpression('partial_test_1', tagCloudExpr, context).toMatchSnapshot()
|
|
).toMatchScreenshot();
|
|
|
|
const metricExpr = `metricVis metric={visdimension 1 format="number"} bucket={visdimension 0}`;
|
|
await (
|
|
await expectExpression('partial_test_2', metricExpr, context).toMatchSnapshot()
|
|
).toMatchScreenshot();
|
|
});
|
|
});
|
|
});
|
|
}
|