Skip to content

Commit

Permalink
Merge branch 'trunk' into Dashboard-Domain-Card-UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ravishanker committed Apr 13, 2023
2 parents 705eb20 + 641a3bb commit 461a103
Show file tree
Hide file tree
Showing 51 changed files with 9,569 additions and 3,912 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
22.2
-----
* [**] [Jetpack-only] Adds a dashboard card for purchasing domains. [https://github.com/wordpress-mobile/WordPress-Android/pull/18240]
* [**] [Jetpack-only] Blogging Prompts: adds the ability to view other users' responses to a prompt. [https://github.com/wordpress-mobile/WordPress-Android/pull/18265]

22.1
-----
* [**] [WordPress-only] Warns user about sites with only individual plugins not supporting core app features and offers the option to switch to the Jetpack app. [https://github.com/wordpress-mobile/WordPress-Android/pull/18199]
* [*] Block editor: Avoid empty Gallery block error [https://github.com/WordPress/gutenberg/pull/49557]

22.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,46 @@ class ReaderTests : BaseTest() {
ReaderPage().go()
}

var mCoachingPostTitle = "Let's check out the coaching team!"
var mCompetitionPostTitle = "Let's focus on the competition."
@Test
fun e2eNavigateThroughPosts() {
ReaderPage()
.tapFollowingTab()
.openPost(mCoachingPostTitle)
.verifyPostDisplayed(mCoachingPostTitle)
.openBlogOrPost(TITLE_COACHING_POST)
.verifyPostDisplayed(TITLE_COACHING_POST)
.slideToPreviousPost()
.verifyPostDisplayed(mCompetitionPostTitle)
.verifyPostDisplayed(TITLE_COMPETITION_POST)
.slideToNextPost()
.verifyPostDisplayed(mCoachingPostTitle)
.verifyPostDisplayed(TITLE_COACHING_POST)
.goBackToReader()
}

@Test
fun e2eLikePost() {
ReaderPage()
.tapFollowingTab()
.openPost(mCoachingPostTitle)
.openBlogOrPost(TITLE_COACHING_POST)
.likePost()
.verifyPostLiked()
.unlikePost()
.verifyPostNotLiked()
.goBackToReader()
}

@Test
fun e2eBookmarkPost() {
ReaderPage()
.tapFollowingTab()
.openBlogOrPost(TITLE_LONGREADS_BLOG)
.bookmarkPost()
.verifyPostBookmarked()
.removeBookmarkPost()
.verifyPostNotBookmarked()
.goBackToReader()
}

companion object {
private const val TITLE_LONGREADS_BLOG = "Longreads"
private const val TITLE_COACHING_POST = "Let's check out the coaching team!"
private const val TITLE_COMPETITION_POST = "Let's focus on the competition."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ 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
Expand Down Expand Up @@ -33,6 +35,10 @@ class StatsTests : BaseTest() {

@Test
fun e2eAllDayStatsLoad() {
// We're not running this test on JP.
// See https://github.com/wordpress-mobile/WordPress-Android/issues/18065
assumeTrue(!BuildConfig.IS_JETPACK_APP)

val todayVisits = StatsVisitsData("97", "28", "14", "11")
val postsList: List<StatsKeyValueData> = StatsMocksReader().readDayTopPostsToList()
val referrersList: List<StatsKeyValueData> = StatsMocksReader().readDayTopReferrersToList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ReaderPage {
return this
}

fun openPost(postTitle: String?): ReaderViewPage {
fun openBlogOrPost(postTitle: String): ReaderViewPage {
val post = Espresso.onView(ViewMatchers.withChild(ViewMatchers.withText(postTitle)))
WPSupportUtils.scrollIntoView(R.id.reader_recycler_view, post, 1f)
WPSupportUtils.clickOn(postTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,88 @@ package org.wordpress.android.e2e.pages
import android.view.KeyEvent
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiScrollable
import androidx.test.uiautomator.UiSelector
import junit.framework.TestCase
import org.wordpress.android.support.WPSupportUtils

class ReaderViewPage {
var mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
var mLikerContainerId = "org.wordpress.android.prealpha:id/liker_faces_container"
var mRelatedPostsId = "org.wordpress.android.prealpha:id/container_related_posts"
var mFooterId = "org.wordpress.android.prealpha:id/layout_post_detail_footer"
var mLikerContainer = mDevice.findObject(UiSelector().resourceId(mLikerContainerId))
var mRelatedPostsContainer = mDevice.findObject(UiSelector().resourceId(mRelatedPostsId))
var mSwipeForMore = mDevice.findObject(UiSelector().textContains("Swipe for more"))
var mFooter = mDevice.findObject(UiSelector().resourceId(mFooterId))
private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private val likerContainer = device.findObject(UiSelector().resourceId(buildResourceId("liker_faces_container")))
private val relatedPostsContainer = device.findObject(
UiSelector().resourceId(buildResourceId("container_related_posts"))
)
private val swipeForMore = device.findObject(UiSelector().textContains("Swipe for more"))
private val recyclerView = UiScrollable(UiSelector().resourceId(buildResourceId("recycler_view")))
private val savePostsForLater = device.findObject(UiSelector().text("Save Posts for Later"))
private val okButton = device.findObject(UiSelector().text("OK"))
private val bookmarkButtonSelector = UiSelector().resourceId(buildResourceId("bookmark"))

private fun buildResourceId(id: String): String {
val packageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName
return "$packageName:id/$id"
}

fun waitUntilLoaded(): ReaderViewPage {
mRelatedPostsContainer.waitForExists(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
relatedPostsContainer.waitForExists(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
return this
}

fun likePost(): ReaderViewPage {
tapLikeButton()
mLikerContainer.waitForExists(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
likerContainer.waitForExists(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
return this
}

fun unlikePost(): ReaderViewPage {
tapLikeButton()
mLikerContainer.waitUntilGone(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
likerContainer.waitUntilGone(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
return this
}

private fun tapLikeButton() {
mSwipeForMore.waitUntilGone(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
swipeForMore.waitUntilGone(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
// Even though it was working locally in simulator, tapping the footer buttons,
// like 'mLikeButton.click()', was not working in CI.
// The current workaround is to use arrows navigation.

// Bring focus to the footer. First button is selected.
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN)
// Navigate to Like button.
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT)
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT)
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT)
// Click the Like button.
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_CENTER)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_CENTER)
// Navigate back to the first footer button.
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_LEFT)
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_LEFT)
mDevice.pressKeyCode(KeyEvent.KEYCODE_DPAD_LEFT)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_LEFT)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_LEFT)
device.pressKeyCode(KeyEvent.KEYCODE_DPAD_LEFT)
}

fun bookmarkPost(): ReaderViewPage {
tapBookmarkButton()
// Dismiss save posts locally dialog.
if (savePostsForLater.exists()) {
okButton.clickAndWaitForNewWindow()
}
return this
}

fun removeBookmarkPost(): ReaderViewPage {
tapBookmarkButton()
return this
}

private fun tapBookmarkButton() {
// Scroll to the bookmark button.
recyclerView.scrollIntoView(bookmarkButtonSelector)
// Tap the bookmark button.
device.findObject(bookmarkButtonSelector).clickAndWaitForNewWindow()
}

fun goBackToReader(): ReaderPage {
mDevice.pressBack()
device.pressBack()
return ReaderPage()
}

Expand All @@ -77,16 +107,29 @@ class ReaderViewPage {
}

fun verifyPostLiked(): ReaderViewPage {
val isLiked = mDevice
val isLiked = device
.findObject(UiSelector().textContains("You like this."))
.waitForExists(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
TestCase.assertTrue("Liker was not displayed.", isLiked)
return this
}

fun verifyPostNotLiked(): ReaderViewPage {
val likerDisplayed = mLikerContainer.exists()
val likerDisplayed = likerContainer.exists()
TestCase.assertFalse("Liker faces container was displayed.", likerDisplayed)
return this
}

fun verifyPostBookmarked(): ReaderViewPage {
val isBookmarked = device.findObject(UiSelector().text("Post saved"))
.waitForExists(WPSupportUtils.DEFAULT_TIMEOUT.toLong())
TestCase.assertTrue("Snackbar was not displayed.", isBookmarked)
return this
}

fun verifyPostNotBookmarked(): ReaderViewPage {
val isBookmarked = device.findObject(bookmarkButtonSelector).isSelected
TestCase.assertFalse("The bookmark button is selected", isBookmarked)
return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import org.hamcrest.Matchers
import org.wordpress.android.BuildConfig
import org.wordpress.android.R
import org.wordpress.android.support.WPSupportUtils
import org.wordpress.android.util.StatsKeyValueData
Expand Down Expand Up @@ -67,41 +66,37 @@ class StatsPage {
}

fun assertVisits(visitsData: StatsVisitsData): StatsPage {
// Skip this check for JP because of the bug with Stats card load.
// See https://github.com/wordpress-mobile/WordPress-Android/issues/18065
if (!BuildConfig.IS_JETPACK_APP) {
val cardStructure = Espresso.onView(
Matchers.allOf(
ViewMatchers.isDescendantOfA(visibleCoordinatorLayout),
ViewMatchers.withId(R.id.stats_block_list),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Views"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.views))
)
),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Visitors"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.visitors))
)
),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Likes"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.likes))
)
),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Comments"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.comments))
)
val cardStructure = Espresso.onView(
Matchers.allOf(
ViewMatchers.isDescendantOfA(visibleCoordinatorLayout),
ViewMatchers.withId(R.id.stats_block_list),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Views"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.views))
)
),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Visitors"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.visitors))
)
),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Likes"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.likes))
)
),
ViewMatchers.hasDescendant(
Matchers.allOf(
ViewMatchers.withText("Comments"),
ViewMatchers.hasSibling(ViewMatchers.withText(visitsData.comments))
)
)
)
cardStructure.check(ViewAssertions.matches(ViewMatchers.isCompletelyDisplayed()))
}
)
cardStructure.check(ViewAssertions.matches(ViewMatchers.isCompletelyDisplayed()))
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
import org.wordpress.android.ui.reader.CommentNotificationsBottomSheetFragment;
import org.wordpress.android.ui.reader.ReaderBlogFragment;
import org.wordpress.android.ui.reader.ReaderPostDetailFragment;
import org.wordpress.android.ui.reader.ReaderPostListActivity;
import org.wordpress.android.ui.reader.ReaderPostListFragment;
import org.wordpress.android.ui.reader.ReaderPostPagerActivity;
import org.wordpress.android.ui.reader.ReaderSearchActivity;
Expand Down Expand Up @@ -342,8 +341,6 @@ public interface AppComponent {

void inject(ReaderPostPagerActivity object);

void inject(ReaderPostListActivity object);

void inject(ReaderBlogFragment object);

void inject(ReaderBlogAdapter object);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package org.wordpress.android.ui.domains

import android.annotation.SuppressLint
import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
@SuppressLint("ParcelCreator")
data class DomainProductDetails(
val productId: Int,
val domainName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.wordpress.android.util.AppLog.T
import org.wordpress.android.util.SiteUtils
import org.wordpress.android.util.config.SiteDomainsFeatureConfig
import org.wordpress.android.util.extensions.isOnSale
import org.wordpress.android.util.extensions.saleCostForDisplay
import org.wordpress.android.util.helpers.Debouncer
import org.wordpress.android.viewmodel.Event
import org.wordpress.android.viewmodel.ScopedViewModel
Expand Down Expand Up @@ -186,7 +185,7 @@ class DomainSuggestionsViewModel @Inject constructor(
domainName = it.domain_name,
cost = it.cost,
isOnSale = product.isOnSale(),
saleCost = product.saleCostForDisplay(),
saleCost = product?.combinedSaleCostDisplay.orEmpty(),
isFree = it.is_free,
supportsPrivacy = it.supports_privacy,
productId = it.product_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.ui.mysite.MySiteSource.MySiteRefreshSource
import org.wordpress.android.ui.mysite.MySiteUiState.PartialState.CardsUpdate
import org.wordpress.android.ui.mysite.SelectedSiteRepository
import org.wordpress.android.util.config.DashboardCardActivityLogConfig
import org.wordpress.android.util.config.DashboardCardPagesConfig
import org.wordpress.android.util.config.MySiteDashboardTodaysStatsCardFeatureConfig
import javax.inject.Inject
Expand All @@ -27,12 +28,15 @@ class CardsSource @Inject constructor(
private val cardsStore: CardsStore,
todaysStatsCardFeatureConfig: MySiteDashboardTodaysStatsCardFeatureConfig,
dashboardCardPagesConfig: DashboardCardPagesConfig,
dashboardCardActivityLogConfig: DashboardCardActivityLogConfig,
@param:Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher
) : MySiteRefreshSource<CardsUpdate> {
private val isTodaysStatsCardFeatureConfigEnabled = todaysStatsCardFeatureConfig.isEnabled()

private val isDashboardCardPagesConfigEnabled = dashboardCardPagesConfig.isEnabled()

private val isDashboardCardActivityLogConfigEnabled = dashboardCardActivityLogConfig.isEnabled()

override val refresh = MutableLiveData(false)

override fun build(coroutineScope: CoroutineScope, siteLocalId: Int): LiveData<CardsUpdate> {
Expand Down Expand Up @@ -104,6 +108,7 @@ class CardsSource @Inject constructor(
private fun getCardTypes() = mutableListOf<Type>().apply {
if (isTodaysStatsCardFeatureConfigEnabled) add(Type.TODAYS_STATS)
if (isDashboardCardPagesConfigEnabled) add(Type.PAGES)
if (isDashboardCardActivityLogConfigEnabled) add(Type.ACTIVITY)
add(Type.POSTS)
}.toList()

Expand Down
Loading

0 comments on commit 461a103

Please sign in to comment.