Skip to content

Commit

Permalink
Use definite article for single file error case
Browse files Browse the repository at this point in the history
  • Loading branch information
eloquence committed Apr 29, 2021
1 parent 14c9d3a commit 0d47f55
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion securedrop/journalist_app/col.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def download_single_file(filesystem_id: str, fn: str) -> werkzeug.Response:
if not Path(file).is_file():
flash(
gettext(
"Your download failed because a file could not be found. An admin can find "
"Your download failed because the file could not be found. An admin can find "
+ "more information in the system and monitoring logs."
),
"error"
Expand Down
7 changes: 5 additions & 2 deletions securedrop/journalist_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ def download(
zf = current_app.storage.get_bulk_archive(submissions, zip_directory=zip_basename)
except FileNotFoundError:
flash(
gettext(
ngettext(
"Your download failed because the file could not be found. An admin can find "
+ "more information in the system and monitoring logs.",
"Your download failed because a file could not be found. An admin can find "
+ "more information in the system and monitoring logs."
+ "more information in the system and monitoring logs.",
len(submissions)
),
"error"
)
Expand Down
17 changes: 13 additions & 4 deletions securedrop/tests/functional/journalist_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,15 +1181,24 @@ def _journalist_uses_js_buttons_to_download_unread(self):
classes = checkbox.get_attribute("class")
assert "unread-cb" in classes

def _journalist_sees_missing_file_error_message(self):
def _journalist_sees_missing_file_error_message(self, single_file=False):
notification = self.driver.find_element_by_css_selector(".error")

if self.accept_languages is None:
expected_text = (
# We use a definite article ("the" instead of "a") if a single file
# is downloaded directly.
if single_file:
error_msg = (
"Your download failed because the file could not be found. An admin can find "
+ "more information in the system and monitoring logs."
)
else:
error_msg = (
"Your download failed because a file could not be found. An admin can find "
+ "more information in the system and monitoring logs."
)
assert expected_text == notification.text

if self.accept_languages is None:
assert notification.text == error_msg

def _journalist_is_on_collection_page(self):
return self.wait_for(
Expand Down
2 changes: 1 addition & 1 deletion securedrop/tests/functional/test_journalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_download_message(self, missing_msg_file):
self._journalist_logs_in()
self._journalist_checks_messages()
self._journalist_downloads_message_missing_file()
self._journalist_sees_missing_file_error_message()
self._journalist_sees_missing_file_error_message(single_file=True)
self._journalist_is_on_collection_page()

def test_select_message_and_download_selected(self, missing_msg_file):
Expand Down

0 comments on commit 0d47f55

Please sign in to comment.