First template pick wins, and a block gone meanwhile isn't reported saved (#172, #154)

This commit is contained in:
makiolaj committed 2026-11-27 14:58:19 +01:00
1 parent 879ae7e244
commit 4aaa1b3a11
3 files changed
+38 -10

No files matched your search

@@ -141,6 +141,25 @@ class RuleEditViewModelTest {
assertThat(runBlocking { prefs.savedFilters.first() }).isEmpty()
}
@Test
fun `a block removed from its view meanwhile isn't reported saved`() {
val viewId = storedView(BlockSource.Smart(SmartList.ALL))
val vm = editor(RuleEditViewModel.Target.Block(viewId, 99), RulePurpose.SOURCE)
vm.startFrom(null)
var done = false
vm.save { done = true }
assertThat(done).isFalse()
assertThat(vm.saveFailed.value).isTrue()
}
@Test
fun `a second template tap while the first is read is ignored`() {
val vm = editor(RuleEditViewModel.Target.Result(null), RulePurpose.SOURCE)
vm.startFrom(null)
vm.startFrom(FilterTemplate.HIGH_PRIORITY)
assertThat(vm.state.value!!.rules.rule).isEqualTo(Rule.Everything)
}
@Test
fun `custom rules opened for a result hand back the filter they were saved as`() {
runBlocking { prefs.setStorageMode(StorageMode.OWN) }