diff --git a/src/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/flyout.js b/src/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/flyout.js index f99789b1932fe..16e856fb610cc 100644 --- a/src/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/flyout.js +++ b/src/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/flyout.js @@ -324,6 +324,7 @@ export class Flyout extends Component { const options = this.state.indexPatterns.map(indexPattern => ({ text: indexPattern.get('title'), value: indexPattern.id, + ['data-test-subj']: `indexPatternOption-${indexPattern.get('title')}`, })); options.unshift({ @@ -333,7 +334,7 @@ export class Flyout extends Component { return ( this.onIndexChanged(id, e)} options={options} /> diff --git a/test/functional/apps/management/_import_objects.js b/test/functional/apps/management/_import_objects.js index 16bd12edcb73c..cc2437e2a6378 100644 --- a/test/functional/apps/management/_import_objects.js +++ b/test/functional/apps/management/_import_objects.js @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.clickKibanaSavedObjects(); await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects-conflicts.json')); await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.settings.setImportIndexFieldOption(2); + await PageObjects.settings.associateIndexPattern('d1e4c910-a2e6-11e7-bb30-233be9be6a15', 'logstash-*'); await PageObjects.settings.clickConfirmChanges(); await PageObjects.header.waitUntilLoadingHasFinished(); await PageObjects.settings.clickImportDone(); @@ -71,7 +71,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_exists.json'), false); await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.settings.setImportIndexFieldOption(2); + await PageObjects.settings.associateIndexPattern('logstash-*', 'logstash-*'); await PageObjects.settings.clickConfirmChanges(); // Override the visualization. @@ -89,7 +89,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_exists.json'), false); await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.settings.setImportIndexFieldOption(2); + await PageObjects.settings.associateIndexPattern('logstash-*', 'logstash-*'); await PageObjects.settings.clickConfirmChanges(); // *Don't* override the visualization. diff --git a/test/functional/apps/management/_mgmt_import_saved_objects.js b/test/functional/apps/management/_mgmt_import_saved_objects.js new file mode 100644 index 0000000000000..e2bfd89f07544 --- /dev/null +++ b/test/functional/apps/management/_mgmt_import_saved_objects.js @@ -0,0 +1,59 @@ +/* + * 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 'expect.js'; +import path from 'path'; + +export default function ({ getService, getPageObjects }) { + const esArchiver = getService('esArchiver'); + const PageObjects = getPageObjects(['common', 'settings', 'header']); + + //in 6.4.0 bug the Saved Search conflict would be resolved and get imported but the visualization + //that referenced the saved search was not imported.( https://github.com/elastic/kibana/issues/22238) + + describe('mgmt saved objects', function describeIndexTests() { + beforeEach(async function () { + await esArchiver.load('discover'); + await PageObjects.settings.navigateTo(); + }); + + afterEach(async function () { + await esArchiver.unload('discover'); + }); + + it('should import saved objects mgmt', async function () { + + await PageObjects.settings.clickKibanaSavedObjects(); + await PageObjects.settings.importFile(path.join(__dirname, 'exports', 'mgmt_import_objects.json')); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.settings.associateIndexPattern('4c3f3c30-ac94-11e8-a651-614b2788174a', 'logstash-*'); + await PageObjects.settings.clickConfirmChanges(); + await PageObjects.settings.clickImportDone(); + await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading(); + + //instead of asserting on count- am asserting on the titles- which is more accurate than count. + const objects = await PageObjects.settings.getSavedObjectsInTable(); + expect(objects.includes('mysavedsearch')).to.be(true); + expect(objects.includes('mysavedviz')).to.be(true); + + }); + + }); + +} diff --git a/test/functional/apps/management/exports/mgmt_import_objects.json b/test/functional/apps/management/exports/mgmt_import_objects.json new file mode 100644 index 0000000000000..88e03585bf1ee --- /dev/null +++ b/test/functional/apps/management/exports/mgmt_import_objects.json @@ -0,0 +1,37 @@ +[ + { + "_id": "6aea5700-ac94-11e8-a651-614b2788174a", + "_type": "search", + "_source": { + "title": "mysavedsearch", + "description": "", + "hits": 0, + "columns": [ + "_source" + ], + "sort": [ + "@timestamp", + "desc" + ], + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"4c3f3c30-ac94-11e8-a651-614b2788174a\",\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[]}" + } + } + }, + { + "_id": "8411daa0-ac94-11e8-a651-614b2788174a", + "_type": "visualization", + "_source": { + "title": "mysavedviz", + "visState": "{\"title\":\"mysavedviz\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}", + "uiStateJSON": "{}", + "description": "", + "savedSearchId": "6aea5700-ac94-11e8-a651-614b2788174a", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[]}" + } + } + } +] diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index adc9a9b882f3c..c81a0b1c53ce6 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -44,6 +44,7 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_index_pattern_filter')); loadTestFile(require.resolve('./_scripted_fields_filter')); loadTestFile(require.resolve('./_import_objects')); + loadTestFile(require.resolve('./_mgmt_import_saved_objects')); loadTestFile(require.resolve('./_test_huge_fields')); loadTestFile(require.resolve('./_handle_alias')); }); diff --git a/test/functional/fixtures/es_archiver/mgmt/data.json.gz b/test/functional/fixtures/es_archiver/mgmt/data.json.gz new file mode 100644 index 0000000000000..d923b3a74e474 Binary files /dev/null and b/test/functional/fixtures/es_archiver/mgmt/data.json.gz differ diff --git a/test/functional/fixtures/es_archiver/mgmt/mappings.json b/test/functional/fixtures/es_archiver/mgmt/mappings.json new file mode 100644 index 0000000000000..107a45fab187b --- /dev/null +++ b/test/functional/fixtures/es_archiver/mgmt/mappings.json @@ -0,0 +1,283 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "auto_expand_replicas": "0-1", + "number_of_replicas": "0" + } + }, + "mappings": { + "doc": { + "dynamic": "strict", + "properties": { + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "graph-workspace": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "numLinks": { + "type": "integer" + }, + "numVertices": { + "type": "integer" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "wsState": { + "type": "text" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + }, + "aliases": {} + } +} \ No newline at end of file diff --git a/test/functional/page_objects/settings_page.js b/test/functional/page_objects/settings_page.js index 1f2fc65a1182c..55d64b3ae18a4 100644 --- a/test/functional/page_objects/settings_page.js +++ b/test/functional/page_objects/settings_page.js @@ -570,9 +570,10 @@ export function SettingsPageProvider({ getService, getPageObjects }) { await testSubjects.click('importSavedObjectsConfirmBtn'); } - async setImportIndexFieldOption(child) { + async associateIndexPattern(oldIndexPatternId, newIndexPatternTitle) { await find.clickByCssSelector( - `select[data-test-subj="managementChangeIndexSelection"] > option:nth-child(${child})` + `select[data-test-subj="managementChangeIndexSelection-${oldIndexPatternId}"] > + [data-test-subj="indexPatternOption-${newIndexPatternTitle}"]` ); } @@ -580,18 +581,6 @@ export function SettingsPageProvider({ getService, getPageObjects }) { await testSubjects.click('changeIndexConfirmButton'); } - async clickVisualizationsTab() { - await testSubjects.click('objectsTab-visualizations'); - } - - async clickSearchesTab() { - await testSubjects.click('objectsTab-searches'); - } - - async getVisualizationRows() { - return await testSubjects.findAll(`objectsTableRow`); - } - async waitUntilSavedObjectsTableIsNotLoading() { return retry.try(async () => { const exists = await find.existsByDisplayedByCssSelector(