@@ -1095,27 +1095,26 @@ def test_pdf_generation_workflow(self, driver, base_config_with_album, caplog):
10951095 pdf_save_button .click ()
10961096 logger .info ("Clicked PDF save button" )
10971097
1098- # Step 7: Wait for PDF generation
1099- # The PDF is now created in a temporary file, but we mock tempfile.mkstemp
1100- # to create it in the library folder so we can check for it
1101- library_path = server_info ["library_path" ]
1102- pdf_file = library_path / "print.pdf"
1098+ # Step 7: Wait for PDF to be downloaded by the browser
1099+ # Check the browser's download directory for the PDF file
1100+ download_dir = driver .download_dir
1101+ expected_pdf = download_dir / "print.pdf"
11031102
1104- pdf_created = False
1103+ pdf_downloaded = False
11051104 max_wait = 30 # seconds
11061105 start_time = time .time ()
11071106
11081107 while time .time () - start_time < max_wait :
1109- if pdf_file .exists () and pdf_file .stat ().st_size > 0 :
1110- pdf_created = True
1111- logger .info (f"PDF file created at { pdf_file } " )
1108+ if expected_pdf .exists () and expected_pdf .stat ().st_size > 0 :
1109+ pdf_downloaded = True
1110+ logger .info (f"PDF file downloaded to { expected_pdf } " )
11121111 break
11131112 time .sleep (1 )
11141113
11151114 # Read and log the server output for debugging
1116- if not pdf_created :
1115+ if not pdf_downloaded :
11171116 logger .error ("=" * 80 )
1118- logger .error ("PDF WAS NOT CREATED - DUMPING SERVER LOGS" )
1117+ logger .error ("PDF WAS NOT DOWNLOADED - DUMPING SERVER LOGS" )
11191118 logger .error ("=" * 80 )
11201119
11211120 if server_info .get ("log_file" ) and server_info ["log_file" ].exists ():
@@ -1130,16 +1129,23 @@ def test_pdf_generation_workflow(self, driver, base_config_with_album, caplog):
11301129 else :
11311130 logger .error ("No server stderr log file found" )
11321131
1132+ # Also check what files exist in the download directory
1133+ if download_dir .exists ():
1134+ files_in_download_dir = list (download_dir .iterdir ())
1135+ logger .error (
1136+ f"Files in download directory: { files_in_download_dir } "
1137+ )
1138+ else :
1139+ logger .error ("Download directory does not exist" )
1140+
11331141 logger .error ("=" * 80 )
11341142
11351143 assert (
1136- pdf_created
1137- ), f"PDF file not created within { max_wait } seconds at { pdf_file } "
1144+ pdf_downloaded
1145+ ), f"PDF file not downloaded within { max_wait } seconds to { expected_pdf } "
11381146
1139- # The PDF should have been downloaded to the browser's download location
1140- # In a real test, we'd check the browser's download directory
1141- # For CI, we just verify the file was created and is valid
1142- logger .info ("PDF generation workflow completed successfully" )
1147+ # Verify the downloaded PDF has valid content
1148+ logger .info ("PDF generation and download workflow completed successfully" )
11431149
11441150 except NoSuchElementException :
11451151 # If chromium is not available, the PDF save button won't be present
0 commit comments