Skip to content

Commit

Permalink
fixed tests in functional/test_submit_and_retrieve_file.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zenmonkeykstop committed Jun 10, 2022
1 parent 64e6ac9 commit 459893f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions securedrop/tests/functional/source_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _source_hits_cancel_at_login_page(self):
assert self._is_on_source_homepage()

def _source_proceeds_to_login(self):
self.safe_send_keys_by_id("codename", self.source_name)
self.safe_send_keys_by_id("passphrase", self.source_name)
self.safe_click_by_css_selector(".form-controls button")

# Check that we've logged in
Expand All @@ -109,8 +109,8 @@ def _source_hits_cancel_at_submit_page(self):
self.safe_click_by_css_selector(".form-controls a")

if not self.accept_languages:
heading = self.driver.find_element_by_id("submit-heading")
assert "Submit Files or Messages" == heading.text
heading = self.driver.find_element_by_id("welcome-heading")
assert "Welcome!" == heading.text

def _source_continues_to_submit_page(self, files_allowed=True):
def submit_page_loaded():
Expand All @@ -127,7 +127,7 @@ def uploader_is_visible():
else:
assert not uploader_is_visible()

def _source_submits_a_file(self):
def _source_submits_a_file(self, first_submission=False):
with tempfile.NamedTemporaryFile() as file:
file.write(self.secret_message.encode("utf-8"))
file.seek(0)
Expand All @@ -138,14 +138,21 @@ def _source_submits_a_file(self):

self.safe_click_by_css_selector(".form-controls button")

def file_submitted():
def file_submitted(first_submission=False):
if not self.accept_languages:
notification = self.driver.find_element_by_class_name("success")
expected_notification = "Success!\nThanks! We received your document."
if first_submission:
expected_notification = "Please check back later for replies."
else:
expected_notification = "Success!\nThanks! We received your document."
assert expected_notification in notification.text

# Allow extra time for file uploads
self.wait_for(file_submitted, timeout=(self.timeout * 3))
self.wait_for(lambda: file_submitted(first_submission), timeout=(self.timeout * 3))

if first_submission:
codename = self.driver.find_element_by_css_selector("#codename span")
self.source_name = codename.text

def _source_submits_a_message(
self, verify_notification=False, first_submission=False, first_login=False
Expand All @@ -161,18 +168,15 @@ def message_submitted():
if first_submission:
codename = self.driver.find_element_by_css_selector("#codename span")
self.source_name = codename.text
print("First sub, source is: {}".format(self.source_name))

if verify_notification:
first_submission_text = (
"Please check back later for replies." in notification.text
)

if first_submission:
print("First sub, source is: {}".format(self.source_name))
assert first_submission_text
else:
print("Not first sub, source is whaaat")
assert not first_submission_text

self.wait_for(message_submitted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_submit_and_retrieve_happy_path(self):
self._source_visits_source_homepage()
self._source_chooses_to_submit_documents()
self._source_continues_to_submit_page()
self._source_submits_a_file()
self._source_submits_a_file(first_submission=True)
self._source_logs_out()
try:
self.switch_to_firefox_driver()
Expand Down

0 comments on commit 459893f

Please sign in to comment.