Skip to content

Commit

Permalink
[Workspace]Fix workspace functional tests (#1556)
Browse files Browse the repository at this point in the history
* Fix functional tests in workspace create and import sample data

Signed-off-by: Lin Wang <[email protected]>

* Fix workspace detail failed

Signed-off-by: Lin Wang <[email protected]>

* Fix lint error

Signed-off-by: Lin Wang <[email protected]>

* Remove no need changes

Signed-off-by: Lin Wang <[email protected]>

* Enable new homepage flag in workspace plugin

Signed-off-by: Lin Wang <[email protected]>

* Remove waitForLoader due to new homepage enabled

Signed-off-by: Lin Wang <[email protected]>

* Update test name in workspace workflow

Signed-off-by: Lin Wang <[email protected]>

* Fix duplicate test cypress result name

Signed-off-by: Lin Wang <[email protected]>

* Fix meta data missing in no auth data source saved object

Signed-off-by: Lin Wang <[email protected]>

* Move selectTopRightNavigationDataSource to utils folder

Signed-off-by: Lin Wang <[email protected]>

* Fix failed workspace import sample data cases

Signed-off-by: Lin Wang <[email protected]>

* Fix failed workspace detail cases

Signed-off-by: Lin Wang <[email protected]>

* Fix workspace create failed

Signed-off-by: Lin Wang <[email protected]>

* Add data source associated cases for workspace create

Signed-off-by: Lin Wang <[email protected]>

* Revert "Fix duplicate test cypress result name"

This reverts commit 20d440b.

Signed-off-by: Lin Wang <[email protected]>

* Fix duplicate artifact name in workspace workflow

Signed-off-by: Lin Wang <[email protected]>

* Fix duplicate artifact in ml commons

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
(cherry picked from commit 8109549)
  • Loading branch information
wanglam authored and github-actions[bot] committed Nov 7, 2024
1 parent f30518f commit 49e6727
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 183 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ml-commons-release-e2e-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ jobs:
test-name: ML Commons With Multi Data Source
test-command: env CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/plugins/ml-commons-dashboards/mds*.js'
osd-serve-args: --ml_commons_dashboards.enabled=true --data_source.enabled=true --data_source.hideLocalCluster=true
artifact-name-suffix: "-with-security-and-mds"
13 changes: 8 additions & 5 deletions .github/workflows/workspace-release-e2e-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,25 @@ jobs:
with:
test-name: dashboards workspace
test-command: env CYPRESS_WORKSPACE_ENABLED=true CYPRESS_SAVED_OBJECTS_PERMISSION_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/*'
osd-serve-args: --workspace.enabled=true --savedObjects.permission.enabled=true --opensearch_security.multitenancy.enabled=false --opensearchDashboards.dashboardAdmin.users='["admin"]'
osd-serve-args: --workspace.enabled=true --savedObjects.permission.enabled=true --opensearch_security.multitenancy.enabled=false --opensearchDashboards.dashboardAdmin.users='["admin"]' --uiSettings.overrides.home:useNewHomePage=true
artifact-name-suffix: "-with-security"
tests-without-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: dashboards workspace
test-name: dashboards workspace without security
test-command: env CYPRESS_WORKSPACE_ENABLED=true yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/*'
osd-serve-args: --workspace.enabled=true --savedObjects.permission.enabled=false
osd-serve-args: --workspace.enabled=true --savedObjects.permission.enabled=false --uiSettings.overrides.home:useNewHomePage=true
security-enabled: false
artifact-name-suffix: "-without-security"
tests-with-multiple-data-source-and-disabled-local-cluster:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: dashboards workspace
test-name: dashboards workspace with MDS
test-command: env CYPRESS_DISABLE_LOCAL_CLUSTER=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true CYPRESS_WORKSPACE_ENABLED=true CYPRESS_SAVED_OBJECTS_PERMISSION_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds*.js'
osd-serve-args: --data_source.enabled=true --data_source.ssl.verificationMode=none --data_source.hideLocalCluster=true --workspace.enabled=true --savedObjects.permission.enabled=true --opensearch_security.multitenancy.enabled=false --opensearchDashboards.dashboardAdmin.users='["admin"]'
osd-serve-args: --data_source.enabled=true --data_source.ssl.verificationMode=none --data_source.hideLocalCluster=true --workspace.enabled=true --savedObjects.permission.enabled=true --opensearch_security.multitenancy.enabled=false --opensearchDashboards.dashboardAdmin.users='["admin"]' --uiSettings.overrides.home:useNewHomePage=true
security-enabled: true
artifact-name-suffix: "-with-security-and-mds"
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,41 @@
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);
const workspaceName = 'test_workspace_az3RBx6cE';
const MDSEnabled = Cypress.env('DATASOURCE_MANAGEMENT_ENABLED');

const inputWorkspaceName = (workspaceName) => {
const nameInputTestId = 'workspaceForm-workspaceDetails-nameInputText';
cy.getElementByTestId(nameInputTestId).clear();
cy.getElementByTestId(nameInputTestId).type(workspaceName);
};

const inputDataSourceWhenMDSEnabled = (dataSourceTitle) => {
if (!MDSEnabled) {
return;
}
cy.getElementByTestId('workspace-creator-dataSources-assign-button').click();

cy.get(`li[title="${dataSourceTitle}"]`).click();

cy.getElementByTestId(
'workspace-detail-dataSources-associateModal-save-button'
).click();
};

if (Cypress.env('WORKSPACE_ENABLED')) {
describe('Create workspace', () => {
let dataSourceTitle;
before(() => {
cy.deleteWorkspaceByName(workspaceName);
if (MDSEnabled) {
cy.deleteAllDataSources();
cy.createDataSourceNoAuth().then((result) => {
dataSourceTitle = result[1];
});
}
});

beforeEach(() => {
Expand All @@ -21,6 +50,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) {

after(() => {
cy.deleteWorkspaceByName(workspaceName);
if (MDSEnabled) {
cy.deleteAllDataSources();
}
});

it('should successfully load the page', () => {
Expand All @@ -29,18 +61,14 @@ if (Cypress.env('WORKSPACE_ENABLED')) {

describe('Create a workspace successfully', () => {
it('should successfully create a workspace', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type(workspaceName);
inputWorkspaceName(workspaceName);
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description.+~!');
cy.getElementByTestId(
'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker'
).type('#000000');
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
Expand All @@ -52,13 +80,13 @@ if (Cypress.env('WORKSPACE_ENABLED')) {

cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/workspace_detail'
`w/${workspaceId}/app`
);

const expectedWorkspace = {
name: workspaceName,
description: 'test_workspace_description.+~!',
features: ['workspace_detail', 'use-case-observability'],
features: ['use-case-observability'],
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});
Expand All @@ -68,53 +96,84 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
describe('Validate workspace name and description', () => {
it('workspace name is required', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
'workspaceForm-workspaceDetails-nameInputText'
).clear();
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains('Name is required. Enter a name.').should('exist');
cy.contains('Enter a name.').should('exist');
});

it('workspace name is not valid', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type('./+');
inputWorkspaceName('./+');
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains('Name is invalid. Enter a valid name.').should('exist');
cy.contains('Enter a valid name.').should('exist');
});

it('workspace name cannot use an existing name', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type(workspaceName);
cy.deleteWorkspaceByName(workspaceName);
cy.createWorkspace({
name: workspaceName,
features: ['use-case-observability'],
});
inputWorkspaceName(workspaceName);
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains('workspace name has already been used').should('exist');
});
});

it('workspace use case is required', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type(workspaceName);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
if (MDSEnabled) {
describe('Create a workspace with associated data sources', () => {
before(() => {
cy.deleteWorkspaceByName(workspaceName);
});

it('should be exists inside workspace data source list', () => {
inputWorkspaceName(workspaceName);
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});

cy.wait('@createWorkspaceRequest')
.then((interception) => {
expect(interception.response.statusCode).to.equal(200);
return interception.response.body.result.id;
})
.then((workspaceId) => {
const dataSourcePathname = `w/${workspaceId}/app/dataSources`;
miscUtils.visitPage(dataSourcePathname);
cy.location('pathname', { timeout: 6000 }).should(
'include',
dataSourcePathname
);
cy.contains(dataSourceTitle).should('exist');
});
});
});
cy.contains('Use case is required. Select a use case.').should('exist');
});
}

if (
Cypress.env('SAVED_OBJECTS_PERMISSION_ENABLED') &&
Expand All @@ -126,25 +185,14 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
});

it('should successfully create a workspace with permissions', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type(workspaceName);
inputWorkspaceName(workspaceName);
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
cy.getElementByTestId(
'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker'
).type('#000000');
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
cy.getElementByTestId(
'workspaceForm-permissionSettingPanel-user-addNew'
).click();
cy.contains('.euiComboBoxPlaceholder', 'Select a user')
.parent()
.find('input')
.type('test_user_sfslja260');
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
Expand All @@ -155,19 +203,13 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
workspaceId = interception.response.body.result.id;
cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/workspace_detail'
`w/${workspaceId}/app`
);
const expectedWorkspace = {
name: workspaceName,
description: 'test_workspace_description',
features: ['workspace_detail', 'use-case-observability'],
features: ['use-case-observability'],
permissions: {
read: {
users: ['test_user_sfslja260'],
},
library_read: {
users: ['test_user_sfslja260'],
},
write: {
users: [`${Cypress.env('username')}`],
},
Expand Down
Loading

0 comments on commit 49e6727

Please sign in to comment.