-
Notifications
You must be signed in to change notification settings - Fork 58
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
Visual testing - Adds Sanity Test 4 Suite #5501
Conversation
70ed290
to
699d17e
Compare
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
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.
Great work! 👏🏻
All of my comments are merely thoughts, not blockers by any means.
Also, I noticed the title selection changed in __device-tests__/image-snapshots/gutenberg-editor-group-visual-test-js-gutenberg-editor-visual-test-for-group-block-should-show-the-empty-placeholder-for-the-unselected-state-1-android.png
. Was that intended?
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); |
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 necessarily required right now — maybe it is premature — but I wonder if we should abstract the modal animation times so that it is (1) clear what is occurring and (2) could be modified across tests as necessary.
const MODAL_OPEN_DURATION = 3000;
const MODAL_CLOSE_DURATION = 2000;
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.
Good idea, maybe even having a waitForModalToOpen
/ waitForModalToClose
utils. I can create a follow-up PR to introduce either that or just the constants.
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.
While I still think naming the sleep durations may help communicate intent, I may "walk back" on my suggestion after spending time in the e2e tests yesterday. My hot take is that we have a lot of test helpers, to the quantity that I find it difficult to comprehend each of them and their intent. I share that to say I now have reservations in regards to expanding test helpers further.
As a tangential thought to consider outside the scope of this PR, I wonder if we would benefit from evaluating if there any helpers we might should remove and replace with composing other existing, lower-level helpers. My perception is that we have some helpers that are very specific and niche. Obviously, a subject to discuss in a different place. Just sharing my thoughts.
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.
My hot take is that we have a lot of test helpers, to the quantity that I find it difficult to comprehend each of them and their intent.
I share the same feeling 😅
I wonder if we would benefit from evaluating if there any helpers we might should remove and replace with composing other existing, lower-level helpers. My perception is that we have some helpers that are very specific and niche. Obviously, a subject to discuss in a different place.
I agree, I think it's good you shared this, working on adding new tests always brings new perspectives and all the feedback will improve our current workflows and the way we do things.
Thanks for reviewing!
Yes! I actually realized we needed to update that screenshot when I changed the comparison method, now it matches the iOS screenshot. |
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.
Happy to have this coverage. Thank you!
await editorPage.removeBlockAtPosition( blockNames.buttons ); | ||
} ); | ||
|
||
it( 'Link from the clipboard is presented as an option in the link picker', async () => { |
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.
My perception is that all tests in this PR besides this one are very visual and likely benefit from visual regression testing snapshots. However, it seems we could likely test the spirit of this link picker test with a (possibly faster or simpler) integration test.
This is more a question regarding our overarching approach to testing, not necessarily directly related to the work of this PR. Not looking to block this PR, but seeking your thoughts. WDYT?
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.
For this case, since we are testing copying a link from the clipboard and expecting it to show in the link picker it is very attached to the device imagine something fails like a new OS permission is added and the link can't be pasted, and having a visual test of the whole workflow would allow us not to have to test this manually.
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.
Fair point. Avoiding a clipboard API mock provides additional coverage (e.g. OS permissions). There a few approaches to testing the spirit of this test case we could consider:
- Capture visual images within an e2e tests.
- Assert element presence within an e2e tests.
- Mock the clipboard API and assert element presence within an integration tests.
It seems you prefer the first two for this specific test case, which I think is reasonable.
Additionally, I do not know if there is a meaningful "cost" between the first two. The first may "cost" more in regards to test speed or repository size for stored images. While the test case description doesn't necessarily require to visual testing (we could just assert the element presence), it is additional coverage. I suppose it is a judgement call as to whether the visual coverage is worth it.
…eyboard in the screenshots as well as passing a custom height value
201bd5f
to
11b7fb9
Compare
Thank you for the review! 🚀 |
Related PRs:
This PR adds the first steps for the Sanity Test Suite 4:
Spacer block
Buttons block
It also updates the
takeScreenshot
util to take into account if the device is in landscape mode, if you want to avoid including the keyboard in the screenshot, or if you want to pass a custom height value for the screenshot to be cropped.After several test failures, I realized that including the keyboard will generate false positives, as the keyboard could look different in our local environments, like having other languages, and the emoji keyboard. I also encountered issues where the Keyboard would have a totally different appearance on CI.
Finally, it changes the
comparisonMethod
to compare the screenshots tossim
. You can find a nice explanation on the docummentation, as the pixel by pixel comparison wasn't working right.Note: Since this PR updates how it takes the screenshots, I'm updating all visual snapshots.
To test CI checks should pass on this PR.
PR submission checklist: