Skip to content

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Jun 5, 2023

Fixes #20790

Implementation

  1. Use WireMock to mock web view pages instead of API endpoints
  2. Create fake checkout and plans pages to be used in UI tests
  3. Redirect to expected pages once the links are tapped
  4. Use Environment to inject WireMock URL and use it instead of WP.com URL
  5. Covered the whole flow with tests

To test:

  • Confirm UI tests succeeding in CI

Regression Notes

  1. Potential unintended areas of impact

Affecting free to paid plans flow

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

Manually retesting the whole purchase flow

  1. What automated tests I added (or what prevented me from doing so)

Covered the whole free to paid plans flow with automated UI Tests

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Video

Full.Flow.UI.Test.mp4

@staskus
Copy link
Contributor Author

staskus commented Jun 5, 2023

@guarani if you're interested, it looks like WireMock can also be used to mock web view content. Check the video from [00:17-] to see how it would look. We would essentially verify that our native code responds to the redirections as expected. This way we can simulate the whole flow. WDYT?

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 5, 2023

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr20805-51fe2ef
Version23.5
Bundle IDorg.wordpress.alpha
Commit51fe2ef
App Center BuildWPiOS - One-Offs #7523
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 5, 2023

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr20805-51fe2ef
Version23.5
Bundle IDcom.jetpack.alpha
Commit51fe2ef
App Center Buildjetpack-installable-builds #6550
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@guarani
Copy link
Contributor

guarani commented Jun 5, 2023

@guarani if you're interested, it looks like WireMock can also be used to mock web view content. Check the video from [00:17-] to see how it would look. We would essentially verify that our native code responds to the redirections as expected. This way we can simulate the whole flow. WDYT?

This seems like an interesting approach. I watched the screen recording and agree this test can ensure that the app can handle the redirects.

On Calypso a test for Automattic/wp-calypso#77029 could verify the sequence of screens and redirect URLs don't get changed.

@staskus
Copy link
Contributor Author

staskus commented Jun 6, 2023

This seems like an interesting approach. I watched the screen recording and agree this test can ensure that the app can handle the redirects.

Yes. These are not E2E tests, only native UI tests. Just like with mocked APIs, we expect our app to behave in a certain way given the input.

On Calypso a test for Automattic/wp-calypso#77029 could verify the sequence of screens and redirect URLs don't get changed.

👍 Good idea

@staskus staskus marked this pull request as ready for review June 6, 2023 11:35
@staskus staskus requested a review from a team as a code owner June 6, 2023 11:35
@staskus staskus requested a review from guarani June 6, 2023 11:35
@staskus
Copy link
Contributor Author

staskus commented Jun 6, 2023

@guarani

Ready for review. The whole free to paid plans flow on the native side is now covered with UI tests

@staskus staskus added this to the 22.6 milestone Jun 6, 2023
Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 While the changes look good, I keep running into the issue where the dashboard card doesn't appear and the UI test keeps trying to scroll the screen up to find it (similar to #20728 (review)). It also works the second time I run the app.

I re-read your comment, #20728 (comment), and the fix you added (reloading local cards after the app fetches the site domains), but don't see anything wrong.

Stopping at breakpoints seems to affect whether the card shows up or not, so I printed hasLoadedDomains in both the failing scenario (1st run after fresh install) and the passing scenario (2nd run) and there's a difference:

Not working Working
Screenshot 2023-06-06 at 20 43 23 Screenshot 2023-06-06 at 20 45 14

I thought to check if this is reproducible on trunk and it isn't. I did two fresh installs and both worked the first time. Have you tried a fresh install on this branch? I'm curious if you can reproduce.

@staskus
Copy link
Contributor Author

staskus commented Jun 7, 2023

I thought to check if this is reproducible on trunk and it isn't. I did two fresh installs and both worked the first time. Have you tried a fresh install on this branch? I'm curious if you can reproduce.

It is reproducible but only sometimes. In a morning investigation, I couldn't point out exactly why it would happen. Even in your "not working" scenario, the third reload of the free to-paid plan card indicates that domains are loaded so the card should appear. I continue investigating.

@staskus
Copy link
Contributor Author

staskus commented Jun 7, 2023

I found the issue that hasMappedDomain unexpectedly returns true with these internal values, causing shouldShowCard to return false.

image

  • API-Mocks have rest_v11_sites_106707880.json that matches urlPath": "/rest/v1.1/sites/106707880 and sets different values for "URL" and "unmapped_url" fields.
  • rest_v11_sites_106707880.json matches urlPathPattern": "/rest/v1.(1|2)/me/sites that shares the same siteID but sets the same "URL" and "unmapped_url" fields.
  • rest_v11_sites_106707880_settings.json that shares the same siteID but has a different "URL" field from the previous one

I haven't identified how these API mocks are matched and how it differs between the first or second launches. However, after making the mocks consistent, I could no longer reproduce the issue in multiple attempts.

Could you try it out again, @guarani, thanks!

@staskus staskus requested a review from guarani June 7, 2023 10:33
@guarani
Copy link
Contributor

guarani commented Jun 7, 2023

👋 Hey @staskus, I gave this a try today and weirdly still getting the same issue. I'd love to investigate more today, but I want to prioritise manually testing the flows since the project is close to finishing.

Do you agree with de-prioritizing this until we're confident we've done enough manual testing? I appreciate you investigating this and I think once it's working, having the UI test here for the happy path will be very valuable to catch regressions going forward.

@staskus
Copy link
Contributor Author

staskus commented Jun 8, 2023

Do you agree with de-prioritizing this until we're confident we've done enough manual testing?

Yes, we can wait given the issues we're facing in producing these tests.

@staskus staskus marked this pull request as draft June 8, 2023 09:00
@staskus staskus removed this from the 22.6 milestone Jun 9, 2023
- Introduce fake checkout and plans pages to be used in UI tests
- Use WireMock mocks to match plans/yearly and checkout pages to open fake views
Use the same mechanism as mocking base WP.com rest API URL by adding and editing the value through Environment struct
- hasMappedDomain returns incorrect value in UI Tests when unmaped_url and url mismatch unintentionally
@staskus staskus force-pushed the task/20790-plans-on-jp-update-ui-tests-to-reach-purchase-result-screen branch from 49f5670 to 74d086e Compare October 24, 2023 14:08
@staskus staskus closed this Jun 17, 2024
@jkmassel jkmassel deleted the task/20790-plans-on-jp-update-ui-tests-to-reach-purchase-result-screen branch July 26, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plans on JP: Update UI test to reach purchase result screen

4 participants