-
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
Changes from 7 commits
a065055
e1403d4
bcdb0b9
9b45ca1
b14d789
4520626
9f559c5
2d8e4a5
e03377f
d45b485
f2a9fc5
b46d5bf
2dd755b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<template> | ||
<div | ||
class="flex overflow-y-hidden" | ||
id="resizable-panels-root" | ||
class="flex" | ||
: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 commentThe reason will be displayed to describe this comment to others. Learn more. this lets the |
||
}" | ||
@mouseup="handleMouseup" | ||
@mousemove="handleMousemove" | ||
|
@@ -209,4 +210,5 @@ watchEffect(() => { | |
|
||
// TODO: UNIFY-1704 - avoid special case for FF | ||
const isFirefox = window.__CYPRESS_BROWSER__?.family === 'firefox' | ||
|
||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This one was just a loose end with open-mode screenshots. |
||
:offset-left="collapsedNavBarWidth" | ||
:max-total-width="windowWidth - collapsedNavBarWidth" | ||
:initial-panel1-width="specsListWidthPreferences" | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -37,6 +37,16 @@ const Layout: FunctionalComponent = () => { | |||||||||||
|
||||||||||||
const captureTypes = ['fullPage', 'viewport', 'runner'] as const | ||||||||||||
|
||||||||||||
function removeGlobalStyles () { | ||||||||||||
cy.get('style').each((item) => { | ||||||||||||
if (item[0].dataset.cy !== 'injected-style-tag') { | ||||||||||||
item.remove() | ||||||||||||
} | ||||||||||||
}) | ||||||||||||
|
||||||||||||
return cy.get('style').should('have.length', 1) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
This comment has great context!! What do you think about including it in the code? |
||||||||||||
} | ||||||||||||
|
||||||||||||
describe('screenshot', () => { | ||||||||||||
captureTypes.forEach((capture) => { | ||||||||||||
it(`takes a standard screenshot with viewport: ${capture}`, () => { | ||||||||||||
|
@@ -45,7 +55,9 @@ describe('screenshot', () => { | |||||||||||
styles, | ||||||||||||
}) | ||||||||||||
|
||||||||||||
cy.screenshot(`percy/component_testing_takes_a_screenshot_viewport_${capture}`, { capture }) | ||||||||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
AFAIK you don't need |
||||||||||||
}) | ||||||||||||
}) | ||||||||||||
|
||||||||||||
|
@@ -55,7 +67,9 @@ describe('screenshot', () => { | |||||||||||
styles, | ||||||||||||
}) | ||||||||||||
|
||||||||||||
cy.screenshot('percy/component_testing_screenshot_custom_viewport_screenshot') | ||||||||||||
removeGlobalStyles().then(() => { | ||||||||||||
cy.screenshot('percy/component_testing_screenshot_custom_viewport_screenshot') | ||||||||||||
}) | ||||||||||||
}) | ||||||||||||
|
||||||||||||
it('screenshot with a really long viewport', () => { | ||||||||||||
|
@@ -64,7 +78,9 @@ describe('screenshot', () => { | |||||||||||
styles, | ||||||||||||
}) | ||||||||||||
|
||||||||||||
cy.screenshot('percy/component_testing_screenshot_long_viewport') | ||||||||||||
removeGlobalStyles().then(() => { | ||||||||||||
cy.screenshot('percy/component_testing_screenshot_long_viewport') | ||||||||||||
}) | ||||||||||||
}) | ||||||||||||
|
||||||||||||
const style = ` | ||||||||||||
|
@@ -134,8 +150,11 @@ describe('screenshot', () => { | |||||||||||
} | ||||||||||||
|
||||||||||||
mount(() => <Comp />, { style }).then(() => { | ||||||||||||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. bump |
||||||||||||
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' }) | ||||||||||||
}) | ||||||||||||
}) | ||||||||||||
}) | ||||||||||||
}) | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe 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 |
||
> | ||
<ul | ||
v-bind="wrapperProps" | ||
|
@@ -157,7 +157,7 @@ a::before { | |
} | ||
|
||
/** h-[calc] was getting dropped so moved to styles. Virtual list requires defined height. */ | ||
/** Header is 64px, padding-bottom is 8px **/ | ||
/** Header is 64px, padding-top is 8px **/ | ||
.specs-list-container { | ||
height: calc(100vh - 64px - 8px); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why TS is happy with this, if I would just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got warnings in vscode when I did plain |
||
|
||
// in the case that an element might change size on scroll | ||
// we trigger a scroll event to ensure that all elements are | ||
// at their final size before we calculate the total height | ||
|
@@ -112,6 +116,8 @@ const scrollOverrides = (win, doc) => { | |
doc.body.style.overflowY = originalBodyOverflowY | ||
} | ||
|
||
document.querySelector('body')?.classList.remove('screenshot-scrolling') | ||
|
||
return win.scrollTo(originalX, originalY) | ||
} | ||
} | ||
|
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.