Skip to content

Fix/screenshot ui tests - #13031

Merged
JavonDavis merged 7 commits into
developfrom
fix/screenshot-ui-tests
Nov 20, 2020
Merged

Fix/screenshot ui tests#13031
JavonDavis merged 7 commits into
developfrom
fix/screenshot-ui-tests

Conversation

@JavonDavis

Copy link
Copy Markdown
Contributor

Fixes issue finding RecyclerView on posts list page

To test: Screenshot tests should pass

PR submission checklist:

  • I have considered adding unit tests where possible.
  • 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.

@peril-wordpress-mobile

peril-wordpress-mobile Bot commented Sep 29, 2020

Copy link
Copy Markdown

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile

peril-wordpress-mobile Bot commented Sep 29, 2020

Copy link
Copy Markdown

You can test the changes on this Pull Request by downloading the APK here.

@jkmassel jkmassel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't compile this branch for some reason – I think I need to sort out a bunch of Android Studio stuff, but I left one comment for your consideration in the mean time.

private static RecyclerView getRecyclerView() {
ViewPager pager = getCurrentActivity().findViewById(R.id.postPager);
return (RecyclerView) pager.getChildAt(pager.getCurrentItem()).findViewById(R.id.recycler_view);
return (RecyclerView) ((ViewGroup) ((ViewGroup) (pager.getChildAt(pager.getCurrentItem()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks tricky – could we add an ID to the RecyclerView in order to be able to fetch it by ID instead? 😅

If not, that's ok, just wanted to check

@JavonDavis JavonDavis Oct 1, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jkmassel There's an ID on the RecyclerView see

https://github.com/wordpress-mobile/WordPress-Android/blob/develop/WordPress/src/main/res/layout/post_list_fragment.xml#L18-L23

but for some reason at runtime it's disappearing and causing us to crash, I spent quite a while investigating this but decided to table figuring that out for later and implemented this workaround. I can make a comment of that here, unless you have some ideas on what could be the root cause for this?

@designsimply designsimply left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After switching to the fix/screenshot-ui-tests branch (and learning that I need to cd into the libs/gutenberg-mobile directory and git checkout . to clean up any dirty files every time), I was able to run WPScreenshotTest to completion with the workaround in this PR.

In my case, I ran the test several times and one test keeps failing for me with some strange looking wiremock error that starts with:

com.github.tomakehurst.wiremock.client.VerificationException: 18 requests were unmatched by any stub mapping. Shown with closest stub mappings:

Click to see the whole wiremock error
com.github.tomakehurst.wiremock.client.VerificationException: 6 requests were unmatched by any stub mapping. Shown with closest stub mappings:
expected:<
GET
/rest/v1.1/sites/106707880/stats/visits/?unit=week&quantity=15&date=2020-10-08&locale=en_US

Query: unit = year
quantity: 15
date: 2020-10-08
locale: en_US
> but was:<
GET
/rest/v1.1/sites/106707880/stats/visits/?unit=week&quantity=15&date=2020-10-08&locale=en_US

unit: week
quantity: 15
date: 2020-10-08
locale: en_US
>

expected:<
GET
/rest/v1.1/sites/106707880/stats/visits/?unit=week&quantity=15&date=2020-10-08&locale=en_US

Query: unit = day
quantity: 15
date: 2020-10-08
locale: en_US
> but was:<
GET
/rest/v1.1/sites/106707880/stats/visits/?unit=week&quantity=15&date=2020-10-08&locale=en_US

unit: week
quantity: 15
date: 2020-10-08
locale: en_US
>

expected:<
GET
/rest/v1.1/sites/106707880/stats/visits/?unit=week&quantity=15&date=2020-10-08&locale=en_US

Query: unit = day
quantity: 15
date: 2020-10-08
locale: en_US
> but was:<
GET
/rest/v1.1/sites/106707880/stats/visits/?unit=week&quantity=15&date=2020-10-08&locale=en_US

unit: week
quantity: 15
date: 2020-10-08
locale: en_US
>

expected:<
GET
/wpcom/v2/read/interests
> but was:<
GET
/wpcom/v2/read/tags/cards?refresh=0&locale=en_US&tags=photography
>

expected:<
GET
/wpcom/v2/plans/mobile
> but was:<
GET
/wpcom/v2/read/tags/cards?refresh=0&locale=en_US&tags=photography
>

expected:<
GET
/wpcom/v2/mobile/feature-announcements/
> but was:<
GET
/wpcom/v2/read/tags/cards?refresh=0&locale=en_US&tags=photography
>
at com.github.tomakehurst.wiremock.junit.WireMockRule.checkForUnmatchedRequests(WireMockRule.java:92)
at com.github.tomakehurst.wiremock.junit.WireMockRule.access$000(WireMockRule.java:34)
at com.github.tomakehurst.wiremock.junit.WireMockRule$1.evaluate(WireMockRule.java:74)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.wordpress.android.ui.screenshots.WPLocaleTestRule$1.evaluate(WPLocaleTestRule.java:39)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)

Tests ran to completion.

Is it okay to assume this issue will be resolved with the mock data updates we're about to complete and this PR should go through because the important thing is that the tests run without error so we can move forward?

@peril-wordpress-mobile

Copy link
Copy Markdown
Warnings
⚠️ PR is not assigned to a milestone.

Generated by 🚫 dangerJS

@JavonDavis
JavonDavis deleted the fix/screenshot-ui-tests branch May 7, 2021 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants