-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[charts] Test pointer events #14042
Conversation
Deploy preview: https://deploy-preview-14042--material-ui-x.netlify.app/ |
CodSpeed Performance ReportMerging #14042 will not alter performanceComparing Summary
|
describe('BarChart - click event', () => { | ||
const { render } = createRenderer(); | ||
|
||
it('should provide the accurate context as second argument', function test() { |
There was a problem hiding this comment.
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.
it('should provide the accurate context as second argument', function test() { | |
it('should provide the right context as second argument', function test() { |
@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 |
There was a problem hiding this comment.
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
@alexfauquette sounds good |
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. |
export function unstable_cleanupDOM() { | ||
const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID); | ||
measurementSpan?.remove(); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
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 ;)
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