-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20422 from wordpress-mobile/andy/issue-20001
[Test] Added UI test for the new stats traffic tab.
- Loading branch information
Showing
6 changed files
with
145 additions
and
27 deletions.
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 | ||
} |