-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workspace] Add functional test for workspace overview page (#1246)
* workspace overview Signed-off-by: Hailong Cui <[email protected]> * update create workspace Signed-off-by: Hailong Cui <[email protected]> * address review comments Signed-off-by: Hailong Cui <[email protected]> * Add assertion Signed-off-by: Hailong Cui <[email protected]> * fix workspacd name Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]>
- Loading branch information
1 parent
c18b673
commit 1b19f50
Showing
5 changed files
with
162 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...e-opensearch-dashboards/opensearch-dashboards/workspace-plugin/workspace_overview.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* 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 currentDate = Date.now(); | ||
const workspaceName = 'foo-workspace' + currentDate; | ||
const workspaceDescription = 'foo-workspace-desc' + currentDate; | ||
|
||
if (Cypress.env('WORKSPACE_ENABLED')) { | ||
let workspaceId = ''; | ||
|
||
describe('Workspace overview', () => { | ||
before(() => { | ||
cy.createWorkspace({ | ||
name: workspaceName, | ||
description: workspaceDescription, | ||
features: [ | ||
'management', | ||
'discover', | ||
'workspace_overview', | ||
'workspace_update', | ||
'dashboards', | ||
'visualize', | ||
], | ||
}).then((id) => { | ||
workspaceId = id; | ||
}); | ||
cy.log(`workspace ${workspaceName} create successfully`); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteWorkspaceById(workspaceId); | ||
}); | ||
|
||
beforeEach(() => { | ||
// Visit workspace overview page | ||
cy.intercept('GET', `/w/${workspaceId}/api/workspaces/${workspaceId}`).as( | ||
'getWorkspace' | ||
); | ||
miscUtils.visitPage(`/w/${workspaceId}/app/workspace_overview`); | ||
cy.wait('@getWorkspace'); | ||
}); | ||
|
||
it('should successfully load the page', () => { | ||
// workspace name is correctly displayed | ||
cy.contains(workspaceName, { timeout: 60000 }).should('be.visible'); | ||
// dashboars and visualization cards are visiable | ||
cy.get('div[data-test-subj="workspaceGetStartCards"') | ||
.as('getStartCards') | ||
.should('be.visible'); | ||
cy.get('@getStartCards').contains('with Dashboards').should('be.visible'); | ||
cy.get('@getStartCards') | ||
.contains('with Visualizations') | ||
.should('be.visible'); | ||
|
||
// tabs | ||
cy.getElementByTestId('workspaceTabs') | ||
.find('.euiTab') | ||
.as('tabs') | ||
.should('have.length', 3); | ||
}); | ||
|
||
it('should collpase start working section when collpase button clicked', () => { | ||
// workspace name is correctly displayed | ||
cy.contains(workspaceName, { timeout: 60000 }).should('be.visible'); | ||
// dashboars and visualization cards are visiable | ||
cy.getElementByTestId('workspaceGetStartCards') | ||
.as('getStartCards') | ||
.should('be.visible'); | ||
cy.get('@getStartCards').contains('with Dashboards').should('be.visible'); | ||
cy.get('@getStartCards') | ||
.contains('with Visualizations') | ||
.should('be.visible'); | ||
|
||
// click Collpase | ||
cy.getElementByTestId('Collapse').click(); | ||
cy.get('@getStartCards').should('not.exist'); | ||
|
||
// click Expand | ||
cy.getElementByTestId('Expand').click(); | ||
cy.get('@getStartCards').should('be.visible'); | ||
}); | ||
|
||
it('should display workspace description correctly in overview tab', () => { | ||
// click on overview tab | ||
cy.get('div[data-test-subj="workspaceTabs"] #overview').click(); | ||
cy.contains(workspaceDescription).should('be.visible'); | ||
}); | ||
|
||
it('should redirect to saved objects page when click on library tab', () => { | ||
// click on library tab | ||
cy.get('div[data-test-subj="workspaceTabs"] #library').click(); | ||
cy.location('pathname', { timeout: 6000 }).should( | ||
'include', | ||
'app/management/opensearch-dashboards/objects' | ||
); | ||
}); | ||
|
||
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.getElementByTestId('workspaceForm-workspaceDetails-nameInputText') | ||
.clear() | ||
.type(`${workspaceDescription}-updated`); | ||
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({ | ||
force: true, | ||
}); | ||
|
||
// workspace update successfully and overview page refreshed | ||
cy.contains('h1', `${workspaceDescription}-updated`).should('be.visible'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters