From 870e5ce9da3b786c590cdee2ead02bbbdafcce3d Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Thu, 6 Nov 2014 11:54:59 -0200 Subject: Deleting functional tests from fake service --- .../features/compose_save_draft_and_send.feature | 30 ------- fake-service/features/environment.py | 38 --------- .../features/forward_trash_archive.feature | 27 ------ fake-service/features/search_and_destroy.feature | 27 ------ fake-service/features/steps/__init__.py | 0 fake-service/features/steps/common.py | 83 ------------------- fake-service/features/steps/compose.py | 73 ---------------- fake-service/features/steps/mail_list.py | 64 --------------- fake-service/features/steps/mail_view.py | 96 ---------------------- fake-service/features/steps/search.py | 33 -------- fake-service/features/steps/tag_list.py | 33 -------- fake-service/features/tag_and_reply.feature | 28 ------- 12 files changed, 532 deletions(-) delete mode 100644 fake-service/features/compose_save_draft_and_send.feature delete mode 100644 fake-service/features/environment.py delete mode 100644 fake-service/features/forward_trash_archive.feature delete mode 100644 fake-service/features/search_and_destroy.feature delete mode 100644 fake-service/features/steps/__init__.py delete mode 100644 fake-service/features/steps/common.py delete mode 100644 fake-service/features/steps/compose.py delete mode 100644 fake-service/features/steps/mail_list.py delete mode 100644 fake-service/features/steps/mail_view.py delete mode 100644 fake-service/features/steps/search.py delete mode 100644 fake-service/features/steps/tag_list.py delete mode 100644 fake-service/features/tag_and_reply.feature diff --git a/fake-service/features/compose_save_draft_and_send.feature b/fake-service/features/compose_save_draft_and_send.feature deleted file mode 100644 index 7be7de0b..00000000 --- a/fake-service/features/compose_save_draft_and_send.feature +++ /dev/null @@ -1,30 +0,0 @@ -# -# 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 . - -Feature: compose mail, save draft and send mail - - @wip - Scenario: user composes and email, save the draft, later sends the draft and checks the sent message - Given I compose a message with - | subject | body | - | Pixelated rocks! | You should definitely use it. Cheers, User. | - And for the 'To' field I type 'ab' and chose the first contact that shows - And I save the draft - When I open the saved draft and send it - Then I see that mail under the 'sent' tag - When I open that mail - Then I see that the subject reads 'Pixelated rocks!' - And I see that the body reads 'You should definitely use it. Cheers, User.' diff --git a/fake-service/features/environment.py b/fake-service/features/environment.py deleted file mode 100644 index 415391d6..00000000 --- a/fake-service/features/environment.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# 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 . -from selenium import webdriver - - -def before_feature(context, feature): - #context.browser = webdriver.Firefox() - context.browser = webdriver.PhantomJS() - context.browser.set_window_size(1280, 1024) - context.browser.implicitly_wait(5) - context.browser.set_page_load_timeout(60) # wait for data - context.browser.get('http://localhost:4567/') - - -def after_feature(context, feature): - context.browser.quit() - - -def take_screenshot(context): - context.browser.save_screenshot('/tmp/screenshot.jpeg') - - -def save_source(context): - with open('/tmp/source.html', 'w') as out: - out.write(context.browser.page_source.encode('utf8')) diff --git a/fake-service/features/forward_trash_archive.feature b/fake-service/features/forward_trash_archive.feature deleted file mode 100644 index dbbf200b..00000000 --- a/fake-service/features/forward_trash_archive.feature +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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 . - -Feature: forward_trash_archive - Scenario: User forwards a mail, add CC and BCC address, later trash the mail - When I open the first mail in the 'inbox' - Then I choose to forward this mail - And for the 'CC' field I type 'ab' and chose the first contact that shows - And for the 'Bcc' field I type 'fr' and chose the first contact that shows - And I forward this mail - When I open the first mail in the 'sent' - Then I see the mail has a cc and a bcc recipient - And I choose to trash - Then I see that mail under the 'trash' tag diff --git a/fake-service/features/search_and_destroy.feature b/fake-service/features/search_and_destroy.feature deleted file mode 100644 index 5b0d550d..00000000 --- a/fake-service/features/search_and_destroy.feature +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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 . - -Feature: search html mail and destroy - - Scenario: User searches for a mail and deletes it - When I search for a mail with the words "this is a html mail" - When I open the first mail in the mail list - Then I see one or more mails in the search results - Then I see if the mail has html content - When I try to delete the first mail - # Then I learn that the mail was deleted - When I select the tag 'trash' - Then the deleted mail is there diff --git a/fake-service/features/steps/__init__.py b/fake-service/features/steps/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/fake-service/features/steps/common.py b/fake-service/features/steps/common.py deleted file mode 100644 index 8255a9de..00000000 --- a/fake-service/features/steps/common.py +++ /dev/null @@ -1,83 +0,0 @@ -# -# 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 . -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.wait import WebDriverWait -from selenium.common.exceptions import NoSuchElementException -from hamcrest import * - -def wait_until_element_is_invisible_by_locator(context, locator_tuple): - wait = WebDriverWait(context.browser, 10) - wait.until(EC.invisibility_of_element_located(locator_tuple)) - -def wait_for_user_alert_to_disapear(context): - wait_until_element_is_invisible_by_locator(context, (By.ID, 'user-alerts')) - -def wait_until_element_is_visible_by_locator(context, locator_tuple): - wait = WebDriverWait(context.browser, 10) - wait.until(EC.visibility_of_element_located(locator_tuple)) - - -def fill_by_xpath(context, xpath, text): - field = context.browser.find_element_by_xpath(xpath) - field.send_keys(text) - -def take_screenshot(context, filename): - context.browser.save_screenshot(filename) - -def dump_source_to(context, filename): - with open(filename, 'w') as out: - out.write(context.browser.page_source.encode('utf8')) - -def page_has_css(context, css): - try: - find_element_by_css_selector(context, css) - return True - except NoSuchElementException: - return False - -def find_element_by_xpath(context, xpath): - return context.browser.find_element_by_xpath(xpath) - -def find_element_by_css_selector(context, css_selector): - return context.browser.find_element_by_css_selector(css_selector) - -def find_elements_by_css_selector(context, css_selector): - return context.browser.find_elements_by_css_selector(css_selector) - -def find_element_containing_text(context, text, element_type='*'): - return context.browser.find_element_by_xpath("//%s[contains(.,'%s')]" % (element_type, text)) - -def element_should_have_content(context, css_selector, content): - e = find_element_by_css_selector(context, css_selector) - assert_that(e.text, equal_to(content)) - -def wait_until_button_is_visible(context, title): - wait = WebDriverWait(context.browser, 10) - locator_tuple = (By.XPATH, ("//%s[contains(.,'%s')]" % ('button', title))) - wait.until(EC.visibility_of_element_located(locator_tuple)) - -def click_button(context, title, element='button'): - button = find_element_containing_text(context, title, element_type=element) - button.click() - -def mail_subject(context): - e = find_element_by_css_selector(context, '#mail-view .subject') - return e.text - -def reply_subject(context): - e = find_element_by_css_selector(context, '#reply-subject') - return e.text diff --git a/fake-service/features/steps/compose.py b/fake-service/features/steps/compose.py deleted file mode 100644 index 24c2e679..00000000 --- a/fake-service/features/steps/compose.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# 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 . -from behave import given, when -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.wait import WebDriverWait -from time import sleep -from common import * -from hamcrest import * - - -@given('I compose a message with') -def impl(context): - take_screenshot(context, '/tmp/screenshot.jpeg') - toggle = context.browser.find_element_by_id('compose-mails-trigger') - toggle.click() - - for row in context.table: - fill_by_xpath(context, '//*[@id="subject"]', row['subject']) - 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() - -@then("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows") -def choose_impl(context, recipients_field, to_type): - recipients_field = recipients_field.lower() - browser = context.browser - field = browser.find_element_by_css_selector( - '#recipients-%s-area .tt-input' % recipients_field - ) - field.send_keys(to_type) - sleep(1) - find_element_by_css_selector(context, '.tt-dropdown-menu div div').click() - -@given('I save the draft') -def save_impl(context): - context.browser.find_element_by_id('draft-button').click() - - -@when('I open the saved draft and send it') -def send_impl(context): - context.execute_steps(u"when I select the tag 'drafts'") - context.execute_steps(u"when I open the first mail in the mail list") - assert_that(is_not(page_has_css(context, '#send-button[disabled]'))) - click_button(context, 'Send') - element_should_have_content(context, '#user-alerts', 'Your message was sent!') - diff --git a/fake-service/features/steps/mail_list.py b/fake-service/features/steps/mail_list.py deleted file mode 100644 index 2ea90c2b..00000000 --- a/fake-service/features/steps/mail_list.py +++ /dev/null @@ -1,64 +0,0 @@ -# -# 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 . -import re -from behave import * -from common import * - -def find_current_mail(context): - return find_element_by_xpath(context, '//*[@id="mail-list"]/li[@id="mail-%s"]//a' % context.current_mail_id) - - -def check_current_mail_is_visible(context): - find_current_mail(context) - -def open_current_mail(context): - e = find_current_mail(context) - e.click() - -@then('I see that mail under the \'{tag}\' tag') -def impl(context, tag): - context.execute_steps("when I select the tag '%s'" % tag) - check_current_mail_is_visible(context) - -@when('I open that mail') -def impl(context): - open_current_mail(context) - -@when('I open the first mail in the mail list') -def impl(context): - elements = context.browser.find_elements_by_xpath('//*[@id="mail-list"]//a') - context.current_mail_id = elements[0].get_attribute('href').split('/')[-1] - elements[0].click() - -@when('I open the first mail in the \'{tag}\'') -def impl(context, tag): - context.browser.execute_script('window.scrollBy(0, -200)') - context.execute_steps(u"When I select the tag '%s'" % tag) - context.execute_steps(u'When I open the first mail in the mail list') - -@then('I open the mail I previously tagged') -def impl(context): - open_current_mail(context) - -@then('I see the mail I sent') -def impl(context): - src = context.browser.page_source - assert_that(src, contains_string(context.reply_subject)) - -@then('the deleted mail is there') -def impl(context): - check_current_mail_is_visible(context) - diff --git a/fake-service/features/steps/mail_view.py b/fake-service/features/steps/mail_view.py deleted file mode 100644 index 089f9bd4..00000000 --- a/fake-service/features/steps/mail_view.py +++ /dev/null @@ -1,96 +0,0 @@ -# -# 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 . -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-.]+')) - diff --git a/fake-service/features/steps/search.py b/fake-service/features/steps/search.py deleted file mode 100644 index 9377bc5f..00000000 --- a/fake-service/features/steps/search.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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 . -from selenium.webdriver.common.keys import Keys -from behave import * -from common import * -from hamcrest import * -from time import sleep - -@when('I search for a mail with the words "{search_term}"') -def impl(context, search_term): - search_field = find_element_by_css_selector(context, '#search-trigger input[type="search"]') - search_field.send_keys(search_term) - search_field.send_keys(Keys.ENTER) - sleep(1) - -@then('I see one or more mails in the search results') -def impl(context): - lis = find_elements_by_css_selector(context, '#mail-list li') - assert_that(len(lis), greater_than_or_equal_to(1)) - diff --git a/fake-service/features/steps/tag_list.py b/fake-service/features/steps/tag_list.py deleted file mode 100644 index f62c390e..00000000 --- a/fake-service/features/steps/tag_list.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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 . -from behave import * -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.wait import WebDriverWait -from common import * - -def click_first_element_with_class(context, classname): - elements = context.browser.find_elements_by_class_name(classname) - elements[0].click() - - -@when('I select the tag \'{tag}\'') -def impl(context, tag): - wait_for_user_alert_to_disapear(context) - click_first_element_with_class(context, 'left-off-canvas-toggle') - context.browser.execute_script("window.scrollBy(0, -200)") - e = context.browser.find_element_by_xpath('//*[@id="tag-list"]/ul/li[contains(translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "%s")]' % tag) - e.click() diff --git a/fake-service/features/tag_and_reply.feature b/fake-service/features/tag_and_reply.feature deleted file mode 100644 index 5e28827f..00000000 --- a/fake-service/features/tag_and_reply.feature +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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 . - -Feature: tagging and replying - Scenario: User tags a mail, replies to it then checks that mail is in the right tag - When I open the first mail in the 'inbox' - Then that email has the 'inbox' tag - When I add the tag 'website' to that mail - Then I see that mail under the 'website' tag - And I open the mail I previously tagged - And I reply to it - When I select the tag 'sent' - Then I see the mail I sent - - -- cgit v1.2.3