summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorSriram Viswanathan <sriramv@thoughtworks.com>2017-04-06 11:47:18 -0300
committerSriram Viswanathan <sriramv@thoughtworks.com>2017-04-06 11:47:18 -0300
commita85e533dfe833f397af18be7c4784c9a049eac7f (patch)
tree07e5eaa66dbfa0eb82b18d421380af73b681ba31 /service/test
parent5b12c004d96564da8c9cc420f0730093445ada4e (diff)
[#938] Uses PageObject pattern for functional test
with @anikarni
Diffstat (limited to 'service/test')
-rw-r--r--service/test/functional/features/account_recovery.feature3
-rw-r--r--service/test/functional/features/page_objects/__init__.py18
-rw-r--r--service/test/functional/features/page_objects/account_recovery_page.py51
-rw-r--r--service/test/functional/features/page_objects/base_page.py35
-rw-r--r--service/test/functional/features/steps/__init__.py2
-rw-r--r--service/test/functional/features/steps/account_recovery.py27
6 files changed, 120 insertions, 16 deletions
diff --git a/service/test/functional/features/account_recovery.feature b/service/test/functional/features/account_recovery.feature
index bdc0664c..cf0144e0 100644
--- a/service/test/functional/features/account_recovery.feature
+++ b/service/test/functional/features/account_recovery.feature
@@ -33,4 +33,5 @@ Feature: Account Recovery
When I submit admin recovery code
And I submit user recovery code
And I submit new password
- Then I see the backup account step
+ And I click on the backup account link
+ Then I see the backup account page
diff --git a/service/test/functional/features/page_objects/__init__.py b/service/test/functional/features/page_objects/__init__.py
new file mode 100644
index 00000000..6868330b
--- /dev/null
+++ b/service/test/functional/features/page_objects/__init__.py
@@ -0,0 +1,18 @@
+#
+# 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
+from account_recovery_page import AccountRecoveryPage
diff --git a/service/test/functional/features/page_objects/account_recovery_page.py b/service/test/functional/features/page_objects/account_recovery_page.py
new file mode 100644
index 00000000..6f502994
--- /dev/null
+++ b/service/test/functional/features/page_objects/account_recovery_page.py
@@ -0,0 +1,51 @@
+#
+# 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 AccountRecoveryPage(BasePage):
+ def __init__(self, context):
+ BasePage.__init__(
+ self,
+ context,
+ context.account_recovery_url
+ )
+
+ self._locators = {
+ 'admin_code': 'input[name="admin-code"]',
+ 'user_code': 'input[name="user-code"]',
+ 'new_password': 'input[name="new-password"]',
+ 'confirm_password': 'input[name="confirm-password"]',
+ 'submit_button': '.submit-button button[type="submit"]',
+ 'backup_account_link': 'a[href="/backup-account"]'
+ }
+
+ def submit_admin_recovery_code(self, admin_code):
+ self.fill_by_css_selector(self._locators['admin_code'], admin_code)
+ self.find_element_by_css_selector(self._locators['submit_button']).click()
+
+ def submit_user_recovery_code(self, user_code):
+ self.fill_by_css_selector(self._locators['user_code'], user_code)
+ self.find_element_by_css_selector(self._locators['submit_button']).click()
+
+ def submit_new_password(self, new_password, confirm_password):
+ 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()
+
+ def go_to_backup_account(self):
+ self.find_element_by_css_selector(self._locators['backup_account_link']).click()
diff --git a/service/test/functional/features/page_objects/base_page.py b/service/test/functional/features/page_objects/base_page.py
new file mode 100644
index 00000000..e5fb9a39
--- /dev/null
+++ b/service/test/functional/features/page_objects/base_page.py
@@ -0,0 +1,35 @@
+#
+# 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 steps.common import (
+ fill_by_css_selector,
+ find_element_by_css_selector)
+
+
+class BasePage(object):
+ def __init__(self, context, base_url):
+ self.context = context
+ self.timeout = 30
+ self.base_url = base_url
+
+ def find_element_by_css_selector(self, loc):
+ return find_element_by_css_selector(self.context, loc)
+
+ def fill_by_css_selector(self, loc, text):
+ fill_by_css_selector(self.context, loc, text)
+
+ def visit(self):
+ self.context.browser.get(self.base_url)
diff --git a/service/test/functional/features/steps/__init__.py b/service/test/functional/features/steps/__init__.py
index 2756a319..5750dc53 100644
--- a/service/test/functional/features/steps/__init__.py
+++ b/service/test/functional/features/steps/__init__.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2014 ThoughtWorks, Inc.
+# 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
diff --git a/service/test/functional/features/steps/account_recovery.py b/service/test/functional/features/steps/account_recovery.py
index 639b1c83..ac66cf76 100644
--- a/service/test/functional/features/steps/account_recovery.py
+++ b/service/test/functional/features/steps/account_recovery.py
@@ -16,35 +16,34 @@
from behave import given, when, then
-from common import (
- fill_by_css_selector,
- find_element_by_css_selector)
+from ..page_objects import AccountRecoveryPage
@given(u'I am on the account recovery page')
def account_recovery_page(context):
- context.browser.get(context.account_recovery_url)
+ AccountRecoveryPage(context).visit()
@when(u'I submit admin recovery code')
def submit_admin_recovery_code(context):
- fill_by_css_selector(context, 'input[name="admin-code"]', '1234')
- find_element_by_css_selector(context, '.submit-button button[type="submit"]').click()
+ AccountRecoveryPage(context).submit_admin_recovery_code('1234')
@when(u'I submit user recovery code')
def submit_user_recovery_code(context):
- fill_by_css_selector(context, 'input[name="user-code"]', '5678')
- find_element_by_css_selector(context, '.submit-button button[type="submit"]').click()
+ AccountRecoveryPage(context).submit_user_recovery_code('5678')
@when(u'I submit new password')
def submit_new_password(context):
- fill_by_css_selector(context, 'input[name="new-password"]', 'new test password')
- fill_by_css_selector(context, 'input[name="confirm-password"]', 'new test password')
- find_element_by_css_selector(context, '.submit-button button[type="submit"]').click()
+ AccountRecoveryPage(context).submit_new_password('new test password', 'new test password')
-@then(u'I see the backup account step')
-def backup_account_step(context):
- find_element_by_css_selector(context, 'a[href="/backup-account"]', timeout=50)
+@when(u'I click on the backup account link')
+def go_to_backup_account(context):
+ AccountRecoveryPage(context).go_to_backup_account()
+
+
+@then(u'I see the backup account page')
+def verify_backup_account_page(context):
+ assert('/backup-account' in context.browser.current_url)