test(sidecar): compare the whole tree when checking the annotation changes nothing else

The old assertions checked one id string and one bounds value, and passed
with every other attribute stripped off every node. Now the annotated tree
minus the two facts it stated must equal the input.
This commit is contained in:
pj committed 2026-09-05 22:31:17 +05:30
1 parent 687f601e10
commit ab0e8a4132
1 file changed
+13 -10
@@ -3,7 +3,6 @@ package dev.sanderling.sidecar
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNull import kotlin.test.assertNull
import kotlin.test.assertTrue
// The tree maestro hands back for a login form: it names both fields and says // The tree maestro hands back for a login form: it names both fields and says
// nothing about either being a credential entry, because maestro's mapper does // nothing about either being a credential entry, because maestro's mapper does
@@ -166,15 +165,19 @@ class SecureFactsTest {
// The rest of the tree has to survive the annotation: it is the same tree // The rest of the tree has to survive the annotation: it is the same tree
// every selector, bounds read and screen classification runs against. // every selector, bounds read and screen classification runs against.
@Test fun theTreeIsOtherwiseUnchanged() { @Test fun theTreeIsOtherwiseUnchanged() {
val annotated = withSecureFacts(LOGIN_TREE) { LOGIN_XML } val mapper = com.fasterxml.jackson.module.kotlin.jacksonObjectMapper()
val annotated = mapper.readTree(
assertTrue(annotated.contains("\"LoginSubmit\"")) withSecureFacts(LOGIN_TREE) {
assertEquals( LOGIN_XML
"[51,249][429,321]", },
jacksonTree(
annotated,
"LoginPassword",
)?.get("attributes")?.get("bounds")?.asText(),
) )
val stated = annotated.findParents("secure")
assertEquals(2, stated.size)
for (node in stated) {
(node as com.fasterxml.jackson.databind.node.ObjectNode)
.remove("secure")
}
assertEquals(mapper.readTree(LOGIN_TREE), annotated)
} }
} }