""" Tests for Issue #132: Basic HTML Generation and Rendering This module tests the core functionality of the md-render command for client-side markdown rendering with JavaScript. """ import pytest import tempfile import os from pathlib import Path from unittest.mock import patch, MagicMock import json import re # Add project root to path for imports import sys project_root = Path(__file__).parent.parent.parent.parent sys.path.insert(0, str(project_root)) from markitect.plugins.builtin.markdown_commands import MarkdownCommandsPlugin class TestIssue132BasicRendering: """Test basic HTML generation and markdown rendering functionality.""" def setup_method(self): """Set up test environment.""" self.plugin = MarkdownCommandsPlugin() self.plugin.initialize() # Create temporary directory for test outputs self.temp_dir = tempfile.mkdtemp() def teardown_method(self): """Clean up test environment.""" # Clean up temporary files import shutil shutil.rmtree(self.temp_dir, ignore_errors=True) def test_md_render_command_exists(self): """Test that md-render command is registered in plugin - Issue #132.""" commands = self.plugin.get_commands() # Should include md-render command assert 'md-render' in commands # Command should be callable md_render_cmd = commands['md-render'] assert callable(md_render_cmd) def test_generate_basic_html_from_simple_markdown(self): """Test generating HTML from simple markdown content - Issue #132.""" # Create test markdown content markdown_content = """# Test Document This is a **test** document with some *italic* text and a [link](https://example.com). ## Section 2 - List item 1 - List item 2 - List item 3 """ # Create temporary input file input_file = Path(self.temp_dir) / "test.md" input_file.write_text(markdown_content) output_file = Path(self.temp_dir) / "output.html" # Test actual command execution from markitect.plugins.builtin.markdown_commands import md_render_command from click.testing import CliRunner runner = CliRunner() result = runner.invoke(md_render_command, [str(input_file), '--output', str(output_file)]) # Should execute successfully assert result.exit_code == 0 assert output_file.exists() # Should generate HTML file with content html_content = output_file.read_text() assert '' in html_content assert '