-
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.
add tests for data source association and dissociation
Signed-off-by: tygao <[email protected]>
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
...earch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_association.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,80 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
const miscUtils = new MiscUtils(cy); | ||
const workspaceName = 'test_workspace_collaborators'; | ||
let workspaceId; | ||
let dataSourceTitle1 = 'no_auth_data_source_title_1'; | ||
let dataSourceTitle2 = 'no_auth_data_source_title_2'; | ||
let dataSourceId1; | ||
let dataSourceId2; | ||
if ( | ||
Cypress.env('WORKSPACE_ENABLED') && | ||
Cypress.env('SECURITY_ENABLED') && | ||
Cypress.env('DATASOURCE_MANAGEMENT_ENABLED') | ||
) { | ||
describe('Workspace association data source', () => { | ||
before(() => { | ||
cy.createDataSourceNoAuth({ title: dataSourceTitle1 }).then((result) => { | ||
dataSourceId1 = result[0]; | ||
}); | ||
cy.createDataSourceNoAuth({ title: dataSourceTitle2 }).then((result) => { | ||
dataSourceId2 = result[0]; | ||
}); | ||
}); | ||
beforeEach(() => { | ||
cy.deleteWorkspaceByName(workspaceName); | ||
//Create a workspace before each test | ||
cy.createWorkspace({ | ||
name: workspaceName, | ||
features: ['use-case-observability'], | ||
settings: { | ||
permissions: { | ||
library_write: { users: ['%me%'] }, | ||
write: { users: ['%me%'] }, | ||
}, | ||
}, | ||
}).then((value) => { | ||
workspaceId = value; | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteDataSource(dataSourceId1); | ||
cy.deleteDataSource(dataSourceId2); | ||
}); | ||
afterEach(() => { | ||
cy.deleteWorkspaceById(workspaceId); | ||
}); | ||
|
||
it('should associate and dissociate data source successfully', () => { | ||
miscUtils.visitPage(`w/${workspaceId}/app/dataSources`); | ||
|
||
cy.getElementByTestId('workspaceAssociateDataSourceButton').click(); | ||
cy.contains('OpenSearch data sources').click(); | ||
cy.contains(dataSourceTitle1, { | ||
withinSubject: parent.document.body, | ||
}).click({ force: true }); | ||
cy.contains(dataSourceTitle2, { | ||
withinSubject: parent.document.body, | ||
}).click({ force: true }); | ||
cy.getElementByTestId( | ||
'workspace-detail-dataSources-associateModal-save-button' | ||
).click(); | ||
|
||
// The table is updated after successful association | ||
cy.contains('table', dataSourceTitle1); | ||
cy.contains('table', dataSourceTitle2); | ||
|
||
// The table is updated after successful dissociation | ||
cy.getElementByTestId('checkboxSelectAll').check(); | ||
cy.getElementByTestId('dissociateSelectedDataSources').click(); | ||
cy.getElementByTestId('confirmModalConfirmButton').click(); | ||
cy.contains('table', dataSourceTitle1).should('not.exist'); | ||
cy.contains('table', dataSourceTitle2).should('not.exist'); | ||
}); | ||
}); | ||
} |