import unittest

from GramAddict.core.telepathic_engine import TelepathicEngine


class TestAPIMismatch(unittest.TestCase):
    def test_repro_extract_semantic_nodes_type_error(self):
        """
        VERIFICATION TEST: Verifies that _extract_semantic_nodes now accepts
        extra arguments (threshold), fixing the regression.
        """
        engine = TelepathicEngine.get_instance()
        xml = "<hierarchy><node resource-id='test' class='android.widget.Button' clickable='true' bounds='[0,0][10,10]' /></hierarchy>"

        # This SHOULD now pass
        try:
            engine._extract_semantic_nodes(xml, "find buttons", threshold=0.1)
            print("\n[V] VERIFICATION SUCCESSFUL: _extract_semantic_nodes accepted extra arguments.")
            success = True
        except TypeError as e:
            print(f"\n[!] BUG STILL PRESENT: Caught TypeError: {e}")
            success = False

        self.assertTrue(success, "Should NOT have failed with TypeError")


if __name__ == "__main__":
    unittest.main()
