-
Notifications
You must be signed in to change notification settings - Fork 130
[MDS]Add FT for Import saved objects #1349
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
base: main
Are you sure you want to change the base?
Changes from all commits
f103a97
8331dbf
1ad7e4e
0842294
1c3b676
c97866e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
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 | ||
); | ||
}); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* 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', () => { | ||
const types = [ | ||
'index-pattern', | ||
'visualization', | ||
'dashboard', | ||
'search', | ||
'query', | ||
'url', | ||
'augment-vis', | ||
'homepage', | ||
'data-source', | ||
'visualization-visbuilder', | ||
'config', | ||
]; | ||
types.forEach((type) => { | ||
cy.deleteSavedObjectByType(type); | ||
}); | ||
}); | ||
|
||
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++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I assume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the length of the test file length, good suggestion if we consider always using this as the test file |
||
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 }); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we reuse existing util to select data source from data source selector?
opensearch-dashboards-functional-test/cypress/utils/commands.js
Line 605 in fc490c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I tried this one, but I found the selector on import page does not have the input, while the dev tools has this functionality, if reusing, it can break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, let's use your util for import then. Great finding, let me file an issue on OSD to make "isClearable" prop consistent across all places that consumes this selector in OSD