Skip to content

Test: Remember value used when increasing reviews#20521

Merged
david-allison merged 1 commit intoankidroid:mainfrom
manocormen:remember-reviews-increase
Mar 22, 2026
Merged

Test: Remember value used when increasing reviews#20521
david-allison merged 1 commit intoankidroid:mainfrom
manocormen:remember-reviews-increase

Conversation

@manocormen
Copy link
Copy Markdown
Contributor

@manocormen manocormen commented Mar 19, 2026

Purpose / Description

When you start a custom study session and increase your "review limit" by a certain value, that value is remembered and becomes the default for your next review limit increase. This PR adds a test to preserve that behavior.

Fixes

Approach

There was already a test for a very similar behavior: remembering "new cards limit" increases. That test is relatively recent, so I used it as reference for the new test, simply adapting it to check the "review limit" instead of "new cards limit". I placed the new test right underneath its "sibling".

How Has This Been Tested?

./gradlew jacocoUnitTestReport
./gradlew lintRelease
./gradlew ktlintCheck

Learning

Lesson learned:

  • @NeedsTest may also be found in existing test files; so far, I'd only searched for them in prod files.
  • Consider the performance cost of your tests.
  • Prefer properties over raw JSON access when possible.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings) NA
  • UI Changes: You have tested your change using the Google Accessibility Scanner NA

@manocormen manocormen marked this pull request as ready for review March 19, 2026 14:34
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One query on performance, then let's get this in

Comment thread AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt Outdated
@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 19, 2026
@manocormen manocormen force-pushed the remember-reviews-increase branch from 2690695 to d1bfd3d Compare March 21, 2026 18:28
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BEAUTIFUL

One recommendation

https://github.com/ankidroid/Anki-Android/wiki/Development-Guide/#applying-a-patch

Subject: [PATCH]
---
Index: AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt
--- a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt	(revision d1bfd3dfc23dc1020c8dd57706613551ebdb4026)
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt	(date 1774149516036)
@@ -164,9 +164,7 @@
     @Test
     fun `previous value for 'increase review card limit' is suggested`() {
         // Reduce review limit to 0, so we can successfully extend with just 1 review card.
-        updateDeckConfig(Consts.DEFAULT_DECK_ID) {
-            rev.jsonObject.put("perDay", 0)
-        }
+        updateDeckConfig(Consts.DEFAULT_DECK_ID) { rev.perDay = 0 }
         addRevBasicNoteDueToday("Review", "Today")
 
         val reviewExtendByValue = 1
Index: libanki/src/main/java/com/ichi2/anki/libanki/DeckConfig.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/libanki/src/main/java/com/ichi2/anki/libanki/DeckConfig.kt b/libanki/src/main/java/com/ichi2/anki/libanki/DeckConfig.kt
--- a/libanki/src/main/java/com/ichi2/anki/libanki/DeckConfig.kt	(revision d1bfd3dfc23dc1020c8dd57706613551ebdb4026)
+++ b/libanki/src/main/java/com/ichi2/anki/libanki/DeckConfig.kt	(date 1774149530767)
@@ -128,6 +128,9 @@
     data class Rev(
         override val jsonObject: JSONObject,
     ) : JSONObjectHolder {
+        @VisibleForTesting
+        var perDay by jsonInt("perDay")
+
         @VisibleForTesting
         var delays by jsonArray("delays")
 

@manocormen manocormen force-pushed the remember-reviews-increase branch from d1bfd3d to f188cfd Compare March 22, 2026 10:30
@manocormen
Copy link
Copy Markdown
Contributor Author

Thanks. That's very clean. I've applied the patch and updated the PR.

Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean indeed, cheers!

@david-allison david-allison added this pull request to the merge queue Mar 22, 2026
Merged via the queue into ankidroid:main with commit 08aaad3 Mar 22, 2026
15 checks passed
@github-actions github-actions Bot removed the Needs Author Reply Waiting for a reply from the original author label Mar 22, 2026
@github-actions github-actions Bot added this to the 2.24 release milestone Mar 22, 2026
@manocormen manocormen deleted the remember-reviews-increase branch March 22, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants