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

[Test] Added UI test for the new stats traffic tab. #20422

Merged
merged 5 commits into from
Mar 14, 2024
Merged

Conversation

notandyvee
Copy link
Contributor

@notandyvee notandyvee commented Mar 6, 2024

Fixes #20001


This PR adds a new UI test, StatsNewTests. It tests simply that we can reach to the new stats traffic tabs and that there are the two default tabs.

In order to get it working I needed a way to toggle feature flags in UI tests. At first I tried using Wiremock options. But required some workarounds. I found a better way, WireMockServer.stubFor. You can find more documentation here. Apparently you can match against a specific url (/wpcom/v2/mobile/feature-flags/) and force return specific responses.

I tried making it a TestRule, but I needed access to WireMockRule. But it wouldn't work in a separate TestRule. The documentation isn't very large for android specifically. So for now I opted to simply pass in the feature file in BaseTest constructor.

To Test:

  • Run StatsNewTests on any emulator. Should pass.
  • Run StatsTests on any emulator. Should pass.
  • Run all UI tests to make sure no regressions were introduced.

Regression Notes

  1. Potential unintended areas of impact

    N/A

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

    Ran UI tests.

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

    Added new simple UI test, StatsNewTests.


PR Submission Checklist:

  • I have completed the Regression Notes.
  • 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.

@notandyvee notandyvee added [Type] Task UI Tests Anything related to automated UI Tests. labels Mar 6, 2024
@notandyvee notandyvee requested a review from irfano March 6, 2024 21:28
@dangermattic
Copy link
Collaborator

dangermattic commented Mar 6, 2024

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 6, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20422-d91cbf9
Commitd91cbf9
Direct Downloadjetpack-prototype-build-pr20422-d91cbf9.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 6, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20422-d91cbf9
Commitd91cbf9
Direct Downloadwordpress-prototype-build-pr20422-d91cbf9.apk
Note: Google Login is not supported on these builds.

@notandyvee notandyvee marked this pull request as ready for review March 11, 2024 23:22
@notandyvee notandyvee requested a review from a team as a code owner March 11, 2024 23:22
@notandyvee
Copy link
Contributor Author

Ok @irfano I kept it simple and added a simple new class, WireMockStub. This will hold a reference of a url path to match and a file name. We can loop through them and stub them in the BaseTest constructor.

Copy link

sonarcloud bot commented Mar 13, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Member

@irfano irfano left a comment

Choose a reason for hiding this comment

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

Thank you for adding the feature alternative endpoint responses. It will help enhance our UI tests.
LGTM! 👍🏻

*
* @param wireMockStubs the wiremock stubs to use for this specific test.
*/
public BaseTest(@Nullable final List<WireMockStub> wireMockStubs) {
Copy link
Member

Choose a reason for hiding this comment

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

We can also send a list. Nice!

@irfano irfano merged commit 5d7c71e into trunk Mar 14, 2024
20 checks passed
@irfano irfano deleted the andy/issue-20001 branch March 14, 2024 11:46
@irfano
Copy link
Member

irfano commented Mar 14, 2024

@notandyvee, I noticed that StatsGranularTabsTest has been flaky since we re-enabled it. I'm informing you because we might consider disabling it soon and monitoring whether the new StatsTest will also behave flaky or not.

@notandyvee
Copy link
Contributor Author

Thank you @irfano . I am aware of that. I created an issue to add retry mechanism since the bug seems to be a card loading issues. Retrying would help mitigate some of it since i was not able to reproduce it that often locally. But good call out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Task UI Tests Anything related to automated UI Tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update UI tests for Traffic tab
4 participants