Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Saved object import functional test assertions #20409

Merged
merged 4 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions test/functional/apps/management/_import_objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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);
});
});
}
Original file line number Diff line number Diff line change
@@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down