Skip to content

Commit 4d4ee6b

Browse files
raintygaogithub-actions[bot]
authored andcommitted
[Workspace] add tests for data source association and dissociation (#1646)
* add tests for data source association and dissociation Signed-off-by: tygao <tygao@amazon.com> * remove security verification Signed-off-by: tygao <tygao@amazon.com> --------- Signed-off-by: tygao <tygao@amazon.com> (cherry picked from commit 7003895)
1 parent 5115b59 commit 4d4ee6b

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
7+
const miscUtils = new MiscUtils(cy);
8+
const workspaceName = 'test_workspace_collaborators';
9+
let workspaceId;
10+
let dataSourceTitle1 = 'no_auth_data_source_title_1';
11+
let dataSourceTitle2 = 'no_auth_data_source_title_2';
12+
let dataSourceId1;
13+
let dataSourceId2;
14+
if (
15+
Cypress.env('WORKSPACE_ENABLED') &&
16+
Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')
17+
) {
18+
describe('Workspace association data source', () => {
19+
before(() => {
20+
cy.createDataSourceNoAuth({ title: dataSourceTitle1 }).then((result) => {
21+
dataSourceId1 = result[0];
22+
});
23+
cy.createDataSourceNoAuth({ title: dataSourceTitle2 }).then((result) => {
24+
dataSourceId2 = result[0];
25+
});
26+
});
27+
beforeEach(() => {
28+
cy.deleteWorkspaceByName(workspaceName);
29+
//Create a workspace before each test
30+
cy.createWorkspace({
31+
name: workspaceName,
32+
features: ['use-case-observability'],
33+
settings: {
34+
permissions: {
35+
library_write: { users: ['%me%'] },
36+
write: { users: ['%me%'] },
37+
},
38+
},
39+
}).then((value) => {
40+
workspaceId = value;
41+
});
42+
});
43+
44+
after(() => {
45+
cy.deleteDataSource(dataSourceId1);
46+
cy.deleteDataSource(dataSourceId2);
47+
});
48+
afterEach(() => {
49+
cy.deleteWorkspaceById(workspaceId);
50+
});
51+
52+
it('should associate and dissociate data source successfully', () => {
53+
miscUtils.visitPage(`w/${workspaceId}/app/dataSources`);
54+
55+
cy.getElementByTestId('workspaceAssociateDataSourceButton').click();
56+
cy.contains('OpenSearch data sources').click();
57+
cy.contains(dataSourceTitle1, {
58+
withinSubject: parent.document.body,
59+
}).click({ force: true });
60+
cy.contains(dataSourceTitle2, {
61+
withinSubject: parent.document.body,
62+
}).click({ force: true });
63+
cy.getElementByTestId(
64+
'workspace-detail-dataSources-associateModal-save-button'
65+
).click();
66+
67+
// The table is updated after successful association
68+
cy.contains('table', dataSourceTitle1);
69+
cy.contains('table', dataSourceTitle2);
70+
71+
// The table is updated after successful dissociation
72+
cy.getElementByTestId('checkboxSelectAll').check();
73+
cy.getElementByTestId('dissociateSelectedDataSources').click();
74+
cy.getElementByTestId('confirmModalConfirmButton').click();
75+
cy.contains('table', dataSourceTitle1).should('not.exist');
76+
cy.contains('table', dataSourceTitle2).should('not.exist');
77+
});
78+
});
79+
}

0 commit comments

Comments
 (0)