Skip to content

[code-infra] Improve Tooltip leaveDelay test#47624

Merged
Janpot merged 9 commits intomui:masterfrom
Janpot:fix-tooltip-leave-delay-test
Jan 16, 2026
Merged

[code-infra] Improve Tooltip leaveDelay test#47624
Janpot merged 9 commits intomui:masterfrom
Janpot:fix-tooltip-leave-delay-test

Conversation

@Janpot
Copy link
Copy Markdown
Member

@Janpot Janpot commented Jan 15, 2026

  • Use clock.tickAsync instead of clock.tick to properly handle async React updates
  • Add intermediate assertion to verify tooltip is still visible before final tick (This was missing in the test, i.e. How do you know leaveDelay is applied if you don't verify the tooltip is still there right before it fires?)
  • Fix jsdom resolution after @mui/internal-test-utils update

This may also address the flakeyness we've been seeing lately

@Janpot Janpot changed the title [code-infra] Fix Tooltip leaveDelay test [code-infra] Improve Tooltip leaveDelay test Jan 15, 2026
@mui-bot
Copy link
Copy Markdown

mui-bot commented Jan 15, 2026

Netlify deploy preview

https://deploy-preview-47624--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 764a435

@zannager zannager added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Jan 15, 2026
@zannager zannager requested a review from a team January 15, 2026 15:14
Copy link
Copy Markdown
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

I had tried using clock.tickAsync but I thought it isn't available because it didn't show in IntelliSense. Also, immediate assertion make sense.

Would be great if this is accepted and merge quickly. The flakiness is very annoying and time consuming.

expect(screen.getByRole('tooltip')).toBeVisible();

await flushMicrotasks();
await clock.tickAsync(2);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this move forward by 1?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm moving it by 2 so we test at 1ms before and 1ms after the exact point in time at which we want the tooltip to leave. Removes all ambiguity that the exact ms tick has when the leave delay ends.

@@ -1,3 +1,4 @@
'use client';
Copy link
Copy Markdown
Member

@ZeeshanTamboli ZeeshanTamboli Jan 16, 2026

Choose a reason for hiding this comment

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

By mistake? Or correct?

Suggested change
'use client';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, it's using react context

@Janpot Janpot merged commit c2df49d into mui:master Jan 16, 2026
20 checks passed
@Janpot
Copy link
Copy Markdown
Member Author

Janpot commented Jan 16, 2026

I had tried using clock.tickAsync but I thought it isn't available because it didn't show in IntelliSense.

It isn't, I updated @mui/internal-test-utils to get it.

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

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants