Carry the view in the home state, drop view pruning for now (#59)

This commit is contained in:
makiolaj committed 2026-11-26 17:23:10 +01:00
1 parent 3f97683c6d
commit 355daad87b
6 files changed
+42 -100

No files matched your search

@@ -84,19 +84,9 @@ class ViewCodecTest {
}
@Test
fun `deleted lists and filters leave the views`() {
val raw = ViewCodec.encode(views, "OWN")
val pruned = ViewCodec.decode(ViewCodec.withoutLists(raw, "OWN") { it == 9L || it == 2L }, "OWN")[1]
assertThat(pruned.blocks.map { it.id }).doesNotContain(2L)
val scope = pruned.scope as Rule.AllOf
// A nested list condition left without this store's lists still names the other store's.
assertThat((scope.children[0] as Rule.AnyOf).children[0]).isEqualTo(Rule.InList(emptySet(), setOf("EXTERNAL:7")))
assertThat(ViewCodec.withoutLists(raw, "OWN") { it == 99L }).isSameInstanceAs(raw)
val withoutFilter = ViewCodec.decode(ViewCodec.withoutFilter(raw, "OWN", 12), "OWN")[1]
assertThat(withoutFilter.blocks.map { it.id }).doesNotContain(4L)
assertThat(ViewCodec.withoutFilter(raw, "OWN", 13)).isSameInstanceAs(raw)
assertThat(ViewCodec.withoutFilter("v9\nwhatever", "OWN", 12)).isEqualTo("v9\nwhatever")
fun `rules are stored in the saved filters' grammar`() {
val view = View(5, "x", ViewIcon.HOME, Rule.AllOf(listOf(Rule.HasTag("a b"), Rule.InList(setOf(3L)))), emptyList())
assertThat(ViewCodec.encode(listOf(view), "OWN").lines()[1]).isEqualTo("view|5|x|HOME|1|and(tag(a+b),list(OWN%3A3))")
}
@Test