Skip to content

Commit

Permalink
Reenable import objects tests (#21250)
Browse files Browse the repository at this point in the history
* Reenable import objects tests. Refine their assertions. Add primary callout to indicate completion of import process when the user has opted to not import anything.
  • Loading branch information
cjcenizal authored Jul 27, 2018
1 parent 489e5bb commit 5fcd10e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,23 @@ export class Flyout extends Component {
}

if (wasImportSuccessful) {
if (importCount === 0) {
return (
<EuiCallOut
data-test-subj="importSavedObjectsSuccessNoneImported"
title="No objects imported"
color="primary"
/>
);
}

return (
<EuiCallOut title="Import successful" color="success" iconType="check">
<EuiCallOut
data-test-subj="importSavedObjectsSuccess"
title="Import successful"
color="success"
iconType="check"
>
<p>Successfully imported {importCount} objects.</p>
</EuiCallOut>
);
Expand Down
55 changes: 20 additions & 35 deletions test/functional/apps/management/_import_objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'settings', 'header']);
const testSubjects = getService('testSubjects');

describe('import objects', function describeIndexTests() {
beforeEach(async function () {
Expand Down Expand Up @@ -53,7 +54,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects-conflicts.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.setImportIndexFieldOption(2);
await PageObjects.settings.clickConfirmConflicts();
await PageObjects.settings.clickConfirmChanges();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.clickImportDone();
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
Expand All @@ -62,56 +63,40 @@ export default function ({ getService, getPageObjects }) {
expect(isSavedObjectImported).to.be(true);
});

// 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 () {
it('should allow the user to override duplicate saved objects', async function () {
await PageObjects.settings.clickKibanaSavedObjects();

// Put in data which already exists
// This data has already been loaded by the "visualize" esArchive. We'll load it again
// so that we can override the existing visualization.
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_exists.json'), false);
// Wait for all the saves to happen

await PageObjects.header.waitUntilLoadingHasFinished();
// Interact with the conflict modal
await PageObjects.settings.setImportIndexFieldOption(2);
await PageObjects.settings.clickConfirmConflicts();
// Now confirm we want to override
await PageObjects.settings.clickConfirmChanges();

// Override the visualization.
await PageObjects.common.clickConfirmOnModal();
// Wait for all the saves to happen
await PageObjects.header.waitUntilLoadingHasFinished();
// Finish the flyout
await PageObjects.settings.clickImportDone();
// Wait...
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();

const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(2);
const isSuccessful = await testSubjects.exists('importSavedObjectsSuccess');
expect(isSuccessful).to.be(true);
});

// 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 () {
it('should allow the user to cancel overriding duplicate saved objects', async function () {
await PageObjects.settings.clickKibanaSavedObjects();

// Put in data which already exists
// This data has already been loaded by the "visualize" esArchive. We'll load it again
// so that we can be prompted to override the existing visualization.
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_exists.json'), false);
// Wait for all the saves to happen

await PageObjects.header.waitUntilLoadingHasFinished();
// Interact with the conflict modal
await PageObjects.settings.setImportIndexFieldOption(2);
await PageObjects.settings.clickConfirmConflicts();
// Now cancel the override
await PageObjects.settings.clickConfirmChanges();

// *Don't* override the visualization.
await PageObjects.common.clickCancelOnModal();
// Wait for all saves to happen
await PageObjects.header.waitUntilLoadingHasFinished();
// Finish the flyout
await PageObjects.settings.clickImportDone();
// Wait for table to refresh
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();

const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.length).to.be(2);
const isSuccessful = await testSubjects.exists('importSavedObjectsSuccessNoneImported');
expect(isSuccessful).to.be(true);
});

it('should import saved objects linked to saved searches', async function () {
Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
await testSubjects.click('importSavedObjectsDoneBtn');
}

async clickConfirmConflicts() {
async clickConfirmChanges() {
await testSubjects.click('importSavedObjectsConfirmBtn');
}

Expand Down

0 comments on commit 5fcd10e

Please sign in to comment.