diff --git a/src/legacy/core_plugins/interpreter/common/types/kibana_datatable.js b/src/legacy/core_plugins/interpreter/common/types/kibana_datatable.js index 477f43b2f1e673..a87615099e7ca6 100644 --- a/src/legacy/core_plugins/interpreter/common/types/kibana_datatable.js +++ b/src/legacy/core_plugins/interpreter/common/types/kibana_datatable.js @@ -23,11 +23,15 @@ export const kibanaDatatable = () => ({ name: 'kibana_datatable', from: { datatable: context => { - context.columns.forEach(c => c.id = c.name); return { type: 'kibana_datatable', rows: context.rows, - columns: context.columns, + columns: context.columns.map(column => { + return { + id: column.name, + name: column.name, + }; + }), }; }, pointseries: context => { diff --git a/src/legacy/core_plugins/interpreter/public/functions/index.js b/src/legacy/core_plugins/interpreter/public/functions/index.js index e7d658821633fb..2f6778b007515a 100644 --- a/src/legacy/core_plugins/interpreter/public/functions/index.js +++ b/src/legacy/core_plugins/interpreter/public/functions/index.js @@ -22,7 +22,8 @@ import { esaggs } from './esaggs'; import { kibana } from './kibana'; import { kibanaContext } from './kibana_context'; import { visualization } from './visualization'; +import { visDimension } from './vis_dimension'; export const functions = [ - clog, esaggs, kibana, kibanaContext, visualization + clog, esaggs, kibana, kibanaContext, visualization, visDimension, ]; diff --git a/src/legacy/core_plugins/interpreter/public/functions/vis_dimension.js b/src/legacy/core_plugins/interpreter/public/functions/vis_dimension.js new file mode 100644 index 00000000000000..e1a6c41198bad4 --- /dev/null +++ b/src/legacy/core_plugins/interpreter/public/functions/vis_dimension.js @@ -0,0 +1,69 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { i18n } from '@kbn/i18n'; + +export const visDimension = () => ({ + name: 'visdimension', + help: i18n.translate('interpreter.function.visDimension.help', { + defaultMessage: 'Generates visConfig dimension object' + }), + type: 'vis_dimension', + context: { + types: [ + 'kibana_datatable' + ], + }, + args: { + accessor: { + types: ['string', 'number'], + aliases: ['_'], + help: i18n.translate('interpreter.function.visDimension.accessor.help', { + defaultMessage: 'Column in your dataset to use (either column index or column name)' + }), + }, + format: { + types: ['string'], + default: 'string' + }, + formatParams: { + types: ['string'], + default: '"{}"', + } + }, + fn: (context, args) => { + const accessor = Number.isInteger(args.accessor) ? + args.accessor : + context.columns.find(c => c.id === args.accessor); + if (accessor === undefined) { + throw new Error(i18n.translate('interpreter.function.visDimension.error.accessor', { + defaultMessage: 'Column name provided is invalid' + })); + } + + return { + type: 'vis_dimension', + accessor: accessor, + format: { + id: args.format, + params: JSON.parse(args.formatParams), + } + }; + }, +}); diff --git a/src/legacy/core_plugins/tagcloud/public/__snapshots__/tag_cloud_fn.test.js.snap b/src/legacy/core_plugins/tagcloud/public/__snapshots__/tag_cloud_fn.test.js.snap index c8449b2dde463e..8e28be33515f7b 100644 --- a/src/legacy/core_plugins/tagcloud/public/__snapshots__/tag_cloud_fn.test.js.snap +++ b/src/legacy/core_plugins/tagcloud/public/__snapshots__/tag_cloud_fn.test.js.snap @@ -12,11 +12,9 @@ Object { "maxFontSize": 72, "metric": Object { "accessor": 0, - "aggType": "count", "format": Object { "id": "number", }, - "params": Object {}, }, "minFontSize": 18, "orientation": "single", diff --git a/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.js b/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.js index 59360af6adeb3e..e49e31fe4741dc 100644 --- a/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.js +++ b/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.js @@ -32,13 +32,61 @@ export const tagcloud = () => ({ defaultMessage: 'Tagcloud visualization' }), args: { - visConfig: { - types: ['string', 'null'], - default: '"{}"', + scale: { + types: ['string'], + default: 'linear', + options: ['linear', 'log', 'square root'], + help: i18n.translate('tagCloud.function.scale.help', { + defaultMessage: 'Scale to determine font size of a word' + }), + }, + orientation: { + types: ['string'], + default: 'single', + options: ['single', 'right angled', 'multiple'], + help: i18n.translate('tagCloud.function.orientation.help', { + defaultMessage: 'Orientation of words inside tagcloud' + }), + }, + minFontSize: { + types: ['number'], + default: 18, + }, + maxFontSize: { + types: ['number'], + default: 72 + }, + showLabel: { + types: ['boolean'], + default: true, + }, + metric: { + types: ['vis_dimension'], + help: i18n.translate('tagCloud.function.metric.help', { + defaultMessage: 'metric dimension configuration' + }), + required: true, + }, + bucket: { + types: ['vis_dimension'], + help: i18n.translate('tagCloud.function.bucket.help', { + defaultMessage: 'bucket dimension configuration' + }), }, }, fn(context, args) { - const visConfig = JSON.parse(args.visConfig); + const visConfig = { + scale: args.scale, + orientation: args.orientation, + minFontSize: args.minFontSize, + maxFontSize: args.maxFontSize, + showLabel: args.showLabel, + metric: args.metric, + }; + + if (args.bucket !== undefined) { + visConfig.bucket = args.bucket; + } return { type: 'render', diff --git a/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.test.js b/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.test.js index d0098d7905ced1..774a9dc35b290f 100644 --- a/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.test.js +++ b/src/legacy/core_plugins/tagcloud/public/tag_cloud_fn.test.js @@ -33,18 +33,11 @@ describe('interpreter/functions#tagcloud', () => { minFontSize: 18, maxFontSize: 72, showLabel: true, - metric: { - accessor: 0, - format: { - id: 'number', - }, - params: {}, - aggType: 'count', - }, + metric: { accessor: 0, format: { id: 'number' } }, }; it('returns an object with the correct structure', () => { - const actual = fn(context, { visConfig: JSON.stringify(visConfig) }); + const actual = fn(context, visConfig); expect(actual).toMatchSnapshot(); }); }); diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap b/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap index ab94880cf53f62..776e62070b8e1c 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap @@ -26,9 +26,9 @@ exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunct exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function without splits or buckets 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[0,1],\\"buckets\\":[]}}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tagcloud function with buckets 1`] = `"tagcloud visConfig='{\\"metric\\":0,\\"bucket\\":1}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tagcloud function with buckets 1`] = `"tagcloud metric={visdimension 0} bucket={visdimension 1 } "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tagcloud function without buckets 1`] = `"tagcloud visConfig='{\\"metric\\":0}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tagcloud function without buckets 1`] = `"tagcloud metric={visdimension 0} "`; exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tile_map function 1`] = `"tilemap visConfig='{\\"metric\\":{},\\"dimensions\\":{\\"metric\\":0,\\"geohash\\":1,\\"geocentroid\\":3}}' "`; diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.test.js b/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.test.js index 50aafbe2848cd7..69fe781d5ef5ab 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.test.js +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.test.js @@ -170,15 +170,15 @@ describe('visualize loader pipeline helpers: build pipeline', () => { const params = {}; it('without buckets', () => { - const schemas = { metric: [0] }; + const schemas = { metric: [{ accessor: 0 }] }; const actual = buildPipelineVisFunction.tagcloud({ params }, schemas); expect(actual).toMatchSnapshot(); }); it('with buckets', () => { const schemas = { - metric: [0], - segment: [1, 2] + metric: [{ accessor: 0 }], + segment: [{ accessor: 1 }] }; const actual = buildPipelineVisFunction.tagcloud({ params }, schemas); expect(actual).toMatchSnapshot(); diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts b/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts index 080c21a6675e4c..332672eead67f2 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts @@ -238,11 +238,35 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = { return `kibana_metric ${prepareJson('visConfig', visConfig)}`; }, tagcloud: (visState, schemas) => { - const visConfig = { - ...visState.params, - ...buildVisConfig.tagcloud(schemas), - }; - return `tagcloud ${prepareJson('visConfig', visConfig)}`; + const { scale, orientation, minFontSize, maxFontSize, showLabel } = visState.params; + const { metric, bucket } = buildVisConfig.tagcloud(schemas); + let expr = `tagcloud metric={visdimension ${metric.accessor}} `; + + if (scale) { + expr += `scale='${scale}' `; + } + if (orientation) { + expr += `orientation='${orientation}' `; + } + if (minFontSize) { + expr += `minFontSize=${minFontSize} `; + } + if (maxFontSize) { + expr += `maxFontSize=${maxFontSize} `; + } + if (showLabel) { + expr += `showLabel=${showLabel} `; + } + + if (bucket) { + expr += ` bucket={visdimension ${bucket.accessor} `; + if (bucket.format) { + expr += `format=${bucket.format.id} `; + expr += prepareJson('formatParams', bucket.format.params); + } + expr += '} '; + } + return expr; }, region_map: (visState, schemas) => { const visConfig = { diff --git a/test/interpreter_functional/README.md b/test/interpreter_functional/README.md index 6918afe3eb90ed..336bfe3405a014 100644 --- a/test/interpreter_functional/README.md +++ b/test/interpreter_functional/README.md @@ -12,10 +12,16 @@ To run these tests during development you can use the following commands: ``` # Start the test server (can continue running) node scripts/functional_tests_server.js --config test/interpreter_functional/config.js + # Start a test run node scripts/functional_test_runner.js --config test/interpreter_functional/config.js ``` # Writing tests -Look into test_suites/run_pipeline/basic.js for examples \ No newline at end of file +Look into test_suites/run_pipeline/basic.js for examples + +to update baseline screenshots and snapshots run with: +``` +node scripts/functional_test_runner.js --config test/interpreter_functional/config.js --updateBaselines +``` \ No newline at end of file diff --git a/test/interpreter_functional/screenshots/baseline/combined_test.png b/test/interpreter_functional/screenshots/baseline/combined_test.png index cc0ada1c913a86..8e2a52bf44c1b5 100644 Binary files a/test/interpreter_functional/screenshots/baseline/combined_test.png and b/test/interpreter_functional/screenshots/baseline/combined_test.png differ diff --git a/test/interpreter_functional/screenshots/baseline/final_screenshot_test.png b/test/interpreter_functional/screenshots/baseline/final_screenshot_test.png index 35aeffaf46c245..8e2a52bf44c1b5 100644 Binary files a/test/interpreter_functional/screenshots/baseline/final_screenshot_test.png and b/test/interpreter_functional/screenshots/baseline/final_screenshot_test.png differ diff --git a/test/interpreter_functional/screenshots/baseline/partial_test_1.png b/test/interpreter_functional/screenshots/baseline/partial_test_1.png index 4b3d9214bd6ccc..8e2a52bf44c1b5 100644 Binary files a/test/interpreter_functional/screenshots/baseline/partial_test_1.png and b/test/interpreter_functional/screenshots/baseline/partial_test_1.png differ diff --git a/test/interpreter_functional/screenshots/baseline/partial_test_2.png b/test/interpreter_functional/screenshots/baseline/partial_test_2.png index cc0ada1c913a86..8e2a52bf44c1b5 100644 Binary files a/test/interpreter_functional/screenshots/baseline/partial_test_2.png and b/test/interpreter_functional/screenshots/baseline/partial_test_2.png differ diff --git a/test/interpreter_functional/screenshots/baseline/partial_test_3.png b/test/interpreter_functional/screenshots/baseline/partial_test_3.png index 1739c32f808ff8..e6b9001a5ca286 100644 Binary files a/test/interpreter_functional/screenshots/baseline/partial_test_3.png and b/test/interpreter_functional/screenshots/baseline/partial_test_3.png differ diff --git a/test/interpreter_functional/screenshots/baseline/tagcloud_all_data.png b/test/interpreter_functional/screenshots/baseline/tagcloud_all_data.png new file mode 100644 index 00000000000000..8e2a52bf44c1b5 Binary files /dev/null and b/test/interpreter_functional/screenshots/baseline/tagcloud_all_data.png differ diff --git a/test/interpreter_functional/screenshots/baseline/tagcloud_fontsize.png b/test/interpreter_functional/screenshots/baseline/tagcloud_fontsize.png new file mode 100644 index 00000000000000..8e2a52bf44c1b5 Binary files /dev/null and b/test/interpreter_functional/screenshots/baseline/tagcloud_fontsize.png differ diff --git a/test/interpreter_functional/screenshots/baseline/tagcloud_invalid_data.png b/test/interpreter_functional/screenshots/baseline/tagcloud_invalid_data.png new file mode 100644 index 00000000000000..e40c1840d29ca0 Binary files /dev/null and b/test/interpreter_functional/screenshots/baseline/tagcloud_invalid_data.png differ diff --git a/test/interpreter_functional/screenshots/baseline/tagcloud_metric_data.png b/test/interpreter_functional/screenshots/baseline/tagcloud_metric_data.png new file mode 100644 index 00000000000000..8e2a52bf44c1b5 Binary files /dev/null and b/test/interpreter_functional/screenshots/baseline/tagcloud_metric_data.png differ diff --git a/test/interpreter_functional/screenshots/baseline/tagcloud_options.png b/test/interpreter_functional/screenshots/baseline/tagcloud_options.png new file mode 100644 index 00000000000000..8e2a52bf44c1b5 Binary files /dev/null and b/test/interpreter_functional/screenshots/baseline/tagcloud_options.png differ diff --git a/test/interpreter_functional/snapshots/baseline/tagcloud_all_data.json b/test/interpreter_functional/snapshots/baseline/tagcloud_all_data.json new file mode 100644 index 00000000000000..1325c7fbed03ea --- /dev/null +++ b/test/interpreter_functional/snapshots/baseline/tagcloud_all_data.json @@ -0,0 +1 @@ +{"as":"visualization","type":"render","value":{"params":{"listenOnChange":true},"visConfig":{"bucket":{"accessor":1,"format":{"id":"string","params":{}},"type":"vis_dimension"},"maxFontSize":72,"metric":{"accessor":0,"format":{"id":"string","params":{}},"type":"vis_dimension"},"minFontSize":18,"orientation":"single","scale":"linear","showLabel":true},"visData":{"columns":[{"id":"col-0-2","name":"response.raw: Descending"},{"id":"col-1-1","name":"Count"}],"rows":[{"col-0-2":"200","col-1-1":12891},{"col-0-2":"404","col-1-1":696},{"col-0-2":"503","col-1-1":417}],"type":"kibana_datatable"},"visType":"tagcloud"}} \ No newline at end of file diff --git a/test/interpreter_functional/snapshots/baseline/tagcloud_fontsize.json b/test/interpreter_functional/snapshots/baseline/tagcloud_fontsize.json new file mode 100644 index 00000000000000..2b063b518665af --- /dev/null +++ b/test/interpreter_functional/snapshots/baseline/tagcloud_fontsize.json @@ -0,0 +1 @@ +{"as":"visualization","type":"render","value":{"params":{"listenOnChange":true},"visConfig":{"bucket":{"accessor":1,"format":{"id":"string","params":{}},"type":"vis_dimension"},"maxFontSize":40,"metric":{"accessor":0,"format":{"id":"string","params":{}},"type":"vis_dimension"},"minFontSize":20,"orientation":"single","scale":"linear","showLabel":true},"visData":{"columns":[{"id":"col-0-2","name":"response.raw: Descending"},{"id":"col-1-1","name":"Count"}],"rows":[{"col-0-2":"200","col-1-1":12891},{"col-0-2":"404","col-1-1":696},{"col-0-2":"503","col-1-1":417}],"type":"kibana_datatable"},"visType":"tagcloud"}} \ No newline at end of file diff --git a/test/interpreter_functional/snapshots/baseline/tagcloud_invalid_data.json b/test/interpreter_functional/snapshots/baseline/tagcloud_invalid_data.json new file mode 100644 index 00000000000000..ae78b3321f0be5 --- /dev/null +++ b/test/interpreter_functional/snapshots/baseline/tagcloud_invalid_data.json @@ -0,0 +1 @@ +{"error":{"message":"[tagcloud] > [vis_dimension] > Objects must have a type property","stack":"Error: [vis_dimension] > Objects must have a type property\n at getType (http://localhost:5620/bundles/commons.bundle.js:15876:27)\n at cast (http://localhost:5620/bundles/commons.bundle.js:15683:46)\n at _callee3$ (http://localhost:5620/bundles/commons.bundle.js:31552:35)\n at tryCatch (webpack://%5Bname%5D/./node_modules/regenerator-runtime/runtime.js?:62:40)\n at Generator.invoke [as _invoke] (webpack://%5Bname%5D/./node_modules/regenerator-runtime/runtime.js?:288:22)\n at Generator.prototype.(anonymous function) [as next] (webpack://%5Bname%5D/./node_modules/regenerator-runtime/runtime.js?:114:21)\n at asyncGeneratorStep (http://localhost:5620/bundles/commons.bundle.js:31397:103)\n at _next (http://localhost:5620/bundles/commons.bundle.js:31399:194)\n at http://localhost:5620/bundles/commons.bundle.js:31399:364\n at new Promise ()"},"type":"error"} \ No newline at end of file diff --git a/test/interpreter_functional/snapshots/baseline/tagcloud_metric_data.json b/test/interpreter_functional/snapshots/baseline/tagcloud_metric_data.json new file mode 100644 index 00000000000000..6152fd406961fc --- /dev/null +++ b/test/interpreter_functional/snapshots/baseline/tagcloud_metric_data.json @@ -0,0 +1 @@ +{"as":"visualization","type":"render","value":{"params":{"listenOnChange":true},"visConfig":{"maxFontSize":72,"metric":{"accessor":0,"format":{"id":"string","params":{}},"type":"vis_dimension"},"minFontSize":18,"orientation":"single","scale":"linear","showLabel":true},"visData":{"columns":[{"id":"col-0-2","name":"response.raw: Descending"},{"id":"col-1-1","name":"Count"}],"rows":[{"col-0-2":"200","col-1-1":12891},{"col-0-2":"404","col-1-1":696},{"col-0-2":"503","col-1-1":417}],"type":"kibana_datatable"},"visType":"tagcloud"}} \ No newline at end of file diff --git a/test/interpreter_functional/snapshots/baseline/tagcloud_options.json b/test/interpreter_functional/snapshots/baseline/tagcloud_options.json new file mode 100644 index 00000000000000..e4c6b09a264ddb --- /dev/null +++ b/test/interpreter_functional/snapshots/baseline/tagcloud_options.json @@ -0,0 +1 @@ +{"as":"visualization","type":"render","value":{"params":{"listenOnChange":true},"visConfig":{"bucket":{"accessor":1,"format":{"id":"string","params":{}},"type":"vis_dimension"},"maxFontSize":72,"metric":{"accessor":0,"format":{"id":"string","params":{}},"type":"vis_dimension"},"minFontSize":18,"orientation":"multiple","scale":"log","showLabel":true},"visData":{"columns":[{"id":"col-0-2","name":"response.raw: Descending"},{"id":"col-1-1","name":"Count"}],"rows":[{"col-0-2":"200","col-1-1":12891},{"col-0-2":"404","col-1-1":696},{"col-0-2":"503","col-1-1":417}],"type":"kibana_datatable"},"visType":"tagcloud"}} \ No newline at end of file diff --git a/test/interpreter_functional/test_suites/run_pipeline/index.js b/test/interpreter_functional/test_suites/run_pipeline/index.js index ecedc7bd4678b5..130eb2a35ea0eb 100644 --- a/test/interpreter_functional/test_suites/run_pipeline/index.js +++ b/test/interpreter_functional/test_suites/run_pipeline/index.js @@ -37,5 +37,6 @@ export default function ({ getService, getPageObjects, loadTestFile }) { }); loadTestFile(require.resolve('./basic')); + loadTestFile(require.resolve('./tag_cloud')); }); } diff --git a/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.js b/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.js new file mode 100644 index 00000000000000..3bcbf8f2075ad8 --- /dev/null +++ b/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.js @@ -0,0 +1,72 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { expectExpressionProvider } from './helpers'; + +// this file showcases how to use testing utilities defined in helpers.js together with the kbn_tp_run_pipeline +// test plugin to write autmated tests for interprete +export default function ({ getService, updateBaselines }) { + + let expectExpression; + describe('tag cloud 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('correctly renders tagcloud', () => { + let dataContext; + before(async () => { + const expression = `kibana | kibana_context | esaggs index='logstash-*' aggConfigs='[ + {"id":"1","enabled":true,"type":"count","schema":"metric","params":{}}, + {"id":"2","enabled":true,"type":"terms","schema":"segment","params": + {"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_tagcloud_test', expression).getResponse(); + }); + + it.skip('with invalid data', async () => { + const expression = 'tagcloud metric={visdimension 0}'; + await (await expectExpression('tagcloud_invalid_data', expression).toMatchSnapshot()).toMatchScreenshot(); + }); + + it('with just metric data', async () => { + const expression = 'tagcloud metric={visdimension 0}'; + await (await expectExpression('tagcloud_metric_data', expression, dataContext).toMatchSnapshot()).toMatchScreenshot(); + }); + + it('with metric and bucket data', async () => { + const expression = 'tagcloud metric={visdimension 0} bucket={visdimension 1}'; + await (await expectExpression('tagcloud_all_data', expression, dataContext).toMatchSnapshot()).toMatchScreenshot(); + }); + + it('with font size options', async () => { + const expression = 'tagcloud metric={visdimension 0} bucket={visdimension 1} minFontSize=20 maxFontSize=40'; + await (await expectExpression('tagcloud_fontsize', expression, dataContext).toMatchSnapshot()).toMatchScreenshot(); + }); + + it('with scale and orientation options', async () => { + const expression = 'tagcloud metric={visdimension 0} bucket={visdimension 1} scale="log" orientation="multiple"'; + await (await expectExpression('tagcloud_options', expression, dataContext).toMatchSnapshot()).toMatchScreenshot(); + }); + }); + }); +}