-
Notifications
You must be signed in to change notification settings - Fork 4.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
[RNMobile] Initialize E2E tests with initial HTML #53434
Conversation
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
// Wait for dragging gesture | ||
await this.driver.sleep( 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.
When executing the action dragFromToForDuration
in the above line, the call is not really waiting for the dragging gesture to finish. For this reason, I added a delay here to ensure we wait for the gesture to initiate the next one (in case it's needed).
I noticed this behavior on iOS when testing the insertion of the Search block, which is located at the bottom of the block list. In that case, the test was failing due to this problem. This hasn't been encountered before because tests for blocks located at the bottom of the block list weren't being inserted.
y: 10, | ||
} ); | ||
} | ||
await blockButton.click(); |
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 far as I tested, on iOS calling the click
function works as expected.
@@ -750,6 +753,30 @@ const clearClipboard = async ( driver, contentType = 'plaintext' ) => { | |||
await driver.setClipboard( '', contentType ); | |||
}; | |||
|
|||
const launchApp = async ( driver, initialProps = {} ) => { | |||
if ( isAndroid() ) { | |||
await driver.execute( 'mobile: startActivity', { |
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.
Here is the documentation about this function:
https://github.com/appium/appium-uiautomator2-driver/tree/v1.70.1#mobile-startactivity
On Android, we don't have a function to terminate the app as on iOS. However, with the stop
argument we can force the app to be closed before launching it again.
Regarding the cryptic extras
argument 😅 , since we are passing a JSON data, we have to wrap it in quotes. This is required because Appium is passing the data via the command line.
], | ||
} ); | ||
} else { | ||
await driver.execute( 'mobile: terminateApp', { |
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.
Here is the documentation about this function:
https://appium.github.io/appium-xcuitest-driver/4.32/execute-methods/#mobile-terminateapp
await driver.execute( 'mobile: terminateApp', { | ||
bundleId: IOS_BUNDLE_ID, | ||
} ); | ||
await driver.execute( 'mobile: launchApp', { |
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.
Here is the documentation about this function:
https://appium.github.io/appium-xcuitest-driver/4.32/execute-methods/#mobile-launchapp
@@ -9,6 +9,7 @@ const ios = { | |||
processArguments: { | |||
args: [ 'uitesting' ], | |||
}, | |||
autoLaunch: false, |
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 capability prevents Appium to automatically launch the app. Tests will now control when it's launched.
guard ProcessInfo.processInfo.arguments.count >= 2 else { | ||
return false | ||
} | ||
return ProcessInfo.processInfo.arguments[1] == "uitesting" |
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.
uitesting
is used here to tweak the app for testing.
@@ -18,8 +15,7 @@ class CustomEnvironment extends JSDOMEnvironment { | |||
async setup() { | |||
try { | |||
await super.setup(); | |||
this.global.editorPage = await initializeEditorPage(); | |||
this.global.editorPage.blockNames = blockNames; |
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.
blockNames
are usually imported from editor-page
module, so we don't need to export it globally.
await paragraphBlockElement.click(); | ||
await editorPage.removeBlock(); | ||
} | ||
expect( await editorPage.getNumberOfParagraphBlocks() ).toEqual( 3 ); |
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 added an expectation as we didn't have one before.
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.
Fantastic work! 👏🏻
Related PRs:
What?
Replaces the mechanism to set the initial HTML for E2E tests. Now, instead of switching to the HTML mode and pasting the content, we pass the initial HTML when starting the app.
Why?
This change introduces the following improvements to the E2E test environment:
How?
editor-page
E2E util has been refactored to prevent starting the app when setting up tests. It now only set up the driver to communicate with Appium. The app is now initiated when callingeditorPage.initializeEditor
and accepts an argument to pass initial props to the editor like the post's content HTML.initialProps
, I only implemented theinitialData
property which is used to set the initial HTML in the editor. In the future, we could expand this and accept other initial props.initializeEditor
helper. Those that were usingsetHtmlContent
are now initializing the editor passing the HTML. Additionally, the clean-up logic of the tests has been removed.Testing Instructions
Testing Instructions for Keyboard
N/A
Screenshots or screencast
N/A