is / is not only on sections that pick something; the simple form survives a look at the advanced editor (#172)

This commit is contained in:
makiolaj committed 2026-11-27 14:58:19 +01:00
1 parent 4aaa1b3a11
commit 02f842016f
4 files changed
+55 -17

No files matched your search

@@ -53,6 +53,23 @@ class RuleDraftTest {
assertThat(advanced.editSimple { it.copy(minPriority = Priority.LOW) }).isEqualTo(advanced)
}
@Test
fun `a look at the advanced editor brings the simple form back as it was left`() {
val any = RuleDraft.of(SimpleRule()).editSimple { it.copy(match = Match.ANY) }
assertThat(any.toAdvanced().toSimple().simple!!.match).isEqualTo(Match.ANY)
val changed = any.toAdvanced().editAdvanced { it.addTo(emptyList(), work) }
assertThat(changed.toSimple().simple).isEqualTo(SimpleRule(listIds = setOf(1L)))
}
@Test
fun `is not drops out of a section once nothing in it is picked`() {
val draft = RuleDraft.of(SimpleRule(tags = setOf("a"), tagsNegated = true))
.editSimple { it.copy(tags = emptySet()) }
assertThat(draft.simple!!.tagsNegated).isFalse()
assertThat(draft.editSimple { it.copy(tags = setOf("b")) }.rule)
.isEqualTo(Rule.AllOf(listOf(Rule.AnyOf(listOf(Rule.HasTag("b"))))))
}
@Test
fun `the simple form keeps a choice its rule can't hold`() {
val any = RuleDraft.of(SimpleRule()).editSimple { it.copy(match = Match.ANY) }