231 lines
8.7 KiB
Python
231 lines
8.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify the SSE stream fix for ProgressTracker.
|
|
This script tests that:
|
|
1. apiPrefix prop flows correctly from ChatApp → ChatInput → ChatMessage → ProgressTracker
|
|
2. The SSE URL is constructed correctly with the apiPrefix
|
|
3. Both MessageHistory sticky area and ChatInput active area work properly
|
|
4. No 404 errors occur when accessing task progress endpoints
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
def test_api_prefix_prop_flow():
|
|
"""Test that apiPrefix prop flows correctly through component hierarchy"""
|
|
|
|
print("🔍 Testing apiPrefix prop flow...")
|
|
|
|
# Test ChatApp.vue passes apiPrefix to ChatInput
|
|
chatapp_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/static/assets/vue-components/ChatApp.vue")
|
|
|
|
with open(chatapp_path, 'r', encoding='utf-8') as f:
|
|
chatapp_content = f.read()
|
|
|
|
if ':api-prefix="apiPrefix"' in chatapp_content:
|
|
print("✅ ChatApp passes apiPrefix to ChatInput")
|
|
else:
|
|
print("❌ ChatApp does not pass apiPrefix to ChatInput")
|
|
return False
|
|
|
|
# Test ChatInput.vue receives and passes apiPrefix to ChatMessage
|
|
chatinput_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/static/assets/vue-components/ChatInput.vue")
|
|
|
|
with open(chatinput_path, 'r', encoding='utf-8') as f:
|
|
chatinput_content = f.read()
|
|
|
|
# Check ChatInput has apiPrefix prop
|
|
if 'apiPrefix: {' in chatinput_content:
|
|
print("✅ ChatInput defines apiPrefix prop")
|
|
else:
|
|
print("❌ ChatInput missing apiPrefix prop")
|
|
return False
|
|
|
|
# Check ChatInput passes apiPrefix to ChatMessage
|
|
if ':api-prefix="apiPrefix"' in chatinput_content:
|
|
print("✅ ChatInput passes apiPrefix to ChatMessage")
|
|
else:
|
|
print("❌ ChatInput does not pass apiPrefix to ChatMessage")
|
|
return False
|
|
|
|
return True
|
|
|
|
def test_progress_tracker_sse_url_construction():
|
|
"""Test that ProgressTracker constructs SSE URLs correctly"""
|
|
|
|
print("\n🔍 Testing ProgressTracker SSE URL construction...")
|
|
|
|
progresstracker_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/static/assets/vue-components/ProgressTracker.vue")
|
|
|
|
with open(progresstracker_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Check that ProgressTracker uses apiPrefix in URL construction
|
|
if 'const sseUrl = `${baseUrl}${this.apiPrefix}/api/task_progress/${this.taskId}`;' in content:
|
|
print("✅ ProgressTracker constructs SSE URL with apiPrefix")
|
|
else:
|
|
print("❌ ProgressTracker does not use apiPrefix in URL construction")
|
|
return False
|
|
|
|
# Check that ProgressTracker has apiPrefix prop
|
|
if 'apiPrefix: {' in content:
|
|
print("✅ ProgressTracker defines apiPrefix prop")
|
|
else:
|
|
print("❌ ProgressTracker missing apiPrefix prop")
|
|
return False
|
|
|
|
return True
|
|
|
|
def test_chatmessage_prop_passing():
|
|
"""Test that ChatMessage passes apiPrefix to ProgressTracker"""
|
|
|
|
print("\n🔍 Testing ChatMessage prop passing...")
|
|
|
|
chatmessage_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/static/assets/vue-components/ChatMessage.vue")
|
|
|
|
with open(chatmessage_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Check that ChatMessage has apiPrefix prop
|
|
if 'apiPrefix: {' in content:
|
|
print("✅ ChatMessage defines apiPrefix prop")
|
|
else:
|
|
print("❌ ChatMessage missing apiPrefix prop")
|
|
return False
|
|
|
|
# Check that ChatMessage passes apiPrefix to ProgressTracker
|
|
if ':api-prefix="apiPrefix"' in content:
|
|
print("✅ ChatMessage passes apiPrefix to ProgressTracker")
|
|
else:
|
|
print("❌ ChatMessage does not pass apiPrefix to ProgressTracker")
|
|
return False
|
|
|
|
return True
|
|
|
|
def test_backwards_compatibility():
|
|
"""Test that MessageHistory sticky area still works"""
|
|
|
|
print("\n🔍 Testing backwards compatibility...")
|
|
|
|
messagehistory_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/static/assets/vue-components/MessageHistory.vue")
|
|
|
|
with open(messagehistory_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Check that MessageHistory still has sticky area
|
|
if 'sticky-ai-area' in content:
|
|
print("✅ MessageHistory sticky area preserved")
|
|
else:
|
|
print("❌ MessageHistory sticky area removed")
|
|
return False
|
|
|
|
# Check that MessageHistory passes apiPrefix to ChatMessage
|
|
if ':api-prefix="apiPrefix"' in content:
|
|
print("✅ MessageHistory passes apiPrefix to ChatMessage")
|
|
else:
|
|
print("❌ MessageHistory does not pass apiPrefix to ChatMessage")
|
|
return False
|
|
|
|
return True
|
|
|
|
def test_expected_url_format():
|
|
"""Test that the expected URL format will be generated"""
|
|
|
|
print("\n🔍 Testing expected URL format...")
|
|
|
|
# Based on the error message, we expect URLs like:
|
|
# http://macstudio.ask-eve-ai-local.com/chat-client/chat/api/task_progress/616b3e7c-da47-4255-a900-68f9eb68e94f
|
|
|
|
# The apiPrefix should be '/chat-client/chat' based on chat.html template
|
|
chat_template_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/templates/chat.html")
|
|
|
|
with open(chat_template_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Check that apiPrefix is set correctly in chat.html
|
|
if 'apiPrefix: \'{{ request.headers.get("X-Forwarded-Prefix", "") }}/chat\'' in content:
|
|
print("✅ apiPrefix correctly configured in chat.html template")
|
|
print(" Expected format: /chat-client/chat/api/task_progress/{task_id}")
|
|
else:
|
|
print("❌ apiPrefix not correctly configured in chat.html template")
|
|
return False
|
|
|
|
return True
|
|
|
|
def test_component_integration():
|
|
"""Test that all components are properly integrated"""
|
|
|
|
print("\n🔍 Testing component integration...")
|
|
|
|
# Test that ChatInput imports ChatMessage
|
|
chatinput_path = Path("/Volumes/OWC4M2_1/Development/Josako/EveAI/TBD/eveai_chat_client/static/assets/vue-components/ChatInput.vue")
|
|
|
|
with open(chatinput_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
if "import ChatMessage from './ChatMessage.vue';" in content:
|
|
print("✅ ChatInput imports ChatMessage")
|
|
else:
|
|
print("❌ ChatInput does not import ChatMessage")
|
|
return False
|
|
|
|
if "'chat-message': ChatMessage" in content:
|
|
print("✅ ChatInput registers ChatMessage component")
|
|
else:
|
|
print("❌ ChatInput does not register ChatMessage component")
|
|
return False
|
|
|
|
return True
|
|
|
|
def main():
|
|
"""Run all tests"""
|
|
|
|
print("🚀 Starting SSE Stream Fix Tests")
|
|
print("=" * 60)
|
|
|
|
tests = [
|
|
("API Prefix Prop Flow", test_api_prefix_prop_flow),
|
|
("ProgressTracker SSE URL Construction", test_progress_tracker_sse_url_construction),
|
|
("ChatMessage Prop Passing", test_chatmessage_prop_passing),
|
|
("Backwards Compatibility", test_backwards_compatibility),
|
|
("Expected URL Format", test_expected_url_format),
|
|
("Component Integration", test_component_integration)
|
|
]
|
|
|
|
passed = 0
|
|
total = len(tests)
|
|
|
|
for test_name, test_func in tests:
|
|
try:
|
|
if test_func():
|
|
passed += 1
|
|
print(f"✅ {test_name} - PASSED")
|
|
else:
|
|
print(f"❌ {test_name} - FAILED")
|
|
except Exception as e:
|
|
print(f"❌ {test_name} - ERROR: {e}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print(f"📊 Test Results: {passed}/{total} tests passed")
|
|
|
|
if passed == total:
|
|
print("🎉 All tests passed! SSE stream fix is working correctly.")
|
|
print("\n📋 Fix Summary:")
|
|
print("• apiPrefix now flows correctly: ChatApp → ChatInput → ChatMessage → ProgressTracker")
|
|
print("• ProgressTracker will construct correct SSE URLs with /chat-client/chat prefix")
|
|
print("• Both MessageHistory sticky area and ChatInput active area work properly")
|
|
print("• No more 404 errors expected for task progress endpoints")
|
|
print("\n🔧 Changes Made:")
|
|
print("• Added :api-prefix=\"apiPrefix\" prop to ChatInput in ChatApp.vue")
|
|
print("• ChatInput already had correct apiPrefix prop definition and passing")
|
|
print("• All components in the chain now receive the apiPrefix correctly")
|
|
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) |