From 459893fe2dc71ac110a1f6613566101fbfa51c9f Mon Sep 17 00:00:00 2001 From: Kevin O'Gorman Date: Thu, 9 Jun 2022 20:00:00 -0400 Subject: [PATCH] fixed tests in functional/test_submit_and_retrieve_file.py --- .../functional/source_navigation_steps.py | 24 +++++++++++-------- .../test_submit_and_retrieve_file.py | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/securedrop/tests/functional/source_navigation_steps.py b/securedrop/tests/functional/source_navigation_steps.py index 1c0cf031a0..09ea671f6a 100644 --- a/securedrop/tests/functional/source_navigation_steps.py +++ b/securedrop/tests/functional/source_navigation_steps.py @@ -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 @@ -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(): @@ -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) @@ -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 @@ -161,7 +168,6 @@ 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 = ( @@ -169,10 +175,8 @@ def message_submitted(): ) 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) diff --git a/securedrop/tests/functional/test_submit_and_retrieve_file.py b/securedrop/tests/functional/test_submit_and_retrieve_file.py index 4bd252aabb..993db7608e 100644 --- a/securedrop/tests/functional/test_submit_and_retrieve_file.py +++ b/securedrop/tests/functional/test_submit_and_retrieve_file.py @@ -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()