Files
TimeTracker/docker/test-routing.py
Dries Peeters d230a41e8a feat: enhance web interface layout and fix logo import circular dependency
- Improve web interface layout for better user-friendliness and mobile responsiveness
  * Update CSS variables for consistent spacing and component sizing
  * Enhance card layouts with improved padding, borders, and shadows
  * Optimize button and form element dimensions for better touch targets
  * Add hover effects and animations for improved user interaction
  * Implement responsive grid system with mobile-first approach

- Refactor mobile JavaScript to prevent duplicate initialization
  * Consolidate mobile enhancements into dedicated utility classes
  * Add initialization guards to prevent double loading
  * Implement MobileUtils and MobileNavigation classes
  * Remove duplicate event listeners and mobile enhancements

- Fix circular import issue in logo handling
  * Replace problematic 'from app import app' with Flask's current_app
  * Add error handling for cases where current_app is unavailable
  * Improve logo path resolution with fallback mechanisms
  * Fix settings model to use proper Flask context

- Clean up template code and remove duplication
  * Remove duplicate mobile enhancements from base template
  * Clean up dashboard template JavaScript
  * Centralize all mobile functionality in mobile.js
  * Add proper error handling and debugging

- Update CSS variables and spacing system
  * Introduce --section-spacing and --card-spacing variables
  * Add mobile-specific spacing variables
  * Improve border-radius and shadow consistency
  * Enhance typography and visual hierarchy

This commit resolves the double loading issue and logo import errors while
significantly improving the overall user experience and mobile responsiveness
of the web interface.
2025-08-30 10:09:06 +02:00

140 lines
4.3 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify invoice routing is working
Run this to check if all invoice endpoints are accessible
"""
import os
import sys
# Add the app directory to the Python path
sys.path.insert(0, '/app')
def test_imports():
"""Test if all required modules can be imported"""
try:
from app import create_app
from app.routes.invoices import invoices_bp
print("✓ All imports successful")
return True
except Exception as e:
print(f"✗ Import failed: {e}")
return False
def test_blueprint_routes():
"""Test if the blueprint has all required routes"""
try:
from app.routes.invoices import invoices_bp
# Check if the blueprint has the required routes
required_routes = [
'list_invoices',
'create_invoice',
'view_invoice',
'edit_invoice',
'update_invoice_status',
'delete_invoice',
'generate_from_time',
'export_invoice_csv',
'export_invoice_pdf',
'duplicate_invoice'
]
print("\nChecking blueprint routes:")
all_routes_ok = True
# Get the actual view functions from the blueprint
view_functions = invoices_bp.view_functions
for route_name in required_routes:
if route_name in view_functions:
print(f"{route_name}")
else:
print(f"{route_name}")
all_routes_ok = False
return all_routes_ok
except Exception as e:
print(f"✗ Route check failed: {e}")
return False
def test_url_generation():
"""Test if URLs can be generated for all routes"""
try:
from app import create_app
from app.routes.invoices import invoices_bp
# Create a test app context
app = create_app()
with app.app_context():
from flask import url_for
# Test URL generation for key routes
test_urls = [
('invoices.list_invoices', {}),
('invoices.create_invoice', {}),
('invoices.view_invoice', {'invoice_id': 1}),
('invoices.edit_invoice', {'invoice_id': 1}),
('invoices.update_invoice_status', {'invoice_id': 1}),
('invoices.delete_invoice', {'invoice_id': 1}),
('invoices.generate_from_time', {'invoice_id': 1}),
('invoices.export_invoice_csv', {'invoice_id': 1}),
('invoices.export_invoice_pdf', {'invoice_id': 1}),
('invoices.duplicate_invoice', {'invoice_id': 1})
]
print("\nTesting URL generation:")
all_urls_ok = True
for endpoint, values in test_urls:
try:
url = url_for(endpoint, **values)
print(f"{endpoint}: {url}")
except Exception as e:
print(f"{endpoint}: {e}")
all_urls_ok = False
return all_urls_ok
except Exception as e:
print(f"✗ URL generation test failed: {e}")
return False
def main():
print("=== Invoice Routing Test ===")
# Test imports
if not test_imports():
print("\n✗ Import test failed - cannot continue")
return
# Test blueprint routes
routes_ok = test_blueprint_routes()
# Test URL generation
urls_ok = test_url_generation()
# Summary
print("\n=== Summary ===")
if routes_ok and urls_ok:
print("✓ All invoice routing tests passed")
print("✓ Application should work correctly")
else:
print("⚠ Some routing tests failed")
print("⚠ Check the errors above")
print("\n=== Recommendations ===")
if not routes_ok:
print("1. Check blueprint route definitions")
print("2. Verify function names match route names")
if not urls_ok:
print("1. Check URL generation in templates")
print("2. Verify endpoint names in url_for() calls")
print("3. Check if all required parameters are provided")
if __name__ == '__main__':
main()