Skip to content

Commit

Permalink
use add instead of update
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Nov 12, 2024
1 parent 906009a commit 5bf332c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ if (
features: ['use-case-observability'],
settings: {
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user'],
},
read: {
users: ['read_user'],
},
},
},
}).then((value) => {
Expand All @@ -32,7 +44,7 @@ if (
});
});

after(() => {
afterEach(() => {
cy.deleteWorkspaceById(workspaceId);
});

Expand All @@ -41,7 +53,9 @@ if (
cy.getElementByTestId('add-collaborator-popover').click();
cy.get('button[id="user"]').click();
cy.contains('Add Users').should('be.visible');
cy.getElementByTestId('workspaceCollaboratorIdInput-0').type('read_user');
cy.getElementByTestId('workspaceCollaboratorIdInput-0').type(
'new_read_user'
);
cy.get('button[type="submit"]')
.contains('span', 'Add collaborators')
.click();
Expand All @@ -51,7 +65,7 @@ if (
cy.get('button[id="group"]').click();
cy.contains('Add Groups').should('be.visible');
cy.getElementByTestId('workspaceCollaboratorIdInput-0').type(
'admin_group'
'new_admin_group'
);
cy.get('span[title="Admin"]').click();
cy.get('button[type="submit"]')
Expand All @@ -61,14 +75,14 @@ if (
cy.wait(2000); // Intentional Wait

cy.get('table')
.contains('td', 'read_user')
.contains('td', 'new_read_user')
.parent()
.within(() => {
cy.get('td').eq(3).contains('Read only');
});

cy.get('table')
.contains('td', 'admin_group')
.contains('td', 'new_admin_group')
.parent()
.within(() => {
cy.get('td').eq(3).contains('Admin');
Expand All @@ -80,49 +94,24 @@ if (
permissions: {
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
groups: ['admin_group', 'new_admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
groups: ['admin_group', 'new_admin_group'],
},
library_read: {
users: ['read_user'],
users: ['read_user', 'new_read_user'],
},
read: {
users: ['read_user'],
users: ['read_user', 'new_read_user'],
},
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});

it('should change access level successfully', () => {
//Add initial collaborators
cy.updateWorkspace({
id: workspaceId,
settings: {
permissions: {
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user'],
},
read: {
users: ['read_user'],
},
},
},
});
miscUtils.visitPage(`w/${workspaceId}/app/workspace_collaborators`);
cy.wait(2000); // Intentional Wait

cy.get('table')
.contains('td', 'read_user')
.parent('tr')
Expand Down Expand Up @@ -185,31 +174,6 @@ if (
});

it('should delete collaborators successfully', () => {
//Add initial collaborators
cy.updateWorkspace({
id: workspaceId,
settings: {
permissions: {
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user'],
},
read: {
users: ['read_user'],
},
},
},
});
miscUtils.visitPage(`w/${workspaceId}/app/workspace_collaborators`);
cy.wait(2000); // Intentional Wait

cy.get('table')
.contains('td', 'read_user')
.parent('tr')
Expand Down
20 changes: 0 additions & 20 deletions cypress/utils/dashboards/workspace-plugin/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,6 @@ Cypress.Commands.add('createWorkspace', ({ settings, ...workspace } = {}) => {
});
});

Cypress.Commands.add('updateWorkspace', ({ settings, attributes, id } = {}) => {
cy.request({
method: 'PUT',
url: `${BASE_PATH}${WORKSPACE_API_PREFIX}/${id}`,
headers: {
'osd-xsrf': true,
},
body: {
attributes,
settings,
},
}).then((resp) => {
if (resp && resp.body && resp.body.success) {
return resp.body.result.id;
} else {
throw new Error(`Update workspace failed!`);
}
});
});

/**
* Check whether the given workspace is equal to the expected workspace or not,
* the given workspace is as exepcted when the name, description, features, and permissions are as expected.
Expand Down

0 comments on commit 5bf332c

Please sign in to comment.