from pathlib import Path import subprocess INTEGRATION_ROOT = Path("integration/dxdesigner795") def test_bridge_core_is_ascii_and_contains_transaction_stages() -> None: common = (INTEGRATION_ROOT / "BridgeCommon.vbs").read_text(encoding="ascii") transaction = (INTEGRATION_ROOT / "core" / "Transaction.vbs").read_text( encoding="ascii" ) snapshot = (INTEGRATION_ROOT / "core" / "Snapshot.vbs").read_text( encoding="ascii" ) mailbox = (INTEGRATION_ROOT / "core" / "Mailbox.vbs").read_text( encoding="ascii" ) entry = (INTEGRATION_ROOT / "DesignBridge.vbs").read_text(encoding="ascii") assert "DxToolsParseScheduleRow" in common assert "DxBridgeIdleWait" in common for name in ( "DxExportSnapshot", "DxRefreshSnapshot", ): assert f"Function {name}" in snapshot for name in ( "DxProcessApply", "DxPreflightApply", "DxApplySchedule", "DxRollback", ): assert f"Function {name}" in transaction assert "DxBridgeMailboxLoop" in mailbox assert "DxToolsRunDesignBridge" in entry for text in (common, transaction, snapshot, mailbox, entry): assert "ViewDraw.Application" not in text assert "GetActiveObject" not in text assert "DXTOOLS_HOME" not in text assert text.isascii() def test_real_vbs_bridge_transaction_harness_passes() -> None: result = subprocess.run( ["cscript", "//nologo", "tests/vbs/test_refdes_bridge.vbs"], capture_output=True, text=True, encoding="mbcs", check=False, timeout=30, ) assert result.returncode == 0, result.stdout + result.stderr assert "DesignBridge transaction assertions passed" in result.stdout def test_real_vbs_snapshot_export_harness_passes() -> None: result = subprocess.run( ["cscript", "//nologo", "tests/vbs/test_refdes_export.vbs"], capture_output=True, text=True, encoding="mbcs", check=False, timeout=30, ) assert result.returncode == 0, result.stdout + result.stderr assert "RefDes export assertions passed" in result.stdout def test_snapshot_export_uses_v2_protocol_fields() -> None: snapshot = (INTEGRATION_ROOT / "core" / "Snapshot.vbs").read_text( encoding="ascii" ) assert '"format_version"": 2' in snapshot assert '"attributes"' in snapshot assert '"nets"' in snapshot assert '"selected_nets"' in snapshot assert '"locked"' in snapshot def test_transaction_supports_property_operations() -> None: transaction = (INTEGRATION_ROOT / "core" / "Transaction.vbs").read_text( encoding="ascii" ) assert 'FindAttribute(' in transaction assert '.Visible =' in transaction assert 'DxBridgeNormalizeVisible' in transaction