-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fdde14e
[Test] Updated BaseTest to allow for using a specific feature mock.
f6628c1
[Test] Add simple new stats traffic test and fix checkstyle issues.
4442ba1
Merge branch 'trunk' into andy/issue-20001
7fa14b2
[Test] Undid previous AssetFileSource edit and instead use WirMock st…
d91cbf9
[Test] Refactored a bit to allow stubbing more than one endpoint.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
WordPress/src/androidTest/java/org/wordpress/android/e2e/StatsGranularTabsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.wordpress.android.e2e | ||
|
||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.After | ||
import org.junit.Assume.assumeTrue | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.wordpress.android.BuildConfig | ||
import org.wordpress.android.R | ||
import org.wordpress.android.e2e.pages.MySitesPage | ||
import org.wordpress.android.support.BaseTest | ||
import org.wordpress.android.support.ComposeEspressoLink | ||
import org.wordpress.android.support.WPSupportUtils | ||
import org.wordpress.android.util.StatsKeyValueData | ||
import org.wordpress.android.util.StatsMocksReader | ||
import org.wordpress.android.util.StatsVisitsData | ||
|
||
@HiltAndroidTest | ||
class StatsGranularTabsTest : BaseTest() { | ||
@Before | ||
fun setUp() { | ||
assumeTrue(BuildConfig.IS_JETPACK_APP) | ||
ComposeEspressoLink().unregister() | ||
logoutIfNecessary() | ||
wpLogin() | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
// "tabLayout" is a Tab switcher for stats. | ||
// We need to leave stats at the end of test. | ||
if (WPSupportUtils.isElementDisplayed(Espresso.onView(ViewMatchers.withId(R.id.tabLayout)))) { | ||
Espresso.pressBack() | ||
} | ||
} | ||
|
||
@Test | ||
fun e2eAllDayStatsLoad() { | ||
val todayVisits = StatsVisitsData("97", "28", "14", "11") | ||
val postsList: List<StatsKeyValueData> = StatsMocksReader().readDayTopPostsToList() | ||
val referrersList: List<StatsKeyValueData> = StatsMocksReader().readDayTopReferrersToList() | ||
val clicksList: List<StatsKeyValueData> = StatsMocksReader().readDayClicksToList() | ||
val authorsList: List<StatsKeyValueData> = StatsMocksReader().readDayAuthorsToList() | ||
val countriesList: List<StatsKeyValueData> = StatsMocksReader().readDayCountriesToList() | ||
val videosList: List<StatsKeyValueData> = StatsMocksReader().readDayVideoPlaysToList() | ||
val downloadsList: List<StatsKeyValueData> = StatsMocksReader().readDayFileDownloadsToList() | ||
MySitesPage() | ||
.go() | ||
.goToStats() | ||
.openDayStats() | ||
.assertVisits(todayVisits) | ||
.scrollToPosts().assertPosts(postsList) | ||
.scrollToReferrers().assertReferrers(referrersList) | ||
.scrollToClicks().assertClicks(clicksList) | ||
.scrollToAuthors().assertAuthors(authorsList) | ||
.scrollToCountries().assertCountries(countriesList) | ||
.scrollToVideos().assertVideos(videosList) | ||
.scrollToFileDownloads().assertDownloads(downloadsList) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
WordPress/src/androidTest/java/org/wordpress/android/wiremock/WireMockStub.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.wordpress.android.wiremock | ||
|
||
/** | ||
* Represents a WireMock#stubFor call on a WireMockServer. | ||
* @property apiPathUrl The API path we are matching against. | ||
* @property fileName The filename used to return as the body stored in the androidTest resources sub directory. | ||
*/ | ||
data class WireMockStub( | ||
val urlPath: WireMockUrlPath, | ||
val fileName: String, | ||
) | ||
|
||
/** | ||
* Enum used to represent supported URLs we can stub. | ||
*/ | ||
enum class WireMockUrlPath(val path: String) { | ||
FEATURE_RESPONSE("/wpcom/v2/mobile/feature-flags/") | ||
} |
3 changes: 3 additions & 0 deletions
3
WordPress/src/androidTest/resources/new-stats-feature-response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"stats_traffic_tab": true | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!