A wildcard deck name pulls in forgotten cards from unrelated decks

Abierto
#784 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
kotlin
Área
mobile

Línea de trabajo

Start with the two proposed tests in AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt, which exercise the STUDY_FORGOT custom study flow. The first checks that forgotten cards from a deck named _* stay in Default; the second checks that the positive button is enabled after unsuspending a forgotten card. The issue says it should be split into separate issues, so confirm the scope with maintainers first. Done means both bugs are reproduced by tests and the tests pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

upstream-issue

Assisted-by: GPT-6.2-Sol xhigh & GPT-6.2-Astra xhigh

Subject: [EXISTING] A wildcard deck name pulls in forgotten cards from unrelated decks

Reviewing forgotten cards in a deck named `_*` can move cards from unrelated decks into the Custom Study Session.

⚠️ This issue existed before the PR and should likely be split off into a separate issue.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
index d7f3bc9c7c..cc7367c5ce 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
@@ -165,6 +165,23 @@ class CustomStudyDialogTest : RobolectricTest() {
             }
         }
 
+    @Test
+    fun `forgotten cards stay within a deck named underscore asterisk`() =
+        runTest {
+            TimeManager.reset()
+            val forgottenCard = addBasicNote().firstCard()
+            col.sched.answerCard(forgottenCard, CardAnswer.Rating.AGAIN)
+            val sourceDeck = addDeck("_*")
+            col.setDeck(listOf(addBasicNote("Unreviewed", "Card").firstCard().id), sourceDeck)
+
+            withCustomStudyFragment(args = argumentsDisplayingSubscreen(ContextMenuOption.STUDY_FORGOT, deckId = sourceDeck)) { fragment ->
+                val dialog = fragment.requireDialog() as AlertDialog
+                if (dialog.positiveButton.isEnabled) fragment.submitSubscreenData()
+            }
+
+            assertEquals(Consts.DEFAULT_DECK_ID, col.getCard(forgottenCard.id).did, "Custom Study must keep cards from Default in Default")
+        }
+
     @Test
     fun `cancelling a defaults read prevents late deck selection`() =
         runTest {
Confirmation stays disabled after a forgotten card becomes eligible [P2]
Subject: Confirmation stays disabled after a forgotten card becomes eligible

Unsuspending the only forgotten card leaves confirmation disabled until the day range is edited.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
index cc7367c5ce..e4a1db3821 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
@@ -58,6 +58,7 @@ import com.ichi2.anki.libanki.DeckId
 import com.ichi2.anki.libanki.Note
 import com.ichi2.anki.libanki.QueueType
 import com.ichi2.anki.libanki.sched.Scheduler
+import com.ichi2.anki.observability.undoableOp
 import com.ichi2.anki.utils.ext.DIALOG_FRAGMENT_TAG
 import com.ichi2.anki.utils.ext.showDialogFragment
 import com.ichi2.testutils.AnkiFragmentScenario
@@ -182,6 +183,27 @@ class CustomStudyDialogTest : RobolectricTest() {
             assertEquals(Consts.DEFAULT_DECK_ID, col.getCard(forgottenCard.id).did, "Custom Study must keep cards from Default in Default")
         }
 
+    @Test
+    fun `forgotten cards become available when unsuspended with the dialog open`() =
+        runTest {
+            TimeManager.reset()
+            val card = addBasicNote().firstCard()
+            col.sched.answerCard(card, CardAnswer.Rating.AGAIN)
+            col.sched.suspendCards(listOf(card.id))
+
+            createHostActivity().use { controller ->
+                val fragment = CustomStudyDialog.createSubDialog(Consts.DEFAULT_DECK_ID, ContextMenuOption.STUDY_FORGOT)
+                controller.get().showDialogFragment(fragment)
+                shadowOf(Looper.getMainLooper()).idle()
+
+                undoableOp { sched.unsuspendCards(listOf(card.id)) }
+                shadowOf(Looper.getMainLooper()).idle()
+
+                val dialog = fragment.requireDialog() as AlertDialog
+                assertTrue(dialog.positiveButton.isEnabled, "Restoring a forgotten card makes the same day range eligible")
+            }
+        }
+
     @Test
     fun `cancelling a defaults read prevents late deck selection`() =
         runTest {

Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/23360#pullrequestreview-6007634151

Lenguaje dominante
Kotlin
Estrellas
93
Forks
60
Merge medio
18 h 14 min
PR fusionados (30 d)
9

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ankidroid/Anki-Android-Backend

Todos los issues de ankidroid/Anki-Android-Backend

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.