Test: Remember value used when increasing reviews#20521
Merged
david-allison merged 1 commit intoankidroid:mainfrom Mar 22, 2026
Merged
Test: Remember value used when increasing reviews#20521david-allison merged 1 commit intoankidroid:mainfrom
david-allison merged 1 commit intoankidroid:mainfrom
Conversation
Member
david-allison
left a comment
There was a problem hiding this comment.
One query on performance, then let's get this in
2690695 to
d1bfd3d
Compare
david-allison
approved these changes
Mar 22, 2026
Member
david-allison
left a comment
There was a problem hiding this comment.
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")
d1bfd3d to
f188cfd
Compare
Contributor
Author
|
Thanks. That's very clean. I've applied the patch and updated the PR. |
david-allison
approved these changes
Mar 22, 2026
Member
david-allison
left a comment
There was a problem hiding this comment.
Very clean indeed, cheers!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
@NeedsTest) #13283.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?
Learning
Lesson learned:
@NeedsTestmay also be found in existing test files; so far, I'd only searched for them in prod files.Checklist
UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)NAUI Changes: You have tested your change using the Google Accessibility ScannerNA