Skip to content

Commit 78d2196

Browse files
Refactor clarification handling and logging in BIABPage; update log_streams usage in conftest.py
1 parent fe406b4 commit 78d2196

2 files changed

Lines changed: 33 additions & 20 deletions

File tree

tests/e2e-test/pages/HomePage.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,14 @@ def approve_retail_task_plan(self):
360360
if clarification_input.is_visible(timeout=5000) and clarification_input.is_enabled():
361361
logger.warning("⚠ Clarification input is enabled - Task plan may require additional clarification")
362362
# Don't raise error - this is expected for some teams like HR
363-
return True # Indicates clarification is needed
364-
logger.info("✓ No clarification required - task completed successfully")
365-
return False # No clarification needed
363+
# Callers should handle clarification as needed
364+
else:
365+
logger.info("✓ No clarification required - task completed successfully")
366366
except (TimeoutError, Exception) as e:
367367
# No clarification input detected, proceed normally
368368
logger.info(f"✓ No clarification input detected - proceeding normally: {e}")
369-
return False
369+
370+
logger.info("Retail task plan approval and processing completed successfully!")
370371

371372
def approve_task_plan(self):
372373
"""Approve the task plan and wait for processing to complete (without clarification check)."""
@@ -468,13 +469,14 @@ def approve_rfp_task_plan(self):
468469
if clarification_input.is_visible(timeout=5000) and clarification_input.is_enabled():
469470
logger.warning("⚠ Clarification input is enabled - RFP Task plan may require additional clarification")
470471
# Don't raise error - this is expected for some workflows
471-
return True # Indicates clarification is needed
472-
logger.info("✓ No clarification required - task completed successfully")
473-
return False # No clarification needed
472+
# Callers should handle clarification as needed
473+
else:
474+
logger.info("✓ No clarification required - task completed successfully")
474475
except (TimeoutError, Exception) as e:
475476
# No clarification input detected, proceed normally
476477
logger.info(f"✓ No clarification input detected - proceeding normally: {e}")
477-
return False
478+
479+
logger.info("RFP task plan approval and processing completed successfully!")
478480

479481
def approve_contract_compliance_task_plan(self):
480482
"""Approve the Contract Compliance task plan and wait for processing to complete."""
@@ -500,13 +502,14 @@ def approve_contract_compliance_task_plan(self):
500502
if clarification_input.is_visible(timeout=5000) and clarification_input.is_enabled():
501503
logger.warning("⚠ Clarification input is enabled - Contract Compliance Task plan may require additional clarification")
502504
# Don't raise error - this is expected for some workflows
503-
return True # Indicates clarification is needed
504-
logger.info("✓ No clarification required - task completed successfully")
505-
return False # No clarification needed
505+
# Callers should handle clarification as needed
506+
else:
507+
logger.info("✓ No clarification required - task completed successfully")
506508
except (TimeoutError, Exception) as e:
507509
# No clarification input detected, proceed normally
508510
logger.info(f"✓ No clarification input detected - proceeding normally: {e}")
509-
return False
511+
512+
logger.info("Contract Compliance task plan approval and processing completed successfully!")
510513

511514
def validate_retail_customer_response(self):
512515
"""Validate the retail customer response."""
@@ -888,14 +891,21 @@ def validate_rai_error_message(self):
888891
continue
889892

890893
if not error_found:
891-
# Check if plan creation didn't start (another valid rejection state)
894+
# Try to confirm plan creation started (to rule out silent acceptance)
895+
# Wait briefly to see if plan creation becomes visible
892896
try:
893-
if not self.page.locator(self.CREATING_PLAN).is_visible(timeout=2000):
894-
logger.warning("⚠ No explicit error message, but plan creation didn't start - input may have been silently rejected or truncated")
897+
# If plan creation becomes visible, the input was accepted (not blocked by RAI)
898+
if self.page.locator(self.CREATING_PLAN).is_visible(timeout=3000):
899+
logger.error("✗ Plan creation started - RAI did not block the prompt as expected")
900+
error_found = False # This is actually a failure case
901+
else:
902+
# Plan creation didn't start within timeout - likely rejected
903+
logger.info("✓ Plan creation did not start - input appears to have been rejected")
895904
error_found = True
896905
except Exception as e:
897-
# Ignore failures in this secondary check, but log for troubleshooting
898-
logger.debug("Failed to verify CREATING_PLAN visibility while checking for RAI rejection state: %s", e)
906+
# If we can't determine, treat as ambiguous but log it
907+
logger.warning("⚠ Could not verify CREATING_PLAN state: %s - assuming rejection", e)
908+
error_found = True
899909

900910
if not error_found:
901911
logger.error("✗ No RAI error or rejection state detected; prompt appears to have been accepted unexpectedly")

tests/e2e-test/tests/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ def pytest_runtest_makereport(item, call):
255255

256256
logging.info("Debug screenshot attached to report: %s", debug_screenshot_path)
257257

258-
handler, stream = log_streams.get(item.nodeid, (None, None))
258+
# Retrieve handler and stream using item id (not nodeid)
259+
# This works even if the test mutated node._nodeid during execution
260+
log_data = log_streams.get(id(item), (None, None, None))
261+
handler, stream, original_nodeid = log_data[0], log_data[1], log_data[2] if len(log_data) == 3 else None
259262

260263
if handler and stream:
261264
# Make sure logs are flushed
@@ -305,8 +308,8 @@ def pytest_runtest_makereport(item, call):
305308
else:
306309
report.description = f"<pre>{log_output.strip()}</pre>"
307310

308-
# Clean up references
309-
log_streams.pop(item.nodeid, None)
311+
# Clean up references using item id (not nodeid)
312+
log_streams.pop(id(item), None)
310313
else:
311314
report.description = ""
312315

0 commit comments

Comments
 (0)