Spaces:
Sleeping
Sleeping
| #!/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() |