Add unit tests that check activity stream is hidden appropriately

This commit is contained in:
Marliana Lara
2020-06-29 13:20:44 -04:00
parent b5bbfaab11
commit eec2177315
3 changed files with 16 additions and 2 deletions

View File

@@ -76,6 +76,7 @@ describe('<HostDetail />', () => {
beforeAll(() => {
const readOnlyHost = { ...mockHost };
readOnlyHost.summary_fields.user_capabilities.edit = false;
readOnlyHost.summary_fields.recent_jobs = [];
wrapper = mountWithContexts(<HostDetail host={mockHost} />);
});
@@ -84,6 +85,12 @@ describe('<HostDetail />', () => {
wrapper.unmount();
});
test('should hide activity stream when there are no recent jobs', async () => {
expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength(
0
);
});
test('should hide edit button for users without edit permission', async () => {
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(0);
});

View File

@@ -50,7 +50,7 @@ function Inventories({ i18n }) {
[`${inventoryHostsPath}/${nested?.id}`]: `${nested?.name}`,
[`${inventoryHostsPath}/${nested?.id}/edit`]: i18n._(t`Edit details`),
[`${inventoryHostsPath}/${nested?.id}/details`]: i18n._(
t`Host Details`
t`Host details`
),
[`${inventoryHostsPath}/${nested?.id}/completed_jobs`]: i18n._(
t`Completed jobs`
@@ -80,7 +80,7 @@ function Inventories({ i18n }) {
),
[`${inventorySourcesPath}/${nested?.id}/schedules/${schedule?.id}`]: `${schedule?.name}`,
[`${inventorySourcesPath}/${nested?.id}/schedules/${schedule?.id}/details`]: i18n._(
t`Schedule Details`
t`Schedule details`
),
});
},

View File

@@ -79,6 +79,7 @@ describe('<InventoryHostDetail />', () => {
beforeAll(() => {
const readOnlyHost = { ...mockHost };
readOnlyHost.summary_fields.user_capabilities.edit = false;
readOnlyHost.summary_fields.recent_jobs = [];
wrapper = mountWithContexts(<InventoryHostDetail host={mockHost} />);
});
@@ -87,6 +88,12 @@ describe('<InventoryHostDetail />', () => {
wrapper.unmount();
});
test('should hide activity stream when there are no recent jobs', async () => {
expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength(
0
);
});
test('should hide edit button for users without edit permission', async () => {
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(0);
});