Skip to content

Commit

Permalink
[Discover] Hide time picker when an indexpattern without timefield is…
Browse files Browse the repository at this point in the history
… selected (#62134)

* Assign valid value whether the timepicker should be displayed

* Add functional tests
  • Loading branch information
kertal authored Apr 9, 2020
1 parent 8d21b6b commit 2a1c8d8
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
query="state.query"
saved-query-id="state.savedQuery"
screen-title="screenTitle"
show-date-picker="enableTimeRangeSelector"
show-date-picker="indexPattern.isTimeBased()"
show-save-query="showSaveQuery"
show-search-bar="true"
use-default-behaviors="true"
Expand Down
52 changes: 52 additions & 0 deletions test/functional/apps/discover/_indexpattern_without_timefield.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'timePicker', 'discover']);

describe('indexpattern without timefield', function() {
before(async function() {
await esArchiver.loadIfNeeded('index_pattern_without_timefield');
});

beforeEach(async function() {
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('without-timefield');
});

after(async function unloadMakelogs() {
await esArchiver.unload('index_pattern_without_timefield');
});

it('should not display a timepicker', async function() {
const timepickerExists = await PageObjects.timePicker.timePickerExists();
expect(timepickerExists).to.be(false);
});

it('should display a timepicker after switching to an index pattern with timefield', async function() {
expect(await PageObjects.timePicker.timePickerExists()).to.be(false);
await PageObjects.discover.selectIndexPattern('with-timefield');
expect(await PageObjects.timePicker.timePickerExists()).to.be(true);
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ export default function({ getService, loadTestFile }) {
loadTestFile(require.resolve('./_doc_navigation'));
loadTestFile(require.resolve('./_date_nanos'));
loadTestFile(require.resolve('./_date_nanos_mixed'));
loadTestFile(require.resolve('./_indexpattern_without_timefield'));
});
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"type": "index",
"value": {
"index": "without-timefield",
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
}
}
},
"settings": {
"index": {
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}

{
"type": "index",
"value": {
"index": "with-timefield",
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
}
}
},
"settings": {
"index": {
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}

0 comments on commit 2a1c8d8

Please sign in to comment.