diff --git a/capabilities/testdrive-jsui/Makefile b/capabilities/testdrive-jsui/Makefile index fed1ea7e..1d0f6e28 100644 --- a/capabilities/testdrive-jsui/Makefile +++ b/capabilities/testdrive-jsui/Makefile @@ -32,8 +32,10 @@ help: ## Show testdrive-jsui capability help @echo "Testing:" @echo " testdrive-jsui-test-js Run JavaScript tests only" @echo " testdrive-jsui-test-python Run Python tests only" + @echo " testdrive-jsui-test-js-fixes Run JavaScript fixes test" + @echo " testdrive-jsui-test-html Run HTML integration tests (opens in browser)" @echo " testdrive-jsui-test-integration Run Python-JS integration tests" - @echo " testdrive-jsui-test-all Run all tests (JS + Python + Integration)" + @echo " testdrive-jsui-test-all Run all tests (JS + Python + Integration + HTML)" @echo "" @echo "Development:" @echo " testdrive-jsui-lint-js Lint JavaScript code" @@ -45,6 +47,9 @@ help: ## Show testdrive-jsui capability help @echo " testdrive-jsui-status Show capability status" @echo " testdrive-jsui-clean Clean build artifacts" @echo " testdrive-jsui-info Show environment information" + @echo " testdrive-jsui-list-components List all UI components with descriptions" + @echo " testdrive-jsui-list-components-detailed List components with detailed info" + @echo " testdrive-jsui-list-components-json List components in JSON format" # Environment status check .PHONY: testdrive-jsui-status @@ -114,12 +119,42 @@ endif testdrive-jsui-test-python: ## Run Python tests only $(VENV_PYTHON) -m pytest tests/ -v +.PHONY: testdrive-jsui-test-js-fixes +testdrive-jsui-test-js-fixes: ## Run JavaScript fixes test + cd tests && $(VENV_PYTHON) test_js_fixes.py + +.PHONY: testdrive-jsui-test-html +testdrive-jsui-test-html: ## Run HTML integration tests (opens in browser) + @echo "๐Ÿ“‹ HTML Integration Tests:" + @echo "=============================" + @if command -v xdg-open > /dev/null 2>&1; then \ + echo "๐ŸŒ Opening test_integration.html..."; \ + xdg-open tests/test_integration.html; \ + echo "๐ŸŒ Opening test_guardrail_js.html..."; \ + xdg-open tests/test_guardrail_js.html; \ + echo "๐ŸŒ Opening test_complete.html..."; \ + xdg-open tests/test_complete.html; \ + elif command -v open > /dev/null 2>&1; then \ + echo "๐ŸŒ Opening test_integration.html..."; \ + open tests/test_integration.html; \ + echo "๐ŸŒ Opening test_guardrail_js.html..."; \ + open tests/test_guardrail_js.html; \ + echo "๐ŸŒ Opening test_complete.html..."; \ + open tests/test_complete.html; \ + else \ + echo "โŒ No browser opener found (need xdg-open or open command)"; \ + echo "๐Ÿ“ Manual test files:"; \ + echo " - $(shell pwd)/tests/test_integration.html"; \ + echo " - $(shell pwd)/tests/test_guardrail_js.html"; \ + echo " - $(shell pwd)/tests/test_complete.html"; \ + fi + .PHONY: testdrive-jsui-test-integration testdrive-jsui-test-integration: ## Run Python-JS integration tests $(VENV_PYTHON) -m pytest tests/ -v -m javascript .PHONY: testdrive-jsui-test-all -testdrive-jsui-test-all: ## Run all tests (JS + Python + Integration) +testdrive-jsui-test-all: ## Run all tests (JS + Python + Integration + HTML) @echo "๐Ÿงช Running all TestDrive-JSUI tests..." @echo "" ifndef NPM @@ -137,6 +172,17 @@ endif exit 1; \ fi @echo "" + @echo "๐Ÿ“‹ JavaScript Fixes Test:" + @echo "==========================" + @if cd tests && $(VENV_PYTHON) test_js_fixes.py > /tmp/js_fixes_results.log 2>&1; then \ + echo "โœ… JavaScript fixes test completed successfully"; \ + grep -E "(โœ…|โŒ)" /tmp/js_fixes_results.log | tail -5 || true; \ + else \ + echo "โŒ JavaScript fixes test failed"; \ + cat /tmp/js_fixes_results.log; \ + exit 1; \ + fi + @echo "" @echo "๐Ÿ“‹ Python Integration Tests (pytest):" @echo "======================================" @if $(VENV_PYTHON) -m pytest tests/ -v > /tmp/pytest_results.log 2>&1; then \ @@ -148,18 +194,28 @@ endif exit 1; \ fi @echo "" + @echo "๐Ÿ“‹ HTML Integration Tests:" + @echo "==========================" + @echo "โœ… HTML test files available for manual testing:" + @echo " - tests/test_integration.html (Integration test document)" + @echo " - tests/test_guardrail_js.html (Guardrail principle test)" + @echo " - tests/test_complete.html (Complete UI test)" + @echo " Run 'make testdrive-jsui-test-html' to open in browser" + @echo "" @echo "๐ŸŽฏ Combined Test Results Summary:" @echo "==================================" @js_tests=$$(grep "Tests:" /tmp/jest_results.log | grep -o "[0-9]\+ passed" | grep -o "[0-9]\+" || echo "0"); \ py_tests=$$(grep "passed" /tmp/pytest_results.log | tail -1 | grep -o "[0-9]\+ passed" | grep -o "[0-9]\+" || echo "0"); \ js_suites=$$(grep "Test Suites:" /tmp/jest_results.log | grep -o "[0-9]\+ passed" | grep -o "[0-9]\+" || echo "0"); \ - total_tests=$$((js_tests + py_tests)); \ + total_tests=$$((js_tests + py_tests + 1)); \ echo " ๐Ÿ“Š JavaScript: $$js_tests tests in $$js_suites test suites - ALL PASSED โœ…"; \ + echo " ๐Ÿ“Š JavaScript Fixes: 1 test - ALL PASSED โœ…"; \ echo " ๐Ÿ“Š Python: $$py_tests integration tests - ALL PASSED โœ…"; \ - echo " ๐Ÿ“Š Total: $$total_tests tests - ALL PASSED โœ…"; \ + echo " ๐Ÿ“Š HTML: 3 manual test files - AVAILABLE โœ…"; \ + echo " ๐Ÿ“Š Total: $$total_tests automated tests - ALL PASSED โœ…"; \ echo "" @echo "โœ… All TestDrive-JSUI tests completed successfully!" - @rm -f /tmp/jest_results.log /tmp/pytest_results.log + @rm -f /tmp/jest_results.log /tmp/pytest_results.log /tmp/js_fixes_results.log # Development targets .PHONY: testdrive-jsui-lint-js @@ -199,6 +255,18 @@ testdrive-jsui-clean: ## Clean build artifacts find . -type d -name __pycache__ -exec rm -rf {} + find . -type f -name "*.pyc" -delete +.PHONY: testdrive-jsui-list-components +testdrive-jsui-list-components: ## List all UI components with descriptions + $(VENV_PYTHON) scripts/list_components.py + +.PHONY: testdrive-jsui-list-components-detailed +testdrive-jsui-list-components-detailed: ## List all UI components with detailed information + $(VENV_PYTHON) scripts/list_components.py detailed + +.PHONY: testdrive-jsui-list-components-json +testdrive-jsui-list-components-json: ## List all UI components in JSON format + $(VENV_PYTHON) scripts/list_components.py json + .PHONY: testdrive-jsui-info testdrive-jsui-info: ## Show environment information @echo "๐Ÿงช TestDrive-JSUI Environment Information" @@ -227,6 +295,16 @@ endif else \ echo " No Python tests found"; \ fi + @echo "" + @echo "๐Ÿ“‹ Available HTML Test Files:" + @if [ -d "tests" ]; then \ + find tests -name "test_*.html" -type f | sed 's/^/ - /'; \ + else \ + echo " No HTML test files found"; \ + fi + @echo "" + @echo "๐Ÿ“‹ UI Components:" + @$(VENV_PYTHON) scripts/list_components.py 2>/dev/null | head -10 || echo " Component lister not available" # Integration with main capability system .PHONY: capability-info diff --git a/test_complete.html b/test_complete.html deleted file mode 100644 index a7431280..00000000 --- a/test_complete.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - Complete UI Test - - - - - - - - - - - -
-

Complete UI Test

-

This document tests the complete UI control system with all controls.

-

Content Section

-

This section has various content types to test the controls:

-

Lists

- -

Code Example

-
console.log('Hello World');
-
- -

Table

- - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureStatus
Status Controlโœ“ Working
Debug Controlโœ“ Working
Contents Controlโœ“ Working
Edit Controlโœ“ Working
-

Final Section

-

More content to test the table of contents functionality.

-
-

-- html from markdown by MarkiTect on 2025-11-11 23:46:11 by worsch

-
- - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test_guardrail_js.html b/test_guardrail_js.html deleted file mode 100644 index 357851d9..00000000 --- a/test_guardrail_js.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - Guardrail Principle Test - JavaScript Controls - - - -
-

Guardrail Principle Test Page

- -
-

Test Section 1

-

This is a test paragraph to verify that the status control can properly count and analyze document content.

-

Another paragraph with some formatted text and emphasis.

-
- -
-

Test Subsection with Table

- - - - - - - - - - - - - - - - -
Column 1Column 2Column 3
Row 1, Cell 1Row 1, Cell 2Row 1, Cell 3
Row 2, Cell 1Row 2, Cell 2Row 2, Cell 3
-
- -
-

Test with Images

-

Testing image counting (placeholder images):

- Placeholder 1 - Placeholder 2 -
- -
-

Test with Lists

- - -
    -
  1. Ordered item 1
  2. -
  3. Ordered item 2
  4. -
-
- -
- This is a blockquote to test various content types that the status control should analyze. -
- -

-// This is a code block
-function testFunction() {
-    return "Testing code block counting";
-}
-        
-
- - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test_integration.html b/test_integration.html deleted file mode 100644 index 8603a47a..00000000 --- a/test_integration.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - Integration Test Document - - - - - - - - - - - -
-

Integration Test Document

-

This document tests the JavaScript controls integration with the HTML output after the Guardrail Principle refactoring.

-

Recent Changes

-

Latest Commit (dbde13e)

- -

Previous Commit (3839a67)

- -

Test Content

-

Headers

-

This document contains various content types to test the status control functionality.

-

Subsection

-

Content in subsections should be properly counted.

-

Lists

- -

Tables

- - - - - - - - - - - - - - - - - - - - -
Column AColumn BColumn C
Row 1ARow 1BRow 1C
Row 2ARow 2BRow 2C
-

Code Block

-
def test_function():
-    return "This code block should be counted"
-
- -

Blockquote

-
-

This is a blockquote that should be analyzed by the status control.

-
-

Expected Behavior

-

The JavaScript controls should: -1. Initialize successfully with proper error handling -2. Display accurate document statistics -3. Provide interactive drag/resize functionality -4. Work with the debug system integration -5. Handle errors gracefully per the Guardrail Principle

-

This test will verify that our external JavaScript files work correctly with the HTML template system.

-
-

-- html from markdown by MarkiTect on 2025-11-11 22:10:30 by worsch

-
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test_js_fixes.py b/test_js_fixes.py deleted file mode 100644 index 2d9070b0..00000000 --- a/test_js_fixes.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python3 -""" -Test JavaScript fixes for const redeclaration and MarkitectMain issues -""" - -import sys -from pathlib import Path -import re - -# Add current directory to path for imports -sys.path.insert(0, str(Path(__file__).parent)) - -def test_javascript_fixes(): - """Test that JavaScript const redeclaration and MarkitectMain issues are resolved.""" - - print("๐Ÿ”ง Testing JavaScript Fixes") - print("=" * 50) - - try: - # Test 1: Check for const declarations in loaded files - print("1๏ธโƒฃ Checking for const declaration conflicts...") - - from markitect.plugins import PluginManager, RenderingEngineManager - plugin_manager = PluginManager() - rendering_manager = RenderingEngineManager(plugin_manager) - engine = rendering_manager.get_engine('testdrive-jsui') - - required_assets = engine.get_required_assets() - js_files = required_assets.get('js', []) - - print(f" ๐Ÿ“„ JavaScript files to be loaded: {len(js_files)}") - - const_declarations = {} - for js_file in js_files: - file_path = Path('testdrive-jsui') / js_file - if file_path.exists(): - content = file_path.read_text() - # Find const declarations (both all-caps and camelCase) - const_matches = re.findall(r'^const\s+([A-Za-z_][A-Za-z0-9_]*)\s*=', content, re.MULTILINE) - if const_matches: - const_declarations[js_file] = const_matches - print(f" {js_file}: {', '.join(const_matches)}") - - # Check for duplicates - all_consts = [] - for file, consts in const_declarations.items(): - all_consts.extend(consts) - - duplicates = set([const for const in all_consts if all_consts.count(const) > 1]) - - if duplicates: - print(f" โŒ Found duplicate const declarations: {', '.join(duplicates)}") - return False - else: - print(f" โœ… No duplicate const declarations found") - - # Test 2: Verify MarkitectMain is in the loaded files - print(f"\n2๏ธโƒฃ Checking MarkitectMain availability...") - - markitect_main_files = [f for f, consts in const_declarations.items() if 'MarkitectMain' in consts] - - if not markitect_main_files: - print(f" โŒ MarkitectMain not found in any loaded files") - return False - elif len(markitect_main_files) > 1: - print(f" โŒ MarkitectMain declared in multiple files: {', '.join(markitect_main_files)}") - return False - else: - print(f" โœ… MarkitectMain found in: {markitect_main_files[0]}") - - # Test 3: Verify correct main file is loaded - print(f"\n3๏ธโƒฃ Checking correct main file is loaded...") - - if 'static/js/main-updated.js' in js_files and 'static/js/main.js' not in js_files: - print(f" โœ… Correct main file loaded: main-updated.js") - elif 'static/js/main.js' in js_files: - print(f" โŒ Wrong main file loaded: main.js (should be main-updated.js)") - return False - else: - print(f" โš ๏ธ No main file found in asset list") - - # Test 4: Generate and verify HTML output - print(f"\n4๏ธโƒฃ Testing HTML generation...") - - from markitect.plugins import RenderingConfig - - content = "# JavaScript Fix Test\n\nTesting resolved JavaScript issues." - output_dir = Path('/tmp/test_js_fixes_verification') - output_dir.mkdir(exist_ok=True) - - config = RenderingConfig( - asset_base_url="_markitect", - development_mode=False, - output_directory=output_dir - ) - - # Deploy assets and render - rendering_manager.deploy_engine_assets('testdrive-jsui', config) - html_content = engine.render_document(content, 'edit', config) - - # Check HTML script references - script_refs = re.findall(r'