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

[test] Wait for images to load #11004

Merged
merged 4 commits into from
Nov 12, 2023

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Nov 11, 2023

@mui-bot
Copy link

mui-bot commented Nov 11, 2023

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

Generated by 🚫 dangerJS against 94c2bb5

@@ -101,12 +101,6 @@ async function main() {
// Move cursor offscreen to not trigger unwanted hover effects.
page.mouse.move(0, 0);

// Wait for the flags to load
await page.waitForFunction(() => {
const images = Array.from(document.querySelectorAll('img'));
Copy link
Member Author

Choose a reason for hiding this comment

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

This didn't work, because sometimes the images were not rendered yet - so I moved it after the '[data-testid="testcase"]:not([aria-busy="true"])' assertion

() => {
const images = Array.from(document.querySelectorAll('img'));
return images.every((img) => {
if (!img.complete && img.loading === 'lazy') {
Copy link
Member Author

Choose a reason for hiding this comment

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

For lazy-loaded images that are not visible img.complete will always be false

});
},
undefined,
{ timeout: 1000 },
Copy link
Member Author

Choose a reason for hiding this comment

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

To fail fast

@cherniavskii
Copy link
Member Author

It worked! 🎉

@cherniavskii cherniavskii marked this pull request as ready for review November 11, 2023 20:22
Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

Looks great! Nice fix! 💪🏻

Copy link
Member

@MBilalShafi MBilalShafi left a comment

Choose a reason for hiding this comment

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

Cool, finally this nasty issue arising since eternity is gone 🎉

@cherniavskii cherniavskii merged commit 961bee1 into mui:next Nov 12, 2023
18 checks passed
@cherniavskii cherniavskii deleted the test-wait-for-images-to-load branch November 12, 2023 07:03
cherniavskii added a commit to cherniavskii/mui-x that referenced this pull request Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants