From ab0e8a41327b79fa7cc72920505d5999b7e5a250 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 5 Sep 2026 22:31:17 +0530 Subject: [PATCH] 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. --- .../dev/sanderling/sidecar/SecureFactsTest.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sidecar/src/test/kotlin/dev/sanderling/sidecar/SecureFactsTest.kt b/sidecar/src/test/kotlin/dev/sanderling/sidecar/SecureFactsTest.kt index e870163..46063d4 100644 --- a/sidecar/src/test/kotlin/dev/sanderling/sidecar/SecureFactsTest.kt +++ b/sidecar/src/test/kotlin/dev/sanderling/sidecar/SecureFactsTest.kt @@ -3,7 +3,6 @@ package dev.sanderling.sidecar import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertNull -import kotlin.test.assertTrue // 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 @@ -166,15 +165,19 @@ class SecureFactsTest { // The rest of the tree has to survive the annotation: it is the same tree // every selector, bounds read and screen classification runs against. @Test fun theTreeIsOtherwiseUnchanged() { - val annotated = withSecureFacts(LOGIN_TREE) { LOGIN_XML } - - assertTrue(annotated.contains("\"LoginSubmit\"")) - assertEquals( - "[51,249][429,321]", - jacksonTree( - annotated, - "LoginPassword", - )?.get("attributes")?.get("bounds")?.asText(), + val mapper = com.fasterxml.jackson.module.kotlin.jacksonObjectMapper() + val annotated = mapper.readTree( + withSecureFacts(LOGIN_TREE) { + LOGIN_XML + }, ) + + 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) } }