Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,31 +961,31 @@ def run_fallback_report() -> TestResult:
"file_upload",
["tests/test_file_upload_comprehensive.py"],
"Running comprehensive file upload testing suite",
"file_upload"
"file_upload",
)

NEW_SUITES.add_test(
"error_boundary",
"error_boundary",
["tests/test_error_boundary_comprehensive.py"],
"Running comprehensive error boundary testing suite",
"error_boundary"
"error_boundary",
)

NEW_SUITES.add_test(
"visualization",
["tests/test_visualization_pipeline_comprehensive.py"],
["tests/test_visualization_pipeline_comprehensive.py"],
"Running comprehensive visualization pipeline testing suite",
"visualization"
"visualization",
)

NEW_SUITES.add_test(
"all_new_suites",
[
"tests/test_file_upload_comprehensive.py",
"tests/test_error_boundary_comprehensive.py",
"tests/test_visualization_pipeline_comprehensive.py"
"tests/test_error_boundary_comprehensive.py",
"tests/test_visualization_pipeline_comprehensive.py",
],
"Running all new comprehensive testing suites"
"Running all new comprehensive testing suites",
)

# Update the TEST_CATEGORIES to include process mining, UI tests, and new suites
Expand Down Expand Up @@ -1286,7 +1286,9 @@ def main():
"--process-mining-all", action="store_true", help="Run all process mining tests"
)
parser.add_argument("--ui-all", action="store_true", help="Run all UI tests")
parser.add_argument("--new-suites-all", action="store_true", help="Run all new comprehensive test suites")
parser.add_argument(
"--new-suites-all", action="store_true", help="Run all new comprehensive test suites"
)

# Category specific test options
parser.add_argument(
Expand Down
61 changes: 60 additions & 1 deletion tests/test_app_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@ def load_sample_data(self) -> None:
This helper abstracts the data loading flow, making tests immune to
changes in the data loading implementation.
"""
import time

try:
# Click the Load Sample Data button using its stable key with increased timeout
self.at.button(key="load_sample_data_button").click().run(timeout=10)
self.at.button(key="load_sample_data_button").click().run(timeout=15)

# Wait for data loading to complete by checking session state
max_retries = 5
for attempt in range(max_retries):
if (
hasattr(self.at.session_state, "events_data")
and self.at.session_state.events_data is not None
and len(self.at.session_state.events_data) > 0
):
# Data loaded successfully, now wait for event_statistics
break
time.sleep(0.5) # Wait 500ms between retries
if attempt < max_retries - 1: # Don't run on last attempt
self.at.run(timeout=10) # Re-run to refresh state

except Exception as e:
# If button interaction fails, manually load sample data for testing
from datetime import datetime, timedelta
Expand Down Expand Up @@ -67,10 +84,52 @@ def load_sample_data(self) -> None:

self.at.session_state.events_data = pd.DataFrame(data)

# CRITICAL FIX: Calculate event_statistics manually when using fallback
# Import the function from app.py
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from app import get_event_statistics

self.at.session_state.event_statistics = get_event_statistics(
self.at.session_state.events_data
)

# Verify data was loaded by checking session state
assert self.at.session_state.events_data is not None, "Sample data should be loaded"
assert len(self.at.session_state.events_data) > 0, "Sample data should not be empty"

# Wait for event_statistics to be calculated (give it more time)
max_retries = 10
for attempt in range(max_retries):
if (
hasattr(self.at.session_state, "event_statistics")
and len(self.at.session_state.event_statistics) > 0
):
break
time.sleep(0.3) # Wait 300ms between retries
if attempt < max_retries - 1: # Don't run on last attempt
self.at.run(
timeout=10
) # Re-run to refresh state and trigger statistics calculation

# Final verification that event_statistics was calculated
if (
not hasattr(self.at.session_state, "event_statistics")
or len(self.at.session_state.event_statistics) == 0
):
# Last resort: manually calculate if still not present
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from app import get_event_statistics

self.at.session_state.event_statistics = get_event_statistics(
self.at.session_state.events_data
)

def build_funnel(self, steps: List[str]) -> None:
"""
Build a funnel by selecting the specified steps.
Expand Down
Loading