Add tests for index patterns without time field on dashboard (#54760) (#54922)

* Add tests for index patterns without time field on dashboard

* add null check

* Hide timefilter in editor only if timeFieldName is explicitly

* eslint

* test to ts

* Code review

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Liza Katz 2020-01-16 00:47:40 +02:00 committed by GitHub
parent 9dcdd2f58d
commit 19ca8174f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 100 additions and 1 deletions

View file

@ -357,7 +357,10 @@ function VisualizeAppController(
};
$scope.showQueryBarTimePicker = () => {
return vis.type.options.showTimePicker;
// tsvb loads without an indexPattern initially (TODO investigate).
// hide timefilter only if timeFieldName is explicitly undefined.
const hasTimeField = $scope.indexPattern ? !!$scope.indexPattern.timeFieldName : true;
return vis.type.options.showTimePicker && hasTimeField;
};
$scope.timeRange = timefilter.getTime();

View file

@ -0,0 +1,90 @@
/*
* 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 expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const filterBar = getService('filterBar');
const renderable = getService('renderable');
const dashboardAddPanel = getService('dashboardAddPanel');
const PageObjects = getPageObjects([
'common',
'visualize',
'header',
'dashboard',
'timePicker',
'visEditor',
'visChart',
]);
describe('data table with index without time filter filters', function indexPatternCreation() {
const vizName1 = 'Visualization DataTable w/o time filter';
before(async function() {
log.debug('navigateToApp visualize');
await PageObjects.visualize.navigateToNewVisualization();
log.debug('clickDataTable');
await PageObjects.visualize.clickDataTable();
log.debug('clickNewSearch');
await PageObjects.visualize.clickNewSearch(
PageObjects.visualize.index.LOGSTASH_NON_TIME_BASED
);
log.debug('Bucket = Split Rows');
await PageObjects.visEditor.clickBucket('Split rows');
log.debug('Aggregation = Histogram');
await PageObjects.visEditor.selectAggregation('Histogram');
log.debug('Field = bytes');
await PageObjects.visEditor.selectField('bytes');
log.debug('Interval = 2000');
await PageObjects.visEditor.setInterval('2000', { type: 'numeric' });
await PageObjects.visEditor.clickGo();
});
it('should be able to save and load', async function() {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visChart.waitForVisualization();
});
it('timefilter should be disabled', async () => {
const isOff = await PageObjects.timePicker.isOff();
expect(isOff).to.be(true);
});
// test to cover bug #54548 - add this visualization to a dashboard and filter
it('should add to dashboard and allow filtering', async function() {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.clickNewDashboard();
await dashboardAddPanel.addVisualization(vizName1);
// hover and click on cell to filter
await PageObjects.visChart.filterOnTableCell('1', '2');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.be(1);
await filterBar.removeAllFilters();
});
});
}

View file

@ -47,6 +47,7 @@ export default function({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_area_chart'));
loadTestFile(require.resolve('./_data_table'));
loadTestFile(require.resolve('./_data_table_nontimeindex'));
loadTestFile(require.resolve('./_data_table_notimeindex_filters'));
});
describe('', function() {

View file

@ -124,6 +124,11 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
await this.setAbsoluteRange(this.defaultStartTime, this.defaultEndTime);
}
async isOff() {
const element = await find.byClassName('euiDatePickerRange--readOnly');
return !!element;
}
async isQuickSelectMenuOpen() {
return await testSubjects.exists('superDatePickerQuickMenu');
}