diff --git a/src/SmartComponents/SystemDetails/EmptyState.js b/src/SmartComponents/SystemDetails/EmptyState.js index 56d3f0b4c..336eaa172 100644 --- a/src/SmartComponents/SystemDetails/EmptyState.js +++ b/src/SmartComponents/SystemDetails/EmptyState.js @@ -12,7 +12,7 @@ const EmptyState = ({ inventoryId, system }) => { params: [inventoryId], skip: system, }); - const policiesCount = system?.policies.length || data?.policies.length; + const policiesCount = system?.policies.length ?? data?.policies.length; const insightsId = system?.insights_id || data?.insights_id; if (!system && !data) { diff --git a/src/SmartComponents/SystemDetails/EmptyState.test.js b/src/SmartComponents/SystemDetails/EmptyState.test.js index 09497d022..56aa4c421 100644 --- a/src/SmartComponents/SystemDetails/EmptyState.test.js +++ b/src/SmartComponents/SystemDetails/EmptyState.test.js @@ -39,11 +39,11 @@ describe('EmptyState for systemDetails', () => { ); expect( - screen.getByText('This system isn’t connected to Insights yet') + screen.getByText(`This system isn't connected to Insights yet`) ).toBeInTheDocument(); }); - it('expect to render NoPoliciesState component', () => { + it('expect to render NoPoliciesState component for Inventory', () => { useSystem.mockImplementation(() => ({ data: { data: { display_name: 'foo', policies: [], insights_id: '123' } }, error: undefined, @@ -62,6 +62,30 @@ describe('EmptyState for systemDetails', () => { ).toBeInTheDocument(); }); + it.only('expect to render NoPoliciesState component for Compliance SystemDetails', () => { + useSystem.mockImplementation(() => ({})); + + render( + + + + ); + + expect(useSystem).toHaveBeenCalledWith({ + params: ['123'], + skip: { insights_id: '123', policies: [] }, // Ensure correct 'skip' value + }); + + expect( + screen.getByText( + 'This system is not part of any SCAP policies defined within Compliance.' + ) + ).toBeInTheDocument(); + }); + it('expect to render NoReportsState component', () => { useSystem.mockImplementation(() => ({ data: { @@ -85,6 +109,8 @@ describe('EmptyState for systemDetails', () => { }); it('expect to render NoReportsState component', () => { + useSystem.mockImplementation(() => ({})); + render(