summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTayane Fernandes <tayane.rmf@gmail.com>2017-03-29 18:49:16 -0300
committerTayane Fernandes <tayane.rmf@gmail.com>2017-03-30 17:55:24 -0300
commited6c3c449b7a947901b45bdb0d0dc017560e7f78 (patch)
tree32d4f54344f92163202661af00061d2138b91994 /service
parent715419e88dcbc4d5f0b8286d917b26b8d425d85b (diff)
[#927] Change account recovery tests to run against a non mocked application
with @thaissiqueira
Diffstat (limited to 'service')
-rw-r--r--service/test/functional/features/account_recovery.feature12
-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.py11
-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
7 files changed, 108 insertions, 16 deletions
diff --git a/service/test/functional/features/account_recovery.feature b/service/test/functional/features/account_recovery.feature
index ec38399f..7a8f9fce 100644
--- a/service/test/functional/features/account_recovery.feature
+++ b/service/test/functional/features/account_recovery.feature
@@ -14,12 +14,16 @@
# 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: User sets up a backup account
- Given I am on the backup account page
- When I submit my email
- Then I see the confirmation page
+ 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 916198f6..56d30211 100644
--- a/service/test/functional/features/steps/backup_account.py
+++ b/service/test/functional/features/steps/backup_account.py
@@ -21,17 +21,18 @@ from common import (
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 email')
+@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, 'button[type="submit"]').click()
+ find_element_by_css_selector(context, '.submit-button button[type="submit"]').click()
-@then(u'I see the confirmation page')
+@then(u'I see the confirmation of this submission')
def confirmation_page(context):
- find_element_by_css_selector(context, '.confirmation-container')
+ 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')