-
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
Update test descriptions of functionality test suite 4 #6013
Update test descriptions of functionality test suite 4 #6013
Conversation
65b9b87
to
5f22327
Compare
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
1 similar comment
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.
I see a red underline below the text, I guess because of the check spelling being enabled on your simulator, I wonder if this would cause issues on CI since I believe the test devices we use don't have autocorrect enabled. Have you encountered any flakiness about it?
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.
Ah, good point. I checked the failures and doesn't seem to be related to visual checks. In any case, I'll review the ones I generated and disable the spelling just in case. Thanks for the feedback 🙇 !
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 was solved in 1680eb6.
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.
As I shared in this comment, this error was caused by using a non-English keyboard, so it's unrelated to having the spell-checking option enabled. In fact, CI's simulator has spell-checking enabled when running the tests.
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.
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.
🚀
...te-4-buttons-block-should-have-its-selection-caret-with-the-same-color-as-the-font-1-ios.png
Show resolved
Hide resolved
On iOS, the context menu displayed when selecting the text wasn't displaying the expected options. To solve this the text is clicked before being selected. Additionally, previous actions for selecting the Button block have been removed as aren't necessary.
My guess is that the skinnier, translucent context menu is a result of the reveal animation having not yet finished. Is this issue resolved if a timeout is added to await the animation? |
Yep, I thought the same, in fact, I tried to solve it by adding an extra wait in a70d9c7. But still, it didn't work. Maybe it can be fixed just by increasing the timeout, I'll take a look 🤔. |
So sorry you're experiencing this flaky test 😓 what if we crop the screenshot? We just need to check that the caret selection has the right color for this test so maybe if we do something like: index 56397746f..2cf3eef29 100644
--- a/__device-tests__/gutenberg-editor-sanity-test-4-visual.test.js
+++ b/__device-tests__/gutenberg-editor-sanity-test-4-visual.test.js
@@ -149,8 +149,10 @@ describe( 'Gutenberg Editor - Test Suite 4', () => {
);
// Visual test check
+ const location = await buttonBlock.getLocation();
const screenshot = await takeScreenshot( {
withoutKeyboard: true,
+ topOffset: location.y,
} );
expect( screenshot ).toMatchImageSnapshot(); index 111f824b3..9ccb5f804 100644
--- a/__device-tests__/utils.js
+++ b/__device-tests__/utils.js
@@ -11,12 +11,14 @@ const { isAndroid } = e2eUtils;
* @param {Object} options Options
* @param {boolean} [options.withoutKeyboard] Prevents showing the keyboard in the screenshot.
* @param {number} [options.heightPercentage] Specify a custom height in percentage.
+ * @param {number} [options.topOffset] Specify a custom top offset to crop.
* @return {Buffer} Sreenshot image.
*/
-export async function takeScreenshot(
- options = { withoutKeyboard: false, heightPercentage: undefined }
-) {
- const { withoutKeyboard, heightPercentage } = options;
+export async function takeScreenshot( {
+ withoutKeyboard,
+ heightPercentage,
+ topOffset,
+} = {} ) {
const iPadDevice = process.env.IPAD;
const orientation = await editorPage.driver.getOrientation();
const isPortrait = orientation === 'PORTRAIT';
@@ -27,6 +29,7 @@ export async function takeScreenshot(
const portraitWidthSize = iPadDevice ? 768 : 320;
const landscapeWidthSize = iPadDevice ? 1024 : 640;
const widthSize = isPortrait ? portraitWidthSize : landscapeWidthSize;
+ const pixelRatio = isAndroid() ? 3.5 : 3;
const base64Image = Buffer.from( screenshot, 'base64' );
const image = await jimp.read( base64Image );
@@ -50,6 +53,20 @@ export async function takeScreenshot(
}
}
+ // Custom top offset
+ if ( topOffset ) {
+ const topOffsetWithRatio = isAndroid()
+ ? topOffset
+ : topOffset * pixelRatio;
+ const finalTopOffset = topOffsetWithRatio - statusBarHeight;
+ image.crop(
+ 0,
+ finalTopOffset,
+ image.getWidth(),
+ image.getHeight() - finalTopOffset
+ );
+ }
+
// Custom height in percentage
if ( heightPercentage ) {
const height = ( heightPercentage * image.getHeight() ) / 100; It would generate:
This would solve the issue of not having the same options in the contextual menu or language. If not, we could disable the test and re-think its approach. |
That's a good idea @geriux ! I'd like to explore first why we are getting a different screenshot, but I agree that the approach of cropping the screenshot would definitely solve the problem. Besides, it would be helpful in other cases where we only want to visual test a specific area of the editor. This approach probably would help make the visual testing less flaky. I haven't being able to focus on moving this forward, but I'll try to spare time today to wrap it up 👍. |
I've checked the video capture in SauceLabs and noticed that the contextual menu is translucid for some reason, which diverges from the local results. That said, I'll take the approach you shared Gerardo, and crop the screenshot to avoid conflicts with that menu between CI and the local environment. |
It's still failing due to just one pixel 🤦. I'll crop the screenshot to avoid including the contextual menu. |
The screenshot is now taken using the Button block instead of the Buttons block.
This PR is a follow up on this comment regarding updating the test descriptions.
To test:
PR submission checklist: