@@ -622,6 +622,9 @@ def test_4094_cwyd_citations_sources_properly_linked(login_logout, request):
622622
623623 # Step 2: Try multiple questions to get one with reference links
624624 test_questions = [
625+ "explain YEHODAYA" ,
626+ "Tell me about india" ,
627+ "explain architecture_pg.png" ,
625628 "What benefits are available to employees (besides health coverage)?" ,
626629 "What are the company benefits available to employees?" ,
627630 "What health coverage options are available?" ,
@@ -1037,74 +1040,68 @@ def test_4473_bug_1744_cwyd_citations_panel_no_crappy_format_shows_table_data(
10371040 ctx .page .wait_for_load_state ("networkidle" )
10381041 logger .info ("[4473] Web page loaded" )
10391042
1040- # Step 2: Ask question about Microsoft share repurchases and dividends
1041- test_question = "Show Microsoft share repurchases and dividends"
1042- logger .info ("[4473] Typing question: %s" , test_question )
1043- ctx .home_page .enter_a_question (test_question )
1044- logger .info ("[4473] Question typed successfully" )
1045-
1046- # Submit the question and wait for response
1047- logger .info ("[4473] Submitting question" )
1048- ctx .home_page .click_send_button ()
1049- logger .info ("[4473] Question submitted" )
1050-
1051- # Wait for response to load
1052- logger .info ("[4473] Waiting for response..." )
1053- ctx .page .wait_for_timeout (15000 ) # Wait longer for AI response
1043+ # Step 2: Try multiple questions to get one with reference links
1044+ test_questions = [
1045+ "Show Microsoft share repurchases and dividends" ,
1046+ "Tell me about india" ,
1047+ "explain architecture_pg.png" ,
1048+ "What options are available to me in terms of health coverage?" ,
1049+ "What benefits are available to employees (besides health coverage)?" ,
1050+ "What are the company benefits available to employees?" ,
1051+ ]
10541052
1055- # Step 3: Check if response has reference links
1056- logger .info ("[4473] Checking if response has reference links" )
1057- has_references = ctx .home_page .has_reference_link ()
1053+ has_references = False
1054+ successful_question = None
10581055
1059- # If no references found, try fallback question
1060- if not has_references :
1061- logger .info (
1062- "[4473] No references found for first question, checking response content"
1063- )
1064- response_text = ctx .home_page .get_last_response_text ()
1056+ for attempt , test_question in enumerate (test_questions , 1 ):
10651057 logger .info (
1066- "[4473] Response text: %s" ,
1067- (
1068- response_text [:100 ] + "..."
1069- if len (response_text ) > 100
1070- else response_text
1071- ),
1058+ "[4473] Attempt %d: Typing question: %s" , attempt , test_question
10721059 )
10731060
1074- # Check if response indicates data not available
1075- if (
1076- "not available" in response_text .lower ()
1077- or "try another query" in response_text .lower ()
1078- ):
1079- logger .info (
1080- "[4473] First question did not return useful data, trying fallback question"
1081- )
1061+ # Clear any previous conversation if this is not the first attempt
1062+ if attempt > 1 :
1063+ logger .info ("[4473] Clearing previous chat for attempt %d" , attempt )
1064+ ctx .home_page .click_clear_chat_icon ()
1065+ ctx .page .wait_for_timeout (2000 )
10821066
1083- # Ask fallback question
1084- fallback_question = (
1085- "What options are available to me in terms of health coverage?"
1086- )
1087- logger .info ("[4473] Typing fallback question: %s" , fallback_question )
1088- ctx .home_page .enter_a_question (fallback_question )
1089- logger .info ("[4473] Fallback question typed successfully" )
1067+ ctx .home_page .enter_a_question (test_question )
1068+ logger .info ("[4473] Question typed successfully" )
10901069
1091- # Submit the fallback question and wait for response
1092- logger .info ("[4473] Submitting fallback question" )
1093- ctx .home_page .click_send_button ()
1094- logger .info ("[4473] Fallback question submitted" )
1070+ # Submit the question and wait for response
1071+ logger .info ("[4473] Submitting question" )
1072+ ctx .home_page .click_send_button ()
1073+ logger .info ("[4473] Question submitted" )
10951074
1096- # Wait for response to load
1097- logger .info ("[4473] Waiting for fallback response..." )
1098- ctx .page .wait_for_timeout (15000 ) # Wait longer for AI response
1075+ # Wait for response to load
1076+ logger .info ("[4473] Waiting for response..." )
1077+ ctx .page .wait_for_timeout (15000 ) # Wait longer for AI response
10991078
1100- # Check if fallback question has references
1101- logger .info ("[4473] Checking if fallback response has reference links" )
1102- has_references = ctx .home_page .has_reference_link ()
1079+ # Check if response has reference links
1080+ logger .info ("[4473] Checking if response has reference links" )
1081+ has_references = ctx .home_page .has_reference_link ()
1082+
1083+ if has_references :
1084+ successful_question = test_question
1085+ logger .info (
1086+ "[4473] SUCCESS: Response contains reference links for question: %s" ,
1087+ test_question ,
1088+ )
1089+ break
1090+ else :
1091+ logger .warning (
1092+ "[4473] Attempt %d: No reference links found for question: %s" ,
1093+ attempt ,
1094+ test_question ,
1095+ )
11031096
1097+ # Assert that we found a question with reference links
11041098 assert (
11051099 has_references
1106- ), "Response should contain reference links for citation testing"
1107- logger .info ("[4473] SUCCESS: Response contains reference links" )
1100+ ), f"None of the test questions generated reference links. Tried: { test_questions } "
1101+ logger .info (
1102+ "[4473] Successfully found question with references: %s" ,
1103+ successful_question ,
1104+ )
11081105
11091106 # Step 4: Look for and click on specific reference link with table data
11101107 logger .info (
0 commit comments