Add new tests for rbac on some of the org pages

This commit is contained in:
mabashian
2019-04-24 10:09:17 -04:00
parent 82db7df6b3
commit e5dda696d7
4 changed files with 78 additions and 11 deletions

View File

@@ -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);
});
});

View File

@@ -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);
});
});