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

[charts] Test pointer events #14042

Merged
merged 10 commits into from
Aug 20, 2024
Merged

Conversation

alexfauquette
Copy link
Member

Part of #13611

For a reason I ignore, the mouse position has a weird conversion. When I set event.clientX=201 I get a SVG position of 196

@alexfauquette alexfauquette added test component: charts This is the name of the generic UI component, not the React module! labels Jul 30, 2024
@mui-bot
Copy link

mui-bot commented Jul 30, 2024

Deploy preview: https://deploy-preview-14042--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against eae6485

Copy link

codspeed-hq bot commented Jul 30, 2024

CodSpeed Performance Report

Merging #14042 will not alter performance

Comparing alexfauquette:pointer-test (eae6485) with master (b217a27)

Summary

✅ 3 untouched benchmarks

describe('BarChart - click event', () => {
const { render } = createRenderer();

it('should provide the accurate context as second argument', function test() {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, I don't think "accurate" is the right word here.

Suggested change
it('should provide the accurate context as second argument', function test() {
it('should provide the right context as second argument', function test() {

@alexfauquette
Copy link
Member Author

@JCQuintas Could have a first look. Once we aggree on the testing for bar, I will add other charts with the same stategy

render(
<div
style={{
margin: -8, // No idea why, but that make the SVG coordinates match the HTML coordinates
Copy link
Member

Choose a reason for hiding this comment

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

This happens because body has a default margin of 8px

@JCQuintas
Copy link
Member

@alexfauquette sounds good

@alexfauquette alexfauquette marked this pull request as ready for review August 13, 2024 09:02
@JCQuintas
Copy link
Member

Seems like the test is not cleaning the dom after it runs?

@alexfauquette
Copy link
Member Author

Seems like the test is not cleaning the dom after it runs?

Effectively, to measure the text size, we add a span in an imperative way.

Comment on lines 157 to 160
export function unstable_cleanupDOM() {
const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
measurementSpan?.remove();
}
Copy link
Member

Choose a reason for hiding this comment

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

Cant we empty the innertext or remove the element before returning the results of getStringSize instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can but it double the number of DOM manipulation (adding + removing).

I propose to use a setTimeout to clean the content only once after the rendering cycle

Copy link
Member

Choose a reason for hiding this comment

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

That seems to have broken the pipeline 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

No, that was just some outrage on GitHub ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants