From 10b03ef1e804928a2d0b434b0c7bcf3965d36c36 Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Wed, 12 Jun 2024 10:30:55 +0800 Subject: [PATCH] Update workspace description usecase tests (#1375) * Remove workspace invalid description cases Signed-off-by: Lin Wang * Add workspace use case test cases Signed-off-by: Lin Wang * Update create workspace page title Signed-off-by: Lin Wang * Update copy to Enter Details Signed-off-by: Lin Wang * Add special characters and move use case out Signed-off-by: Lin Wang * Remove user & permissions button Signed-off-by: Lin Wang * Update expected worksapce content Signed-off-by: Lin Wang --------- Signed-off-by: Lin Wang (cherry picked from commit c5ae8b4eab5417a7e85a5cb7cedfcb6411867dcc) --- .../mds_workspace_create.spec.js | 49 +++++++-------- .../mds_workspace_dropdown_menu.spec.js | 18 +++++- .../mds_workspace_overview.spec.js | 7 +-- .../mds_workspace_update.spec.js | 59 +++++++++---------- 4 files changed, 67 insertions(+), 66 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 c8b0471e6..fb8cda62b 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 @@ -24,7 +24,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); it('should successfully load the page', () => { - cy.contains('Create Workspace', { timeout: 60000 }); + cy.contains('Create a workspace', { timeout: 60000 }); }); describe('Create a workspace successfully', () => { @@ -34,14 +34,13 @@ if (Cypress.env('WORKSPACE_ENABLED')) { ).type(workspaceName); cy.getElementByTestId( 'workspaceForm-workspaceDetails-descriptionInputText' - ).type('test_workspace_description'); + ).type('test_workspace_description.+~!'); cy.getElementByTestId( 'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker' ).type('#000000'); - cy.getElementByTestId( - 'workspaceForm-workspaceFeatureVisibility-OpenSearch Dashboards' - ).check({ force: true }); - cy.get('[id$="discover"]').uncheck({ force: true }); + cy.getElementByTestId('workspaceUseCase-observability').check({ + force: true, + }); cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ force: true, }); @@ -58,12 +57,11 @@ if (Cypress.env('WORKSPACE_ENABLED')) { const expectedWorkspace = { name: workspaceName, - description: 'test_workspace_description', + description: 'test_workspace_description.+~!', features: [ - 'dashboards', - 'visualize', 'workspace_update', 'workspace_overview', + 'use-case-observability', ], }; cy.checkWorkspace(workspaceId, expectedWorkspace); @@ -102,24 +100,24 @@ if (Cypress.env('WORKSPACE_ENABLED')) { cy.getElementByTestId( 'workspaceForm-workspaceDetails-descriptionInputText' ).type('test_workspace_description'); + cy.getElementByTestId('workspaceUseCase-observability').check({ + force: true, + }); cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ force: true, }); cy.contains('workspace name has already been used').should('exist'); }); + }); - it('workspace description is not valid', () => { - cy.getElementByTestId( - 'workspaceForm-workspaceDetails-nameInputText' - ).type(workspaceName); - cy.getElementByTestId( - 'workspaceForm-workspaceDetails-descriptionInputText' - ).type('./+'); - cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ - force: true, - }); - cy.contains('Invalid workspace description').should('exist'); + it('workspace use case is required', () => { + cy.getElementByTestId( + 'workspaceForm-workspaceDetails-nameInputText' + ).type(workspaceName); + cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({ + force: true, }); + cy.contains('Use case is required. Select a use case.').should('exist'); }); if ( @@ -141,11 +139,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) { cy.getElementByTestId( 'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker' ).type('#000000'); - cy.getElementByTestId( - 'workspaceForm-workspaceFeatureVisibility-OpenSearch Dashboards' - ).check({ force: true }); - cy.get('[id$="discover"]').uncheck({ force: true }); - cy.get('button').contains('Users & Permissions').click(); + cy.getElementByTestId('workspaceUseCase-observability').check({ + force: true, + }); cy.getElementByTestId( 'workspaceForm-permissionSettingPanel-user-addNew' ).click(); @@ -168,10 +164,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) { name: workspaceName, description: 'test_workspace_description', features: [ - 'dashboards', - 'visualize', 'workspace_update', 'workspace_overview', + 'use-case-observability', ], permissions: { read: { diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_dropdown_menu.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_dropdown_menu.spec.js index 7e8aed992..3e688c739 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_dropdown_menu.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_dropdown_menu.spec.js @@ -20,7 +20,14 @@ if (Cypress.env('WORKSPACE_ENABLED')) { cy.deleteAllWorkspaces(); for (const workspaceName of workspaceNames) { - cy.createWorkspace({ name: workspaceName }).then((workspaceId) => { + cy.createWorkspace({ + name: workspaceName, + features: [ + 'workspace_overview', + 'workspace_update', + 'use-case-observability', + ], + }).then((workspaceId) => { workspaceNameIdMapping[workspaceName] = workspaceId; }); } @@ -98,7 +105,14 @@ if (Cypress.env('WORKSPACE_ENABLED')) { // Create 3 more workspaces so that there are more than 5 workspaces in the system for (const workspaceName of newWorkspaceNames) { - cy.createWorkspace({ name: workspaceName }); + cy.createWorkspace({ + name: workspaceName, + features: [ + 'workspace_overview', + 'workspace_update', + 'use-case-observability', + ], + }); } cy.wait(1000); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_overview.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_overview.spec.js index 7fcbe9c90..cd8ca526f 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_overview.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_overview.spec.js @@ -19,12 +19,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) { name: workspaceName, description: workspaceDescription, features: [ - 'management', - 'discover', 'workspace_overview', 'workspace_update', - 'dashboards', - 'visualize', + 'use-case-observability', ], }).then((id) => { workspaceId = id; @@ -103,7 +100,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) { it('should show wokrspace update when click on settings tab', () => { // click on settings tab cy.getElementByTestId('workspaceTabs').find('#settings').click(); - cy.contains('Workspace Details').should('be.visible'); + cy.contains('Enter Details').should('be.visible'); cy.getElementByTestId('workspaceForm-workspaceDetails-nameInputText') .clear() diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_update.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_update.spec.js index be67609a6..d22fd0cd4 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_update.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_update.spec.js @@ -12,9 +12,14 @@ if (Cypress.env('WORKSPACE_ENABLED')) { describe('Update workspace', () => { before(() => { cy.deleteWorkspaceByName(workspaceName); - cy.createWorkspace({ name: workspaceName }).then( - (value) => (workspaceId = value) - ); + cy.createWorkspace({ + name: workspaceName, + features: [ + 'workspace_overview', + 'workspace_update', + 'use-case-observability', + ], + }).then((value) => (workspaceId = value)); }); beforeEach(() => { @@ -77,21 +82,16 @@ if (Cypress.env('WORKSPACE_ENABLED')) { }); cy.contains('Invalid workspace name').should('exist'); }); + }); - it('workspace description is not valid', () => { - cy.getElementByTestId( - 'workspaceForm-workspaceDetails-descriptionInputText' - ).clear({ - force: true, - }); - cy.getElementByTestId( - 'workspaceForm-workspaceDetails-descriptionInputText' - ).type('./+'); - cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({ - force: true, - }); - cy.contains('Invalid workspace description').should('exist'); + it('workspace use case is required', () => { + cy.getElementByTestId('workspaceUseCase-observability').uncheck({ + force: true, + }); + cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({ + force: true, }); + cy.contains('Use case is required. Select a use case.').should('exist'); }); describe('Update a workspace successfully', () => { @@ -111,13 +111,13 @@ if (Cypress.env('WORKSPACE_ENABLED')) { ).type(workspaceName); cy.getElementByTestId( 'workspaceForm-workspaceDetails-descriptionInputText' - ).type('test_workspace_description'); + ).type('test_workspace_description.+~!'); cy.getElementByTestId( 'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker' ).type('#D36086'); - cy.getElementByTestId( - 'workspaceForm-workspaceFeatureVisibility-OpenSearch Dashboards' - ).check({ force: true }); + cy.getElementByTestId('workspaceUseCase-observability').check({ + force: true, + }); cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({ force: true, }); @@ -130,13 +130,11 @@ if (Cypress.env('WORKSPACE_ENABLED')) { ); const expectedWorkspace = { name: workspaceName, - description: 'test_workspace_description', + description: 'test_workspace_description.+~!', features: [ - 'dashboards', - 'visualize', - 'discover', 'workspace_update', 'workspace_overview', + 'use-case-observability', ], }; cy.checkWorkspace(workspaceId, expectedWorkspace); @@ -148,7 +146,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) { Cypress.env('SECURITY_ENABLED') ) { describe('Update a workspace with permissions successfully', () => { - it.only('should successfully update a workspace with permissions', () => { + it('should successfully update a workspace with permissions', () => { cy.getElementByTestId( 'workspaceForm-workspaceDetails-nameInputText' ).clear({ @@ -168,11 +166,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) { cy.getElementByTestId( 'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker' ).type('#000000'); - cy.getElementByTestId( - 'workspaceForm-workspaceFeatureVisibility-OpenSearch Dashboards' - ).check({ force: true }); - cy.get('[id$="discover"]').uncheck({ force: true }); - cy.get('button').contains('Users & Permissions').click(); + cy.getElementByTestId('workspaceUseCase-observability').check({ + force: true, + }); cy.getElementByTestId( 'workspaceForm-permissionSettingPanel-user-addNew' ).click(); @@ -193,10 +189,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) { name: workspaceName, description: 'test_workspace_description', features: [ - 'dashboards', - 'visualize', 'workspace_update', 'workspace_overview', + 'use-case-observability', ], permissions: { read: {