-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yujin-emma <[email protected]>
- Loading branch information
1 parent
4ddffc9
commit bb0d184
Showing
7 changed files
with
155 additions
and
4,603 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 0 additions & 185 deletions
185
...tegration/core-opensearch-dashboards/opensearch-dashboards/mds_import_export_test.spec.js
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
cypress/integration/core-opensearch-dashboards/opensearch-dashboards/mds_import_test.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
import { CURRENT_TENANT } from '../../../utils/commands'; | ||
import 'cypress-file-upload'; | ||
|
||
const miscUtils = new MiscUtils(cy); | ||
|
||
if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { | ||
let dataSourceTitle; | ||
|
||
describe('import saved object test', () => { | ||
before(() => { | ||
// Go to the saved object page | ||
cy.deleteAllDataSources(); | ||
cy.wait(1000); | ||
|
||
cy.deleteAllSavedObjects(); | ||
miscUtils.visitPage('app/management/opensearch-dashboards/objects'); | ||
|
||
CURRENT_TENANT.newTenant = 'global'; | ||
cy.wait(1000); | ||
|
||
// create data source | ||
cy.createDataSourceNoAuth().then((result) => { | ||
dataSourceTitle = result[1]; | ||
}); | ||
cy.reload(true); | ||
cy.wait(1000); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteAllSavedObjects(); | ||
}); | ||
|
||
it('can import saved objects from ndjson file and create new copies', () => { | ||
cy.uploadSavedObjectsToDataSource( | ||
'createNewCopiesEnabled', | ||
'', | ||
dataSourceTitle | ||
); | ||
}); | ||
it('can import saved objects from ndjson file and automatically override conflict', () => { | ||
cy.uploadSavedObjectsToDataSource( | ||
'createNewCopiesDisabled', | ||
'overwriteEnabled', | ||
dataSourceTitle | ||
); | ||
}); | ||
|
||
it('can import saved objects from ndjson file and request action when conflict exit', () => { | ||
cy.uploadSavedObjectsToDataSource( | ||
'createNewCopiesDisabled', | ||
'overwriteDisabled', | ||
dataSourceTitle | ||
); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
cypress/utils/dashboards/saved_objects_management/commands.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
Cypress.Commands.add('selectDataSourceForImport', (dataSourceTitle) => { | ||
cy.getElementByTestId('dataSourceSelectorComboBox').click(); | ||
cy.get('.euiFilterSelectItem') | ||
.contains(dataSourceTitle) // Find the element containing dataSourceTitle | ||
.click(); | ||
}); | ||
|
||
Cypress.Commands.add('deleteAllSavedObjects', () => { | ||
cy.wait(1000); | ||
cy.deleteSavedObjectByType('dashboard'); | ||
cy.wait(1000); | ||
cy.deleteSavedObjectByType('index-pattern'); | ||
cy.wait(1000); | ||
cy.deleteSavedObjectByType('search'); | ||
cy.wait(1000); | ||
cy.deleteSavedObjectByType('visualization'); | ||
cy.wait(1000); | ||
cy.deleteSavedObjectByType('metrics'); | ||
cy.wait(1000); | ||
cy.deleteSavedObjectByType('vega'); | ||
}); | ||
|
||
Cypress.Commands.add( | ||
'uploadSavedObjectsToDataSource', | ||
(importMode, override, dataSourceTitle) => { | ||
cy.contains('button', 'Import').click(); | ||
cy.wait(1000); | ||
cy.fixture( | ||
'dashboard/opensearch_dashboards/saved_objects_management/mds_log_objects.ndjson' | ||
).then((fileContent) => { | ||
cy.get('input[type="file"]').attachFile({ | ||
fileContent: fileContent, | ||
fileName: 'mds_log_objects.ndjson', | ||
mimeType: 'text/plain', // use 'application/json' to treat the ndsjon as json, keep 'text/plain' to use ndjson | ||
}); | ||
}); | ||
cy.wait(1000); | ||
cy.selectDataSourceForImport(dataSourceTitle); // choose the data source that is created at the beginning of the test | ||
cy.handleImportMode(importMode); | ||
if (override !== '') { | ||
cy.handleImportMode(override); | ||
} | ||
cy.wait(1000); | ||
cy.getElementByTestId('importSavedObjectsImportBtn').click({ | ||
force: true, | ||
}); | ||
cy.getElementByTestId('importSavedObjectsConfirmBtn').click({ | ||
force: true, | ||
}); | ||
cy.wait(1000); | ||
if (importMode === 'createNewCopiesEnabled') { | ||
cy.contains('new').should('be.visible'); | ||
} else { | ||
if (override !== 'overwriteEnabled') { | ||
for (let i = 0; i < 29; i++) { | ||
cy.getElementByTestId('confirmModalConfirmButton').click(); | ||
} | ||
cy.getElementByTestId('confirmModalCancelButton').click(); | ||
} | ||
cy.contains('error').should('not.exist'); | ||
} | ||
cy.getElementByTestId('importSavedObjectsDoneBtn').click({ force: true }); | ||
} | ||
); | ||
|
||
Cypress.Commands.add('handleImportMode', (importMode) => { | ||
cy.get(`#${importMode}`).check({ force: true }); | ||
}); |
Oops, something went wrong.