function test_web_ui
Integration test function that validates a Flask web UI for meeting minutes generation by testing file upload, generation, and regeneration endpoints with sample transcript and PowerPoint files.
/tf/active/vicechatdev/leexi/test_ui.py
13 - 110
moderate
Purpose
This function performs end-to-end testing of a web-based meeting minutes generation service. It verifies server health, uploads test files (transcript and PowerPoint), generates meeting minutes using specified AI models and instructions, and tests the regeneration feature with modified instructions. The function provides detailed console feedback about each step's success or failure, making it useful for development, CI/CD pipelines, and manual testing scenarios.
Source Code
def test_web_ui():
"""Test the web UI with sample files"""
base_url = "http://localhost:5000"
# Check if server is running
try:
response = requests.get(f"{base_url}/health")
if response.status_code == 200:
print("โ
Server is running")
else:
print("โ Server health check failed")
return
except requests.exceptions.ConnectionError:
print("โ Cannot connect to server. Make sure Flask app is running.")
return
# Prepare test data
test_files = {
'transcript': 'leexi-20250618-transcript-development_team_meeting.md',
'powerpoint': '2025 06 18 Development Team meeting.pptx'
}
# Check if test files exist
missing_files = []
for file_type, filename in test_files.items():
if not Path(filename).exists():
missing_files.append(filename)
if missing_files:
print(f"โ Missing test files: {missing_files}")
print("Please ensure these files are in the current directory")
return
print("๐งช Testing web UI with sample data...")
# Prepare form data
data = {
'meeting_title': 'Demo Meeting - Web UI Test',
'model': 'gpt-4o',
'user_instructions': 'Focus on action items and technical decisions. Use pharmaceutical industry terminology.'
}
# Prepare files
files = {}
if Path(test_files['transcript']).exists():
files['transcript'] = open(test_files['transcript'], 'rb')
if Path(test_files['powerpoint']).exists():
files['powerpoint'] = open(test_files['powerpoint'], 'rb')
try:
print("๐ค Sending request to generate meeting minutes...")
response = requests.post(f"{base_url}/generate", data=data, files=files)
if response.status_code == 200:
result = response.json()
if result.get('success'):
print("โ
Meeting minutes generated successfully!")
print(f"๐ Report saved to: {result.get('report_path')}")
print(f"๐ Session ID: {result.get('session_id')}")
# Test regeneration
print("\n๐ Testing regeneration with modified instructions...")
regen_data = {
'session_id': result.get('session_id'),
'new_instructions': 'Emphasize regulatory compliance and timeline impacts.',
'new_model': 'gpt-4o'
}
regen_response = requests.post(f"{base_url}/regenerate", data=regen_data)
if regen_response.status_code == 200:
regen_result = regen_response.json()
if regen_result.get('success'):
print("โ
Regeneration successful!")
print(f"๐ New report saved to: {regen_result.get('report_path')}")
else:
print(f"โ Regeneration failed: {regen_result.get('error')}")
else:
print(f"โ Regeneration request failed: {regen_response.status_code}")
else:
print(f"โ Generation failed: {result.get('error')}")
else:
print(f"โ Request failed: {response.status_code}")
print(response.text)
except Exception as e:
print(f"โ Error during testing: {str(e)}")
finally:
# Close file handles
for file_handle in files.values():
if hasattr(file_handle, 'close'):
file_handle.close()
print("\n๐ฏ Test completed!")
print(f"๐ Web UI available at: {base_url}")
Return Value
This function does not return any value (implicitly returns None). It outputs test results directly to the console using print statements, indicating success (โ ) or failure (โ) of various test steps including server connectivity, file availability, generation, and regeneration operations.
Dependencies
requestspathlib
Required Imports
import requests
from pathlib import Path
Usage Example
# Ensure Flask server is running first
# Place required test files in current directory:
# - leexi-20250618-transcript-development_team_meeting.md
# - 2025 06 18 Development Team meeting.pptx
import requests
from pathlib import Path
# Run the test
test_web_ui()
# Expected output:
# โ
Server is running
# ๐งช Testing web UI with sample data...
# ๐ค Sending request to generate meeting minutes...
# โ
Meeting minutes generated successfully!
# ๐ Report saved to: [path]
# ๐ Session ID: [id]
# ๐ Testing regeneration with modified instructions...
# โ
Regeneration successful!
# ๐ New report saved to: [path]
# ๐ฏ Test completed!
# ๐ Web UI available at: http://localhost:5000
Best Practices
- Ensure the Flask server is running before executing this test function
- Place the required test files in the current working directory before running
- The function properly closes file handles in a finally block to prevent resource leaks
- Server health check is performed first to fail fast if the service is unavailable
- File existence is validated before attempting uploads to provide clear error messages
- The function tests both initial generation and regeneration workflows for comprehensive coverage
- Consider parameterizing the base_url, test files, and model selection for more flexible testing
- In production testing, consider adding timeout parameters to requests to prevent hanging
- The function uses emoji indicators for easy visual parsing of test results in console output
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function generate_minutes 70.6% similar
-
function test_multiple_file_upload 67.2% similar
-
function regenerate_minutes 62.2% similar
-
function test_upload_modalities 60.1% similar
-
function test_frontend_files 60.0% similar