diff options
Diffstat (limited to 'service')
7 files changed, 67 insertions, 10 deletions
diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index bc2e1283..379583bc 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -30,6 +30,7 @@ from pixelated.resources.features_resource import FeaturesResource from test.support.integration import AppTestClient from steps.common import DEFAULT_IMPLICIT_WAIT_TIMEOUT_IN_S from steps import utils +from ..page_objects import BackupAccountPage class UnsuportedWebDriverError(Exception): @@ -135,12 +136,21 @@ def after_feature(context, feature): def after_step(context, step): - _debug_on_error(context, step) - _save_screenshot(context, step) + if step.status == 'failed': + _debug_on_error(context, step) + _save_screenshot(context, step) + _logout(context, step) + + +def _logout(context, step): + if context.browser.current_url == context.inbox_url: + utils.log_out() + elif context.browser.current_url == context.backup_account_url: + BackupAccountPage().logout() def _debug_on_error(context, step): - if step.status == 'failed' and context.config.userdata.getbool("debug"): + if context.config.userdata.getbool("debug"): try: import ipdb ipdb.post_mortem(step.exc_traceback) @@ -150,8 +160,7 @@ def _debug_on_error(context, step): def _save_screenshot(context, step): - if (step.status == 'failed' and - context.config.userdata.getbool("screenshots", True)): + if context.config.userdata.getbool("screenshots", True): timestamp = time.strftime("%Y-%m-%d-%H-%M-%S") filename = _slugify('{} failed {}'.format(timestamp, str(step.name))) filepath = os.path.join('screenshots', filename + '.png') diff --git a/service/test/functional/features/page_objects/__init__.py b/service/test/functional/features/page_objects/__init__.py index 920bf541..af50948c 100644 --- a/service/test/functional/features/page_objects/__init__.py +++ b/service/test/functional/features/page_objects/__init__.py @@ -17,3 +17,4 @@ from account_recovery_page import AccountRecoveryPage from base_page import BasePage from inbox_page import InboxPage +from backup_account_page import BackupAccountPage diff --git a/service/test/functional/features/page_objects/account_recovery_page.py b/service/test/functional/features/page_objects/account_recovery_page.py index 4826b6ec..8a4e05cd 100644 --- a/service/test/functional/features/page_objects/account_recovery_page.py +++ b/service/test/functional/features/page_objects/account_recovery_page.py @@ -22,8 +22,11 @@ class AccountRecoveryPage(BasePage): super(AccountRecoveryPage, self).__init__(context, context.account_recovery_url) self._locators = { + 'admin_form': '.account-recovery-form.admin-code', 'admin_code': 'input[name="admin-code"]', + 'user_form': '.account-recovery-form.user-code', 'user_code': 'input[name="user-code"]', + 'new_password_form': '.account-recovery-form.new-password', 'new_password': 'input[name="new-password"]', 'confirm_password': 'input[name="confirm-password"]', 'submit_button': '.submit-button button[type="submit"]', @@ -31,17 +34,24 @@ class AccountRecoveryPage(BasePage): } def submit_admin_recovery_code(self, admin_code): + self.find_element_by_css_selector(self._locators['admin_form']) self.fill_by_css_selector(self._locators['admin_code'], admin_code) - self.find_element_by_css_selector(self._locators['submit_button']).click() + self.click_submit() def submit_user_recovery_code(self, user_code): + self.find_element_by_css_selector(self._locators['user_form']) self.fill_by_css_selector(self._locators['user_code'], user_code) - self.find_element_by_css_selector(self._locators['submit_button']).click() + self.click_submit() def submit_new_password(self, new_password, confirm_password): + self.find_element_by_css_selector(self._locators['new_password_form']) self.fill_by_css_selector(self._locators['new_password'], new_password) self.fill_by_css_selector(self._locators['confirm_password'], confirm_password) - self.find_element_by_css_selector(self._locators['submit_button']).click() + self.click_submit() def go_to_backup_account(self): self.find_element_by_css_selector(self._locators['backup_account_link']).click() + + def click_submit(self): + submit_button = self.find_element_by_css_selector(self._locators['submit_button']) + submit_button.click() diff --git a/service/test/functional/features/page_objects/backup_account_page.py b/service/test/functional/features/page_objects/backup_account_page.py new file mode 100644 index 00000000..d5f84b40 --- /dev/null +++ b/service/test/functional/features/page_objects/backup_account_page.py @@ -0,0 +1,30 @@ +# +# Copyright (c) 2017 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/>. + +from base_page import BasePage + + +class BackupAccountPage(BasePage): + def __init__(self, context): + super(BackupAccountPage, self).__init__(context, context.backup_account_url) + + self._locators = { + 'logout_button': 'button[name="logout"]' + } + + def logout(self): + logout_button = self.find_element_by_css_selector(self._locators['logout_button']) + logout_button.click() diff --git a/service/test/functional/features/page_objects/inbox_page.py b/service/test/functional/features/page_objects/inbox_page.py index 67ef1375..a6b5fef7 100644 --- a/service/test/functional/features/page_objects/inbox_page.py +++ b/service/test/functional/features/page_objects/inbox_page.py @@ -15,7 +15,7 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. from base_page import BasePage -from common import execute_ignoring_staleness +from steps.common import execute_ignoring_staleness class InboxPage(BasePage): diff --git a/service/test/functional/features/smoke.feature b/service/test/functional/features/smoke.feature index b8fdbf35..d4149334 100644 --- a/service/test/functional/features/smoke.feature +++ b/service/test/functional/features/smoke.feature @@ -31,7 +31,8 @@ Feature: sign up, login and logout When I enter username and password as credentials And I click on the login button Then I should see the fancy interstitial - Then I have mails + And I should see the inbox + And I have mails When I logout Then I should see the login page @@ -40,6 +41,7 @@ Feature: sign up, login and logout When I enter username and password as credentials And I click on the login button Then I should see the fancy interstitial + And I should see the inbox Given I go to the backup account page When I logout from the header Then I should see the login page diff --git a/service/test/functional/features/steps/login.py b/service/test/functional/features/steps/login.py index 7360adb7..338550b3 100644 --- a/service/test/functional/features/steps/login.py +++ b/service/test/functional/features/steps/login.py @@ -56,6 +56,11 @@ def see_interstitial(context): find_element_by_css_selector(context, 'section#hive-section') +@then(u'I should see the inbox') +def see_inbox(context): + _see_inbox(context) + + @then(u'I logout') @when(u'I logout') def click_logout(context): |