summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTayane Fernandes <tayane.rmf@gmail.com>2017-03-31 11:39:23 -0300
committerGitHub <noreply@github.com>2017-03-31 11:39:23 -0300
commitdadf39c1574d53612410371b8b639a159841eaf5 (patch)
treeb2ad876064ba53fda571bd6382277cc1ec0d4cac
parent76454872267976c3cd16608a8371d27b062b062d (diff)
parented6c3c449b7a947901b45bdb0d0dc017560e7f78 (diff)
Merge pull request #1021 from pixelated/email-recovery-code
[#927] Creates functional tests for backup account flow
-rw-r--r--Makefile6
-rw-r--r--service/test/functional/features/account_recovery.feature29
-rw-r--r--service/test/functional/features/environment.py6
-rw-r--r--service/test/functional/features/smoke.feature2
-rw-r--r--service/test/functional/features/steps/backup_account.py20
-rw-r--r--service/test/functional/features/steps/login.py17
-rw-r--r--service/test/functional/features/steps/signup.py21
-rw-r--r--service/test/functional/features/steps/utils.py55
8 files changed, 147 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index ccad7d5b..f34f37db 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,12 @@ functional_tests_ci: clean requirements install
cd service;\
behave --tags ~@wip --tags ~@smoke test/functional/features
+functional_tests_wip:
+ @. $(VIRTUALENV)/bin/activate;\
+ export PATH=$(PATH):/usr/lib/chromium/;\
+ cd service;\
+ xvfb-run --server-args="-screen 0 1280x1024x24" behave --tags @wip test/functional/features
+
ensure_virtualenv_installed:
@if [ ! `which virtualenv` ]; then\
echo "Virtualenv must be installed";\
diff --git a/service/test/functional/features/account_recovery.feature b/service/test/functional/features/account_recovery.feature
new file mode 100644
index 00000000..7a8f9fce
--- /dev/null
+++ b/service/test/functional/features/account_recovery.feature
@@ -0,0 +1,29 @@
+#
+# 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/>.
+
+@smoke
+Feature: Account Recovery
+ As a user of Pixelated
+ I want to recover my account
+ So that I can see my emails if I lose my password
+
+ Scenario: Sending recovery code
+ Given I am logged in Pixelated
+ When I go to the backup account page
+ And I submit my backup account
+ Then I see the confirmation of this submission
+ And I logout from the header
+ And I should see the login page
diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py
index 9f8507b2..eefa22b7 100644
--- a/service/test/functional/features/environment.py
+++ b/service/test/functional/features/environment.py
@@ -29,6 +29,7 @@ from pixelated.config.site import PixelatedSite
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
class UnsuportedWebDriverError(Exception):
@@ -64,6 +65,11 @@ def before_all(context):
context.username = 'username'
+def before_tag(context, tag):
+ if tag == "smoke":
+ utils.create_user(context)
+
+
def _setup_webdriver(context):
browser = context.config.userdata.get('webdriver', 'chrome')
supported_webdrivers = {
diff --git a/service/test/functional/features/smoke.feature b/service/test/functional/features/smoke.feature
index 1467baf9..d106da1b 100644
--- a/service/test/functional/features/smoke.feature
+++ b/service/test/functional/features/smoke.feature
@@ -40,6 +40,6 @@ 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
- Given I am on the backup account page
+ 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/backup_account.py b/service/test/functional/features/steps/backup_account.py
index 914309f2..56d30211 100644
--- a/service/test/functional/features/steps/backup_account.py
+++ b/service/test/functional/features/steps/backup_account.py
@@ -14,9 +14,25 @@
# 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 behave import given
+from behave import given, when, then
+from common import (
+ fill_by_css_selector,
+ find_element_by_css_selector)
-@given(u'I am on the backup account page')
+
+@when(u'I go to the backup account page')
+@given(u'I go to the backup account page')
def backup_account_page(context):
context.browser.get(context.backup_account_url)
+
+
+@when(u'I submit my backup account')
+def submit_backup_email(context):
+ fill_by_css_selector(context, 'input[name="email"]', 'test@test.com')
+ find_element_by_css_selector(context, '.submit-button button[type="submit"]').click()
+
+
+@then(u'I see the confirmation of this submission')
+def confirmation_page(context):
+ find_element_by_css_selector(context, '.confirmation-container', timeout=50)
diff --git a/service/test/functional/features/steps/login.py b/service/test/functional/features/steps/login.py
index 2d7be259..432186f5 100644
--- a/service/test/functional/features/steps/login.py
+++ b/service/test/functional/features/steps/login.py
@@ -21,12 +21,25 @@ from common import (
find_element_by_css_selector)
+@given('I am logged in Pixelated')
+def login_user(context):
+ login_page(context)
+ enter_credentials(context, 'username', 'password')
+ click_login(context)
+ see_interstitial(context)
+ _see_inbox(context)
+
+
@given(u'a user is accessing the login page')
@when(u'I open the login page')
def login_page(context):
context.browser.get(context.login_url)
+def _see_inbox(context):
+ find_element_by_css_selector(context, '#compose', timeout=40)
+
+
@when(u'I enter {username} and {password} as credentials')
def enter_credentials(context, username, password):
fill_by_css_selector(context, 'input[name="username"]', context.username)
@@ -39,7 +52,7 @@ def click_login(context):
@then(u'I should see the fancy interstitial')
-def step_impl(context):
+def see_interstitial(context):
find_element_by_css_selector(context, 'section#hive-section')
@@ -48,11 +61,13 @@ def click_logout(context):
find_element_by_css_selector(context, '#logout-form div').click()
+@then(u'I logout from the header')
@when(u'I logout from the header')
def click_logout(context):
find_element_by_css_selector(context, 'button[name="logout"]').click()
+@when(u'I should see the login page')
@then(u'I should see the login page')
def see_login_page(context):
find_element_by_css_selector(context, 'form#login_form')
diff --git a/service/test/functional/features/steps/signup.py b/service/test/functional/features/steps/signup.py
index d89cbb97..2fa1773a 100644
--- a/service/test/functional/features/steps/signup.py
+++ b/service/test/functional/features/steps/signup.py
@@ -14,6 +14,8 @@
# 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 uuid
+
from behave import given, then, when
from common import (
@@ -23,22 +25,31 @@ from common import (
@given(u'a user is accessing the signup page') # noqa
-def step_impl(context):
+def access_signup_page(context):
context.browser.get(context.signup_url)
+@given(u'I am an existent Pixelated user')
+def setup_user(context):
+ access_signup_page(context)
+ enter_user_information(context)
+ click_signup_button(context)
+ see_user_control_panel(context)
+
+
@when(u'I enter username, password and password confirmation') # noqa
-def step_impl(context):
- fill_by_css_selector(context, '#srp_username', context.username)
+def enter_user_information(context):
+ username = 'testuser_{}'.format(uuid.uuid4())
+ fill_by_css_selector(context, '#srp_username', username)
fill_by_css_selector(context, '#srp_password', 'password')
fill_by_css_selector(context, '#srp_password_confirmation', 'password')
@when(u'I click on the signup button') # noqa
-def step_impl(context):
+def click_signup_button(context):
find_element_by_css_selector(context, 'input[type=submit]').click()
@then(u'I should see the user control panel') # noqa
-def step_impl(context):
+def see_user_control_panel(context):
element_should_have_content(context, 'h1', 'user control panel')
diff --git a/service/test/functional/features/steps/utils.py b/service/test/functional/features/steps/utils.py
new file mode 100644
index 00000000..7a066b91
--- /dev/null
+++ b/service/test/functional/features/steps/utils.py
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2016 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 uuid
+
+from behave import given, then, when
+
+from common import (
+ element_should_have_content,
+ fill_by_css_selector,
+ find_element_by_css_selector)
+
+
+def access_signup_page(context):
+ context.browser.get(context.signup_url)
+
+
+def create_user(context):
+ context.browser.get(context.login_url)
+ access_signup_page(context)
+ enter_user_information(context)
+ click_signup_button(context)
+ see_user_control_panel(context)
+ log_out(context)
+
+
+def log_out(context):
+ find_element_by_css_selector(context, 'a[href="/logout"]').click()
+
+
+def enter_user_information(context):
+ fill_by_css_selector(context, '#srp_username', context.username)
+ fill_by_css_selector(context, '#srp_password', 'password')
+ fill_by_css_selector(context, '#srp_password_confirmation', 'password')
+
+
+def click_signup_button(context):
+ find_element_by_css_selector(context, 'input[type=submit]').click()
+
+
+def see_user_control_panel(context):
+ element_should_have_content(context, 'h1', 'user control panel')