Upload via an on_drop handler bound with an extra arg and verify it arrives. Regression test for https://github.com/reflex-dev/reflex/issues/5290: extra args bound to an upload handler must reach the backend handler, not just the compiled event spec. Args: tmp_path: pytest
(
tmp_path, upload_file: AppHarness, driver: WebDriver
)
| 682 | |
| 683 | |
| 684 | def test_upload_file_with_bound_arg( |
| 685 | tmp_path, upload_file: AppHarness, driver: WebDriver |
| 686 | ): |
| 687 | """Upload via an on_drop handler bound with an extra arg and verify it arrives. |
| 688 | |
| 689 | Regression test for https://github.com/reflex-dev/reflex/issues/5290: extra |
| 690 | args bound to an upload handler must reach the backend handler, not just the |
| 691 | compiled event spec. |
| 692 | |
| 693 | Args: |
| 694 | tmp_path: pytest tmp_path fixture. |
| 695 | upload_file: harness for UploadFile app. |
| 696 | driver: WebDriver instance. |
| 697 | """ |
| 698 | assert upload_file.app_instance is not None |
| 699 | poll_for_token(driver, upload_file) |
| 700 | clear_btn = driver.find_element(By.ID, "clear_uploads") |
| 701 | clear_btn.click() |
| 702 | |
| 703 | upload_box = get_upload_box(driver, upload_root_id="quaternary") |
| 704 | assert upload_box |
| 705 | |
| 706 | exp_name = "bound_arg.txt" |
| 707 | target_file = tmp_path / exp_name |
| 708 | target_file.write_text("bound arg upload contents!") |
| 709 | |
| 710 | # Selecting a file fires on_drop, which carries the bound "resume-field" arg. |
| 711 | upload_box.send_keys(str(target_file)) |
| 712 | |
| 713 | upload_done = driver.find_element(By.ID, "upload_done") |
| 714 | assert upload_file.poll_for_value(upload_done, exp_not_equal="false") == "true" |
| 715 | |
| 716 | # The bound arg must have reached the handler. |
| 717 | field_display = driver.find_element(By.ID, "quaternary_field") |
| 718 | assert upload_file.poll_for_value(field_display, exp_not_equal="") == "resume-field" |
| 719 | |
| 720 | # The uploaded file itself must still arrive. |
| 721 | names_display = driver.find_element(By.ID, "quaternary_files") |
| 722 | assert Path(exp_name).name in names_display.text |
| 723 | |
| 724 | |
| 725 | @pytest.mark.parametrize("upload_root_id", [None, "secondary"]) |
nothing calls this directly
no test coverage detected