|
-
+ |
{inventory.pending_deletion ? (
{inventory.name}
) : (
@@ -73,30 +74,32 @@ function InventoryListItem({
)}
|
-
+ |
{inventory.kind !== 'smart' && }
|
-
+ |
{inventory.kind === 'smart'
? i18n._(t`Smart Inventory`)
: i18n._(t`Inventory`)}
|
-
+ |
{inventory.summary_fields.organization.name}
|
- {inventory.total_groups} |
- {inventory.total_hosts} |
- {inventory.total_inventory_sources} |
+ {inventory.total_groups} |
+ {inventory.total_hosts} |
+
+ {inventory.total_inventory_sources}
+ |
{inventory.pending_deletion ? (
-
+ |
|
) : (
-
+
', () => {
test('initially renders succesfully', () => {
mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: true,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
});
test('should render prompt list item data', () => {
const wrapper = mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ kind: '',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: true,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
- expect(wrapper.find('SyncStatusIndicator').length).toBe(1);
+ expect(wrapper.find('StatusLabel').length).toBe(1);
expect(
wrapper
- .find('DataListCell')
+ .find('Td')
.at(1)
.text()
).toBe('Inventory');
expect(
wrapper
- .find('DataListCell')
+ .find('Td')
.at(2)
.text()
+ ).toBe('Disabled');
+ expect(
+ wrapper
+ .find('Td')
+ .at(3)
+ .text()
).toBe('Inventory');
expect(
wrapper
- .find('DataListCell')
- .at(3)
- .text()
- ).toBe('OrganizationDefault');
- expect(
- wrapper
- .find('DataListCell')
+ .find('Td')
.at(4)
.text()
- ).toBe('GroupsHostsSources');
+ ).toBe('Default');
});
test('edit button shown to users with edit capabilities', () => {
const wrapper = mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: true,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
});
+
test('edit button hidden from users without edit capabilities', () => {
const wrapper = mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: false,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
expect(wrapper.find('PencilAltIcon').exists()).toBeFalsy();
});
+
test('should call api to copy inventory', async () => {
InventoriesAPI.copy.mockResolvedValue();
const wrapper = mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: false,
+ copy: true,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
await act(async () =>
@@ -161,25 +183,29 @@ describe('', () => {
InventoriesAPI.copy.mockRejectedValue(new Error());
const wrapper = mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: false,
+ copy: true,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
await act(async () =>
wrapper.find('Button[aria-label="Copy"]').prop('onClick')()
@@ -191,25 +217,29 @@ describe('', () => {
test('should not render copy button', async () => {
const wrapper = mountWithContexts(
-
+
+ {}}
- />
+ name: 'Inventory',
+ summary_fields: {
+ organization: {
+ id: 1,
+ name: 'Default',
+ },
+ user_capabilities: {
+ edit: false,
+ copy: false,
+ },
+ },
+ }}
+ detailUrl="/inventories/inventory/1"
+ isSelected
+ onSelect={() => {}}
+ />
+
+
);
expect(wrapper.find('CopyButton').length).toBe(0);
});
diff --git a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx
index 05d66f2ada..49ab977167 100644
--- a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx
+++ b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx
@@ -122,14 +122,12 @@ function OrganizationsList({ i18n }) {
', () => {
});
test('Item appears selected after selecting it', async () => {
- const itemCheckboxInput = 'input#select-organization-1';
+ const itemCheckboxInput = 'tr#org-row-1 input[type="checkbox"]';
await act(async () => {
wrapper = mountWithContexts();
});
@@ -115,7 +115,6 @@ describe('', () => {
await act(async () => {
wrapper
.find(itemCheckboxInput)
- .closest('DataListCheck')
.props()
.onChange();
});
@@ -128,9 +127,9 @@ describe('', () => {
test('All items appear selected after select-all and unselected after unselect-all', async () => {
const itemCheckboxInputs = [
- 'input#select-organization-1',
- 'input#select-organization-2',
- 'input#select-organization-3',
+ 'tr#org-row-1 input[type="checkbox"]',
+ 'tr#org-row-2 input[type="checkbox"]',
+ 'tr#org-row-3 input[type="checkbox"]',
];
await act(async () => {
wrapper = mountWithContexts();
@@ -227,7 +226,7 @@ describe('', () => {
});
test('Error dialog shown for failed deletion', async () => {
- const itemCheckboxInput = 'input#select-organization-1';
+ const itemCheckboxInput = 'tr#org-row-1 input[type="checkbox"]';
OrganizationsAPI.destroy.mockRejectedValue(
new Error({
response: {
@@ -250,7 +249,6 @@ describe('', () => {
await act(async () => {
wrapper
.find(itemCheckboxInput)
- .closest('DataListCheck')
.props()
.onChange();
});
diff --git a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx
index 9bf440e165..1db1d7e859 100644
--- a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx
+++ b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx
@@ -20,7 +20,7 @@ function OrganizationListItem({
}) {
const labelId = `check-action-${organization.id}`;
return (
-
+
| ', () => {
mountWithContexts(
- {}}
- />
+
);
});
+
test('edit button shown to users with edit capabilities', () => {
const wrapper = mountWithContexts(
- {}}
- />
+
);
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
});
+
test('edit button hidden from users without edit capabilities', () => {
const wrapper = mountWithContexts(
- {}}
- />
+
);