Use default index pattern when one is not present in visualize (#30574)

* Use default index pattern when one is not present in visualize

* Review feedback

* Add functional test

* Fix test

* Attempt to fix test again

* Try moving test to its own describe
This commit is contained in:
Lukas Olson 2019-02-19 17:32:05 -07:00
parent 76654b548f
commit 3639f4c972
2 changed files with 18 additions and 2 deletions

View file

@ -119,6 +119,7 @@ function VisEditor(
AppState,
$window,
$injector,
indexPatterns,
kbnUrl,
redirectWhenMissing,
Private,
@ -313,7 +314,14 @@ function VisEditor(
function init() {
// export some objects
$scope.savedVis = savedVis;
$scope.indexPattern = vis.indexPattern;
if (vis.indexPattern) {
$scope.indexPattern = vis.indexPattern;
} else {
indexPatterns.getDefault().then(defaultIndexPattern => {
$scope.indexPattern = defaultIndexPattern;
});
}
$scope.searchSource = searchSource;
$scope.state = $state;

View file

@ -43,11 +43,19 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.clickGo();
});
it('should not have inspector enabled', async function () {
await inspector.expectIsNotEnabled();
});
describe('filter bar', () => {
it('should show the default index pattern when clicking "Add filter"', async () => {
await testSubjects.click('addFilter');
const fields = await filterBar.getFilterEditorFields();
await filterBar.ensureFieldEditorModalIsClosed();
expect(fields.length).to.be.greaterThan(0);
});
});
describe('updateFiltersOnChange is false', () => {
it('should contain dropdown with terms aggregation results as options', async () => {