Skip to content

Commit 840e739

Browse files
Kapian1234wanglam
andauthored
Add test cases for workspace creation (#1635)
* Update functional tests for workspace create Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Fix duplicate creation Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Add conditions for test cases Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Optimize the condition check Signed-off-by: Kapian1234 <wanjinch@amazon.com> --------- Signed-off-by: Kapian1234 <wanjinch@amazon.com> Co-authored-by: Lin Wang <wonglam@amazon.com>
1 parent 7003895 commit 840e739

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/workspace-plugin/mds_workspace_create.spec.js

+97
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,103 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
9191
cy.checkWorkspace(workspaceId, expectedWorkspace);
9292
});
9393
});
94+
95+
it('should successfully create a workspace from home page', () => {
96+
cy.deleteWorkspaceByName(workspaceName);
97+
miscUtils.visitPage('app/workspace_initial');
98+
cy.getElementByTestId(
99+
'workspace-initial-card-createWorkspace-button'
100+
).click({
101+
force: true,
102+
});
103+
cy.getElementByTestId(
104+
'workspace-initial-button-create-observability-workspace'
105+
).click({
106+
force: true,
107+
});
108+
cy.contains('Observability')
109+
.first()
110+
.closest('.euiCheckableCard-isChecked')
111+
.should('exist');
112+
113+
miscUtils.visitPage('app/workspace_initial');
114+
cy.getElementByTestId(
115+
'workspace-initial-useCaseCard-security-analytics-button-createWorkspace'
116+
).click({
117+
force: true,
118+
});
119+
cy.contains('Security Analytics')
120+
.first()
121+
.closest('.euiCheckableCard-isChecked')
122+
.should('exist');
123+
124+
inputWorkspaceName(workspaceName);
125+
inputDataSourceWhenMDSEnabled(dataSourceTitle);
126+
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
127+
force: true,
128+
});
129+
130+
let workspaceId;
131+
cy.wait('@createWorkspaceRequest').then((interception) => {
132+
expect(interception.response.statusCode).to.equal(200);
133+
workspaceId = interception.response.body.result.id;
134+
135+
cy.location('pathname', { timeout: 6000 }).should(
136+
'include',
137+
`w/${workspaceId}/app`
138+
);
139+
140+
const expectedWorkspace = {
141+
name: workspaceName,
142+
features: ['use-case-security-analytics'],
143+
};
144+
cy.checkWorkspace(workspaceId, expectedWorkspace);
145+
});
146+
});
147+
148+
if (
149+
Cypress.env('SAVED_OBJECTS_PERMISSION_ENABLED') &&
150+
Cypress.env('SECURITY_ENABLED')
151+
) {
152+
it('should successfully jump to collaborators page after creating a workspace', () => {
153+
cy.deleteWorkspaceByName(workspaceName);
154+
inputWorkspaceName(workspaceName);
155+
inputDataSourceWhenMDSEnabled(dataSourceTitle);
156+
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
157+
force: true,
158+
});
159+
160+
let workspaceId;
161+
cy.wait('@createWorkspaceRequest').then((interception) => {
162+
expect(interception.response.statusCode).to.equal(200);
163+
workspaceId = interception.response.body.result.id;
164+
165+
cy.location('pathname', { timeout: 6000 }).should(
166+
'include',
167+
`w/${workspaceId}/app/workspace_collaborators`
168+
);
169+
});
170+
});
171+
}
172+
173+
it('should correctly display the summary card', () => {
174+
inputWorkspaceName(workspaceName);
175+
cy.getElementByTestId(
176+
'workspaceForm-workspaceDetails-descriptionInputText'
177+
).type('test_workspace_description.+~!');
178+
cy.getElementByTestId('workspaceUseCase-essentials').click({
179+
force: true,
180+
});
181+
inputDataSourceWhenMDSEnabled(dataSourceTitle);
182+
cy.get('.workspaceCreateRightSidebar').within(() => {
183+
cy.contains(workspaceName).should('exist');
184+
cy.contains('test_workspace_description.+~!').should('exist');
185+
cy.contains('Essentials').should('exist');
186+
if (MDSEnabled) {
187+
cy.contains(dataSourceTitle).should('exist');
188+
}
189+
});
190+
});
94191
});
95192

96193
describe('Validate workspace name and description', () => {

0 commit comments

Comments
 (0)