-
Notifications
You must be signed in to change notification settings - Fork 114
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 functional test for workspace overview page #1246
Merged
Hailong-am
merged 5 commits into
opensearch-project:main
from
Hailong-am:workspace_overview
Apr 30, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: just curious why we need to add
force: true
, is it being covered by other elements?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
covered by
when doing test in local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the root cause of this toast is CSP restriction. Could we create a separate issue and add related config like OSD cypress workflow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a issue #1252 to track this.