Skip to content

Commit e839a90

Browse files
committed
Fix test compatibility with panel-material-ui < 0.10
- Use hasattr fallback for footer_actions/footer_objects in tests - Disable follow_up_suggestions in edit test to avoid MockLLM exhaustion
1 parent 80d5efb commit e839a90

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

lumen/tests/ai/test_ui.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,7 @@ async def test_edit_on_second_exploration_preserves_first(explorer_ui):
14661466
second one, only the second exploration (sql_2 + spec_2) should be
14671467
removed. The first exploration (sql_1 + spec_1) must remain intact."""
14681468
ui = explorer_ui
1469+
ui.follow_up_suggestions = False
14691470
test_source = ui.context["source"]
14701471
SQLQueryWithTables = make_sql_model([(test_source.name, "test_table")])
14711472

@@ -1673,7 +1674,8 @@ async def test_followup_suggestions_after_query(explorer_ui):
16731674
await asyncio.sleep(0.5)
16741675

16751676
last_msg = ui.interface.objects[-1]
1676-
footer_actions = last_msg.footer_actions or []
1677+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1678+
footer_actions = getattr(last_msg, _attr) or []
16771679
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
16781680
assert len(followup_icons) == 1
16791681
assert followup_icons[0].icon == "lightbulb"
@@ -1708,7 +1710,8 @@ async def test_followup_suggestions_disabled(explorer_ui):
17081710
await asyncio.sleep(0.3)
17091711

17101712
last_msg = ui.interface.objects[-1]
1711-
footer_actions = last_msg.footer_actions or []
1713+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1714+
footer_actions = getattr(last_msg, _attr) or []
17121715
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
17131716
assert len(followup_icons) == 0
17141717

@@ -1719,7 +1722,8 @@ async def test_followup_suggestions_not_on_error(explorer_ui_with_error):
17191722
await asyncio.sleep(0.3)
17201723

17211724
last_msg = ui.interface.objects[-1]
1722-
footer_actions = last_msg.footer_actions or []
1725+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1726+
footer_actions = getattr(last_msg, _attr) or []
17231727
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
17241728
assert len(followup_icons) == 0
17251729

@@ -1758,7 +1762,8 @@ def raise_error():
17581762
# Should not crash, no followup suggestions, but plan succeeded
17591763
assert len(ui._explorations.items) == 2
17601764
last_msg = ui.interface.objects[-1]
1761-
footer_actions = last_msg.footer_actions or []
1765+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1766+
footer_actions = getattr(last_msg, _attr) or []
17621767
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
17631768
assert len(followup_icons) == 0
17641769

@@ -1799,7 +1804,8 @@ async def test_followup_suggestion_click_sends_query(explorer_ui):
17991804

18001805
# Get the follow-up icon button
18011806
last_msg = ui.interface.objects[-1]
1802-
footer_actions = last_msg.footer_actions or []
1807+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1808+
footer_actions = getattr(last_msg, _attr) or []
18031809
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
18041810
assert len(followup_icons) == 1
18051811

@@ -1846,7 +1852,8 @@ async def test_followup_icon_cycles_suggestions(explorer_ui):
18461852
await asyncio.sleep(0.5)
18471853

18481854
last_msg = ui.interface.objects[-1]
1849-
footer_actions = last_msg.footer_actions or []
1855+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1856+
footer_actions = getattr(last_msg, _attr) or []
18501857
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
18511858
assert len(followup_icons) == 1
18521859
icon = followup_icons[0]
@@ -1917,7 +1924,8 @@ async def invoke_with_extra_message(*args, **kwargs):
19171924
# The extra message means num_objects changed, so no FollowUp should appear
19181925
footer_with_followup = []
19191926
for msg in ui.interface.objects:
1920-
footer_actions = msg.footer_actions or []
1927+
_attr = "footer_actions" if hasattr(msg, "footer_actions") else "footer_objects"
1928+
footer_actions = getattr(msg, _attr) or []
19211929
footer_with_followup.extend(
19221930
f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"
19231931
)
@@ -1959,7 +1967,8 @@ async def test_analysis_suggestions_still_use_default_group_name(explorer_ui):
19591967
last_msg = ui.interface.objects[-1]
19601968

19611969
# FollowUp is now in footer_actions (icon button), not footer_objects
1962-
footer_actions = last_msg.footer_actions or []
1970+
_attr = "footer_actions" if hasattr(last_msg, "footer_actions") else "footer_objects"
1971+
footer_actions = getattr(last_msg, _attr) or []
19631972
followup_icons = [f for f in footer_actions if getattr(f, 'name', '') == "FollowUp"]
19641973
assert len(followup_icons) == 1
19651974

0 commit comments

Comments
 (0)