WooCommerce for iOS has UI acceptance tests for critical user flows through the app. The tests use mocked network requests with WireMock.
The following flows are covered/planned to be covered by UI tests. Tests that are covered will be checked.
- Login
- Log in with Store Address
- Log in with email/password
- Invalid password
- Log in with magic link
- Log in with Apple
- Log in with Google
- My Store
- Stats Today, This Week, This Month, This Year load
- View detailed chart stats
- Orders
- Orders list loads
- Single Order Screen:
- Single order screen loads
- View product on single order screen
- Add customer note
- Add order note
- Update order status
- Issue refund
- Add shipping details
- Create a new order:
- With a selected order status
- With a product
- With customer details
- With shipping
- With a fee
- With a customer note
- Edit an existing order:
- Open edit flow
- Check existing order number
- Check existing product
- Edit products
- Edit customer details
- Order Edit flow can be dismissed
- Order Creation flow can be dismissed
- Products
- Products list and single product screens load
- Add new product - Simple physical product
- Add new product - Simple virtual product
- Add new product - Variable product
- Add new product - Grouped product
- Add new product - External product
- Search product
- Filter product
- Edit product
- Add media library image to existing product
- Add camera image to existing product
- Reviews
- Reviews list and single review screens load
- Mark review as spam
- Trash review
- Approve/unapprove review
- Undo action
- Push Notifications
- New order results in a push notification
- Orders push notification opens the correct order
- Reviews push notification opens the correct review
- Universal Links and Deeplinks - Tests are temporarily disabled, will re-enable/remove when Issue 9706 is resolved.
- Universal Link to Payments screen
- Universal Link to an Order
- Settings
- Contact support - Validate buttons and text fields
- Contact support - Submit support ticket
- Payments
- Make a Simple payment - Cash
- Make a Simple payment - Card Reader
- Make a Tap to Pay on iPhone payment
- Manage Card Reader - Connect/Disconnect Reader
- Card Reader Manual (Chipper) loads
- Learn More link loads
Note that due to the mock server setup, tests cannot be run on physical devices right now.
You can run the tests locally with these steps:
- Follow the build instructions to clone the project, install the dependencies, and open the project in Xcode.
- Run
rake mocks
to start a local mock server. - Select the
WooCommerceUITests
scheme in Xcode. - Navigate to Product > Test to run all the tests, or use the Test Navigator to run specific tests or test suites.
We also run the UI tests on Buildkite on every commit. See the Buildkite config for more details.
When adding a new UI test, consider:
- Whether you need to test a user flow (to accomplish a task or goal) or a specific feature (e.g. boundary testing).
- What screens are being tested (defined as screen objects in the Screens directory).
- Whether there are actions or flows that could be shared across tests (defined in the Utils directory).
- What network requests are made during the test (defined in the Mocks directory).
It's preferred to focus UI tests on entire user flows, and group tests with related flows or goals in the same test suite.
When you add a new test, you may need to add new screens and methods. We use ScreenObject and method chaining for clarity in our tests. Wherever possible, use an existing accessibilityIdentifier
(or add one to the app) instead of a string to select a UI element on the screen. This ensures tests can be run regardless of the device language.
When adding a new test case, please mark the test case as done on the list above. If the test case is not on the list, please add it to the list and mark it as done.
When you add a test (or when the app changes), the request definitions for WireMock need to be updated. You can read the WireMock documentation for more details.
If you are unsure what network requests need to be mocked for a test, an easy way to find out is to run the app through Charles Proxy and observe the required requests.