-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add ability to whitelist visible elements in percy #45733
Add ability to whitelist visible elements in percy #45733
Conversation
💚 Build Succeeded |
@spalger could you take a look at this when you get a minute? Thanks |
I think we should consider the risks this pose to the value of Percy. Visual testing is definitely important to purely visual components like graphs. However, it's also vital to ensure that the PR doesn't contain changes that affect the surrounding UI. By enabling white listing, you can more easily completely ignore what effects your changes have on the surrounding UI. Take your screenshots for example, it not only ignores the outer UI, but the container the component sits in. Therefore, you'll miss the fact that the new graph's x-axis is actually extending beyond the container's bounds: Another example is say, in your graph you wanted the text red. So you added This won't be picked up by Percy because the test completely isolates only the component you've deemed necessary. The nice thing about Percy, is that while it will indicate that there are differences, you can always accept them. It's a more manual process, but at the very least makes you consider your changes and how it affects other areas. I am of course using the general "you" for all devs. |
@cchaos Yup I agree entirely. I think of this as merely a temporary fix as we venture into the world of visual testing and work through all of the kinks. TLDR; The issue we are facing right now is that the Percy tests are currently unstable. The The discover page is facing similar issues on top of the general issue of Percy not completely loading assets, such as font-awesome, before taking the screenshot. I think the approach of whitelisting will help us build up to a final standard of the visual testing, while in the meantime not skipping tests because the current implementation needs to be fine-tuned. Also given we are charged per screenshot per PR per push, it would be ideal to test as much as we can in one shot as you have pointed out. You pointed out another issue related to |
@nickofthyme these failing checks aren't run on draft PRs, if you want to start with a draft in the future. Otherwise please resolve them? |
test/visual_regression/services/visual_testing/visual_testing.ts
Outdated
Show resolved
Hide resolved
Gotcha, thank you for the background. My concerns aren't meant to hinder progress for sure. I mainly wanted to raise them to consider why we're using Percy in the first place. But I see there's still a ways to go before full utilization, like fixing the font issue. |
💚 Build Succeeded |
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 looks great, but I just saw this article and now I'm wondering if we could accomplish the same functionality with a call signature like:
takePercySnapshot({ show: ['foo'], hide: ['bar'] })
The idea would be that when show.length > 0
the .percyHideByDefault
class would be added to the body, hide
selectors would always be applied.
@spalger yeah I saw you mention deciding to whitelist or blacklist. I'll take a look at the article. |
test/visual_regression/services/visual_testing/take_percy_snapshot.js
Outdated
Show resolved
Hide resolved
test/visual_regression/services/visual_testing/take_percy_snapshot.js
Outdated
Show resolved
Hide resolved
test/visual_regression/services/visual_testing/take_percy_snapshot.js
Outdated
Show resolved
Hide resolved
test/visual_regression/services/visual_testing/take_percy_snapshot.js
Outdated
Show resolved
Hide resolved
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
💚 Build Succeeded |
@spalger Are you ok with me merging this? |
💚 Build Succeeded |
💚 Build Succeeded |
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.
LGTM
💚 Build Succeeded |
@elastic/kibana-design could someone take a look at this before merging, please? Thanks! |
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.
Removal from SASS looks fine
* add ability to whitelist visible elements in percy * allow white and blacklisting elements in visual tests * remove unnecessary webElement methods * refactor snapshot options to use show and hide * refactor add/remove and visual test helpers * [percy] rework css rules to allow hiding inside shown elements * [percy] adjust logic to support showing inside hiding * attach styles to hide percy when capturing the snapshot * refactor in order to make sure all logic is executed if snapshot fails * remove sleeps * add back skipFirefox tag
* add ability to whitelist visible elements in percy * allow white and blacklisting elements in visual tests * remove unnecessary webElement methods * refactor snapshot options to use show and hide * refactor add/remove and visual test helpers * [percy] rework css rules to allow hiding inside shown elements * [percy] adjust logic to support showing inside hiding * attach styles to hide percy when capturing the snapshot * refactor in order to make sure all logic is executed if snapshot fails * remove sleeps * add back skipFirefox tag
* add ability to whitelist visible elements in percy * allow white and blacklisting elements in visual tests * remove unnecessary webElement methods * refactor snapshot options to use show and hide * refactor add/remove and visual test helpers * [percy] rework css rules to allow hiding inside shown elements * [percy] adjust logic to support showing inside hiding * attach styles to hide percy when capturing the snapshot * refactor in order to make sure all logic is executed if snapshot fails * remove sleeps * add back skipFirefox tag
* add ability to whitelist visible elements in percy * allow white and blacklisting elements in visual tests * remove unnecessary webElement methods * refactor snapshot options to use show and hide * refactor add/remove and visual test helpers * [percy] rework css rules to allow hiding inside shown elements * [percy] adjust logic to support showing inside hiding * attach styles to hide percy when capturing the snapshot * refactor in order to make sure all logic is executed if snapshot fails * remove sleeps * add back skipFirefox tag
Summary
Add the ability to whitelist OR blacklist visible elements in percy visual regression tests.
blacklist: select elements to ignore/hide
default
whitelist: select only elements you want to show in the screenshot
Add
SnapshotOptions
tosnapshot
method in visual regression service.The
selectors
options accept an array ontestSubject
selectors to identify which elements to hide or show.See example Percy diff here. Notice the first whitelists only the chart and the second blacklists the side panel
@liza-mae are you ok with me un-skipping the discover tests to see if they are stable with these changes?
Checklist
For maintainers