Improve Saved object import functional test assertions (#20409) (#20419)

* disable broken functional tests in saved object import

* add better assertions to verify objects are imported as expected

* more discriptive variable name

* add test case for imported object linked to saved search when saved search does not exist
This commit is contained in:
Nathan Reese 2018-07-03 12:45:08 -06:00 committed by GitHub
parent 3ca54d06fd
commit 80452ba9d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 21 deletions

View file

@ -37,17 +37,18 @@ export default function ({ getService, getPageObjects }) {
await esArchiver.unload('management');
});
it('should import saved objects normally', async function () {
it('should import saved objects', async function () {
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.clickImportDone();
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(3);
const isSavedObjectImported = objects.includes('Log Agents');
expect(isSavedObjectImported).to.be(true);
});
it('should import conflicts using a confirm modal', async function () {
it('should provide dialog to allow the importing of saved objects with index pattern conflicts', async function () {
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects-conflicts.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
@ -57,10 +58,14 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.clickImportDone();
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(3);
const isSavedObjectImported = objects.includes('saved object with index pattern conflict');
expect(isSavedObjectImported).to.be(true);
});
it('should allow for overrides', async function () {
// Test should be testing that user is warned when saved object will override another because of an id collision
// This is not the case. Instead the test just loads a saved object with an index pattern conflict
// Disabling until the issue is resolved since the test does not test the intended behavior
it.skip('should allow for overrides', async function () {
await PageObjects.settings.clickKibanaSavedObjects();
// Put in data which already exists
@ -83,7 +88,10 @@ export default function ({ getService, getPageObjects }) {
expect(objects.length).to.be(2);
});
it('should allow for cancelling overrides', async function () {
// Test should be testing that user is warned when saved object will overrides another because of an id collision
// This is not the case. Instead the test just loads a saved object with an index pattern conflict
// Disabling until the issue is resolved since the test does not test the intended behavior
it.skip('should allow for cancelling overrides', async function () {
await PageObjects.settings.clickKibanaSavedObjects();
// Put in data which already exists
@ -106,7 +114,37 @@ export default function ({ getService, getPageObjects }) {
expect(objects.length).to.be(2);
});
it('should handle saved searches and objects with saved searches properly', async function () {
it('should import saved objects linked to saved searches', async function () {
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_saved_search.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.clickImportDone();
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
const isSavedObjectImported = objects.includes('saved object connected to saved search');
expect(isSavedObjectImported).to.be(true);
});
it('should not import saved objects linked to saved searches when saved search does not exist', async function () {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.clickImportDone();
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
const isSavedObjectImported = objects.includes('saved object connected to saved search');
expect(isSavedObjectImported).to.be(false);
});
it('should not import saved objects linked to saved searches when saved search index pattern does not exist', async function () {
// First, import the saved search
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_saved_search.json'));
@ -130,10 +168,11 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(2);
const isSavedObjectImported = objects.includes('saved object connected to saved search');
expect(isSavedObjectImported).to.be(false);
});
it('should work with index patterns', async () => {
it('should import saved objects with index patterns when index patterns already exists', async () => {
// First, import the objects
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json'));
@ -143,19 +182,17 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(2);
const isSavedObjectImported = objects.includes('saved object imported with index pattern');
expect(isSavedObjectImported).to.be(true);
});
it('should work when the index pattern does not exist', async () => {
it('should import saved objects with index patterns when index patterns does not exists', async () => {
// First, we need to delete the index pattern
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndices();
await PageObjects.settings.clickOnOnlyIndexPattern();
await PageObjects.settings.removeIndexPattern();
// Second, create it
await PageObjects.settings.createIndexPattern('logstash-', '@timestamp');
// Then, import the objects
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json'));
@ -165,7 +202,8 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(2);
const isSavedObjectImported = objects.includes('saved object imported with index pattern');
expect(isSavedObjectImported).to.be(true);
});
});
}

View file

@ -1,9 +1,9 @@
[
{
"_id": "082f1d60-a2e7-11e7-bb30-233be9be6a15",
"_id": "saved_object_with_index_pattern_conflict",
"_type": "visualization",
"_source": {
"title": "Log Agents",
"title": "saved object with index pattern conflict",
"visState": "{\"title\":\"Log Agents\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{\"text\":\"agent.raw: Descending\"}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"agent.raw\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}",
"uiStateJSON": "{}",
"description": "",

View file

@ -1,9 +1,9 @@
[
{
"_id": "cbd520f0-ba72-11e7-a8f9-ad70f02e633d",
"_id": "saved_object_connected_to_saved_search",
"_type": "visualization",
"_source": {
"title": "PHP Viz",
"title": "saved object connected to saved search",
"visState": "{\"title\":\"PHP Viz\",\"type\":\"horizontal_bar\",\"params\":{\"type\":\"histogram\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":200},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":75,\"filter\":true,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":true,\"type\":\"histogram\",\"mode\":\"normal\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}",
"uiStateJSON": "{}",
"description": "",

View file

@ -12,10 +12,10 @@
}
},
{
"_id": "Shared-Item-Visualization-AreaChart",
"_id": "saved_object_imported_with_index_pattern",
"_type": "visualization",
"_source": {
"title": "Shared-Item Visualization AreaChart",
"title": "saved object imported with index pattern",
"visState": "{\"title\":\"New Visualization\",\"type\":\"area\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"smoothLines\":false,\"scale\":\"linear\",\"interpolate\":\"linear\",\"mode\":\"stacked\",\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}",
"uiStateJSON": "{}",
"description": "AreaChart",