Skip to content

Commit

Permalink
[code-infra] Fix flaky dashboard screenshot - take 2 (mui#43937)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Potoms <[email protected]>
  • Loading branch information
Janpot authored Oct 1, 2024
1 parent 085a6b0 commit 90f0ce2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ jobs:
command: xvfb-run pnpm test:regressions
- run:
name: Build packages for fixtures
command: xvfb-run pnpm release:build
command: pnpm release:build
- run:
name: Run visual regression tests using Pigment CSS
command: xvfb-run pnpm test:regressions-pigment-css
Expand Down
7 changes: 7 additions & 0 deletions apps/pigment-css-vite-app/src/pages/fixtures/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ async function main() {
routes = routes.map((route) => route.replace(baseUrl, ''));

async function renderFixture(index) {
await page.evaluate(() => {
// Playwright hides scrollbar when capturing a screenshot on an element or with fullPage: true.
// When the body has a scrollbar, this causes a brief layout shift. Disable the body overflow
// altogether to prevent this
window.document.body.style.overflow = 'hidden';
});

// Use client-side routing which is much faster than full page navigation via page.goto().
// Could become an issue with test isolation.
// If tests are flaky due to global pollution switch to page.goto(route);
Expand Down
7 changes: 6 additions & 1 deletion test/regressions/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ async function main() {
* @param {string} route
*/
async function renderFixture(route) {
// Use client-side routing which is much faster than full page navigation via page.goto().
await page.evaluate((_route) => {
// Use client-side routing which is much faster than full page navigation via page.goto().
window.muiFixture.navigate(`${_route}#no-dev`);

// Playwright hides scrollbar when capturing a screenshot on an element or with fullPage: true.
// When the body has a scrollbar, this causes a brief layout shift. Disable the body overflow
// altogether to prevent this
window.document.body.style.overflow = 'hidden';
}, route);

// Move cursor offscreen to not trigger unwanted hover effects.
Expand Down
9 changes: 0 additions & 9 deletions test/regressions/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
<style>
body {
background-color: white;
/*
Hide scrollbars but keep scrollable. Playwright hides scrollbar when capturing a screenshot on an element
or with fullPage: true. When the body has a scrollbar, this causes a brief layout shift.
*/
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */
}
body::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
</style>
</head>
Expand Down

0 comments on commit 90f0ce2

Please sign in to comment.