Skip to content

Commit

Permalink
Fix workspace failed integration tests (#1442) (#1450)
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
(cherry picked from commit 25f947d)

Co-authored-by: Lin Wang <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
  • Loading branch information
3 people authored Jul 31, 2024
1 parent a16bd8e commit cd008d1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains("Name can't be empty").should('exist');
cy.contains('Name is required. Enter a name.').should('exist');
});

it('workspace name is not valid', () => {
Expand All @@ -90,7 +90,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains('Invalid workspace name').should('exist');
cy.contains('Name is invalid. Enter a valid name.').should('exist');
});

it('workspace name cannot use an existing name', () => {
Expand Down Expand Up @@ -145,8 +145,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId(
'workspaceForm-permissionSettingPanel-user-addNew'
).click();
cy.getElementByTestId('comboBoxSearchInput')
.last()
cy.contains('.euiComboBoxPlaceholder', 'Select a user')
.parent()
.find('input')
.type('test_user_sfslja260');
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,39 @@ if (Cypress.env('WORKSPACE_ENABLED')) {

before(() => {
if (MDSEnabled) {
cy.createDataSourceNoAuth().then((result) => {
dataSourceId = result[0];
dataSourceTitle = result[1];
cy.createDataSourceNoAuth()
.then((result) => {
dataSourceId = result[0];
dataSourceTitle = result[1];
return result;
})
.then((result) => {
cy.createWorkspace({
name: workspaceName,
settings: MDSEnabled
? {
dataSources: [result[0]],
}
: undefined,
}).then((id) => {
workspaceId = id;
});
});
} else {
cy.createWorkspace({
name: workspaceName,
}).then((id) => {
workspaceId = id;
});
}
cy.createWorkspace({ name: workspaceName }).then((id) => {
workspaceId = id;
});
});

after(() => {
if (workspaceId) {
cy.deleteWorkspaceById(workspaceId);
}
if (dataSourceId) {
cy.deleteDataSource(dataSourceId);
if (MDSEnabled) {
cy.deleteAllDataSources();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
'workspace_update',
'use-case-observability',
],
settings: {
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
},
},
}).then((id) => {
workspaceId = id;
});
Expand Down Expand Up @@ -97,14 +103,17 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
);
});

it('should show wokrspace update when click on settings tab', () => {
it('should show workspace update when click on settings tab', () => {
// click on settings tab
cy.getElementByTestId('workspaceTabs').find('#settings').click();
cy.contains('Enter Details').should('be.visible');

cy.getElementByTestId('workspaceForm-workspaceDetails-nameInputText')
.clear()
.type(`${workspaceDescription}-updated`);
cy.contains('Enter details').should('be.visible');

cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).clear();
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type(`${workspaceDescription}-updated`);
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
'workspace_update',
'use-case-observability',
],
settings: {
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
},
},
}).then((value) => (workspaceId = value));
});

Expand Down Expand Up @@ -57,7 +63,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
cy.contains("Name can't be empty").should('exist');
cy.contains('Name is required. Enter a name.').should('exist');
});

it('workspace name is not valid', () => {
Expand All @@ -80,7 +86,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
cy.contains('Invalid workspace name').should('exist');
cy.contains('Name is invalid. Enter a valid name.').should('exist');
});
});

Expand Down Expand Up @@ -172,8 +178,9 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId(
'workspaceForm-permissionSettingPanel-user-addNew'
).click();
cy.getElementByTestId('comboBoxSearchInput')
.last()
cy.contains('.euiComboBoxPlaceholder', 'Select a user')
.parent()
.find('input')
.type('test_user_Fnxs972xC');
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
Expand Down
3 changes: 2 additions & 1 deletion cypress/utils/dashboards/workspace-plugin/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Cypress.Commands.add('deleteWorkspaceByName', (workspaceName) => {
});
});

Cypress.Commands.add('createWorkspace', (workspace) => {
Cypress.Commands.add('createWorkspace', ({ settings, ...workspace } = {}) => {
cy.request({
method: 'POST',
url: `${BASE_PATH}${WORKSPACE_API_PREFIX}`,
Expand All @@ -53,6 +53,7 @@ Cypress.Commands.add('createWorkspace', (workspace) => {
...workspace,
description: workspace.description || 'test_description',
},
settings,
},
}).then((resp) => {
if (resp && resp.body && resp.body.success) {
Expand Down

0 comments on commit cd008d1

Please sign in to comment.