diff options
Diffstat (limited to 'service/test/functional/features/steps')
-rw-r--r-- | service/test/functional/features/steps/__init__.py | 15 | ||||
-rw-r--r-- | service/test/functional/features/steps/common.py | 20 | ||||
-rw-r--r-- | service/test/functional/features/steps/compose.py | 20 | ||||
-rw-r--r-- | service/test/functional/features/steps/mail_list.py | 8 | ||||
-rw-r--r-- | service/test/functional/features/steps/mail_view.py | 13 | ||||
-rw-r--r-- | service/test/functional/features/steps/tag_list.py | 19 |
6 files changed, 60 insertions, 35 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/common.py b/service/test/functional/features/steps/common.py index 558361d0..7848089b 100644 --- a/service/test/functional/features/steps/common.py +++ b/service/test/functional/features/steps/common.py @@ -20,8 +20,8 @@ from selenium.common.exceptions import TimeoutException from hamcrest import * -def wait_until_element_is_invisible_by_locator(context, locator_tuple): - wait = WebDriverWait(context.browser, 10) +def wait_until_element_is_invisible_by_locator(context, locator_tuple, timeout=10): + wait = WebDriverWait(context.browser, timeout) wait.until(EC.invisibility_of_element_located(locator_tuple)) @@ -30,18 +30,18 @@ def wait_until_element_is_deleted(context, locator_tuple, timeout=10): wait.until(lambda s: len(s.find_elements(locator_tuple[0], locator_tuple[1])) == 0) -def wait_for_user_alert_to_disapear(context): - wait_until_element_is_invisible_by_locator(context, (By.ID, 'user-alerts')) +def wait_for_user_alert_to_disapear(context, timeout=10): + wait_until_element_is_invisible_by_locator(context, (By.ID, 'user-alerts'), timeout) -def wait_until_elements_are_visible_by_locator(context, locator_tuple): - wait = WebDriverWait(context.browser, 10) +def wait_until_elements_are_visible_by_locator(context, locator_tuple, timeout=10): + wait = WebDriverWait(context.browser, timeout) wait.until(EC.presence_of_all_elements_located(locator_tuple)) return context.browser.find_elements(locator_tuple[0], locator_tuple[1]) -def wait_until_element_is_visible_by_locator(context, locator_tuple): - wait = WebDriverWait(context.browser, 10) +def wait_until_element_is_visible_by_locator(context, locator_tuple, timeout=10): + wait = WebDriverWait(context.browser, timeout) wait.until(EC.visibility_of_element_located(locator_tuple)) return context.browser.find_element(locator_tuple[0], locator_tuple[1]) @@ -93,8 +93,8 @@ def element_should_have_content(context, css_selector, content): assert_that(e.text, equal_to(content)) -def wait_until_button_is_visible(context, title): - wait = WebDriverWait(context.browser, 10) +def wait_until_button_is_visible(context, title, timeout=10): + wait = WebDriverWait(context.browser, timeout) locator_tuple = (By.XPATH, ("//%s[contains(.,'%s')]" % ('button', title))) wait.until(EC.visibility_of_element_located(locator_tuple)) 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 ca0d68dc..98591aa4 100644 --- a/service/test/functional/features/steps/mail_view.py +++ b/service/test/functional/features/steps/mail_view.py @@ -46,9 +46,10 @@ def impl(context, tag): e = wait_until_element_is_visible_by_locator(context, (By.ID, 'new-tag-input')) e.send_keys(tag) e.send_keys(Keys.ENTER) + 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') @@ -72,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') @@ -94,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 62b2571f..348b121a 100644 --- a/service/test/functional/features/steps/tag_list.py +++ b/service/test/functional/features/steps/tag_list.py @@ -21,10 +21,25 @@ def click_first_element_with_class(context, classname): elements[0].click() +def is_side_nax_expanded(context): + e = context.browser.find_elements_by_class_name('content')[0].get_attribute('class').count(u'move-right') == 1 + return e + + +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() + + @when('I select the tag \'{tag}\'') def impl(context, tag): wait_for_user_alert_to_disapear(context) - click_first_element_with_class(context, 'fake-left-off-canvas-toggle') - context.browser.execute_script("window.scrollBy(0, -200)") + expand_side_nav(context) + + 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() |