summaryrefslogtreecommitdiff
path: root/service/test/functional/features/steps
diff options
context:
space:
mode:
authorTiago Ferraz <tiago.ferraz@gmail.com>2015-03-09 16:14:50 -0300
committerTiago Ferraz <tiago.ferraz@gmail.com>2015-03-09 16:14:50 -0300
commit6b5de66fc5adc3c62a92738e9f317c4b1335f838 (patch)
tree09ad2b63806e9f72f10fee0c7e6825578ff4cd69 /service/test/functional/features/steps
parenta9a8a7330756d2fe9b6607dc670841b0ecfa64c5 (diff)
Refactoring of fuctional tests
The scenarios were updated to follow the conventions of gherkin steps. Removal of duplicated code.
Diffstat (limited to 'service/test/functional/features/steps')
-rw-r--r--service/test/functional/features/steps/__init__.py15
-rw-r--r--service/test/functional/features/steps/compose.py20
-rw-r--r--service/test/functional/features/steps/mail_list.py8
-rw-r--r--service/test/functional/features/steps/mail_view.py12
-rw-r--r--service/test/functional/features/steps/tag_list.py13
5 files changed, 37 insertions, 31 deletions
diff --git a/service/test/functional/features/steps/__init__.py b/service/test/functional/features/steps/__init__.py
index e69de29b..2756a319 100644
--- a/service/test/functional/features/steps/__init__.py
+++ b/service/test/functional/features/steps/__init__.py
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2014 ThoughtWorks, Inc.
+#
+# Pixelated is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pixelated is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
diff --git a/service/test/functional/features/steps/compose.py b/service/test/functional/features/steps/compose.py
index cf75979e..aeef11c4 100644
--- a/service/test/functional/features/steps/compose.py
+++ b/service/test/functional/features/steps/compose.py
@@ -20,7 +20,7 @@ from common import *
from hamcrest import *
-@given('I compose a message with')
+@when('I compose a message with')
def impl(context):
take_screenshot(context, '/tmp/screenshot.jpeg')
toggle = context.browser.find_element_by_id('compose-mails-trigger')
@@ -31,31 +31,19 @@ def impl(context):
fill_by_xpath(context, '//*[@id="text-box"]', row['body'])
-@given("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows")
-def choose_impl(context, recipients_field, to_type):
- browser = context.browser
- browser.find_element_by_css_selector('#recipients-to-area span input.tt-input').click()
- recipients_field = recipients_field.lower()
- css_selector = '#recipients-%s-area' % recipients_field
- recipients_element = browser.find_element_by_css_selector(css_selector)
- recipients_element.find_element_by_css_selector('.tt-input').send_keys(to_type)
- wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, '.tt-dropdown-menu div div'))
- browser.find_element_by_css_selector('.tt-dropdown-menu div div').click()
-
-
-@given("for the '{recipients_field}' field I enter '{to_type}'")
+@when("for the '{recipients_field}' field I enter '{to_type}'")
def enter_address_impl(context, recipients_field, to_type):
_enter_recipient(context, recipients_field, to_type + "\n")
-@then("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows")
+@when("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows")
def choose_impl(context, recipients_field, to_type):
_enter_recipient(context, recipients_field, to_type)
sleep(1)
find_element_by_css_selector(context, '.tt-dropdown-menu div div').click()
-@given('I save the draft')
+@when('I save the draft')
def save_impl(context):
context.browser.find_element_by_id('draft-button').click()
diff --git a/service/test/functional/features/steps/mail_list.py b/service/test/functional/features/steps/mail_list.py
index 6a764568..4122f065 100644
--- a/service/test/functional/features/steps/mail_list.py
+++ b/service/test/functional/features/steps/mail_list.py
@@ -54,7 +54,7 @@ def impl(context, tag):
context.execute_steps(u'When I open the first mail in the mail list')
-@then('I open the mail I previously tagged')
+@when('I open the mail I previously tagged')
def impl(context):
open_current_mail(context)
@@ -68,3 +68,9 @@ def impl(context):
@then('the deleted mail is there')
def impl(context):
check_current_mail_is_visible(context)
+
+
+@given('I have mails')
+def impl(context):
+ elements = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
+ assert len(elements) > 0
diff --git a/service/test/functional/features/steps/mail_view.py b/service/test/functional/features/steps/mail_view.py
index 46e01515..98591aa4 100644
--- a/service/test/functional/features/steps/mail_view.py
+++ b/service/test/functional/features/steps/mail_view.py
@@ -49,7 +49,7 @@ def impl(context, tag):
wait_until_element_is_visible_by_locator(context, (By.XPATH, '//li[@data-tag="%s"]' % tag))
-@then('I reply to it')
+@when('I reply to it')
def impl(context):
click_button(context, 'Reply')
click_button(context, 'Send')
@@ -73,20 +73,20 @@ def impl(context):
assert_that(e.text, equal_to('Your message was moved to trash!'))
-@then('I choose to forward this mail')
+@when('I choose to forward this mail')
def impl(context):
wait_until_button_is_visible(context, 'Forward')
click_button(context, 'Forward')
-@then('I forward this mail')
+@when('I forward this mail')
def impl(context):
- context.execute_steps(u'Given I save the draft') # FIXME: this won't be necessary after #89 is done
+ context.execute_steps(u'When I save the draft') # FIXME: this won't be necessary after #89 is done
wait_until_button_is_visible(context, 'Send')
click_button(context, 'Send')
-@then('I remove all tags')
+@when('I remove all tags')
def impl(context):
e = find_element_by_css_selector(context, '.tagsArea')
tags = e.find_elements_by_css_selector('.tag')
@@ -95,7 +95,7 @@ def impl(context):
tag.click()
-@then('I choose to trash')
+@when('I choose to trash')
def impl(context):
context.browser.execute_script("$('button#view-more-actions').click()")
click_button(context, 'Delete this message', 'span')
diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py
index c50387f0..348b121a 100644
--- a/service/test/functional/features/steps/tag_list.py
+++ b/service/test/functional/features/steps/tag_list.py
@@ -22,27 +22,24 @@ def click_first_element_with_class(context, classname):
def is_side_nax_expanded(context):
- return context.browser.find_elements_by_class_name('content')[0].get_attribute('class').count(u'move-right') == 1
+ e = context.browser.find_elements_by_class_name('content')[0].get_attribute('class').count(u'move-right') == 1
+ return e
-def ensure_side_nav_is_expanded(context):
+def expand_side_nav(context):
if is_side_nax_expanded(context):
return
toggle = context.browser.find_elements_by_class_name('side-nav-toggle')[0]
toggle.click()
- wait = WebDriverWait(context, 5)
- wait.until(is_side_nax_expanded)
-
@when('I select the tag \'{tag}\'')
def impl(context, tag):
wait_for_user_alert_to_disapear(context)
+ expand_side_nav(context)
- ensure_side_nav_is_expanded(context)
-
- wait_until_element_is_visible_by_locator(context, (By.ID, 'tag-%s' % tag.lower()), 20)
+ wait_until_element_is_visible_by_locator(context, (By.ID, 'tag-%s' % tag), 20)
e = find_element_by_id(context, 'tag-%s' % tag.lower())
e.click()