From 08737dd5451b4f5e50c5d3d4692c963ab7559bd3 Mon Sep 17 00:00:00 2001 From: Kapian1234 Date: Mon, 11 Nov 2024 12:01:00 +0800 Subject: [PATCH 1/4] Update functional tests for workspace create Signed-off-by: Kapian1234 --- .../mds_workspace_create.spec.js | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js index 61a24dced..004dba1b9 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js @@ -91,6 +91,94 @@ if (Cypress.env('WORKSPACE_ENABLED')) { cy.checkWorkspace(workspaceId, expectedWorkspace); }); }); + + it('should successfully create a workspace from home page', () => { + miscUtils.visitPage('app/workspace_initial'); + cy.getElementByTestId( + 'workspace-initial-card-createWorkspace-button' + ).click({ + force: true, + }); + cy.getElementByTestId( + 'workspace-initial-button-create-observability-workspace' + ).click({ + force: true, + }); + cy.contains('Observability') + .first() + .closest('.euiCheckableCard-isChecked') + .should('exist'); + + miscUtils.visitPage('app/workspace_initial'); + cy.getElementByTestId( + 'workspace-initial-useCaseCard-security-analytics-button-createWorkspace' + ).click({ + force: true, + }); + cy.contains('Security Analytics') + .first() + .closest('.euiCheckableCard-isChecked') + .should('exist'); + + inputWorkspaceName(workspaceName); + inputDataSourceWhenMDSEnabled(dataSourceTitle); + cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ + force: true, + }); + + let workspaceId; + cy.wait('@createWorkspaceRequest').then((interception) => { + expect(interception.response.statusCode).to.equal(200); + workspaceId = interception.response.body.result.id; + + cy.location('pathname', { timeout: 6000 }).should( + 'include', + `w/${workspaceId}/app` + ); + + const expectedWorkspace = { + name: workspaceName, + features: ['use-case-security-analytics'], + }; + cy.checkWorkspace(workspaceId, expectedWorkspace); + }); + }); + + it('should successfully jump to collaborators page create a workspace after creating a workspace', () => { + inputWorkspaceName(workspaceName); + inputDataSourceWhenMDSEnabled(dataSourceTitle); + cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ + force: true, + }); + + let workspaceId; + cy.wait('@createWorkspaceRequest').then((interception) => { + expect(interception.response.statusCode).to.equal(200); + workspaceId = interception.response.body.result.id; + + cy.location('pathname', { timeout: 6000 }).should( + 'include', + `w/${workspaceId}/app/workspace_collaborators` + ); + }); + }); + + it('should correctly display create a workspace', () => { + inputWorkspaceName(workspaceName); + cy.getElementByTestId( + 'workspaceForm-workspaceDetails-descriptionInputText' + ).type('test_workspace_description.+~!'); + cy.getElementByTestId('workspaceUseCase-essentials').click({ + force: true, + }); + inputDataSourceWhenMDSEnabled(dataSourceTitle); + cy.get('.workspaceCreateRightSidebar').within(() => { + cy.contains(workspaceName).should('exist'); + cy.contains('test_workspace_description.+~!').should('exist'); + cy.contains('Essentials').should('exist'); + cy.contains(dataSourceTitle).should('exist'); + }); + }); }); describe('Validate workspace name and description', () => { From 00b3e70e6a7670054c0a8bccb7cc8fb18e0f86b8 Mon Sep 17 00:00:00 2001 From: Kapian1234 Date: Mon, 11 Nov 2024 12:20:39 +0800 Subject: [PATCH 2/4] Fix duplicate creation Signed-off-by: Kapian1234 --- .../workspace-plugin/mds_workspace_create.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js index 004dba1b9..afc2e52f0 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js @@ -93,6 +93,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); it('should successfully create a workspace from home page', () => { + cy.deleteWorkspaceByName(workspaceName); miscUtils.visitPage('app/workspace_initial'); cy.getElementByTestId( 'workspace-initial-card-createWorkspace-button' @@ -144,7 +145,8 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); }); - it('should successfully jump to collaborators page create a workspace after creating a workspace', () => { + it('should successfully jump to collaborators page after creating a workspace', () => { + cy.deleteWorkspaceByName(workspaceName); inputWorkspaceName(workspaceName); inputDataSourceWhenMDSEnabled(dataSourceTitle); cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ @@ -163,7 +165,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); }); - it('should correctly display create a workspace', () => { + it('should correctly display the summary card', () => { inputWorkspaceName(workspaceName); cy.getElementByTestId( 'workspaceForm-workspaceDetails-descriptionInputText' From e7214c666dbd5562757bb66782e2040c4e0afd87 Mon Sep 17 00:00:00 2001 From: Kapian1234 Date: Wed, 13 Nov 2024 11:54:24 +0800 Subject: [PATCH 3/4] Add conditions for test cases Signed-off-by: Kapian1234 --- .../mds_workspace_create.spec.js | 69 ++++++++++--------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js index afc2e52f0..d4fa1dbea 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js @@ -145,42 +145,49 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); }); - it('should successfully jump to collaborators page after creating a workspace', () => { - cy.deleteWorkspaceByName(workspaceName); - inputWorkspaceName(workspaceName); - inputDataSourceWhenMDSEnabled(dataSourceTitle); - cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ - force: true, - }); + if ( + Cypress.env('SAVED_OBJECTS_PERMISSION_ENABLED') && + Cypress.env('SECURITY_ENABLED') + ) { + it('should successfully jump to collaborators page after creating a workspace', () => { + cy.deleteWorkspaceByName(workspaceName); + inputWorkspaceName(workspaceName); + inputDataSourceWhenMDSEnabled(dataSourceTitle); + cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ + force: true, + }); - let workspaceId; - cy.wait('@createWorkspaceRequest').then((interception) => { - expect(interception.response.statusCode).to.equal(200); - workspaceId = interception.response.body.result.id; + let workspaceId; + cy.wait('@createWorkspaceRequest').then((interception) => { + expect(interception.response.statusCode).to.equal(200); + workspaceId = interception.response.body.result.id; - cy.location('pathname', { timeout: 6000 }).should( - 'include', - `w/${workspaceId}/app/workspace_collaborators` - ); + cy.location('pathname', { timeout: 6000 }).should( + 'include', + `w/${workspaceId}/app/workspace_collaborators` + ); + }); }); - }); + } - it('should correctly display the summary card', () => { - inputWorkspaceName(workspaceName); - cy.getElementByTestId( - 'workspaceForm-workspaceDetails-descriptionInputText' - ).type('test_workspace_description.+~!'); - cy.getElementByTestId('workspaceUseCase-essentials').click({ - force: true, - }); - inputDataSourceWhenMDSEnabled(dataSourceTitle); - cy.get('.workspaceCreateRightSidebar').within(() => { - cy.contains(workspaceName).should('exist'); - cy.contains('test_workspace_description.+~!').should('exist'); - cy.contains('Essentials').should('exist'); - cy.contains(dataSourceTitle).should('exist'); + if (MDSEnabled) { + it('should correctly display the summary card', () => { + inputWorkspaceName(workspaceName); + cy.getElementByTestId( + 'workspaceForm-workspaceDetails-descriptionInputText' + ).type('test_workspace_description.+~!'); + cy.getElementByTestId('workspaceUseCase-essentials').click({ + force: true, + }); + inputDataSourceWhenMDSEnabled(dataSourceTitle); + cy.get('.workspaceCreateRightSidebar').within(() => { + cy.contains(workspaceName).should('exist'); + cy.contains('test_workspace_description.+~!').should('exist'); + cy.contains('Essentials').should('exist'); + cy.contains(dataSourceTitle).should('exist'); + }); }); - }); + } }); describe('Validate workspace name and description', () => { From a06f04bf94bdf37e90de73216fbc12154ed0186b Mon Sep 17 00:00:00 2001 From: Kapian1234 Date: Wed, 13 Nov 2024 17:45:15 +0800 Subject: [PATCH 4/4] Optimize the condition check Signed-off-by: Kapian1234 --- .../mds_workspace_create.spec.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js index d4fa1dbea..c133bdc65 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js @@ -170,24 +170,24 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); } - if (MDSEnabled) { - it('should correctly display the summary card', () => { - inputWorkspaceName(workspaceName); - cy.getElementByTestId( - 'workspaceForm-workspaceDetails-descriptionInputText' - ).type('test_workspace_description.+~!'); - cy.getElementByTestId('workspaceUseCase-essentials').click({ - force: true, - }); - inputDataSourceWhenMDSEnabled(dataSourceTitle); - cy.get('.workspaceCreateRightSidebar').within(() => { - cy.contains(workspaceName).should('exist'); - cy.contains('test_workspace_description.+~!').should('exist'); - cy.contains('Essentials').should('exist'); + it('should correctly display the summary card', () => { + inputWorkspaceName(workspaceName); + cy.getElementByTestId( + 'workspaceForm-workspaceDetails-descriptionInputText' + ).type('test_workspace_description.+~!'); + cy.getElementByTestId('workspaceUseCase-essentials').click({ + force: true, + }); + inputDataSourceWhenMDSEnabled(dataSourceTitle); + cy.get('.workspaceCreateRightSidebar').within(() => { + cy.contains(workspaceName).should('exist'); + cy.contains('test_workspace_description.+~!').should('exist'); + cy.contains('Essentials').should('exist'); + if (MDSEnabled) { cy.contains(dataSourceTitle).should('exist'); - }); + } }); - } + }); }); describe('Validate workspace name and description', () => {