summaryrefslogtreecommitdiff
path: root/service/test/functional/features/steps
diff options
context:
space:
mode:
Diffstat (limited to 'service/test/functional/features/steps')
-rw-r--r--service/test/functional/features/steps/common.py6
-rw-r--r--service/test/functional/features/steps/compose.py1
-rw-r--r--service/test/functional/features/steps/data_setup.py25
-rw-r--r--service/test/functional/features/steps/login.py34
-rw-r--r--service/test/functional/features/steps/mail_list.py1
5 files changed, 65 insertions, 2 deletions
diff --git a/service/test/functional/features/steps/common.py b/service/test/functional/features/steps/common.py
index 9a547375..fb5698f0 100644
--- a/service/test/functional/features/steps/common.py
+++ b/service/test/functional/features/steps/common.py
@@ -26,6 +26,12 @@ TIMEOUT_IN_S = 20
DEFAULT_IMPLICIT_WAIT_TIMEOUT_IN_S = 10.0
+HOMEPAGE_URL = 'http://localhost:8889/'
+
+MULTI_USER_PORT = 4568
+
+MULTI_USER_URL = 'http://localhost:%d/' % MULTI_USER_PORT
+
class ImplicitWait(object):
def __init__(self, context, timeout=5.0):
diff --git a/service/test/functional/features/steps/compose.py b/service/test/functional/features/steps/compose.py
index f0bed86e..67b1bd51 100644
--- a/service/test/functional/features/steps/compose.py
+++ b/service/test/functional/features/steps/compose.py
@@ -21,7 +21,6 @@ from common import *
@when('I compose a message with')
def impl(context):
- take_screenshot(context, '/tmp/screenshot.jpeg')
toggle = context.browser.find_element_by_id('compose-mails-trigger')
toggle.click()
diff --git a/service/test/functional/features/steps/data_setup.py b/service/test/functional/features/steps/data_setup.py
index fb825aba..167acf9a 100644
--- a/service/test/functional/features/steps/data_setup.py
+++ b/service/test/functional/features/steps/data_setup.py
@@ -17,6 +17,7 @@ from uuid import uuid4
from test.support.integration import MailBuilder
from behave import given
from common import wait_for_condition
+from crochet import wait_for
@given('I have a mail in my inbox')
@@ -24,8 +25,30 @@ def add_mail_impl(context):
subject = 'Hi! This the subject %s' % uuid4()
input_mail = MailBuilder().with_subject(subject).build_input_mail()
- context.client.add_mail_to_inbox(input_mail)
+ context.client.add_mail_to_inbox(input_mail)
wait_for_condition(context, lambda _: context.client.search_engine.search(subject)[1] > 0, poll_frequency=0.1)
context.last_subject = subject
+
+
+@given('I have a mail for {username} in my inbox')
+def add_mail_to_user_inbox(context, username):
+ subject = 'Hi! This the subject %s' % uuid4()
+
+ input_mail = MailBuilder().with_subject(subject).build_input_mail()
+
+ context.multi_user_client.add_mail_to_user_inbox(input_mail, username)
+ wait_for_condition(context, lambda _: context.multi_user_client.account_for(username).search_engine.search(subject)[1] > 0, poll_frequency=0.1)
+
+ context.last_subject = subject
+
+
+@wait_for(timeout=10.0)
+def add_multi_user_account(context, username):
+ return context.multi_user_client.create_user('username')
+
+
+@given(u'Account for user {username} exists')
+def add_account(context, username):
+ add_multi_user_account(context, username)
diff --git a/service/test/functional/features/steps/login.py b/service/test/functional/features/steps/login.py
new file mode 100644
index 00000000..3c80e819
--- /dev/null
+++ b/service/test/functional/features/steps/login.py
@@ -0,0 +1,34 @@
+#
+# 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/>.
+from behave import when, then
+from common import *
+
+
+@when(u'I open the login page')
+def login_page(context):
+ context.browser.get(MULTI_USER_URL + '/login')
+
+
+@when(u'I enter {username} and {password} as credentials')
+def enter_credentials(context, username, password):
+ fill_by_css_selector(context, 'input#email', username)
+ fill_by_css_selector(context, 'input#password', password)
+
+
+@when(u'I click on the login button')
+def click_login(context):
+ login_button = wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, 'input[name="login"]'))
+ login_button.click()
diff --git a/service/test/functional/features/steps/mail_list.py b/service/test/functional/features/steps/mail_list.py
index 1b850578..d19de6cd 100644
--- a/service/test/functional/features/steps/mail_list.py
+++ b/service/test/functional/features/steps/mail_list.py
@@ -76,6 +76,7 @@ def impl(context):
@given('I have mails')
+@then(u'I have mails')
def impl(context):
emails = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '#mail-list li span a'))
assert len(emails) > 0