MCPcopy
hub / github.com/reflex-dev/reflex / test_on_drop

Function test_on_drop

tests/integration/test_upload.py:1086–1128  ·  view source on GitHub ↗

Test the on_drop event handler. Args: tmp_path: pytest tmp_path fixture upload_file: harness for UploadFile app. driver: WebDriver instance.

(
    tmp_path,
    upload_file: AppHarness,
    driver: WebDriver,
)

Source from the content-addressed store, hash-verified

1084
1085
1086def test_on_drop(
1087 tmp_path,
1088 upload_file: AppHarness,
1089 driver: WebDriver,
1090):
1091 """Test the on_drop event handler.
1092
1093 Args:
1094 tmp_path: pytest tmp_path fixture
1095 upload_file: harness for UploadFile app.
1096 driver: WebDriver instance.
1097 """
1098 assert upload_file.app_instance is not None
1099 poll_for_token(driver, upload_file)
1100 clear_btn = driver.find_element(By.ID, "clear_uploads")
1101 clear_btn.click()
1102
1103 upload_box = get_upload_box(driver, upload_root_id="quaternary")
1104 assert upload_box
1105
1106 exp_name = "drop_test.txt"
1107 exp_contents = "dropped file contents!"
1108 target_file = tmp_path / exp_name
1109 target_file.write_text(exp_contents)
1110
1111 # Simulate file drop by directly setting the file input
1112 upload_box.send_keys(str(target_file))
1113
1114 # Wait for the upload to complete.
1115 upload_done = driver.find_element(By.ID, "upload_done")
1116 assert upload_file.poll_for_value(upload_done, exp_not_equal="false") == "true"
1117
1118 def exp_name_in_quaternary():
1119 quaternary_files = driver.find_element(By.ID, "quaternary_files").text
1120 if quaternary_files:
1121 files = json.loads(quaternary_files)
1122 return exp_name in files
1123 return False
1124
1125 # Poll until the file names appear in the display
1126 AppHarness._poll_for(exp_name_in_quaternary)
1127
1128 assert exp_name_in_quaternary()

Callers

nothing calls this directly

Calls 5

get_upload_boxFunction · 0.85
exp_name_in_quaternaryFunction · 0.85
poll_for_valueMethod · 0.80
_poll_forMethod · 0.80
poll_for_tokenFunction · 0.70

Tested by

no test coverage detected