Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ class FilteredDeckOptionsViewModel(
buildBrowserQueryResult
.onFailure { throwable ->
updateCurrentState {
currentState().copy(throwable = InvalidSearchException(cause = throwable))
currentState().copy(
throwable =
InvalidSearchException(
cause = throwable,
message = throwable.localizedMessage,
),
)
}
}.onSuccess {
updateCurrentState { currentState().copy(browserQuery = buildBrowserQueryResult.getOrThrow()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import anki.decks.filteredDeckForUpdate
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.Flag
import com.ichi2.anki.RobolectricTest
import com.ichi2.anki.exception.InvalidSearchException
import com.ichi2.anki.flagCardForNote
import com.ichi2.anki.libanki.DeckId
import com.ichi2.anki.libanki.Note
Expand Down Expand Up @@ -203,6 +204,21 @@ class FilteredDeckOptionsViewModelTest : RobolectricTest() {
}
}

@Test
fun `invalid search in browser produces state with error`() =
runTest {
withViewModel {
onSearchChange(FilterIndex.First, "\"deck:A is:new")
onSearchInBrowser(FilterIndex.First)
val currentState = state.value
assertInstanceOf<FilteredDeckOptions>(currentState)
assertNotNull(currentState.throwable)
assertInstanceOf<InvalidSearchException>(currentState.throwable)
assertNull(currentState.browserQuery)
clearError()
}
}

@Test
fun `invalid limit inputs produce expected state`() =
runTest {
Expand Down
Loading