Skip to content

Conversation

@gitdallas
Copy link

fixes: SAT38877
image

would like someone to test in the plugins, or help me do so. hoping it is good as all the props are unchanged and the charts i'm able to look at seem good.

Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial review:
The failing integration tests will need selectors update probably, they are written in capybara (github action: webpack:compile test:integration apipie:cache - Ruby 2.7 and Node 18).
and the JS tests need to be fixed (JavaScript / test (13, 3.0, 22) )
I tested it on the dashboard where it navigates to a url (no "onclick" prop), and in foreman_remote_execution where it changes the search query with onclick

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the DonutChart component from PatternFly React v2 (C3.js-based) to PatternFly 5 (Victory charts-based) while maintaining backward compatibility with existing props and interfaces.

Key Changes:

  • Replaced C3.js-based DonutChart with PF5's Victory-based ChartDonut component
  • Added new getDonutChartConfigPF5 function to transform data from C3.js format to Victory format
  • Updated all tests from Enzyme snapshots to React Testing Library with comprehensive assertions

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
DonutChart/index.js Replaced PF2 DonutChart with PF5 ChartDonut, maintained all existing props
DonutChartService.js Updated to call new PF5-specific configuration function
ChartService.js Added getDonutChartConfigPF5 to handle Victory chart data transformation
ChartService.consts.js Added PF5-compatible configuration properties (innerRadius, padding)
DonutChart.test.js Migrated from Enzyme to React Testing Library with 12 comprehensive tests
DonutChartService.test.js Replaced snapshots with 18 assertion-based tests
ChartBox.test.js Updated tests to use React Testing Library
DonutChart.fixtures.js Updated fixtures from C3.js to Victory format
Snapshot files Removed outdated snapshot tests
Documentation Added migration summary and testing documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gitdallas gitdallas force-pushed the update/DonutChartWrapper-pf5 branch 2 times, most recently from bdcf432 to 35fb2d9 Compare October 28, 2025 18:22
@adamruzicka
Copy link
Contributor

The markdown files shouldn't be included in the pull request, should they?

@gitdallas
Copy link
Author

notes for now, planning to clean up some stuff before removing WIP, but i have some failing tests i don't feel are related to changes

@MariaAga
Copy link
Member

The tests that fail now are unrelated

@gitdallas gitdallas force-pushed the update/DonutChartWrapper-pf5 branch 2 times, most recently from 257c8f6 to f608c82 Compare October 30, 2025 17:23
@gitdallas gitdallas changed the title [WIP] Update donut chart wrapper to pf5 Fixes #38877 - Update donut chart wrapper to pf5 Oct 31, 2025
Signed-off-by: Dallas Nicol <[email protected]>

add/update testing

cleanup

Signed-off-by: Dallas Nicol <[email protected]>

pr review comments

Signed-off-by: Dallas Nicol <[email protected]>

update test snaps

Signed-off-by: Dallas Nicol <[email protected]>
@gitdallas gitdallas force-pushed the update/DonutChartWrapper-pf5 branch from f608c82 to 2bf6a42 Compare October 31, 2025 13:04
@gitdallas gitdallas requested a review from MariaAga October 31, 2025 13:36
Copy link
Contributor

@kmalyjur kmalyjur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I'm leaving some comments as well.

I see two tooltips when hovering over the chart. Could we leave just one? Also, when the chart was clickable, the mouse pointer used to change. Could it be added again?
Image

All requested changes from @MariaAga were taken care of.

);
const percentage =
total > 0
? ((maxItem.y / total) * 100).toFixed(title.precision || 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the title.precision = 0, it will still return 1

innerRadius: chartConfigForType.innerRadius,
labels,
events,
legendData: undefined, // Can be added if needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this line be removed?

Comment on lines +12 to +32
// Mock the ChartDonut component from PatternFly
jest.mock('@patternfly/react-charts', () => ({
ChartDonut: ({ title, subTitle, data }) => (
<div data-testid="chart-donut">
{title && <div data-testid="chart-title">{title}</div>}
{subTitle && <div data-testid="chart-subtitle">{subTitle}</div>}
{data && data.length > 0 && (
<div data-testid="chart-data">
{data.map((d, i) => (
<div key={i} data-testid={`chart-segment-${i}`}>
{d.x}: {d.y}
</div>
))}
</div>
)}
</div>
),
ChartThemeColor: {
multiOrdered: 'multiOrdered',
},
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be please possible to have this test without this mock, so we can test the real component?

Comment on lines +6 to +32
// Mock the DonutChart and BarChart components
jest.mock('../common/charts/DonutChart', () => ({
__esModule: true,
default: ({ data }) => (
<div data-testid="donut-chart">
{data && data.length > 0 ? 'Donut Chart with data' : 'Empty donut chart'}
</div>
),
}));

jest.mock('../common/charts/BarChart', () => ({
__esModule: true,
default: ({ data }) => (
<div data-testid="bar-chart">
{data && data.length > 0 ? 'Bar Chart with data' : 'Empty bar chart'}
</div>
),
}));

jest.mock('../common/Loader', () => ({
__esModule: true,
default: ({ status, children }) => (
<div data-testid="loader" data-status={status}>
{children}
</div>
),
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MariaAga, I'm not sure about those mocks, is it okay to have them like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants