-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore: compare cy.screenshot
images in percy
#21598
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
.is-screenshotting #resizable-panels-root { | ||
overflow-x: visible; | ||
overflow-y: visible; | ||
} |
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.
I'd actually like to consolidate more of our screenshot css rules into this structure, instead of conditionally managing tailwind classes with JS. But to keep this PR focused, I'm not doing that here, just moving what's needed.
:class="{ | ||
'select-none': panel1IsDragging || panel2IsDragging, | ||
'overflow-x-auto': !isFirefox | ||
'overflow-x-hidden': isFirefox |
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 lets the !important
that comes with the utility class override the otherwise-preferred overflow.
@@ -13,7 +13,7 @@ | |||
/> | |||
<ResizablePanels | |||
v-else | |||
:style="{width: `calc(100vw - ${collapsedNavBarWidth}px)`}" | |||
:style="{width: `calc(100vw - ${screenshotStore.isScreenshotting ? 0 : collapsedNavBarWidth}px)`}" |
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 one was just a loose end with open-mode screenshots.
} | ||
}) | ||
|
||
return cy.get('style').should('have.length', 1) |
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 now means that only the existing CSS injected by the component will be applied. Other CSS targeting body, HTML, global reset CSS etc will not apply here.
We may want to change this later, but for now this gives us the clearest diff with 10.0-release.
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 now means that only the existing CSS injected by the component will be applied.
This comment has great context!! What do you think about including it in the code?
@@ -1,7 +1,7 @@ | |||
<template> | |||
<div | |||
v-bind="containerProps" | |||
class="pt-8px specs-list-container overflow-y-auto overflow-x-hidden" | |||
class="pt-8px specs-list-container overflow-hidden" |
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.
Since the scrolling in the specs list takes place within a virtual list, the overflow-x value of auto
was causing a weird empty space at the bottom of the parent, to do with how the vh
works in the specs-list-container
height calculation below.
removeGlobalStyles().then(() => { | ||
cy.screenshot(`percy/component_testing_takes_a_screenshot_viewport_${capture}`, { capture }) | ||
}) |
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.
removeGlobalStyles().then(() => { | |
cy.screenshot(`percy/component_testing_takes_a_screenshot_viewport_${capture}`, { capture }) | |
}) | |
removeGlobalStyles() | |
cy.screenshot(`percy/component_testing_takes_a_screenshot_viewport_${capture}`, { capture }) |
AFAIK you don't need .then
because Cypress runs promises sequentially and you're not using the return value from removeGlobalStyles
within cy.screenshot
cy.screenshot(`percy/large_component_hardcoded_size_viewport_${viewport[0]}_${viewport[1]}`, { capture: 'viewport' }) | ||
cy.screenshot(`percy/large_component_hardcoded_size_fullPage_${viewport[0]}_${viewport[1]}`, { capture: 'fullPage' }) | ||
removeGlobalStyles().then(() => { | ||
cy.pause() |
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 pause is still hanging out here.
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.
bump
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.
I compared the generated screenshots to what's in develop, everything lines up how we'd expect. Also validated that they're showing up in Percy.
Great work on this @marktnoonan. It's nice to have regression coverage here, puts us in a good spot to refactor/condense some of these styles going forward.
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.
Other than the pause looks good to me!
@@ -98,6 +98,10 @@ const scrollOverrides = (win, doc) => { | |||
// hide scrollbars | |||
doc.documentElement.style.overflow = 'hidden' | |||
|
|||
// this body class is used to set some other overflow-related CSS | |||
// around the resizable panels in the Runner | |||
document.querySelector('body')?.classList.add('screenshot-scrolling') |
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.
Not sure why TS is happy with this, if document.querySelector('body')?
is ever null (which it shouldn't be) it would be safer to use document.querySelector('body')?.classList?.add('screenshot-scrolling')
I would just do document.body.classList.add('screenshot-scrolling')
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.
I got warnings in vscode when I did plain document.body
so not sure what's up.
cy.screenshot(`percy/large_component_hardcoded_size_viewport_${viewport[0]}_${viewport[1]}`, { capture: 'viewport' }) | ||
cy.screenshot(`percy/large_component_hardcoded_size_fullPage_${viewport[0]}_${viewport[1]}`, { capture: 'fullPage' }) | ||
removeGlobalStyles().then(() => { | ||
cy.pause() |
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.
bump
…ess into tgriesser/fix/UNIFY-1408 * 'tgriesser/fix/UNIFY-1408' of github.com:cypress-io/cypress: chore: compare `cy.screenshot` images in percy (#21598)
…pack * develop: fix: UNIFY-1408, warnings should be nested appropriately & clearable (#21630) chore: fix unit-tests-release job (#21652) chore(deps): update dependency eventsource to v2 [security] (#21639) fix: Add hover states for test titles in reporter (#21635) docs(CONTRIBUTING): Fix link to "good first issue" for newcomers (#21614) chore: compare `cy.screenshot` images in percy (#21598) fix: switching from ct to e2e (non-configured) does not go through setup (#21607) fix: issue with compilation failures in component testing (#21599) test: fix flaky launchpad test (#21637) docs: remove gitter link in contributing guide. (#21592) fix: order projects by most recently opened (#21589) fix: prevent crash on runs visit when offline (#21618) fix: pass family parameter to connect method (#21545) chore: clean up `debug` statements in preparation for 10.0 release, add `debug` docs (#21621) chore: add regression test for ts detection (#21578)
The main change here is a circle.yml update, to use Percy to diff the screenshot images generated using the
cy.screenshot()
command from screenshot.cy.tsx. We do this currently on develop, so this ticket was just catch up.When I did get these uploads working, there were some differences to investigate. Most were are result of global styles and only required changes to test code, not to the app itself.
After those changes to the test code, images only contained some differences in the presence/absences of scrollbars, so this PR includes changes to the app around overflow behavior, to fix those differences.
In addition to these Percy snapshots, I used ImageMagick to compare images generated by the screenshot system tests on both branches, confirming that none of these changes have altered those images.
User facing changelog
Scrollbars in screenshots will now be present/absent in the same situations in 9.x and 10.0. There were some situations where this previously was not the case in 10.0.
Additional details
The rest of the PR is:
is-screenshotting
body class to add anscreenshot-scrolling
class. This allows us to conditionally add/remove CSS rules related to overflow without adding/removing classes with JavaScript in the nested Vue components. When managing the conditional classes in the Vue components, the styles were modified too late for the screenshot.specs-list-container
which fixes another edge case that only appeared when scrollbars are present.Since the latest Percy diff will compare this branch against 10.0-release, I've captured some diffs here between these screenshots on this branch and develop. What can be seen in these screenshots is a 1px shift to the left of all the content, since on 10.0-release (in this PR) we have previously fixed a 1px border bug in component test screenshots.
That means the 1px shifts, shown here in the diff with develop, are expected:
How has the user experience changed?
No UX changes.
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?