The Browse tab ignores saved search selections
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with the new regression test in AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt and trace the saved search selection from the legacy Browse tab into CardBrowserFragment. The test sets up saved search “Cats” and expects only the matching card to remain; make that assertion pass and run the focused BottomNavigationRestoreTest.
Written by the indexing model from the issue text.
Description
Assisted-by: GPT-6.2-Sol xhigh & GPT-6.2-Astra xhigh
[EXISTING] The Browse tab ignores saved search selections
⚠️ This issue existed before the PR and should likely be split off into a separate issue.
Subject: [EXISTING] The Browse tab ignores saved search selections
Choosing a saved search from the legacy Browse tab dismisses the dialog and leaves the previous results on screen.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt
index 6392ad5af1..2370fc1ff5 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt
@@ -8,11 +8,19 @@ import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.widget.Toolbar
import androidx.core.view.isVisible
+import androidx.test.espresso.Espresso.onView
+import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.matcher.RootMatchers.isDialog
+import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.ichi2.anki.BottomNavController.NavigationItem
import com.ichi2.anki.browser.CardBrowserFragment
+import com.ichi2.anki.browser.CardOrNoteId
+import com.ichi2.anki.browser.search.SavedSearch
+import com.ichi2.anki.common.utils.ext.savedFilters
import com.ichi2.anki.settings.Prefs
import com.ichi2.testutils.withPref
import org.hamcrest.MatcherAssert.assertThat
@@ -21,6 +29,9 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.android.controller.ActivityController
+import kotlin.test.assertEquals
+import kotlin.test.assertIs
+import kotlin.test.assertTrue
@RunWith(AndroidJUnit4::class)
class BottomNavigationRestoreTest : RobolectricTest() {
@@ -58,6 +69,32 @@ class BottomNavigationRestoreTest : RobolectricTest() {
}
}
+ @Test
+ fun `selecting a saved search filters the Browse tab`() =
+ withBottomNavigation {
+ withPref(Prefs::devUsingCardBrowserSearchView, false) {
+ runTest {
+ val cat = addBasicNote("cat", "meows").firstCard()
+ addBasicNote("dog", "barks")
+ col.config.savedFilters = listOf(SavedSearch("Cats", "cat"))
+
+ val deckPicker = launchOn(NavigationItem.BROWSER).get()
+ val browser = assertIs<CardBrowserFragment>(deckPicker.supportFragmentManager.findFragmentByTag(NavigationItem.BROWSER.tag))
+ advanceRobolectricLooperUntil { browser.activityViewModel.rowCount == 2 }
+
+ val toolbar = browser.requireView().findViewById<Toolbar>(R.id.toolbar)
+ assertTrue(toolbar.menu.performIdentifierAction(R.id.action_list_my_searches, 0))
+ advanceRobolectricLooper()
+ onView(withText("Cats")).inRoot(isDialog()).perform(click())
+ advanceRobolectricLooper()
+ browser.activityViewModel.searchJob?.join()
+ advanceRobolectricLooper()
+
+ assertEquals(listOf(CardOrNoteId(cat.id)), browser.activityViewModel.cards.toList())
+ }
+ }
+ }
+
@Test
fun `restoring after process death keeps the open tab on screen`() =
forEachTab { tab ->
Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/23355#pullrequestreview-5968098762
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 377
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ankidroid/Anki-Android#23557 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ankidroid/Anki-Android#23556 ·
Maintainers usually reply within 1 day
-
Next version
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
ankidroid/Anki-Android#23555 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
ankidroid/Anki-Android#23545 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
ankidroid/Anki-Android#23544 ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
hoglite
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Android: with view recycling on, a recycled View keeps its nextFocusLeftPossibly taken A pull request linked to this issue is open or already merged. OpenNeeds: Triage :mag: Platform: Android
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/react-native#60167 ·
Maintainers usually reply within 2 days
-
CI/CD ⚒️ Flaky-tests 🐦 python 🐍
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
valkey-io/valkey-glide#7804 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[New Rule] InMobiOpen
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
LibChecker/LibChecker-Rules#1489 ·