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] Remove top-level inline-block from the regression tests #43656

Merged
merged 7 commits into from
Sep 13, 2024

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Sep 8, 2024

In an effort to solve mui/mui-x#13477 (comment) and the flaky dashboard screenshot.

We're seeing glitches in the screenshot of the dashboard template. It looks like it's caused by being nested it in a inline-block container (the docs demo host has flex).

I manually went through all 240 mismatches, I don't see much out of the ordinary other than that most now size to their parent instead of their content. Would argue that real world scenarios are much more likely to be in this situation.
It even captures more information in many of them:

Things to investigate:

All-in-all, I believe this simple change is a step in the good direction. Would definitely encourage anyone with an hour to spare to manually review our visual tests from time to time.

@Janpot Janpot added the test label Sep 8, 2024
@mui-bot
Copy link

mui-bot commented Sep 8, 2024

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against a68ac62

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 12, 2024

the docs demo host has flex

The intent to do inline-block was to get as close as possible to codesandbox output. I don't think that we should expect developers to copy and post our demos into a flexbox container. The goal of the screenshot was to make sure it's not broken into people's codebase, not "not broken" into the docs.

Fun fact: we use opposite box-sizing between docs and screenshot environment to maximize test coverage (should be invariant).

@@ -77,7 +84,7 @@ function TestViewer(props) {
<JoyBox
aria-busy={!ready}
data-testid="testcase"
sx={{ bgcolor: 'background.body', display: 'inline-block', p: 1 }}
sx={{ bgcolor: 'background.body', ...viewerBoxSx }}
Copy link
Member

@oliviertassinari oliviertassinari Sep 12, 2024

Choose a reason for hiding this comment

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

would this be enough?

Suggested change
sx={{ bgcolor: 'background.body', ...viewerBoxSx }}
sx={{ bgcolor: 'background.body', display: 'block', p: 1 }}

It still makes the screenshots to take more space, so the diff might be slower, but we pay per screenshots now, so we don't have to care so much 😄

Copy link
Member Author

@Janpot Janpot Sep 13, 2024

Choose a reason for hiding this comment

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

would this be enough?

Yes, it has the same effect. I'm indifferent to the exact solution, as long as it's not inline 🙂 My first commit actually removed the property, which would be the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

Are we ok with docs demos potentially looking slightly different to their corresponding regression screenshots? If that's ok block is fine. Probably the demo wrapper should wrap the contents in a <div> so the demo contents are not affected by flex, although flex can be a good thing to help build more robust components e.g. https://app.argos-ci.com/mui/material-ui/builds/31842/107814095 breaks because it has several top-level elements instead of just one.

Copy link
Member Author

@Janpot Janpot Sep 13, 2024

Choose a reason for hiding this comment

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

Are we ok with docs demos potentially looking slightly different to their corresponding regression screenshots?

There's a nuance here that not all screenshots are originating from docs demos. Some come from the templates. And I believe there's a set of separately curated ones as well. This is what made me open this PR in the first place as the templates behave flaky when rendered in an inline container. I think in light of that, block makes sense. I'm personally ok either way, but let's not waste too much time on this, the idea is to get away from inline-block, the difference between flex and block is far from as impactful as that.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, block then sounds like the best choice.

@oliviertassinari oliviertassinari added the scope: code-infra Specific to the core-infra product label Sep 12, 2024
@oliviertassinari oliviertassinari changed the title [tests] Remove top-level inline-block from the regression tests [test] Remove top-level inline-block from the regression tests Sep 12, 2024
Copy link
Member

@aarongarciah aarongarciah 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! I'm fine with flex or block. flex causes some tests to change because they have several top-level elements, but ideally those components should be "fixed" to be able to render just fine inside flex containers e.g. https://app.argos-ci.com/mui/material-ui/builds/31842/107814095

edit: block seems better since we not only do regression tests of demos but templates and other stuff as well.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 13, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 13, 2024
@Janpot
Copy link
Member Author

Janpot commented Sep 13, 2024

@aarongarciah
Copy link
Member

@Janpot I'll fix those demos in another PR.

@Janpot Janpot merged commit f5179dd into mui:master Sep 13, 2024
19 checks passed
@Janpot Janpot deleted the deflake-test branch September 13, 2024 09:30
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

ideally those components should be "fixed" to be able to render just fine inside flex containers e.g. https://app.argos-ci.com/mui/material-ui/builds/31842/107814095

@aarongarciah Agree but this screenshot is not a valid one. It's part of a template, only the top level template screenshot should be taken, so this one should be skipped, it's redundant with: https://app.argos-ci.com/mui/material-ui/builds/31842/107814093.

const viewerBoxSx = {
display: 'block',
p: 1,
position: 'relative',
Copy link
Member

@oliviertassinari oliviertassinari Sep 13, 2024

Choose a reason for hiding this comment

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

Can we remove this one?

Suggested change
position: 'relative',

I think we want to be able to catch cases where demos relies on a special parent position properly to be set. When developers copy and past a demo, they won't have this style set.

Copy link
Member

Choose a reason for hiding this comment

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

I'll open a PR for this cc @Janpot

Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: code-infra Specific to the core-infra product test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants