-
Notifications
You must be signed in to change notification settings - Fork 22
Fixes #38958 - Add basic Leapp preupgrade report table to the new job invocation page #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2baca5e
Fixes #38958 - Add leapp preupgrade table to job invocation page
kmalyjur 76c9218
Fix ESLint errors in plugin code
adamruzicka ca3b1e1
Fix test failures in PreupgradeReportsTable
adamruzicka ba5ec56
Drop trailing whitespace
adamruzicka b419319
Drop all (but one) global foremanReact mocks
adamruzicka 4a97492
Drop some more mocks
adamruzicka e369a39
Drop even more mocks
adamruzicka 24efc66
Migrate PreupgradeReportsList tests from snapshots to RTL
adamruzicka 7fbd625
Address review comments
adamruzicka f0f99ec
Move columns back to the table itself
adamruzicka 2c260dd
Pagination changes
adamruzicka 6a684d4
Address comments
adamruzicka b7fb96c
Drop custom perPageOptions
adamruzicka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| object @preupgrade_report_entry | ||
|
|
||
| attributes :id, :preupgrade_report_id, :host_id, :hostname, :title, :actor, :audience, | ||
| attributes :id, :detail, :preupgrade_report_id, :host_id, :hostname, :title, :actor, :audience, | ||
| :severity, :leapp_run_id, :summary, :tags, :flags, :created_at, :updated_at |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
webpack/__mocks__/foremanReact/components/common/MessageBox.js
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
154 changes: 119 additions & 35 deletions
154
webpack/components/PreupgradeReportsList/__tests__/PreupgradeReportsList.test.js
This file contains hidden or 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 |
|---|---|---|
| @@ -1,40 +1,124 @@ | ||
| import { testComponentSnapshotsWithFixtures } from '@theforeman/test'; | ||
| import React from 'react'; | ||
| import { render, screen, fireEvent } from '@testing-library/react'; | ||
| import '@testing-library/jest-dom'; | ||
|
|
||
| import PreupgradeReportsList from '../index'; | ||
|
|
||
| const allEntries = [ | ||
| { title: 'Fix me!', severity: 'Too severe to talk about' }, | ||
| { title: 'I am broken too', severity: 'medium' }, | ||
| { title: 'Octocat is not happy', severity: 'high' }, | ||
| { title: 'Not enough credits', severity: 'low' }, | ||
| ]; | ||
|
|
||
| const isSelected = () => false; | ||
| const toggleSelected = () => {}; | ||
| const sort = { attribute: '', order: 'asc' }; | ||
| const changeSort = () => {}; | ||
| const toggleSelectAll = () => {}; | ||
|
|
||
| const fixtures = { | ||
| 'should render': { | ||
| allEntries, | ||
| fixAllWorking: false, | ||
| isSelected, | ||
| toggleSelected, | ||
| sort, | ||
| changeSort, | ||
| toggleSelectAll, | ||
| }, | ||
| 'should render when working': { | ||
| allEntries, | ||
| fixAllWorking: true, | ||
| isSelected, | ||
| toggleSelected, | ||
| sort, | ||
| changeSort, | ||
| toggleSelectAll, | ||
| }, | ||
| jest.mock('foremanReact/components/Pagination', () => { | ||
| const MockPagination = () => <div data-testid="pagination">Pagination</div>; | ||
| return MockPagination; | ||
| }); | ||
|
|
||
| jest.mock('../components/images/i_severity-high.svg', () => 'severity-high.svg'); | ||
| jest.mock('../components/images/i_severity-med.svg', () => 'severity-med.svg'); | ||
| jest.mock('../components/images/i_severity-low.svg', () => 'severity-low.svg'); | ||
|
|
||
| const createMockEntries = count => | ||
| Array.from({ length: count }, (_, i) => ({ | ||
| id: i + 1, | ||
| preupgradeReportId: 100, | ||
| title: `Entry ${i + 1}`, | ||
| hostname: `host${i + 1}.example.com`, | ||
| severity: i % 3 === 0 ? 'high' : i % 3 === 1 ? 'medium' : 'low', | ||
| flags: i === 0 ? ['inhibitor'] : [], | ||
| detail: { | ||
| remediations: | ||
| i < 2 | ||
| ? [{ type: 'command', context: ['echo', 'fix', 'command'] }] | ||
| : [], | ||
| }, | ||
| })); | ||
|
|
||
| const defaultProps = { | ||
| allEntries: createMockEntries(4), | ||
| isSelected: () => false, | ||
| toggleSelected: jest.fn(), | ||
| sort: { attribute: '', order: 'asc' }, | ||
| changeSort: jest.fn(), | ||
| toggleSelectAll: jest.fn(), | ||
| }; | ||
|
|
||
| describe('PreupgradeReportsList', () => | ||
| testComponentSnapshotsWithFixtures(PreupgradeReportsList, fixtures)); | ||
| const renderComponent = (props = {}) => | ||
| render(<PreupgradeReportsList {...defaultProps} {...props} />); | ||
|
|
||
| describe('PreupgradeReportsList', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('renders the list header', () => { | ||
| renderComponent(); | ||
|
|
||
| expect(screen.getByText('Title')).toBeInTheDocument(); | ||
| expect(screen.getByText('Host')).toBeInTheDocument(); | ||
| expect(screen.getByText('Risk Factor')).toBeInTheDocument(); | ||
| expect(screen.getByText('Has Remediation?')).toBeInTheDocument(); | ||
| expect(screen.getByText('Inhibitor?')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders entry titles', () => { | ||
| renderComponent(); | ||
|
|
||
| expect(screen.getByText('Entry 1')).toBeInTheDocument(); | ||
| expect(screen.getByText('Entry 2')).toBeInTheDocument(); | ||
| expect(screen.getByText('Entry 3')).toBeInTheDocument(); | ||
| expect(screen.getByText('Entry 4')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders entry hostnames', () => { | ||
| renderComponent(); | ||
|
|
||
| expect(screen.getByText('host1.example.com')).toBeInTheDocument(); | ||
| expect(screen.getByText('host2.example.com')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders checkboxes for entries', () => { | ||
| renderComponent(); | ||
|
|
||
| const checkboxes = screen.getAllByRole('checkbox'); | ||
| expect(checkboxes.length).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| it('calls toggleSelectAll when header checkbox is clicked', () => { | ||
| const toggleSelectAll = jest.fn(); | ||
| renderComponent({ toggleSelectAll }); | ||
|
|
||
| const checkboxes = screen.getAllByRole('checkbox'); | ||
| fireEvent.click(checkboxes[0]); | ||
|
|
||
| expect(toggleSelectAll).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('renders with empty entries array', () => { | ||
| renderComponent({ allEntries: [] }); | ||
|
|
||
| expect(screen.getByText('Title')).toBeInTheDocument(); | ||
| expect(screen.queryByText('Entry 1')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders entries with selected state', () => { | ||
| const isSelected = entry => entry.id === 1; | ||
| renderComponent({ isSelected }); | ||
|
|
||
| const checkboxes = screen.getAllByRole('checkbox'); | ||
| const entryCheckboxes = checkboxes.slice(1); | ||
| expect(entryCheckboxes[0]).toBeChecked(); | ||
| expect(entryCheckboxes[1]).not.toBeChecked(); | ||
| }); | ||
|
|
||
| it('calls toggleSelected when entry checkbox is clicked', () => { | ||
| const toggleSelected = jest.fn(); | ||
| renderComponent({ toggleSelected }); | ||
|
|
||
| const checkboxes = screen.getAllByRole('checkbox'); | ||
| fireEvent.click(checkboxes[1]); | ||
|
|
||
| expect(toggleSelected).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('renders pagination component', () => { | ||
| renderComponent(); | ||
|
|
||
| expect(screen.getByTestId('pagination')).toBeInTheDocument(); | ||
| }); | ||
| }); |
135 changes: 0 additions & 135 deletions
135
...mponents/PreupgradeReportsList/__tests__/__snapshots__/PreupgradeReportsList.test.js.snap
kmalyjur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
webpack/components/PreupgradeReportsTable/PreupgradeReportsTable.scss
This file contains hidden or 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,4 @@ | ||
| .leapp-report-section .table-title-section, | ||
| .leapp-report-section .table-toolbar-section { | ||
| padding-top: 0 !important; | ||
| } | ||
kmalyjur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.