mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 19:35:02 -02:30
Add new tests for rbac on some of the org pages
This commit is contained in:
@@ -176,4 +176,38 @@ describe('<OrganizationAccessList />', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('add role button visible for user that can edit org', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
|
||||
setImmediate(() => {
|
||||
const addRole = wrapper.update().find('DataListToolbar').find('PlusIcon');
|
||||
expect(addRole.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
test('add role button hidden for user that cannot edit org', () => {
|
||||
const readOnlyOrg = { ...organization };
|
||||
readOnlyOrg.summary_fields.user_capabilities.edit = false;
|
||||
const wrapper = mountWithContexts(
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={readOnlyOrg}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
|
||||
setImmediate(() => {
|
||||
const addRole = wrapper.update().find('DataListToolbar').find('PlusIcon');
|
||||
expect(addRole.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,4 +10,14 @@ describe('<OrganizationView />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mountWithContexts(<Organization me={me} />);
|
||||
});
|
||||
test('notifications tab shown/hidden based on permissions', () => {
|
||||
const wrapper = mountWithContexts(<Organization me={me} />);
|
||||
expect(wrapper.find('.pf-c-tabs__item').length).toBe(3);
|
||||
expect(wrapper.find('.pf-c-tabs__button[children="Notifications"]').length).toBe(0);
|
||||
wrapper.find('Organization').setState({
|
||||
isNotifAdmin: true
|
||||
});
|
||||
expect(wrapper.find('.pf-c-tabs__item').length).toBe(4);
|
||||
expect(wrapper.find('.pf-c-tabs__button[children="Notifications"]').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -88,4 +88,28 @@ describe('<OrganizationDetail />', () => {
|
||||
expect(modifiedDetail.find('h6').text()).toBe('Last Modified');
|
||||
expect(modifiedDetail.find('p').text()).toBe('Boo');
|
||||
});
|
||||
|
||||
test('should show edit button for users with edit permission', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<OrganizationDetail
|
||||
organization={mockDetails}
|
||||
/>
|
||||
).find('OrganizationDetail');
|
||||
|
||||
const editLink = wrapper.findWhere(node => node.props().to === '/organizations/undefined/edit');
|
||||
expect(editLink.length).toBe(1);
|
||||
});
|
||||
|
||||
test('should hide edit button for users without edit permission', () => {
|
||||
const readOnlyOrg = { ...mockDetails };
|
||||
readOnlyOrg.summary_fields.user_capabilities.edit = false;
|
||||
const wrapper = mountWithContexts(
|
||||
<OrganizationDetail
|
||||
organization={readOnlyOrg}
|
||||
/>
|
||||
).find('OrganizationDetail');
|
||||
|
||||
const editLink = wrapper.findWhere(node => node.props().to === '/organizations/undefined/edit');
|
||||
expect(editLink.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user