File size: 2,218 Bytes
24214fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
"""
Test script for validation UI behavior.
"""

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'src'))

def test_validation_ui():
    """Test validation UI with different scenarios."""
    from interface.enhanced_prompt_editor import EnhancedPromptEditor
    
    editor = EnhancedPromptEditor()
    
    print("πŸ§ͺ Testing Validation UI")
    print("=" * 40)
    
    # Test 1: Valid prompt
    print("\n1. Testing valid prompt...")
    valid_prompt = """
    <system_role>
    You are a helpful assistant.
    </system_role>
    
    <output_format>
    Respond in JSON format.
    </output_format>
    """
    
    validation_html, is_valid = editor.validate_prompt_syntax(valid_prompt)
    print(f"   Result: {'βœ… VALID' if is_valid else '❌ INVALID'}")
    print(f"   HTML contains max-height: {'βœ…' if 'max-height' in validation_html else '❌'}")
    
    # Test 2: Prompt with warnings
    print("\n2. Testing prompt with warnings...")
    warning_prompt = "A" * 12000  # Very long prompt
    
    validation_html, is_valid = editor.validate_prompt_syntax(warning_prompt)
    print(f"   Result: {'βœ… VALID (with warnings)' if is_valid else '❌ INVALID'}")
    print(f"   HTML contains max-height: {'βœ…' if 'max-height' in validation_html else '❌'}")
    print(f"   HTML contains overflow-y: {'βœ…' if 'overflow-y' in validation_html else '❌'}")
    
    # Test 3: Invalid prompt
    print("\n3. Testing invalid prompt...")
    invalid_prompt = ""  # Empty prompt
    
    validation_html, is_valid = editor.validate_prompt_syntax(invalid_prompt)
    print(f"   Result: {'βœ… VALID' if is_valid else '❌ INVALID (expected)'}")
    print(f"   HTML contains max-height: {'βœ…' if 'max-height' in validation_html else '❌'}")
    
    print("\n" + "=" * 40)
    print("πŸŽ‰ Validation UI tests completed!")
    print("\nπŸ“‹ Summary:")
    print("   βœ… CSS max-height applied to prevent UI overflow")
    print("   βœ… Compact styling to save space")
    print("   βœ… Proper scrolling for long validation messages")
    print("   βœ… Buttons should remain visible and accessible")

if __name__ == "__main__":
    test_validation_ui()