-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(RHINENG-14893): Correct empty state SystemDetails (#2312)
- Refactor: Remove GQL implementation - Correct empty state usage on System details page - Handle number of API calls depending on Page
- Loading branch information
1 parent
a019538
commit fb2602c
Showing
9 changed files
with
212 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import TestWrapper from '@/Utilities/TestWrapper'; | ||
|
||
import EmptyState from './EmptyState.js'; | ||
import useSystem from 'Utilities/hooks/api/useSystem'; | ||
|
||
jest.mock('Utilities/hooks/api/useSystem', () => jest.fn()); | ||
|
||
describe('EmptyState for systemDetails', () => { | ||
it('expect to render loading state while waiting for data', () => { | ||
useSystem.mockImplementation(() => ({ | ||
data: { data: undefined }, | ||
error: undefined, | ||
loading: undefined, | ||
})); | ||
render( | ||
<TestWrapper> | ||
<EmptyState inventoryId={'123'} /> | ||
</TestWrapper> | ||
); | ||
|
||
expect(screen.getByLabelText('Contents')).toHaveAttribute( | ||
'aria-valuetext', | ||
'Loading...' | ||
); | ||
}); | ||
|
||
it('expect to render NotConnected component', () => { | ||
useSystem.mockImplementation(() => ({ | ||
data: { data: { display_name: 'foo', policies: [], insights_id: '' } }, | ||
error: undefined, | ||
loading: undefined, | ||
})); | ||
render( | ||
<TestWrapper> | ||
<EmptyState inventoryId={'123'} /> | ||
</TestWrapper> | ||
); | ||
|
||
expect( | ||
screen.getByText('This system isn’t connected to Insights yet') | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('expect to render NoPoliciesState component', () => { | ||
useSystem.mockImplementation(() => ({ | ||
data: { data: { display_name: 'foo', policies: [], insights_id: '123' } }, | ||
error: undefined, | ||
loading: undefined, | ||
})); | ||
render( | ||
<TestWrapper> | ||
<EmptyState inventoryId={'123'} /> | ||
</TestWrapper> | ||
); | ||
|
||
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: { | ||
data: { display_name: 'foo', policies: [{}, {}], insights_id: '123' }, | ||
}, | ||
error: undefined, | ||
loading: undefined, | ||
})); | ||
render( | ||
<TestWrapper> | ||
<EmptyState inventoryId={'123'} /> | ||
</TestWrapper> | ||
); | ||
|
||
expect(screen.getByText('No results reported')).toBeInTheDocument(); | ||
expect( | ||
screen.getByText( | ||
`This system is part of 2 policies, but has not returned any results.` | ||
) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('expect to render NoReportsState component', () => { | ||
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('No results reported')).toBeInTheDocument(); | ||
expect( | ||
screen.getByText( | ||
`This system is part of 1 policy, but has not returned any results.` | ||
) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.