From b6f60fd007efc84ef7cc2b63988448a61bbeb8d2 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Wed, 30 Nov 2016 17:36:39 -0200 Subject: Add sign up smoke test See: https://github.com/pixelated/project-issues/issues/381 --- service/test/functional/features/environment.py | 20 ++++++++--- service/test/functional/features/smoke.feature | 37 +++++++++++++++++++ service/test/functional/features/steps/login.py | 2 +- service/test/functional/features/steps/signup.py | 45 ++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 service/test/functional/features/smoke.feature create mode 100644 service/test/functional/features/steps/signup.py (limited to 'service/test/functional') diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index 981fd33e..efbf3412 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -16,6 +16,7 @@ import os import re import time +from urlparse import urlparse from crochet import setup, wait_for from leap.common.events.server import ensure_server @@ -45,8 +46,16 @@ def before_all(context): userdata = context.config.userdata context.host = userdata.get('host', 'http://localhost') + if not context.host.startswith('http'): + context.host = 'https://{}'.format(context.host) + + hostname = urlparse(context.host).hostname + context.signup_url = 'https://{}/signup'.format(hostname) + context.login_url = 'https://mail.{}/login'.format(hostname) + if 'localhost' in context.host: _mock_user_agent(context) + context.login_url = context.multi_user_url + '/login' def _mock_user_agent(context): @@ -74,16 +83,19 @@ def _define_url(port): def after_all(context): context.browser.quit() - context.single_user_client.stop() + if 'localhost' in context.host: + context.single_user_client.stop() def before_feature(context, feature): - context.browser.get(context.single_user_url) + if 'localhost' in context.host: + context.browser.get(context.single_user_url) def after_feature(context, feature): - cleanup_all_mails(context) - context.last_mail = None + if 'localhost' in context.host: + cleanup_all_mails(context) + context.last_mail = None def after_step(context, step): diff --git a/service/test/functional/features/smoke.feature b/service/test/functional/features/smoke.feature new file mode 100644 index 00000000..3a9378e4 --- /dev/null +++ b/service/test/functional/features/smoke.feature @@ -0,0 +1,37 @@ +# +# 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 . + +@smoke @wip +Feature: sign up, login and logout + As a visitor of Pixelated + I want to sign up + So I can log in to my account and see the welcome email + + Scenario: Visitor creates his account + Given a user is accessing the signup page + When I enter username, password and password confirmation + And I click on the signup button + Then I should see the user control panel + + Scenario: Existing user logs into his account + Given a user is accessing the login page + #And I have a mail for username in my inbox + And 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 + When I logout + 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 d1840900..a8db6f49 100644 --- a/service/test/functional/features/steps/login.py +++ b/service/test/functional/features/steps/login.py @@ -26,7 +26,7 @@ from common import ( @when(u'I open the login page') def login_page(context): - context.browser.get(context.multi_user_url + '/login') + context.browser.get(context.login_url) @when(u'I enter {username} and {password} as credentials') diff --git a/service/test/functional/features/steps/signup.py b/service/test/functional/features/steps/signup.py new file mode 100644 index 00000000..1252017c --- /dev/null +++ b/service/test/functional/features/steps/signup.py @@ -0,0 +1,45 @@ +# +# 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 . + +import uuid +from behave import given, then, when + +from common import ( + fill_by_css_selector, + find_element_by_css_selector) + + +@given(u'a user is accessing the signup page') # noqa +def step_impl(context): + context.browser.get(context.signup_url) + + +@when(u'I enter username, password and password confirmation') # noqa +def step_impl(context): + fill_by_css_selector(context, '#srp_username', 'testuser_{}'.format(uuid.uuid4())) + 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): + find_element_by_css_selector(context, 'button[type=submit]').click() + + +@then(u'I should see the user control panel') # noqa +def step_impl(context): + text = find_element_by_css_selector(context, 'h1').text + assert text == 'user control panel' -- cgit v1.2.3