- Start met Mobiele versie van de chat client.
This commit is contained in:
257
test_mobile_responsive.py
Normal file
257
test_mobile_responsive.py
Normal file
@@ -0,0 +1,257 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify mobile responsive functionality for eveai_chat_client
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def test_files_exist():
|
||||
"""Test that all required files exist"""
|
||||
print("Testing file existence...")
|
||||
|
||||
files_to_check = [
|
||||
# Vue components
|
||||
'eveai_chat_client/static/assets/vue-components/MobileHeader.vue',
|
||||
'eveai_chat_client/static/assets/vue-components/SideBar.vue',
|
||||
'eveai_chat_client/static/assets/vue-components/index.js',
|
||||
|
||||
# Templates
|
||||
'eveai_chat_client/templates/base.html',
|
||||
'eveai_chat_client/templates/scripts.html',
|
||||
|
||||
# CSS
|
||||
'eveai_chat_client/static/assets/css/chat.css',
|
||||
|
||||
# Source files
|
||||
'frontend_src/js/chat-client.js',
|
||||
|
||||
# Built files
|
||||
'eveai_chat_client/static/dist/chat-client.js',
|
||||
'eveai_chat_client/static/dist/chat-client.css',
|
||||
]
|
||||
|
||||
missing_files = []
|
||||
for file_path in files_to_check:
|
||||
if not os.path.exists(file_path):
|
||||
missing_files.append(file_path)
|
||||
else:
|
||||
print(f"✓ {file_path}")
|
||||
|
||||
if missing_files:
|
||||
print(f"\n❌ Missing files:")
|
||||
for file_path in missing_files:
|
||||
print(f" - {file_path}")
|
||||
return False
|
||||
|
||||
print("✅ All required files exist")
|
||||
return True
|
||||
|
||||
def test_mobile_header_component():
|
||||
"""Test MobileHeader component structure"""
|
||||
print("\nTesting MobileHeader component...")
|
||||
|
||||
mobile_header_path = 'eveai_chat_client/static/assets/vue-components/MobileHeader.vue'
|
||||
|
||||
with open(mobile_header_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for required elements
|
||||
required_elements = [
|
||||
'class="mobile-header"',
|
||||
'SideBarLogo',
|
||||
'LanguageSelector',
|
||||
'@media (min-width: 769px)',
|
||||
'display: none'
|
||||
]
|
||||
|
||||
missing_elements = []
|
||||
for element in required_elements:
|
||||
if element not in content:
|
||||
missing_elements.append(element)
|
||||
else:
|
||||
print(f"✓ Found: {element}")
|
||||
|
||||
if missing_elements:
|
||||
print(f"❌ Missing elements in MobileHeader:")
|
||||
for element in missing_elements:
|
||||
print(f" - {element}")
|
||||
return False
|
||||
|
||||
print("✅ MobileHeader component structure is correct")
|
||||
return True
|
||||
|
||||
def test_css_responsive_rules():
|
||||
"""Test CSS responsive rules"""
|
||||
print("\nTesting CSS responsive rules...")
|
||||
|
||||
css_path = 'eveai_chat_client/static/assets/css/chat.css'
|
||||
|
||||
with open(css_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for required CSS rules
|
||||
required_rules = [
|
||||
'#mobile-header-container',
|
||||
'#sidebar-container',
|
||||
'@media (max-width: 768px)',
|
||||
'flex-direction: column',
|
||||
'display: none',
|
||||
'display: block'
|
||||
]
|
||||
|
||||
missing_rules = []
|
||||
for rule in required_rules:
|
||||
if rule not in content:
|
||||
missing_rules.append(rule)
|
||||
else:
|
||||
print(f"✓ Found: {rule}")
|
||||
|
||||
if missing_rules:
|
||||
print(f"❌ Missing CSS rules:")
|
||||
for rule in missing_rules:
|
||||
print(f" - {rule}")
|
||||
return False
|
||||
|
||||
print("✅ CSS responsive rules are correct")
|
||||
return True
|
||||
|
||||
def test_base_html_structure():
|
||||
"""Test base.html structure"""
|
||||
print("\nTesting base.html structure...")
|
||||
|
||||
base_html_path = 'eveai_chat_client/templates/base.html'
|
||||
|
||||
with open(base_html_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for required elements
|
||||
required_elements = [
|
||||
'id="mobile-header-container"',
|
||||
'id="sidebar-container"',
|
||||
'class="content-area"'
|
||||
]
|
||||
|
||||
missing_elements = []
|
||||
for element in required_elements:
|
||||
if element not in content:
|
||||
missing_elements.append(element)
|
||||
else:
|
||||
print(f"✓ Found: {element}")
|
||||
|
||||
if missing_elements:
|
||||
print(f"❌ Missing elements in base.html:")
|
||||
for element in missing_elements:
|
||||
print(f" - {element}")
|
||||
return False
|
||||
|
||||
print("✅ base.html structure is correct")
|
||||
return True
|
||||
|
||||
def test_component_exports():
|
||||
"""Test component exports"""
|
||||
print("\nTesting component exports...")
|
||||
|
||||
index_js_path = 'eveai_chat_client/static/assets/vue-components/index.js'
|
||||
|
||||
with open(index_js_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for required exports
|
||||
required_exports = [
|
||||
'export { default as SideBar }',
|
||||
'export { default as MobileHeader }'
|
||||
]
|
||||
|
||||
missing_exports = []
|
||||
for export in required_exports:
|
||||
if export not in content:
|
||||
missing_exports.append(export)
|
||||
else:
|
||||
print(f"✓ Found: {export}")
|
||||
|
||||
if missing_exports:
|
||||
print(f"❌ Missing exports:")
|
||||
for export in missing_exports:
|
||||
print(f" - {export}")
|
||||
return False
|
||||
|
||||
print("✅ Component exports are correct")
|
||||
return True
|
||||
|
||||
def test_chat_client_js():
|
||||
"""Test chat-client.js mounting logic"""
|
||||
print("\nTesting chat-client.js mounting logic...")
|
||||
|
||||
chat_client_path = 'frontend_src/js/chat-client.js'
|
||||
|
||||
with open(chat_client_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for required mounting logic
|
||||
required_elements = [
|
||||
'getElementById(\'sidebar-container\')',
|
||||
'getElementById(\'mobile-header-container\')',
|
||||
'Components.SideBar',
|
||||
'Components.MobileHeader',
|
||||
'mount(\'#sidebar-container\')',
|
||||
'mount(\'#mobile-header-container\')'
|
||||
]
|
||||
|
||||
missing_elements = []
|
||||
for element in required_elements:
|
||||
if element not in content:
|
||||
missing_elements.append(element)
|
||||
else:
|
||||
print(f"✓ Found: {element}")
|
||||
|
||||
if missing_elements:
|
||||
print(f"❌ Missing elements in chat-client.js:")
|
||||
for element in missing_elements:
|
||||
print(f" - {element}")
|
||||
return False
|
||||
|
||||
print("✅ chat-client.js mounting logic is correct")
|
||||
return True
|
||||
|
||||
def main():
|
||||
"""Run all tests"""
|
||||
print("🧪 Testing Mobile Responsive Implementation")
|
||||
print("=" * 50)
|
||||
|
||||
tests = [
|
||||
test_files_exist,
|
||||
test_mobile_header_component,
|
||||
test_css_responsive_rules,
|
||||
test_base_html_structure,
|
||||
test_component_exports,
|
||||
test_chat_client_js
|
||||
]
|
||||
|
||||
passed = 0
|
||||
failed = 0
|
||||
|
||||
for test in tests:
|
||||
try:
|
||||
if test():
|
||||
passed += 1
|
||||
else:
|
||||
failed += 1
|
||||
except Exception as e:
|
||||
print(f"❌ Test failed with error: {e}")
|
||||
failed += 1
|
||||
print()
|
||||
|
||||
print("=" * 50)
|
||||
print(f"📊 Test Results: {passed} passed, {failed} failed")
|
||||
|
||||
if failed == 0:
|
||||
print("🎉 All tests passed! Mobile responsive implementation is complete.")
|
||||
return True
|
||||
else:
|
||||
print("⚠️ Some tests failed. Please review the implementation.")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = main()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user