Skip to content

Commit

Permalink
Add change test
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Nov 1, 2024
1 parent cf9234b commit e22bdf1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions s3file/static/s3file/js/s3file.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export class S3FileInput extends globalThis.HTMLInputElement {
changeHandler () {
this.keys = []
this.upload = null
try {
this.form.removeEventListener('submit', this.submitHandler.bind(this))
} catch (error) {
console.debug(error)
}
this.form.addEventListener('submit', this.submitHandler.bind(this), { once: true })
}

/**
Expand Down
22 changes: 13 additions & 9 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,6 @@ def test_file_update(
def test_file_insert_submit_value(
self, driver, live_server, upload_file, freeze_upload_folder
):
driver.get(live_server + self.create_url)
file_input = driver.find_element(By.XPATH, "//input[@name='file']")
file_input.send_keys(upload_file)
assert file_input.get_attribute("name") == "file"
save_button = driver.find_element(By.XPATH, "//input[@name='save']")
with wait_for_page_load(driver, timeout=10):
save_button.click()
assert "save" in driver.page_source

driver.get(live_server + self.create_url)
file_input = driver.find_element(By.XPATH, "//input[@name='file']")
file_input.send_keys(upload_file)
Expand All @@ -266,6 +257,19 @@ def test_file_insert_submit_formaction(
assert "foo" in driver.page_source
assert "bar" in driver.page_source

@pytest.mark.selenium
def test_file_insert_change_event(
self, driver, live_server, upload_file, another_upload_file, freeze_upload_folder
):
driver.get(live_server + self.create_url)
file_input = driver.find_element(By.XPATH, "//input[@name='file']")
file_input.send_keys(upload_file)
file_input.send_keys(another_upload_file)
save_button = driver.find_element(By.CSS_SELECTOR, "input[name=save]")
with wait_for_page_load(driver, timeout=10):
save_button.click()
assert "save" in driver.page_source

@pytest.mark.selenium
def test_multi_file(
self,
Expand Down

0 comments on commit e22bdf1

Please sign in to comment.