Issue #19176: Exit select mode when removing tab (#19486)

upstream-sync
Jonathan Almeida 3 years ago committed by GitHub
parent 8edcaab7ce
commit ede909e858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -198,8 +198,6 @@ class DefaultNavigationInteractor(
}
}
tabsTrayStore.dispatch(TabsTrayAction.ExitSelectMode)
// TODO show successful snackbar here (regardless of operation succes).
}

@ -8,6 +8,7 @@ import android.content.Context
import androidx.annotation.VisibleForTesting
import mozilla.components.browser.menu.BrowserMenuBuilder
import org.mozilla.fenix.tabstray.NavigationInteractor
import org.mozilla.fenix.tabstray.TabsTrayAction
import org.mozilla.fenix.tabstray.TabsTrayInteractor
import org.mozilla.fenix.tabstray.TabsTrayStore
import org.mozilla.fenix.utils.Do
@ -30,12 +31,14 @@ class SelectionMenuIntegration(
@VisibleForTesting
internal fun handleMenuClicked(item: SelectionMenu.Item) {
Do exhaustive when (item) {
is SelectionMenu.Item.BookmarkTabs -> navInteractor.onSaveToBookmarks(
store.state.mode.selectedTabs
)
is SelectionMenu.Item.DeleteTabs -> trayInteractor.onDeleteTabs(
store.state.mode.selectedTabs
)
is SelectionMenu.Item.BookmarkTabs -> {
navInteractor.onSaveToBookmarks(store.state.mode.selectedTabs)
store.dispatch(TabsTrayAction.ExitSelectMode)
}
is SelectionMenu.Item.DeleteTabs -> {
trayInteractor.onDeleteTabs(store.state.mode.selectedTabs)
store.dispatch(TabsTrayAction.ExitSelectMode)
}
}
}
}

@ -6,32 +6,45 @@ package org.mozilla.fenix.tabstray.browser
import io.mockk.mockk
import io.mockk.verify
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.middleware.CaptureActionsMiddleware
import org.junit.Test
import org.mozilla.fenix.tabstray.NavigationInteractor
import org.mozilla.fenix.tabstray.TabsTrayAction
import org.mozilla.fenix.tabstray.TabsTrayInteractor
import org.mozilla.fenix.tabstray.TabsTrayState
import org.mozilla.fenix.tabstray.TabsTrayStore
class SelectionMenuIntegrationTest {
private val navInteractor = mockk<NavigationInteractor>(relaxed = true)
private val trayInteractor = mockk<TabsTrayInteractor>(relaxed = true)
private val store = TabsTrayStore()
private val capture = CaptureActionsMiddleware<TabsTrayState, TabsTrayAction>()
private val store = TabsTrayStore(middlewares = listOf(capture))
@Test
fun `WHEN bookmark item is clicked THEN invoke interactor`() {
fun `WHEN bookmark item is clicked THEN invoke interactor and close tray`() {
val menu = SelectionMenuIntegration(mockk(), store, navInteractor, trayInteractor)
menu.handleMenuClicked(SelectionMenu.Item.BookmarkTabs)
store.waitUntilIdle()
verify { navInteractor.onSaveToBookmarks(store.state.mode.selectedTabs) }
capture.findLastAction(TabsTrayAction.ExitSelectMode::class)
}
@Test
fun `WHEN delete tabs item is clicked THEN invoke interactor`() {
fun `WHEN delete tabs item is clicked THEN invoke interactor and close tray`() {
val menu = SelectionMenuIntegration(mockk(), store, navInteractor, trayInteractor)
menu.handleMenuClicked(SelectionMenu.Item.DeleteTabs)
store.waitUntilIdle()
verify { trayInteractor.onDeleteTabs(store.state.mode.selectedTabs) }
capture.findLastAction(TabsTrayAction.ExitSelectMode::class)
}
}

Loading…
Cancel
Save