Skip to content

Commit

Permalink
fix(RHINENG-14893): Fix bug with OR and improve tests (#2355)
Browse files Browse the repository at this point in the history
  • Loading branch information
LightOfHeaven1994 authored Jan 28, 2025
1 parent 06c7c86 commit e47cd04
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SmartComponents/SystemDetails/EmptyState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
30 changes: 28 additions & 2 deletions src/SmartComponents/SystemDetails/EmptyState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ describe('EmptyState for systemDetails', () => {
);

expect(
screen.getByText('This system isnt 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,
Expand All @@ -62,6 +62,30 @@ describe('EmptyState for systemDetails', () => {
).toBeInTheDocument();
});

it.only('expect to render NoPoliciesState component for Compliance SystemDetails', () => {
useSystem.mockImplementation(() => ({}));

render(
<TestWrapper>
<EmptyState
inventoryId={'123'}
system={{ insights_id: '123', policies: [] }}
/>
</TestWrapper>
);

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: {
Expand All @@ -85,6 +109,8 @@ describe('EmptyState for systemDetails', () => {
});

it('expect to render NoReportsState component', () => {
useSystem.mockImplementation(() => ({}));

render(
<TestWrapper>
<EmptyState
Expand Down

0 comments on commit e47cd04

Please sign in to comment.