Skip to content
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

Upgrade Recharts. (PP-1531) #127

Merged
merged 3 commits into from
Aug 23, 2024
Merged

Upgrade Recharts. (PP-1531) #127

merged 3 commits into from
Aug 23, 2024

Conversation

tdilauro
Copy link
Contributor

@tdilauro tdilauro commented Aug 21, 2024

Description

  • Upgrades Recharts package to a modern version.
  • Moves some more tests over to jest.
  • Also adds text wrap balancing to the statistics group headings and descriptions.

Note: This work builds on #126 and should be merged after it.

Motivation and Context

  • Updates a transitive dependency with a high-impact vulnerability.

[Jira PP-1531]

How Has This Been Tested?

  • Manually tested in dev-server environment.
  • Added and migrated tests.
  • CI tests pass for associated branch.

Checklist:

  • N/A - I have updated the documentation accordingly.
  • All new and existing tests passed.

@tdilauro tdilauro requested a review from ray-lee August 21, 2024 14:38
Comment on lines 17 to 24
// These values are needed for testing, in some cases.
export const COLLECTION_BAR_CHART_TEST_FLAG_KEY =
"COLLECTION_BAR_CHART_TEST_FLAG_KEY";
const TestResponsiveContainer = ({ children }) => (
<RechartsResponsiveContainer width={800} height={800}>
{children}
</RechartsResponsiveContainer>
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this and the overall testingFlags approach to:

  • provide a higher-level way to support some tricky test scenarios without having to drill a prop through a bunch of components; and
  • to keep as much of the mocking near the component, so that it is easier to keep them aligned.

Would appreciate feedback on this. Bad idea? Any better ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

In general I'd rather have control of the tests be completely inside the test files, rather than interleaved into the components that are tested. If I'm reading this right, this test flag is overriding the width and height props of RechartsResponsiveContainer. My preference would be instead of setting a testing flag, allow specifying the width and height overrides directly. So your context might contain something like

config: { // these key names are off the cuff, I don't care much what they are exactly
  StatsCollectionsBarChart: {
    width: 800,
    height: 800
  } 
}

That way it's easy to see in the test what exactly is happening, and different tests can pass different settings if they want to, instead of having them hardcoded into the component. From the component's POV, it doesn't know or care if it's under test, it just has a feature (that can itself be tested) that some settings are configurable from context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @ray-lee! That's very helpful. I think it makes a lot of sense and reduces complexity. I've made changes in that direction.

Base automatically changed from feature/usage-dashboard-component to main August 22, 2024 14:23
@tdilauro tdilauro marked this pull request as ready for review August 22, 2024 15:16
@tdilauro
Copy link
Contributor Author

@ray-lee This has been rebased onto main now.

Copy link
Contributor

@ray-lee ray-lee left a comment

Choose a reason for hiding this comment

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

Looks good!

@tdilauro tdilauro merged commit a8e6da9 into main Aug 23, 2024
1 check passed
@tdilauro tdilauro deleted the chore/upgrade-recharts branch August 23, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants