Skip to content

Commit

Permalink
Update functional tests for submit buttons
Browse files Browse the repository at this point in the history
We are no longer changing icon hover state, so it's not useful to
continue to test for it.
  • Loading branch information
eloquence committed Aug 1, 2019
1 parent 3b07163 commit bdbbe8c
Showing 1 changed file with 9 additions and 50 deletions.
59 changes: 9 additions & 50 deletions securedrop/tests/functional/source_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import time
import json

from selenium.webdriver.common.action_chains import ActionChains


class SourceNavigationStepsMixin:
def _is_on_source_homepage(self):
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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"):
Expand All @@ -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():
Expand Down

0 comments on commit bdbbe8c

Please sign in to comment.