From bdbbe8c333b4f585f8ad7be8baf05877d4142b90 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Wed, 31 Jul 2019 15:53:29 -0700 Subject: [PATCH] Update functional tests for submit buttons We are no longer changing icon hover state, so it's not useful to continue to test for it. --- .../functional/source_navigation_steps.py | 59 +++---------------- 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/securedrop/tests/functional/source_navigation_steps.py b/securedrop/tests/functional/source_navigation_steps.py index ad712138b92..f6d1ed88cd5 100644 --- a/securedrop/tests/functional/source_navigation_steps.py +++ b/securedrop/tests/functional/source_navigation_steps.py @@ -2,8 +2,6 @@ import time import json -from selenium.webdriver.common.action_chains import ActionChains - class SourceNavigationStepsMixin: def _is_on_source_homepage(self): @@ -15,6 +13,9 @@ def _is_logged_in(self): def _is_on_lookup_page(self): return self.wait_for(lambda: self.driver.find_element_by_id("upload")) + def _is_on_generate_page(self): + return self.wait_for(lambda: self.driver.find_element_by_id("create-form")) + def _source_visits_source_homepage(self): self.driver.get(self.source_location) assert self._is_on_source_homepage() @@ -27,31 +28,14 @@ def _source_checks_instance_metadata(self): assert j["gpg_fpr"] != "" def _source_clicks_submit_documents_on_homepage(self): - # First move the cursor to a known position in case it happens to - # be hovering over one of the buttons we are testing below. - header_image = self.driver.find_element_by_css_selector(".header") - ActionChains(self.driver).move_to_element(header_image).perform() # It's the source's first time visiting this SecureDrop site, so they # choose to "Submit Documents". - submit_button = self.driver.find_element_by_id("submit-documents-button") - - submit_button_icon = self.driver.find_element_by_css_selector( - "a#submit-documents-button > img.off-hover" - ) - self.wait_for(lambda: submit_button_icon.is_displayed()) + self.safe_click_by_id("submit-documents-button") - # The source hovers their cursor over the button, and the visual style - # of the button changes to encourage them to click it. - ActionChains(self.driver).move_to_element(submit_button).perform() - - # Let's make sure toggling the icon image with the hover state is working. - hovered_icon_selector = "a#submit-documents-button > img.on-hover" - submit_button_hover_icon = self.driver.find_element_by_css_selector(hovered_icon_selector) - self.wait_for(lambda: submit_button_hover_icon.is_displayed()) - - # The source clicks the submit button. - submit_button.click() + # The source should now be on the page where they are presented with + # a diceware codename they can use for subsequent logins + assert self._is_on_generate_page() def _source_chooses_to_submit_documents(self): self._source_clicks_submit_documents_on_homepage() @@ -120,24 +104,7 @@ def _source_hits_cancel_at_submit_page(self): assert "Submit Files or Messages" == headline.text def _source_continues_to_submit_page(self): - continue_button = self.driver.find_element_by_id("continue-button") - - continue_button_icon = self.driver.find_element_by_css_selector( - "button#continue-button > img.off-hover" - ) - assert continue_button_icon.is_displayed() - - # Hover over the continue button test toggle the icon images - # with the hover state. - ActionChains(self.driver).move_to_element(continue_button).perform() - assert continue_button_icon.is_displayed() is False - - continue_button_hover_icon = self.driver.find_element_by_css_selector( - "button#continue-button img.on-hover" - ) - assert continue_button_hover_icon.is_displayed() - - continue_button.click() + self.safe_click_by_id("continue-button") def submit_page_loaded(): if not hasattr(self, "accept_languages"): @@ -155,15 +122,7 @@ def _source_submits_a_file(self): self.safe_send_keys_by_css_selector("[name=fh]", filename) - submit_button = self.driver.find_element_by_id("submit-doc-button") - ActionChains(self.driver).move_to_element(submit_button).perform() - - toggled_submit_button_icon = self.driver.find_element_by_css_selector( - "button#submit-doc-button img.on-hover" - ) - assert toggled_submit_button_icon.is_displayed() - - submit_button.click() + self.safe_click_by_id("submit-doc-button") self.wait_for_source_key(self.source_name) def file_submitted():