ERMA / test_frontend.py
mfirat007's picture
Upload 27 files
5cf374f verified
import unittest
from unittest.mock import patch, MagicMock
import sys
import os
# Add the src directory to the path
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
# Import the frontend components
class TestChatbotFrontend(unittest.TestCase):
def test_html_structure(self):
"""Test that the HTML file exists and has the expected structure"""
html_path = os.path.join(os.path.dirname(__file__), '..', 'src', 'static', 'index.html')
self.assertTrue(os.path.exists(html_path), "Frontend HTML file should exist")
with open(html_path, 'r') as f:
content = f.read()
# Check for essential elements
self.assertIn('<html', content, "Should have HTML tag")
self.assertIn('<head', content, "Should have head section")
self.assertIn('<body', content, "Should have body section")
self.assertIn('chat-container', content, "Should have chat container")
self.assertIn('chat-messages', content, "Should have messages container")
self.assertIn('user-input', content, "Should have user input field")
self.assertIn('send-button', content, "Should have send button")
# Check for citation display
self.assertIn('citation', content, "Should have citation styling")
# Check for responsive design
self.assertIn('viewport', content, "Should have viewport meta tag for responsiveness")
# Check for JavaScript functionality
self.assertIn('addEventListener', content, "Should have event listeners")
self.assertIn('fetch', content, "Should have API fetch functionality")
self.assertIn('conversation_history', content, "Should track conversation history")
if __name__ == '__main__':
unittest.main()