summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorGislene Pereira <gislene01@gmail.com>2016-01-27 18:40:42 -0300
committerGislene Pereira <gislene01@gmail.com>2016-01-28 16:53:49 -0300
commit2c2b3e9d390f3b0dc16014b8fd6417ff7c191a34 (patch)
tree29cd173a77a978b6e0e5faa5b09ff45a27397e1f /service
parentad66b76146672cc646066fd32eb939a13221e760 (diff)
Issue #550 - Adding BDD tests to cover case when file is bigger than 1 MB.
Diffstat (limited to 'service')
-rw-r--r--service/test/functional/features/attachments.feature8
-rw-r--r--service/test/functional/features/files/image_over_1MB.pngbin0 -> 1094522 bytes
-rw-r--r--service/test/functional/features/steps/attachments.py31
3 files changed, 36 insertions, 3 deletions
diff --git a/service/test/functional/features/attachments.feature b/service/test/functional/features/attachments.feature
index 859ee590..5cdbf7be 100644
--- a/service/test/functional/features/attachments.feature
+++ b/service/test/functional/features/attachments.feature
@@ -32,8 +32,12 @@ Feature: Attachments
| Pixelated rocks! | You should definitely use it. Cheers, User. |
And for the 'To' field I enter 'pixelated@friends.org'
And I find an attachment icon
- When I upload a file
+ When I try to upload a file bigger than 1MB
+ Then I see an upload error message
+ When I dismiss the error message
+ Then It should not show the error message anymore
+ When I upload a valid file
And I send it
When I select the tag 'sent'
And I open the first mail in the mail list
- Then I see the mail has an attachment \ No newline at end of file
+ Then I see the mail has an attachment
diff --git a/service/test/functional/features/files/image_over_1MB.png b/service/test/functional/features/files/image_over_1MB.png
new file mode 100644
index 00000000..874eac0a
--- /dev/null
+++ b/service/test/functional/features/files/image_over_1MB.png
Binary files differ
diff --git a/service/test/functional/features/steps/attachments.py b/service/test/functional/features/steps/attachments.py
index 8dc4e244..b0c7c791 100644
--- a/service/test/functional/features/steps/attachments.py
+++ b/service/test/functional/features/steps/attachments.py
@@ -60,7 +60,36 @@ def find_icon(context):
assert find_element_by_css_selector(context, '#attachment-button .fa.fa-paperclip')
-@when(u'I upload a file')
+@when(u'I try to upload a file bigger than 1MB')
+def upload_big_file(context):
+ base_dir = "test/functional/features/files/"
+ fname = "image_over_1MB.png"
+ fill_by_css_selector(context, '#fileupload', base_dir + fname)
+ wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, '#upload-error-message'))
+
+
+@then(u'I see an upload error message')
+def show_upload_error_message(context):
+ upload_error_message = find_elements_by_css_selector(context, '#upload-error-message')
+ error_messages = [e.text for e in upload_error_message]
+ assert "Upload failed. This file exceeds the 1MB limit." in error_messages
+
+
+@when(u'I dismiss the error message')
+def dismiss_error_message(context):
+ dismiss_button = find_elements_by_css_selector(context, '#dismiss-button')
+ assert len(dismiss_button) > 0
+ for button in dismiss_button:
+ button.click()
+
+
+@then(u'It should not show the error message anymore')
+def should_not_show_upload_error_message(context):
+ upload_error_message_is_present = page_has_css(context, '#upload-error-message')
+ assert not upload_error_message_is_present
+
+
+@when(u'I upload a valid file')
def upload_attachment(context):
base_dir = "test/functional/features/files/"
fname = "upload_test_file.txt"