diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-09 12:20:18 +0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-09 12:25:29 +0200 |
commit | f28906c1c417800f5823dc937a7671a04d14193c (patch) | |
tree | 6704c2ae664e4b6b481427f1f5770a1f15ba0ba9 /service/test/functional/features/steps/mail_view.py | |
parent | 0bad14f4b0e6dd5128660d94a436463cbe7dc720 (diff) |
moving fake-service features to service, getting rid of setup.py test requires and getting them into test_requirements.txt
Diffstat (limited to 'service/test/functional/features/steps/mail_view.py')
-rw-r--r-- | service/test/functional/features/steps/mail_view.py | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/service/test/functional/features/steps/mail_view.py b/service/test/functional/features/steps/mail_view.py new file mode 100644 index 00000000..98647958 --- /dev/null +++ b/service/test/functional/features/steps/mail_view.py @@ -0,0 +1,107 @@ +# +# 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/>. +import re +from selenium.webdriver.common.keys import Keys +from behave import * +from common import * +from hamcrest import * +from time import sleep + + +@then('I see that the subject reads \'{subject}\'') +def impl(context, subject): + e = find_element_by_css_selector(context, '#mail-view .subject') + assert_that(e.text, equal_to(subject)) + + +@then('I see that the body reads \'{expected_body}\'') +def impl(context, expected_body): + e = find_element_by_css_selector(context, '#mail-view .bodyArea') + assert_that(e.text, equal_to(expected_body)) + + +@then('that email has the \'{tag}\' tag') +def impl(context, tag): + elements = find_elements_by_css_selector(context, '#mail-view .tagsArea .tag') + tags = [e.text for e in elements] + assert_that(tags, has_item(tag.upper())) + + +@when('I add the tag \'{tag}\' to that mail') +def impl(context, tag): + context.browser.execute_script("$('#new-tag-button').click();") + context.browser.execute_script("$('#new-tag-input').val('%s');" % tag) + e = find_element_by_css_selector(context, '#new-tag-input') + e.send_keys(Keys.ENTER) + + +@then('I reply to it') +def impl(context): + click_button(context, 'Reply') + click_button(context, 'Send') + context.reply_subject = reply_subject(context) + + +@then('I see if the mail has html content') +def impl(context): + e = find_element_by_css_selector(context, '#mail-view .bodyArea') + h2 = e.find_element_by_css_selector("h2[style*='color: #3f4944']") + assert_that(h2.text, contains_string('cborim')) + + +@when('I try to delete the first mail') +def impl(context): + context.execute_steps(u"When I open the first mail in the mail list") + find_element_by_css_selector(context, '#mail-view #view-more-actions').click() + context.browser.execute_script("$('#delete-button-top').click();") + + e = find_element_by_css_selector(context, '#user-alerts') + assert_that(e.text, equal_to('Your message was moved to trash!')) + + +@then('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') +def impl(context): + wait_until_button_is_visible(context, 'Send') + click_button(context, 'Send') + + +@then('I remove all tags') +def impl(context): + e = find_element_by_css_selector(context, '.tagsArea') + tags = e.find_elements_by_css_selector('.tag') + assert_that(len(tags), greater_than(0)) + for tag in tags: + tag.click() + + +@then('I choose to trash') +def impl(context): + context.browser.execute_script("$('button#view-more-actions').click()") + click_button(context, 'Trash this message', 'span') + + +@then('I see the mail has a cc and a bcc recipient') +def impl(context): + cc = find_element_by_css_selector(context, '.msg-header .cc') + bcc = find_element_by_css_selector(context, '.msg-header .bcc') + + assert_that(cc.text, matches_regexp('[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+')) |