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

[Mobile] Appium 2 Migration #55166

Merged
merged 40 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9ebbc40
Dependencies update:
Oct 6, 2023
8b5af07
- Adds appium:setup script to install needed drivers for Appium.
Oct 6, 2023
009346b
Update Android Runner to cache the Appium drivers
Oct 6, 2023
5f9b11a
Update iOS Runner - Bump Xcode to 14.2
Oct 6, 2023
c4a9b2e
Update iOS Runner with these changes:
Oct 6, 2023
b03f738
Updates the E2E capabilities settings:
Oct 6, 2023
4d02fe1
Updates the E2E serverConfigs file with the updated SauceLabs setting…
Oct 6, 2023
70d400a
E2E Utils:
Oct 6, 2023
f52a355
E2E Utils:
Oct 6, 2023
c80e54b
E2E Utils:
Oct 6, 2023
da3fdbe
E2E Utils - Update the stopDriver function with:
Oct 6, 2023
0f241cf
E2E Utils - Updates swipeFromTo to WebdriverIO
Oct 6, 2023
23dfa7c
E2E Utils - Updates isEditorVisible to WebdriverIO
Oct 6, 2023
e09e15c
Remove usage of sauceJobStatus, WebdriverIO internally handles this
Oct 6, 2023
f9c55ef
EditorPage - Remove import of wd and keep a null value while we migra…
Oct 6, 2023
ff802a4
EditorPage - Migrate initializeEditor to WebdriverIO
Oct 6, 2023
024afb2
Gutenberg Editor Rendering Media Blocks test - Migrate to WebdriverIO
Oct 6, 2023
9db690e
E2E Utils - Revert removing passing the auth token for the jobURL, it…
Oct 10, 2023
f6f0cef
Remove idleTimeout desktop-only SauceLabs option
Oct 10, 2023
d1ce7b3
[Mobile] - Update E2E Block Insertion tests (#55167)
Oct 10, 2023
35293d9
test: Update Search tests for Appium 2 (#55170)
dcalhoun Oct 10, 2023
3027b7e
E2E Editor Page - Update dismissKeyboard to use WebdiverIO's hideKeyb…
Oct 11, 2023
9ffbe9a
test: Update Media Blocks tests for Appium 2 (#55222)
dcalhoun Oct 11, 2023
db1605b
test: Update Paragraph tests for Appium 2 (#55215)
dcalhoun Oct 11, 2023
ced4287
E2E Utils - Migrate dragAndDropAfterElement to WebdriverIO (#55254)
Oct 11, 2023
b384a3b
[Mobile] - Move Appium drivers setup to bash script (#55257)
Oct 11, 2023
12f876a
Merge branch 'trunk' of github.com:WordPress/gutenberg into rnmobile/…
dcalhoun Oct 12, 2023
c545e8f
test: Update E2E utilities (#55322)
dcalhoun Oct 16, 2023
0dbf082
Merge branch 'trunk' of github.com:WordPress/gutenberg into rnmobile/…
dcalhoun Oct 16, 2023
d482aa0
test: Replace swipe gesture with simple tap (#55427)
dcalhoun Oct 18, 2023
1bde2af
[Mobile] - Appium 2 Migration - Updating more utils (#55420)
Oct 19, 2023
d36cf9c
[Mobile] - Update closePicker util and updates Image Block test data …
Oct 19, 2023
efecd41
[Mobile] Improve Screen recording on Android for Appium 2 (#55443)
Oct 19, 2023
1d3b48a
Merge branch 'trunk' of github.com:WordPress/gutenberg into rnmobile/…
dcalhoun Oct 19, 2023
15e4023
docs: Update E2E test documentation (#55519)
dcalhoun Oct 23, 2023
7f99ec7
[Mobile] Remove `wd` usage and removes disabled tests (#55541)
Oct 23, 2023
b37ad19
Merge branch 'trunk' into rnmobile/appium-2
Oct 23, 2023
9d4613a
test: Improve E2E test consistency (#55554)
dcalhoun Oct 24, 2023
52b04f1
build: Ignore generated Android files (#55569)
dcalhoun Oct 24, 2023
020bb1b
docs: Avoid GMA project name until it is approved
dcalhoun Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ jobs:
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Restore tests setup cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~/.appium
key: ${{ runner.os }}-tests-setup-${{ hashFiles('package-lock.json') }}

- name: Prepare tests setup
run: npm run native test:e2e:setup

- name: Gradle cache
uses: gradle/gradle-build-action@b5126f31dbc19dd434c3269bf8c28c315e121da2 # v2.8.1

Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
matrix:
xcode: ['13.3.1']
xcode: ['14.2']
geriux marked this conversation as resolved.
Show resolved Hide resolved
device: ['iPhone 13']
native-test-name: [gutenberg-editor-rendering]

Expand All @@ -27,9 +27,25 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Switch Xcode version to ${{ matrix.xcode }}
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app

- name: Launch simulator
geriux marked this conversation as resolved.
Show resolved Hide resolved
run: (open -a Simulator && xcrun simctl boot '${{ matrix.device }}') &

- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Restore tests setup cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~/.appium
key: ${{ runner.os }}-tests-setup-${{ hashFiles('package-lock.json') }}

- name: Prepare tests setup
run: npm run native test:e2e:setup

- name: Prepare build cache key
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt

Expand All @@ -54,18 +70,12 @@ jobs:
- name: Bundle iOS
run: npm run native test:e2e:bundle:ios

- name: Switch Xcode version to ${{ matrix.xcode }}
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app

- name: Build (if needed)
run: test -e packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/GutenbergDemo || npm run native test:e2e:build-app:ios

- name: Build Web Driver Agent (if needed)
run: test -d packages/react-native-editor/ios/build/WDA || npm run native test:e2e:build-wda

- name: Launch simulator
run: open -a Simulator && xcrun simctl boot '${{ matrix.device }}'

- name: Run iOS Device Tests
run: TEST_RN_PLATFORM=ios npm run native device-tests:local ${{ matrix.native-test-name }}

Expand Down
6 changes: 3 additions & 3 deletions docs/contributors/code/react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Also, the mobile client is packaged and released via the [official WordPress app

If you encounter a failed Android/iOS test on your pull request, we recommend the following steps:

1. Re-running the failed GitHub Action job ([guide for how to re-run](https://docs.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#viewing-your-workflow-history)) - This should fix failed tests the majority of the time. Cases where you need to re-run tests for a pass should go down in the near future as flakiness in tests is actively being worked on. See the following GitHub issue for updated info on known failures: https://github.com/WordPress/gutenberg/issues/23949
2. You can check if the test is failing locally by following the steps to run the E2E test on your machine from the [mobile getting started guide](/docs/contributors/code/react-native/getting-started-react-native.md#ui-tests), with even more relevant info in the [relevant directory README.md](https://github.com/WordPress/gutenberg/tree/HEAD/packages/react-native-editor/__device-tests__#running-the-tests-locally)
1. Re-running the failed GitHub Action job ([guide for how to re-run](https://docs.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#viewing-your-workflow-history)) - This should fix failed tests the majority of the time.
2. You can check if the test is failing locally by following the steps to run the E2E test on your machine from the [E2E testing documentation](/packages/react-native-editor/__device-tests__/README.md).
3. In addition to reading the logs from the E2E test, you can download a video recording from the Artifacts section of the GitHub job that may have additional useful information.
4. Check if any changes in your PR would require corresponding changes to `.native.js` versions of files.
5. Lastly, if you're stuck on a failing mobile test, feel free to reach out to contributors on Slack in the #mobile or #core-editor chats in the WordPress Core Slack, [free to join](https://make.wordpress.org/chat/).
Expand All @@ -32,4 +32,4 @@ Follow the instructions in [Native mobile testing](/docs/contributors/code/react

## Internationalization (i18n)

Further information about this topic can be found in the [React Native Internationalization Guide](/docs/contributors/code/react-native/internationalization-guide.md).
Further information about this topic can be found in the [React Native Internationalization Guide](/docs/contributors/code/react-native/internationalization-guide.md).
Original file line number Diff line number Diff line change
Expand Up @@ -141,34 +141,8 @@ Then, open `chrome://inspect` in Chrome to attach the debugger (look into the "R

This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` or with the `.test.js` extension to have the files loaded by jest. See an example test [here](https://github.com/WordPress/gutenberg/blob/HEAD/packages/react-native-editor/src/test/api-fetch-setup.test.js). The [jest documentation](https://facebook.github.io/jest/docs/en/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/en/tutorial-react-native.html).

## UI Tests
## End-to-End Tests

This repository uses Appium to run UI tests. The tests live in `__device-tests__` and are written using Appium to run tests against simulators and real devices. To run these you'll need to check off a few things:
In addition to unit tests, the Gutenberg for Mobile Apps (GMA) project relies upon end-to-end (E2E) tests to automate testing critical flows in an environment similar to that of an end user. We generally prefer unit tests due to their speed and ease of maintenance. However, assertions that require OS-level features (e.g. complex gestures, text selection) or visual regression testing (e.g. dark mode, contrast levels) we use E2E tests.

- When running the tests, you'll need to ensure the Metro bundler (`npm run native start`) is not running.
- [Appium CLI](https://github.com/appium/appium/blob/1.x/docs/en/about-appium/getting-started.md) installed and available globally. We also recommend using [appium-doctor](https://github.com/appium/appium-doctor) to ensure all of Appium's dependencies are good to go. You don't have to worry about starting the server yourself, the tests handle starting the server on port 4723, just be sure that the port is free or feel free to change the port number in the test file.
- For iOS a simulator should automatically launch but for Android you'll need to have an emulator _with at least platform version 8.0_ fired up and running.

Then, to run the UI tests on iOS:

```sh
npm run native test:e2e:ios:local
```

and for Android:

```sh
npm run native test:e2e:android:local
```

To run a single test instead of the entire suite, use `npm run native device-tests:local`. Here's an example that runs only `gutenberg-editor-paragraph.test.js`:

```sh
npm run native test:e2e:android:local gutenberg-editor-paragraph.test.js
```

Note: You might experience problems that seem to be related to the tests starting the Appium server, e.g. errors that say `Connection Refused`, `Connection Reset` or `The requested environment is not available`. If so, you can manually start the Appium server via `npm run native appium:start`, and (optionally) comment out related code in the `beforeAll` and `afterAll` block.

For a more detailed outline of the UI tests and how to get started writing one, please visit the [UI Test documentation](/packages/react-native-editor/__device-tests__/README.md) and our [contributing guide](/packages/react-native-editor/__device-tests__/CONTRIBUTING.md).

You might want to use Visual Studio Code as an editor. The project includes the configuration needed to use the above codestyle and linting tools automatically.
The E2E tests are found in the [`packages/react-native-editor/__device-tests__`](/packages/react-native-editor/__device-tests__) directory. Additional documentation on running and contributing to these tests can be found in the [tests directory](/packages/react-native-editor/__device-tests__#readme).
Loading
Loading