diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx index 6d18102d40..5e644cde9d 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx @@ -79,6 +79,7 @@ function InventoryListItem({ syncStatus = inventory.inventory_sources_with_failures > 0 ? 'error' : 'success'; } + return ( , + + + {inventory.summary_fields.organization.name} + + , {i18n._(t`Groups`)} diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.test.jsx index fc5bf838f2..7507f37cb1 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.test.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.test.jsx @@ -1,6 +1,4 @@ import React from 'react'; -import { MemoryRouter } from 'react-router-dom'; -import { I18nProvider } from '@lingui/react'; import { act } from 'react-dom/test-utils'; import { mountWithContexts } from '../../../../testUtils/enzymeHelpers'; import { InventoriesAPI } from '../../../api'; @@ -11,81 +9,117 @@ jest.mock('../../../api/models/Inventories'); describe('', () => { test('initially renders succesfully', () => { mountWithContexts( - - - {}} - /> - - + name: 'Default', + }, + user_capabilities: { + edit: true, + }, + }, + }} + detailUrl="/inventories/inventory/1" + isSelected + onSelect={() => {}} + /> ); }); + + test('should render prompt list item data', () => { + const wrapper = mountWithContexts( + {}} + /> + ); + expect( + wrapper + .find('DataListCell') + .at(1) + .text() + ).toBe('Inventory'); + expect( + wrapper + .find('DataListCell') + .at(2) + .text() + ).toBe('Inventory'); + expect( + wrapper + .find('DataListCell') + .at(3) + .text() + ).toBe('Default'); + expect( + wrapper + .find('DataListCell') + .at(4) + .text() + ).toBe('GroupsHostsSources'); + }); + test('edit button shown to users with edit capabilities', () => { const wrapper = mountWithContexts( - - - {}} - /> - - + 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: 'Default', + }, + user_capabilities: { + edit: false, + }, + }, + }} + detailUrl="/inventories/inventory/1" + isSelected + onSelect={() => {}} + /> ); expect(wrapper.find('PencilAltIcon').exists()).toBeFalsy(); }); @@ -93,29 +127,25 @@ describe('', () => { InventoriesAPI.copy.mockResolvedValue(); const wrapper = mountWithContexts( - - - {}} - /> - - + name: 'Default', + }, + user_capabilities: { + edit: false, + copy: true, + }, + }, + }} + detailUrl="/inventories/inventory/1" + isSelected + onSelect={() => {}} + /> ); await act(async () => @@ -129,29 +159,25 @@ describe('', () => { InventoriesAPI.copy.mockRejectedValue(new Error()); const wrapper = mountWithContexts( - - - {}} - /> - - + 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')() @@ -163,29 +189,25 @@ describe('', () => { test('should not render copy button', async () => { const wrapper = mountWithContexts( - - - {}} - /> - - + name: 'Default', + }, + user_capabilities: { + edit: false, + copy: false, + }, + }, + }} + detailUrl="/inventories/inventory/1" + isSelected + onSelect={() => {}} + /> ); expect(wrapper.find('CopyButton').length).toBe(0); });