-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
27 changed files
with
250 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/legacy/core_plugins/interpreter/public/functions/vis_dimension.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
} | ||
}; | ||
}, | ||
}); |
2 changes: 0 additions & 2 deletions
2
src/legacy/core_plugins/tagcloud/public/__snapshots__/tag_cloud_fn.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...acy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-21.9 KB
(34%)
test/interpreter_functional/screenshots/baseline/combined_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-22 KB
(34%)
test/interpreter_functional/screenshots/baseline/final_screenshot_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-10.1 KB
(53%)
test/interpreter_functional/screenshots/baseline/partial_test_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-21.9 KB
(34%)
test/interpreter_functional/screenshots/baseline/partial_test_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-8.56 KB
(63%)
test/interpreter_functional/screenshots/baseline/partial_test_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
test/interpreter_functional/screenshots/baseline/tagcloud_all_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
test/interpreter_functional/screenshots/baseline/tagcloud_fontsize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+97.8 KB
test/interpreter_functional/screenshots/baseline/tagcloud_invalid_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
test/interpreter_functional/screenshots/baseline/tagcloud_metric_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
test/interpreter_functional/screenshots/baseline/tagcloud_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
test/interpreter_functional/snapshots/baseline/tagcloud_all_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}} |
1 change: 1 addition & 0 deletions
1
test/interpreter_functional/snapshots/baseline/tagcloud_fontsize.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}} |
1 change: 1 addition & 0 deletions
1
test/interpreter_functional/snapshots/baseline/tagcloud_invalid_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 (<anonymous>)"},"type":"error"} |
1 change: 1 addition & 0 deletions
1
test/interpreter_functional/snapshots/baseline/tagcloud_metric_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}} |
1 change: 1 addition & 0 deletions
1
test/interpreter_functional/snapshots/baseline/tagcloud_options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
test/interpreter_functional/test_suites/run_pipeline/tag_cloud.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); | ||
} |