Files
eveAI/test_tabulator_fix.py
Josako acad28b623 - Introduction of eveai-listview (to select objects) that is sortable, filterable, ...
- npm build does now also include building css files.
- Source javascript and css are now defined in the source directories (eveai_app or eveai_chat_client), and automatically built for use with nginx
- eveai.css is now split into several more manageable files (per control type)
2025-07-11 15:25:28 +02:00

160 lines
5.5 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify that the Tabulator library is properly loaded and the table displays correctly.
This script will test the specialists view to ensure the table formatting is fixed.
"""
import sys
import os
import json
# Add the project root to the Python path
project_root = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, project_root)
def test_tabulator_library_inclusion():
"""Test that Tabulator library is included in the templates."""
# Check head.html for Tabulator CSS
head_file = os.path.join(project_root, 'eveai_app/templates/head.html')
with open(head_file, 'r') as f:
head_content = f.read()
if 'tabulator' in head_content.lower():
print("✓ Tabulator CSS found in head.html")
else:
print("✗ Tabulator CSS not found in head.html")
return False
# Check scripts.html for Tabulator JavaScript
scripts_file = os.path.join(project_root, 'eveai_app/templates/scripts.html')
with open(scripts_file, 'r') as f:
scripts_content = f.read()
if 'tabulator' in scripts_content.lower():
print("✓ Tabulator JavaScript found in scripts.html")
else:
print("✗ Tabulator JavaScript not found in scripts.html")
return False
return True
def test_list_view_template():
"""Test that the list view template has proper column configuration."""
list_view_file = os.path.join(project_root, 'eveai_app/templates/eveai_list_view.html')
with open(list_view_file, 'r') as f:
template_content = f.read()
# Check for key Tabulator configuration elements
required_elements = [
'_buildColumns',
'new Tabulator',
'layout: "fitColumns"',
'columns:',
'data:'
]
for element in required_elements:
if element in template_content:
print(f"✓ Found required element: {element}")
else:
print(f"✗ Missing required element: {element}")
return False
return True
def test_specialists_template():
"""Test that the specialists template properly initializes the list view."""
specialists_file = os.path.join(project_root, 'eveai_app/templates/interaction/specialists.html')
with open(specialists_file, 'r') as f:
template_content = f.read()
# Check for proper initialization
required_elements = [
'EveAI.ListView.initialize',
'specialists-list-view',
'data: {{ specialists_data | tojson }}',
'columns: {{ columns | tojson }}',
'selectable: true'
]
for element in required_elements:
if element in template_content:
print(f"✓ Found required element: {element}")
else:
print(f"✗ Missing required element: {element}")
return False
return True
def test_column_configuration():
"""Test that the column configuration in the view is correct."""
try:
# Import the view function
from eveai_app.views.interaction_views import specialists
# Test the column configuration structure
sample_columns = [
{'title': 'ID', 'field': 'id', 'type': 'number', 'width': 80},
{'title': 'Name', 'field': 'name', 'type': 'text', 'dynamicValues': True},
{'title': 'Type', 'field': 'type', 'type': 'text', 'dynamicValues': True},
{'title': 'Type Version', 'field': 'type_version', 'type': 'text'},
{'title': 'Active', 'field': 'active', 'type': 'boolean', 'formatter': 'tickCross'}
]
# Validate column structure
for i, column in enumerate(sample_columns):
if 'title' in column and 'field' in column:
print(f"✓ Column {i+1} ({column['title']}) has required title and field")
else:
print(f"✗ Column {i+1} missing title or field")
return False
print("✓ Column configuration structure is correct")
return True
except Exception as e:
print(f"✗ Error testing column configuration: {e}")
return False
def main():
"""Run all tests."""
print("Testing Tabulator table formatting fix...")
print("=" * 50)
# Test Tabulator library inclusion
print("\n1. Testing Tabulator library inclusion...")
tabulator_test_passed = test_tabulator_library_inclusion()
# Test list view template
print("\n2. Testing list view template...")
list_view_test_passed = test_list_view_template()
# Test specialists template
print("\n3. Testing specialists template...")
specialists_test_passed = test_specialists_template()
# Test column configuration
print("\n4. Testing column configuration...")
column_test_passed = test_column_configuration()
# Summary
print("\n" + "=" * 50)
if all([tabulator_test_passed, list_view_test_passed, specialists_test_passed, column_test_passed]):
print("✓ All tests passed! The table formatting should now work correctly.")
print("\nThe table should now display with proper columns:")
print("- ID column (80px width)")
print("- Name column (with dynamic filtering)")
print("- Type column (with dynamic filtering)")
print("- Type Version column")
print("- Active column (with tick/cross formatter)")
return 0
else:
print("✗ Some tests failed. Please check the implementation.")
return 1
if __name__ == "__main__":
sys.exit(main())