- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
197 lines
6.0 KiB
Python
197 lines
6.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Comprehensive integration test for Enhanced Agent V0 components
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import json
|
|
import tempfile
|
|
import time
|
|
from datetime import datetime
|
|
|
|
# Add agent_v0 to path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'agent_v0'))
|
|
|
|
from agent_v0.workflow_namer import WorkflowNamer
|
|
from agent_v0.enhanced_raw_session import EnhancedRawSession
|
|
from agent_v0.enhanced_event_captor import EnhancedEventCaptor, UIContext
|
|
from agent_v0.targeted_screen_capturer import TargetedScreenCapturer
|
|
from agent_v0.processing_monitor import ProcessingMonitor, ProcessingStage, ProcessingStatus
|
|
from agent_v0.workflow_locator import WorkflowLocator, WorkflowFilters
|
|
|
|
|
|
def test_workflow_naming_integration():
|
|
"""Test workflow naming integration"""
|
|
print("=== Testing Workflow Naming Integration ===")
|
|
|
|
session = EnhancedRawSession.create_enhanced(
|
|
user_id="integration_test",
|
|
workflow_name=None,
|
|
auto_generate_name=True
|
|
)
|
|
|
|
# Add form filling events
|
|
session.add_enhanced_mouse_click_event(
|
|
button="left",
|
|
pos=[200, 100],
|
|
window_title="Customer Registration Form - CRM Pro",
|
|
app_name="CRM_Pro",
|
|
screenshot_id="shot_001",
|
|
element_type="input",
|
|
element_text="First Name",
|
|
confidence=0.9
|
|
)
|
|
|
|
session.add_enhanced_key_event(
|
|
keys=["John"],
|
|
window_title="Customer Registration Form - CRM Pro",
|
|
app_name="CRM_Pro",
|
|
screenshot_id="shot_002",
|
|
text_content="John",
|
|
input_method="typing"
|
|
)
|
|
|
|
# Generate intelligent name
|
|
intelligent_name = session.generate_intelligent_name()
|
|
print(f"Generated name: {intelligent_name}")
|
|
|
|
# Analyze session
|
|
analysis = session.analyze_session()
|
|
print(f"Workflow type: {analysis.workflow_type}")
|
|
print(f"Primary app: {analysis.primary_application}")
|
|
|
|
session.close_with_analysis()
|
|
|
|
assert session.workflow_metadata is not None
|
|
print("✓ Workflow naming integration test passed\n")
|
|
return session
|
|
|
|
|
|
def test_enhanced_event_capture():
|
|
"""Test enhanced event capture system"""
|
|
print("=== Testing Enhanced Event Capture ===")
|
|
|
|
def on_click(button, x, y, context):
|
|
pass
|
|
|
|
captor = EnhancedEventCaptor(on_mouse_click=on_click)
|
|
|
|
# Test UI context detection
|
|
context = captor.ui_detector.get_ui_context(100, 200)
|
|
assert context.window_title is not None
|
|
|
|
# Test sensitive field detection
|
|
password_context = UIContext(
|
|
window_title="Login - Password Required",
|
|
app_name="TestApp",
|
|
element_text="Password"
|
|
)
|
|
|
|
is_sensitive = captor.sensitive_detector.is_sensitive_field(password_context)
|
|
assert is_sensitive
|
|
|
|
print("✓ Enhanced event capture test passed\n")
|
|
|
|
|
|
def test_targeted_screenshot_system():
|
|
"""Test targeted screenshot capture system"""
|
|
print("=== Testing Targeted Screenshot System ===")
|
|
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
capturer = TargetedScreenCapturer(temp_dir, "test_shot")
|
|
|
|
stats = capturer.get_capture_statistics()
|
|
assert stats["total_captures"] == 0
|
|
assert stats["session_dir"] == temp_dir
|
|
|
|
print("✓ Targeted screenshot system test passed\n")
|
|
|
|
|
|
def test_processing_monitor():
|
|
"""Test processing monitoring system"""
|
|
print("=== Testing Processing Monitor ===")
|
|
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
monitor = ProcessingMonitor(temp_dir)
|
|
|
|
session_id = "test_session_001"
|
|
workflow_name = "Test_Customer_Registration"
|
|
|
|
processing_info = monitor.create_processing_session(session_id, workflow_name)
|
|
|
|
assert processing_info.session_id == session_id
|
|
assert processing_info.status == ProcessingStatus.PENDING
|
|
|
|
# Simulate processing
|
|
monitor.update_step_progress(session_id, ProcessingStage.UPLOAD, 100)
|
|
monitor.complete_step(session_id, ProcessingStage.UPLOAD)
|
|
|
|
final_info = monitor.get_processing_status(session_id)
|
|
assert final_info is not None
|
|
|
|
print("✓ Processing monitor test passed\n")
|
|
|
|
|
|
def test_workflow_organization():
|
|
"""Test workflow organization and discovery"""
|
|
print("=== Testing Workflow Organization ===")
|
|
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
# Create test workflow
|
|
workflow_dir = os.path.join(temp_dir, "Test_Workflow_sess_1")
|
|
os.makedirs(workflow_dir, exist_ok=True)
|
|
|
|
json_data = {
|
|
"session_id": "sess_1",
|
|
"started_at": datetime.now().isoformat(),
|
|
"workflow_metadata": {
|
|
"workflow_name": "Test_Workflow",
|
|
"workflow_type": "form_filling",
|
|
"primary_application": "TestApp"
|
|
},
|
|
"quality_score": 0.85,
|
|
"events": [{"type": "mouse_click"}],
|
|
"screenshots": [{"id": "shot_1"}]
|
|
}
|
|
|
|
json_path = os.path.join(workflow_dir, "sess_1_enhanced.json")
|
|
with open(json_path, 'w') as f:
|
|
json.dump(json_data, f, indent=2)
|
|
|
|
# Test discovery
|
|
locator = WorkflowLocator(temp_dir)
|
|
discovered = locator.discover_workflows()
|
|
|
|
assert len(discovered) == 1
|
|
assert discovered[0].name == "Test_Workflow"
|
|
|
|
print("✓ Workflow organization test passed\n")
|
|
|
|
|
|
def main():
|
|
"""Run all integration tests"""
|
|
print("Starting Enhanced Agent V0 Integration Tests")
|
|
print("=" * 50)
|
|
|
|
try:
|
|
test_enhanced_event_capture()
|
|
test_targeted_screenshot_system()
|
|
test_processing_monitor()
|
|
test_workflow_organization()
|
|
test_workflow_naming_integration()
|
|
|
|
print("=" * 50)
|
|
print("✓ ALL INTEGRATION TESTS PASSED!")
|
|
|
|
return 0
|
|
|
|
except Exception as e:
|
|
print(f"✗ Integration test failed: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main()) |