Revert "Bug 2058533 - Add a PromoCard highlighting the Collections to Tab Groups migration in the Tab Groups page r=android-reviewers,gl" for causing fenix failures @AddressAutofillTest#verifyAddAddressViewTest.

This reverts commit 1d37bac63c.
This commit is contained in:
agoloman
2026-09-12 06:49:22 +00:00
committed by agoloman@mozilla.com
parent f984cb1cff
commit a1ede75a77
13 changed files with 9 additions and 269 deletions
@@ -5,22 +5,16 @@
package org.mozilla.fenix.tabgroups
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasClickAction
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.TestCase.assertEquals
import junit.framework.TestCase.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.R
import org.mozilla.fenix.tabstray.TabsTrayTestTag
import org.mozilla.fenix.tabstray.data.TabsTrayItem
import org.mozilla.fenix.tabstray.data.createTabGroup
@@ -33,8 +27,6 @@ class TabGroupsPageTest {
@get:Rule val composeTestRule = createComposeRule()
private val context = InstrumentationRegistry.getInstrumentation().targetContext
@Test
fun verifyEmptyState() {
composeTestRule.setContent {
@@ -45,7 +37,6 @@ class TabGroupsPageTest {
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
@@ -70,7 +61,6 @@ class TabGroupsPageTest {
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
@@ -98,7 +88,6 @@ class TabGroupsPageTest {
},
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
@@ -127,7 +116,6 @@ class TabGroupsPageTest {
clickedGroup = it
},
onShareTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
@@ -138,81 +126,4 @@ class TabGroupsPageTest {
assertTrue(editClicked)
assertEquals(group, clickedGroup)
}
@Test
fun verifyCollectionsMigrationCardHiddenByDefault() {
val group = createTabGroup(title = "Group 1")
composeTestRule.setContent {
FirefoxTheme {
TabGroupsPage(
state = TabsTrayState.TabGroupState(groups = listOf(group)),
onTabGroupClick = {},
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
composeTestRule.onNodeWithTag(TabsTrayTestTag.COLLECTIONS_MIGRATION_CARD).assertDoesNotExist()
}
@Test
fun verifyCollectionsMigrationCardDisplayed() {
val group = createTabGroup(title = "Group 1")
val title = context.getString(R.string.collections_migration_homepage_banner_title)
val message = context.getString(R.string.collections_migration_homepage_card_message)
composeTestRule.setContent {
FirefoxTheme {
TabGroupsPage(
state =
TabsTrayState.TabGroupState(
groups = listOf(group),
showCollectionsMigrationCard = true,
),
onTabGroupClick = {},
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
composeTestRule.onNodeWithTag(TabsTrayTestTag.COLLECTIONS_MIGRATION_CARD).assertIsDisplayed()
composeTestRule.onNodeWithText(title).assertIsDisplayed()
composeTestRule.onNodeWithText(message).assertIsDisplayed()
}
@Test
fun verifyCollectionsMigrationCardDismiss() {
val group = createTabGroup(title = "Group 1")
var dismissed = false
composeTestRule.setContent {
FirefoxTheme {
TabGroupsPage(
state =
TabsTrayState.TabGroupState(
groups = listOf(group),
showCollectionsMigrationCard = true,
),
onTabGroupClick = {},
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = { dismissed = true },
)
}
}
composeTestRule
.onNode(hasClickAction() and hasAnyAncestor(hasTestTag(TabsTrayTestTag.COLLECTIONS_MIGRATION_CARD)))
.performClick()
assertTrue(dismissed)
}
}
@@ -21,15 +21,13 @@ import org.mozilla.fenix.theme.FirefoxTheme
/**
* Collections to tab groups migration card.
*
* @param onClick Invoked when the user clicks on the "View my tab groups" link.
* @param modifier The [Modifier] to be applied to the [PromoCard].
* @param onClick Invoked when the user clicks on the "View my tab groups" link. When null, the link is not shown.
* @param onDismiss Invoked when the user clicks the close button. When null, the close button is not shown.
*/
@Composable
fun CollectionsMigrationPromoCard(
onClick: () -> Unit,
modifier: Modifier = Modifier,
onClick: (() -> Unit)? = null,
onDismiss: (() -> Unit)? = null,
) {
val linkText = stringResource(R.string.collections_migration_homepage_card_link)
@@ -38,14 +36,12 @@ fun CollectionsMigrationPromoCard(
modifier = modifier,
title = stringResource(R.string.collections_migration_homepage_banner_title),
footer =
onClick?.let { onLinkClick ->
linkText to
LinkTextState(
text = linkText,
url = "",
onClick = { onLinkClick() },
)
},
linkText to
LinkTextState(
text = linkText,
url = "",
onClick = { onClick() },
),
illustration = {
Image(
painter = painterResource(R.drawable.mozac_ic_kit_tab_groups),
@@ -58,7 +54,6 @@ fun CollectionsMigrationPromoCard(
backgroundColor = MaterialTheme.colorScheme.primaryContainer,
actionsTextColor = MaterialTheme.colorScheme.tertiary,
),
onDismiss = onDismiss,
)
}
@@ -69,11 +64,3 @@ private fun CollectionsMigrationPromoCardPreview() {
CollectionsMigrationPromoCard(onClick = {})
}
}
@Composable
@PreviewLightDark
private fun CollectionsMigrationPromoCardWithCloseButtonPreview() {
FirefoxTheme {
CollectionsMigrationPromoCard(onDismiss = {})
}
}
@@ -44,7 +44,6 @@ internal object TabsTrayTestTag {
const val EMPTY_NORMAL_TABS_LIST = "$NORMAL_TABS_LIST.empty"
const val EMPTY_PRIVATE_TABS_LIST = "$PRIVATE_TABS_LIST.empty"
const val EMPTY_TAB_GROUPS_LIST = "$TAB_GROUPS_LIST.empty"
const val COLLECTIONS_MIGRATION_CARD = "$TAB_GROUPS_LIST.collectionsMigrationCard"
const val UNAUTHENTICATED_SYNCED_TABS_PAGE = "$SYNCED_TABS_LIST.unauthenticated"
// Tab items
@@ -177,7 +177,4 @@ sealed interface TabGroupAction : TabsTrayAction {
/** Invoked when a new group's animation is played. */
data object NewGroupAnimationFinished : TabGroupAction
/** Invoked when the user dismisses the Collections to Tab Groups migration card. */
data object CollectionsMigrationCardDismissed : TabGroupAction
}
@@ -1,35 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.tabstray.redux.middleware
import mozilla.components.lib.state.Middleware
import mozilla.components.lib.state.Store
import org.mozilla.fenix.home.collections.migration.CollectionsMigrationRepository
import org.mozilla.fenix.tabstray.redux.action.TabGroupAction
import org.mozilla.fenix.tabstray.redux.action.TabsTrayAction
import org.mozilla.fenix.tabstray.redux.state.TabsTrayState
/**
* [Middleware] that persists the visibility of the Collections to Tab Groups migration card. The visibility is shared
* with the homepage card, so dismissing the card on the Tab Groups page also stops advertising the migration on the
* homepage.
*
* @param repository The repository for the Collections migration.
*/
class CollectionsMigrationMiddleware(private val repository: CollectionsMigrationRepository) :
Middleware<TabsTrayState, TabsTrayAction> {
override fun invoke(
store: Store<TabsTrayState, TabsTrayAction>,
next: (TabsTrayAction) -> Unit,
action: TabsTrayAction,
) {
if (action is TabGroupAction.CollectionsMigrationCardDismissed) {
repository.updateCollectionsMigrationCardVisibility(visible = false)
}
next(action)
}
}
@@ -73,8 +73,6 @@ object TabGroupActionReducer {
state.copy(backStack = state.backStack.popDeleteTabGroupFlow())
is TabGroupAction.OnboardingDismissed ->
state.copy(config = state.config.copy(tabGroupsOnboardingEnabled = false))
is TabGroupAction.CollectionsMigrationCardDismissed ->
state.copy(tabGroupState = state.tabGroupState.copy(showCollectionsMigrationCard = false))
is TabGroupAction.OnboardingShown ->
state.copy(tabGroupState = state.tabGroupState.copy(hasRecordedOnboardingImpression = true))
is TabGroupAction.DragAndDropProcessed ->
@@ -202,7 +202,6 @@ data class TabsTrayState(
* @property hasViewedTabGroupsPage Whether the user has viewed the Tab Groups page.
* @property skipUngroupConfirmation Whether the ungroup confirmation dialog should be skipped.
* @property hasRecordedOnboardingImpression Whether an onboarding impression has been recorded this session.
* @property showCollectionsMigrationCard Whether the Collections to Tab Groups migration card is shown.
* @property enteringGroupId Recently created group id, to be referenced for animations. Cleared after entrance
* animations are played.
* @property dragProcessingState The lifecycle state of tab-group drag handling
@@ -217,7 +216,6 @@ data class TabsTrayState(
internal val hasViewedTabGroupsPage: Boolean = false,
internal val skipUngroupConfirmation: Boolean = false,
internal val hasRecordedOnboardingImpression: Boolean = false,
val showCollectionsMigrationCard: Boolean = false,
val enteringGroupId: String? = null,
val dragProcessingState: DragProcessingState = DragProcessingState.UNINITIALIZED,
)
@@ -117,7 +117,6 @@ import org.mozilla.fenix.tabstray.data.TabsTrayItem
import org.mozilla.fenix.tabstray.navigation.TabManagerNavDestination
import org.mozilla.fenix.tabstray.redux.action.TabGroupAction
import org.mozilla.fenix.tabstray.redux.action.TabsTrayAction
import org.mozilla.fenix.tabstray.redux.middleware.CollectionsMigrationMiddleware
import org.mozilla.fenix.tabstray.redux.middleware.TabManagerUiStateStorageMiddleware
import org.mozilla.fenix.tabstray.redux.middleware.TabSearchMiddleware
import org.mozilla.fenix.tabstray.redux.middleware.TabSearchNavigationMiddleware
@@ -709,7 +708,6 @@ class TabManagementFragment : Fragment() {
),
scope = lifecycleScope,
),
CollectionsMigrationMiddleware(repository = requireComponents.collectionsMigrationRepository),
),
)
}
@@ -747,11 +745,6 @@ class TabManagementFragment : Fragment() {
shouldShowBanner = shouldShowBanner(settings),
),
),
tabGroupState =
TabsTrayState.TabGroupState(
showCollectionsMigrationCard =
requireComponents.collectionsMigrationRepository.shouldShowCollectionsMigrationCard()
),
sync = TabsTrayState.SyncState(isSignedIn = settings.signedInFxaAccount),
config =
TabsTrayState.TabsTrayConfig(
@@ -17,7 +17,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import mozilla.components.browser.state.state.createTab
import org.mozilla.fenix.tabgroups.TabGroupRow
import org.mozilla.fenix.tabstray.data.TabGroupTheme
@@ -37,7 +36,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
*
* @param groups The list of tab groups to display.
* @param modifier: The Modifier applied to the tab group list.
* @param topPadding The padding applied above the first tab group.
* @param onTabGroupClick Invoked when the user clicks on a tab group.
* @param onEditTabGroupClick Invoked when the user clicks to edit the tab group.
* @param onShareTabGroupClick Invoked when the user clicks to share the tab group.
@@ -47,7 +45,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
fun TabGroupList(
groups: List<TabsTrayItem.TabGroup>,
modifier: Modifier = Modifier,
topPadding: Dp = FirefoxTheme.layout.space.dynamic200,
onTabGroupClick: (TabsTrayItem.TabGroup) -> Unit,
onEditTabGroupClick: (TabsTrayItem.TabGroup) -> Unit,
onShareTabGroupClick: (TabsTrayItem.TabGroup) -> Unit,
@@ -63,7 +60,7 @@ fun TabGroupList(
.width(FirefoxTheme.layout.size.containerMaxWidth)
.padding(
start = FirefoxTheme.layout.space.dynamic200,
top = topPadding,
top = FirefoxTheme.layout.space.dynamic200,
end = FirefoxTheme.layout.space.dynamic200,
),
verticalArrangement = Arrangement.spacedBy(FirefoxTheme.layout.space.static25),
@@ -27,7 +27,6 @@ import mozilla.components.compose.base.annotation.FlexibleWindowLightDarkPreview
import mozilla.components.ui.icons.R as iconsR
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.BetaLabel
import org.mozilla.fenix.home.collections.CollectionsMigrationPromoCard
import org.mozilla.fenix.tabstray.TabsTrayTestTag
import org.mozilla.fenix.tabstray.data.TabGroupTheme
import org.mozilla.fenix.tabstray.data.TabsTrayItem
@@ -45,7 +44,6 @@ private val EmptyPageWidth = 225.dp
* @param onEditTabGroupClick Invoked when a group is requested to be edited.
* @param onShareTabGroupClick Invoked when a group is requested to be shared.
* @param onDeleteTabGroupClick Invoked when a group is requested to be deleted.
* @param onCollectionsMigrationCardDismiss Invoked when the Collections to Tab Groups migration card is dismissed.
*/
@Composable
internal fun TabGroupsPage(
@@ -54,7 +52,6 @@ internal fun TabGroupsPage(
onEditTabGroupClick: (TabsTrayItem.TabGroup) -> Unit,
onShareTabGroupClick: (TabsTrayItem.TabGroup) -> Unit,
onDeleteTabGroupClick: (TabsTrayItem.TabGroup) -> Unit,
onCollectionsMigrationCardDismiss: () -> Unit,
) {
if (state.groups.isNotEmpty()) {
Column {
@@ -66,27 +63,8 @@ internal fun TabGroupsPage(
)
)
if (state.showCollectionsMigrationCard) {
CollectionsMigrationPromoCard(
modifier =
Modifier.padding(
start = FirefoxTheme.layout.space.dynamic200,
top = FirefoxTheme.layout.space.dynamic200,
end = FirefoxTheme.layout.space.dynamic200,
)
.testTag(TabsTrayTestTag.COLLECTIONS_MIGRATION_CARD),
onDismiss = onCollectionsMigrationCardDismiss,
)
}
TabGroupList(
groups = state.groups,
topPadding =
if (state.showCollectionsMigrationCard) {
FirefoxTheme.layout.space.static100
} else {
FirefoxTheme.layout.space.dynamic200
},
onTabGroupClick = onTabGroupClick,
onEditTabGroupClick = onEditTabGroupClick,
onShareTabGroupClick = onShareTabGroupClick,
@@ -190,33 +168,6 @@ private fun TabGroupsPagePreview(
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
@FlexibleWindowLightDarkPreview
@Composable
private fun TabGroupsPageWithCollectionsMigrationCardPreview() {
FirefoxTheme {
TabGroupsPage(
state =
TabGroupState(
groups =
listOf(
TabsTrayItem.TabGroup(
title = "Work",
theme = TabGroupTheme.Blue,
tabs = mutableListOf(createTab(url = "https://www.mozilla.org")),
)
),
showCollectionsMigrationCard = true,
),
onTabGroupClick = {},
onEditTabGroupClick = {},
onShareTabGroupClick = {},
onDeleteTabGroupClick = {},
onCollectionsMigrationCardDismiss = {},
)
}
}
@@ -319,9 +319,6 @@ fun TabsTray(
onDeleteTabGroupClick = { group ->
onAction(TabGroupAction.DeleteClicked(group))
},
onCollectionsMigrationCardDismiss = {
onAction(TabGroupAction.CollectionsMigrationCardDismissed)
},
)
}
}
@@ -1,43 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.tabstray.redux.middleware
import kotlin.test.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue
import org.mozilla.fenix.home.collections.migration.fake.FakeCollectionsMigrationRepository
import org.mozilla.fenix.tabstray.redux.action.TabGroupAction
import org.mozilla.fenix.tabstray.redux.state.TabsTrayState
import org.mozilla.fenix.tabstray.redux.store.TabsTrayStore
class CollectionsMigrationMiddlewareTest {
private val repository = FakeCollectionsMigrationRepository(cardVisible = true)
@Test
fun `WHEN the migration card is dismissed THEN the card visibility is persisted as hidden`() {
val store = createStore()
store.dispatch(TabGroupAction.CollectionsMigrationCardDismissed)
assertFalse(repository.shouldShowCollectionsMigrationCard())
}
@Test
fun `WHEN an unrelated action is dispatched THEN the card visibility is unchanged`() {
val store = createStore()
store.dispatch(TabGroupAction.NewGroupAnimationFinished)
assertTrue(repository.shouldShowCollectionsMigrationCard())
}
private fun createStore() =
TabsTrayStore(
initialState =
TabsTrayState(tabGroupState = TabsTrayState.TabGroupState(showCollectionsMigrationCard = true)),
middlewares = listOf(CollectionsMigrationMiddleware(repository = repository)),
)
}
@@ -961,14 +961,4 @@ class TabGroupReducerTest {
resultState.tabGroupState.dragProcessingState,
)
}
@Test
fun `WHEN CollectionsMigrationCardDismissed THEN the migration card is hidden`() {
val initialState =
TabsTrayState(tabGroupState = TabsTrayState.TabGroupState(showCollectionsMigrationCard = true))
val resultState = TabGroupActionReducer.reduce(initialState, TabGroupAction.CollectionsMigrationCardDismissed)
assertFalse(resultState.tabGroupState.showCollectionsMigrationCard)
}
}