askrobots / dbbasic-web-native
Public
100+ copy-paste UI components in plain HTML and CSS: no dependencies, no build step.
danq9
Add canonical.html v1.0 - The single source of truth for usability standards
fb6e650
1 year ago
History
test_visual_single.py · 1.5 KB · 51 lines
| 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | Single-component AI vision testing. |
| 4 | Cost-efficient way to test only changed components. |
| 5 | Cost: ~$0.06 per component (3 tests × $0.02) |
| 6 | Run: On changed files in PR |
| 7 | """ |
| 8 | |
| 9 | import sys |
| 10 | from test_visual_ai import VisualAIAnalyzer |
| 11 | import os |
| 12 | |
| 13 | def main(): |
| 14 | if len(sys.argv) < 2: |
| 15 | print("Usage: python3 test_visual_single.py <component-name>") |
| 16 | print("\nExamples:") |
| 17 | print(" python3 test_visual_single.py semantic-modal") |
| 18 | print(" python3 test_visual_single.py semantic-action") |
| 19 | print("\nAvailable components:") |
| 20 | print(" - semantic-action") |
| 21 | print(" - semantic-card") |
| 22 | print(" - semantic-input") |
| 23 | print(" - semantic-modal") |
| 24 | print(" - semantic-navigator") |
| 25 | print(" - semantic-list") |
| 26 | print(" - semantic-menu") |
| 27 | print(" - semantic-feedback") |
| 28 | print(" - semantic-adjuster") |
| 29 | sys.exit(1) |
| 30 | |
| 31 | component = sys.argv[1] |
| 32 | if not component.endswith('.html'): |
| 33 | component = f"{component}.html" |
| 34 | |
| 35 | api_key = os.getenv('ANTHROPIC_API_KEY') |
| 36 | if not api_key: |
| 37 | print("❌ ANTHROPIC_API_KEY environment variable not set") |
| 38 | sys.exit(1) |
| 39 | |
| 40 | analyzer = VisualAIAnalyzer(api_key) |
| 41 | |
| 42 | # Filter to only test this component |
| 43 | analyzer.COMPONENT_PAGES = [component] |
| 44 | |
| 45 | print(f"\n🔍 Testing single component: {component}") |
| 46 | print(f" Cost: ~$0.06 (3 AI vision tests)\n") |
| 47 | |
| 48 | analyzer.run_all_tests() |
| 49 | |
| 50 | if __name__ == '__main__': |
| 51 | main() |