-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: propose renaming decks to '01' to reorder
A regular complaint is that '10' is between '1' and '2' in the deck list: ['1', '10', '2'] If a user renames a deck, the ordering is correct: ['01', '02', '10'] We should inform the user that this is the solution Fixes 16036
- Loading branch information
1 parent
bcfdac5
commit 7bbf72c
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/**************************************************************************************** | ||
* Copyright (c) 2021 Akshay Jadhav <[email protected]> * | ||
* Copyright (c) 2024 David Allison <[email protected]> * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify it under * | ||
* the terms of the GNU General Public License as published by the Free Software * | ||
|
@@ -33,7 +34,8 @@ import com.ichi2.utils.positiveButton | |
import okhttp3.internal.closeQuietly | ||
import org.hamcrest.CoreMatchers.equalTo | ||
import org.hamcrest.CoreMatchers.nullValue | ||
import org.hamcrest.MatcherAssert.* | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
@@ -116,6 +118,28 @@ class CreateDeckDialogTest : RobolectricTest() { | |
} | ||
} | ||
|
||
@Test | ||
fun `deck ordering hint`() { | ||
// The correct way to order a deck is ['01', '02', '10'] | ||
val expectedText = "If you have deck ordering issues (e.g. ‘10’ appears before ‘2’), replace ‘2’ with ‘02’" | ||
testDialog(DeckDialogType.DECK) { | ||
fun assertHelperText(reason: String?, matcher: Matcher<in CharSequence?>) = | ||
assertThat(reason, getInputTextLayout().helperText, matcher) | ||
|
||
input = "test" | ||
assertHelperText("no number suggestion if text-only", nullValue()) | ||
input = "1. Cheese" | ||
assertHelperText("no number suggestion if number is less than 10", nullValue()) | ||
input = "10. Cheese" | ||
assertHelperText( | ||
"Number suggestion if number is greater than or equal to 10", | ||
equalTo(expectedText) | ||
) | ||
input = "1. Cheese" | ||
assertHelperText("hint is removed if the number is removed", nullValue()) | ||
} | ||
} | ||
|
||
@Test | ||
fun nameMayNotBeZeroLength() { | ||
testDialog(DeckDialogType.DECK) { | ||
|
@@ -234,3 +258,19 @@ class CreateDeckDialogTest : RobolectricTest() { | |
.joinToString("::") | ||
} | ||
} | ||
|
||
/** Test of [CreateDeckDialog] */ | ||
class CreateDeckDialogNonAndroidTest { | ||
@Test | ||
fun `number larger than nine detection`() { | ||
fun assertLargerThanNine(reason: String?, input: String, result: Boolean) = | ||
assertThat(reason, input.containsNumberLargerThanNine(), equalTo(result)) | ||
|
||
assertLargerThanNine("empty string", "", false) | ||
assertLargerThanNine("text", "deck name", false) | ||
assertLargerThanNine("less than ten", "9. - Chemicals", false) | ||
assertLargerThanNine("Ten or greater", "10. - Chemicals", true) | ||
assertLargerThanNine("Ten or greater", "99. - Chemicals", true) | ||
assertLargerThanNine("zero prefix", "09. - Chemicals", false) | ||
} | ||
} |