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

Percy: Introduce hide-in-percy and hide diff problematic elements #3689

Merged
merged 7 commits into from
Apr 11, 2019

Conversation

gabrieldutra
Copy link
Member

@gabrieldutra gabrieldutra commented Apr 9, 2019

What type of PR is this? (check all applicable)

  • Other

Description

This introduces the .hide-in-percy class to hide elements in the Page on Percy Screenshots and hide the following elements:

  • User Edit Page: API Key
  • All Pages: Pace progress bar

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Check Percy diff 🙂

@gabrieldutra gabrieldutra self-assigned this Apr 9, 2019
@@ -36,14 +41,6 @@ describe('Edit Profile', () => {
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps return the original "secret" api key at the end of the test so that test ordering wouldn't matter?

Copy link
Member Author

@gabrieldutra gabrieldutra Apr 9, 2019

Choose a reason for hiding this comment

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

IMO setting the state after the test is not a good approach as well. My ideas to improve it are:

  • try to intercept API response and modify "api_key" from it (it isn't as easy as I initially thought ^^);
  • modify the edit_profile_spec to do something I should've done at first, but leaned later: create a user to be tested prior the tests instead of asserting on the Admin user (this should fix this one).

The goal here is to get some time to do the above without annoyance in Percy. LMK what you think 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

The best approach IMO is to actually "blackout" the element so it doesn't get included in screenshots.

@media only percy {
  .hide-in-percy {
    visibility: hidden;
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@gabrieldutra if you go this route, can you piggyback pace as well (it's causing Percy false negatives)

Copy link
Member Author

@gabrieldutra gabrieldutra Apr 11, 2019

Choose a reason for hiding this comment

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

Not sure this is the very best solution to those cases as we are not capturing changes to that part of the UI. However this seems the best for now and I wanted to introduce Percy specific css anyway 🙂.

@ranbena please leave your comments, when you think this is ok I'll rename the PR and merge it.

@@ -84,6 +84,8 @@ jobs:
command: |
npm run cypress start
docker-compose run cypress npm run cypress db-seed
# Make sure the API key is the same so Percy snapshots are consistent
docker-compose -p cypress run postgres psql -U postgres -h postgres -c "update users set api_key = 'secret' where email ='admin@redash.io';"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you instead make this be able to be set from db seeding?

{
    route: '/setup',
    type: 'form',
    data: {
      name: 'Example Admin',
      email: 'admin@redash.io',
      password: 'password',
      org_name: 'Redash',
      api_key: 'secret', // <- HERE
    },
  },

Copy link
Member Author

@gabrieldutra gabrieldutra Apr 9, 2019

Choose a reason for hiding this comment

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

I don't like very much the idea of changing the API to this, in any case, please check my ideas in the other comment and LMK what you think.

-----------------------------------------------------------*/
@media only percy {
.hide-in-percy, .pace {
display: none;
Copy link
Member Author

@gabrieldutra gabrieldutra Apr 11, 2019

Choose a reason for hiding this comment

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

display: none; seemed better, but tell me if you think we get some value on having a white space i.e.: to know it's hidden or for alignment purposes (this last one seems important, but we can create another class when it becomes necessary)

Copy link
Contributor

@ranbena ranbena Apr 11, 2019

Choose a reason for hiding this comment

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

There's no difference to Percy comparison.
But visibility keeps the layout unaltered while display might mess things up, which might confuse a human looking at the images. So I favor visibility: hidden.

You can even go as far as this, to have full clarity 😬 (only if you want to):

@media only percy {
  .hide-in-percy, .pace {
    visibility: hidden;
    position: relative;

    &:after {
      content: 'Hidden from Percy';
      font-size: 10px;
      color: #000;
      opacity: 0.5;
      visibility: visible;
      position: absolute;
      left: 2px;
      top: 2px;
    }
  }
}

Copy link
Member Author

@gabrieldutra gabrieldutra Apr 11, 2019

Choose a reason for hiding this comment

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

You can even go as far as this, to have full clarity grimacing (only if you want to)

Nah, this may create issues when we want to hide small things or when the object will eventually disappear from the DOM.

@gabrieldutra
Copy link
Member Author

Next step is certainly discover a fix to those square icons. They are even more annoying than Pace 😆

@@ -176,7 +176,7 @@ export default class UserEdit extends React.Component {
const { user, regeneratingApiKey } = this.state;

return (
<Form layout="vertical">
<Form className="hide-in-percy" layout="vertical">
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's important to hide only the precise offending content <InputWithCopy>.

Copy link
Contributor

@ranbena ranbena left a comment

Choose a reason for hiding this comment

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

a few comments

@gabrieldutra gabrieldutra changed the title Cypress tests: preset the admin API key to a static value using SQL again Percy: Introduce hide-in-percy and hide diff problematic elements Apr 11, 2019
@gabrieldutra gabrieldutra merged commit 1524d06 into master Apr 11, 2019
@gabrieldutra gabrieldutra deleted the cypress-api-key branch July 4, 2019 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants