Skip to content
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

[Workspace] add tests for data source association and dissociation #1646

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
}
Loading